Fix #1714 conditionally halting stream (#2200)

* Fix #1714 conditionally halting stream

* Add note in changelog
This commit is contained in:
Rasmus Porsager 2018-08-08 16:06:21 +02:00 committed by Barney Carroll
parent 4d0047380c
commit d64e0a950f
3 changed files with 23 additions and 1 deletions

View file

@ -164,6 +164,27 @@ o.spec("stream", function() {
o(b()).equals(undefined)
o(count).equals(0)
})
o("combine can conditionaly halt", function() {
var count = 0
var halt = false
var a = Stream(1)
var b = Stream.combine(function(a) {
if (halt) {
return Stream.HALT
}
return a()
}, [a])["fantasy-land/map"](function(a) {
count++
return a
})
o(b()).equals(1)
o(count).equals(1)
halt = true
count = 0
a(2)
o(b()).equals(1)
o(count).equals(0)
})
o("combine will throw with a helpful error if given non-stream values", function () {
var spy = o.spy()
var a = Stream(1)