Comparing version 0.9.0 to 0.9.1
{ | ||
"name": "most", | ||
"main": "most.js", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"homepage": "https://github.com/cujojs/most", | ||
@@ -40,4 +40,4 @@ "authors": [ | ||
"dependencies": { | ||
"when": "~3.5" | ||
"when": "~3.6.2" | ||
} | ||
} |
@@ -77,13 +77,17 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
function take(n, stream) { | ||
var stepper = stream.step; | ||
return stream.beget(function(s) { | ||
return stepTake(stepper, s); | ||
}, new Yield(stream.scheduler.now(), void 0, new Pair(n|0, stream.state))); | ||
// Note: abusing Yield, using it as a Tuple :/ | ||
return stream.beget(stepTake, new Yield(stream.scheduler.now(), n|0, stream), disposeTake); | ||
} | ||
function stepTake(stepper, s) { | ||
var ss = s.state; | ||
function disposeTake(t, x, s) { | ||
// Unwrap original stream's state | ||
var stream = s.state; | ||
return stream.dispose(t, x, stream.state); | ||
} | ||
if(ss.value === 0) { | ||
return new End(s.time, s.value, ss.state); | ||
function stepTake(s) { | ||
var stream = s.state; | ||
if(s.value === 0) { | ||
return new End(s.time, s.value, stream.state); | ||
} | ||
@@ -93,4 +97,4 @@ | ||
return i.done ? i | ||
: i.withState(new Yield(i.time, i.value, new Pair(ss.value-1, i.state))); | ||
}, when(stepper, ss.state)); | ||
: i.withState(new Yield(i.time, s.value-1, stream.beget(stream.step, i.state))); | ||
}, when(stream.step, stream.state)); | ||
} | ||
@@ -97,0 +101,0 @@ |
@@ -14,3 +14,3 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
var neverP = promise.never(); | ||
var never = promise.never; | ||
var when = promise.when; | ||
@@ -28,3 +28,3 @@ var all = promise.Promise.all; | ||
function join(stream) { | ||
return stream.begetWithDispose(stepJoin, [{ stream: stream, i: null }], disposeInners); | ||
return stream.begetWithDispose(stepJoin, [{ stream: stream, i: null, disposed: false }], disposeInners); | ||
} | ||
@@ -58,3 +58,3 @@ | ||
var sp = without(i, index, s); | ||
if(sp.length === 1 && sp[0].i === neverP) { | ||
if(sp.length === 1 && sp[0].disposed) { | ||
return when(function(s) { | ||
@@ -77,7 +77,7 @@ return i.withState(s); | ||
function stepPair(stream) { | ||
return { stream: stream, i: when(stream.step, stream.state) }; | ||
return { stream: stream, i: when(stream.step, stream.state), disposed: false }; | ||
} | ||
function endOuter(i, stream) { | ||
return { stream: stream, i: disposeOuter(i, stream) }; | ||
return { stream: stream, i: disposeOuter(i, stream), disposed: true }; | ||
} | ||
@@ -99,5 +99,5 @@ | ||
function disposeOuter (i, stream) { | ||
return when(function () { | ||
return neverP; | ||
}, stream.dispose(i.time, i.value, i.state)); | ||
// return a neverPromise placeholder for the outer stream so | ||
// it will never win the stream stepping race | ||
return when(never, stream.dispose(i.time, i.value, i.state)); | ||
} | ||
@@ -111,6 +111,6 @@ | ||
function disposeInner (t, x, si) { | ||
return when(function (i) { | ||
return si.stream.dispose(t, x, i.state); | ||
}, si.i); | ||
function disposeInner (t, x, s) { | ||
when(function(i) { | ||
return s.stream.dispose(t, x, i.state); | ||
}, s.i); | ||
} |
@@ -16,2 +16,4 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
var emptyStream = new Stream(identity, new End(0)); | ||
/** | ||
@@ -21,3 +23,3 @@ * @returns {Stream} stream that contains no items, and immediately ends | ||
function empty() { | ||
return new Stream(identity, new End(Stream.getDefaultScheduler().now())); | ||
return emptyStream; | ||
} | ||
@@ -32,3 +34,3 @@ | ||
function concat(left, right) { | ||
return new Stream(stepConcat, { stream: left, state: left.state, tail: right }, void 0, disposeCurrent); | ||
return new Stream(stepConcat, { stream: left, tail: right }, void 0, disposeCurrent); | ||
} | ||
@@ -39,3 +41,3 @@ | ||
return handleStep(s, i); | ||
}, s.stream.step(s.state)); | ||
}, s.stream.step(s.stream.state)); | ||
} | ||
@@ -50,3 +52,3 @@ | ||
return i.withState({ stream: s.stream, state: i.state, tail: s.tail }); | ||
return i.withState({ stream: s.stream.beget(s.stream.step, i.state), tail: s.tail }); | ||
} | ||
@@ -56,8 +58,9 @@ | ||
var tail = s.tail; | ||
return tail === null ? i.withState({ stream: s.stream, state: i.state, tail: null }) : | ||
stepConcat({ stream: tail, state: tail.state, tail: null }); | ||
return tail === null ? i.withState({ stream: emptyStream, tail: null }) : | ||
stepConcat({ stream: tail, tail: null }); | ||
} | ||
function disposeCurrent(t, x, s) { | ||
return s.stream.dispose(t, x, s.state); | ||
var stream = s.stream; | ||
return stream.dispose(t, x, stream.state); | ||
} |
@@ -118,15 +118,17 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
return when(function (i) { | ||
var next = stream.beget(stream.step, i.state); | ||
if (i.done) { | ||
return i.withState(stream); | ||
return i.withState(new Pair(i.value, next)); | ||
} | ||
var x = f(s.value, i.value); | ||
return new Yield(i.time, x, new Pair(x, stream.beget(stream.step, i.state))); | ||
return new Yield(i.time, x, new Pair(x, next)); | ||
}, when(stream.step, stream.state)); | ||
} | ||
function disposeScan(t, x, stream) { | ||
function disposeScan(t, x, s) { | ||
// Unwrap original stream's state from scan state | ||
var state = stream.state.state; | ||
return stream.dispose(t, x, state); | ||
var stream = s.state; | ||
return stream.dispose(t, x, stream.state); | ||
} |
@@ -29,3 +29,3 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
var never = new Stream(identity, neverPromise()); | ||
var never = new Stream(neverPromise); | ||
@@ -32,0 +32,0 @@ Stream.getDefaultScheduler = getDefaultScheduler; |
@@ -19,2 +19,3 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
exports.fromPromise = Stream.fromPromise; | ||
exports.never = Stream.never; | ||
@@ -21,0 +22,0 @@ //----------------------------------------------------------------------- |
{ | ||
"name": "most", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Monadic streams", | ||
@@ -36,4 +36,4 @@ "main": "most.js", | ||
"dependencies": { | ||
"when": "~3.5" | ||
"when": "~3.6.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119203
2685
+ Addedwhen@3.6.4(transitive)
- Removedwhen@3.5.2(transitive)
Updatedwhen@~3.6.2