+58
-59
@@ -1,5 +0,4 @@ | ||
| "use strict"; | ||
| 'use strict' | ||
| var async = require('transduce-async'), | ||
| Prom = require('any-promise'), | ||
| undef; | ||
| Prom = require('any-promise') | ||
@@ -13,9 +12,9 @@ module.exports = function(_r){ | ||
| as = _r.as, | ||
| _ = _r._; | ||
| _ = _r._ | ||
| _r.resolveAsync = resolveAsync; | ||
| _r.resolveAsync = resolveAsync | ||
| _r.mixin({ | ||
| defer: defer, | ||
| delay: delay | ||
| }); | ||
| }) | ||
@@ -27,12 +26,12 @@ // Helper to mark transducer to resolve as a Promise | ||
| if(as(self)){ | ||
| self._opts.resolveAsync = true; | ||
| self._opts.resolveAsync = true | ||
| } | ||
| } | ||
| _r.prototype.async = function(){ | ||
| resolveAsync(this); | ||
| return this; | ||
| }; | ||
| resolveAsync(this) | ||
| return this | ||
| } | ||
| function isAsync(self){ | ||
| return as(self) && self._opts.resolveAsync; | ||
| return as(self) && self._opts.resolveAsync | ||
| } | ||
@@ -42,17 +41,17 @@ | ||
| _r.value.register(function(r){ | ||
| var promise; | ||
| var promise | ||
| if(r._opts.resolveAsync){ | ||
| if(!r._opts.resolveSingleValue){ | ||
| promise = r.into(); | ||
| promise = r.into() | ||
| } else { | ||
| promise = r | ||
| .into(IGNORE) | ||
| .then(_value); | ||
| .then(_value) | ||
| } | ||
| return promise; | ||
| return promise | ||
| } | ||
| }); | ||
| }) | ||
| function _value(result){ | ||
| return result === IGNORE ? undef : result; | ||
| return result === IGNORE ? void 0 : result | ||
| } | ||
@@ -63,16 +62,16 @@ | ||
| /*jshint validthis:true*/ | ||
| resolveAsync(this); | ||
| resolveAsync(this) | ||
| } | ||
| }); | ||
| }) | ||
| _r.prototype.then = function(resolve, reject){ | ||
| resolveAsync(this); | ||
| resolveAsync(this) | ||
| return this.value() | ||
| .then(resolve, reject); | ||
| }; | ||
| .then(resolve, reject) | ||
| } | ||
| function defer(){ | ||
| /*jshint validthis:true*/ | ||
| resolveAsync(this); | ||
| return async.defer(); | ||
| resolveAsync(this) | ||
| return async.defer() | ||
| } | ||
@@ -82,4 +81,4 @@ | ||
| /*jshint validthis:true*/ | ||
| resolveAsync(this); | ||
| return async.delay(wait); | ||
| resolveAsync(this) | ||
| return async.delay(wait) | ||
| } | ||
@@ -89,11 +88,11 @@ | ||
| if(isAsync(self)){ | ||
| return async.compose.apply(null, self._wrappedFns); | ||
| return async.compose.apply(null, self._wrappedFns) | ||
| } | ||
| }); | ||
| }) | ||
| function asXf(xf){ | ||
| if(as(xf)){ | ||
| xf = transducer(xf); | ||
| xf = transducer(xf) | ||
| } | ||
| return xf; | ||
| return xf | ||
| } | ||
@@ -103,11 +102,11 @@ | ||
| if(isAsync(xf)){ | ||
| return reduceAsync(xf, init, coll); | ||
| return reduceAsync(xf, init, coll) | ||
| } | ||
| }); | ||
| }) | ||
| function reduceAsync(xf, init, coll) { | ||
| if (coll === null || coll === undef) coll = empty(coll); | ||
| if (coll === null || coll === void 0) coll = empty(coll) | ||
| return async | ||
| .reduce(asXf(xf), init, coll) | ||
| .then(unwrap); | ||
| .then(unwrap) | ||
| } | ||
@@ -117,5 +116,5 @@ | ||
| if(isAsync(xf)){ | ||
| return transduceAsync(xf, f, init, coll); | ||
| return transduceAsync(xf, f, init, coll) | ||
| } | ||
| }); | ||
| }) | ||
@@ -125,3 +124,3 @@ function transduceAsync(xf, f, init, coll){ | ||
| .transduce(asXf(xf), f, init, coll) | ||
| .then(unwrap); | ||
| .then(unwrap) | ||
| } | ||
@@ -131,15 +130,15 @@ | ||
| if(isAsync(xf)){ | ||
| return intoAsync(to, xf, from); | ||
| return intoAsync(to, xf, from) | ||
| } | ||
| }); | ||
| }) | ||
| function intoAsync(to, xf, from){ | ||
| if(from === undef){ | ||
| from = xf; | ||
| xf = undef; | ||
| if(from === void 0){ | ||
| from = xf | ||
| xf = void 0 | ||
| } | ||
| xf = asXf(xf); | ||
| xf = asXf(xf) | ||
| return Prom | ||
| .all([to, from]) | ||
| .then(_into(xf)); | ||
| .then(_into(xf)) | ||
| } | ||
@@ -150,17 +149,17 @@ | ||
| var to = toFrom[0], | ||
| from = toFrom[1]; | ||
| if(from === undef){ | ||
| from = empty(); | ||
| from = toFrom[1] | ||
| if(from === void 0){ | ||
| from = empty() | ||
| } | ||
| if(to === undef){ | ||
| to = empty(from); | ||
| if(to === void 0){ | ||
| to = empty(from) | ||
| } | ||
| if(xf === undef){ | ||
| return reduceAsync(append, to, from); | ||
| if(xf === void 0){ | ||
| return reduceAsync(append, to, from) | ||
| } | ||
| return transduceAsync(xf, append, to, from); | ||
| }; | ||
| return transduceAsync(xf, append, to, from) | ||
| } | ||
| } | ||
@@ -173,12 +172,12 @@ | ||
| .all([from]) | ||
| .then(_toArray(xf)); | ||
| .then(_toArray(xf)) | ||
| } | ||
| }); | ||
| }) | ||
| function _toArray(xf){ | ||
| return function(from){ | ||
| from = from[0]; | ||
| return intoAsync(empty(from), xf, from); | ||
| }; | ||
| from = from[0] | ||
| return intoAsync(empty(from), xf, from) | ||
| } | ||
| } | ||
| }; | ||
| } |
+5
-6
@@ -1,7 +0,6 @@ | ||
| "use strict"; | ||
| var undef; | ||
| 'use strict' | ||
| module.exports = function(_r){ | ||
| var _ = _r._ || {}; | ||
| _.debounce = require('lodash-node/underscore/functions/debounce'); | ||
| _.throttle = require('lodash-node/underscore/functions/throttle'); | ||
| }; | ||
| var _ = _r._ || {} | ||
| _.debounce = require('lodash-node/underscore/functions/debounce') | ||
| _.throttle = require('lodash-node/underscore/functions/throttle') | ||
| } |
+19
-20
@@ -1,5 +0,4 @@ | ||
| "use strict"; | ||
| var undef; | ||
| 'use strict' | ||
| module.exports = function(_r){ | ||
| var _ = _r._; | ||
| var _ = _r._ | ||
@@ -9,10 +8,10 @@ _r.mixin({ | ||
| debounce: debounce | ||
| }); | ||
| }) | ||
| function throttle(wait, options){ | ||
| return sample(sampler_(_.throttle, wait, options)); | ||
| return sample(sampler_(_.throttle, wait, options)) | ||
| } | ||
| function debounce(wait, immediate){ | ||
| return sample(sampler_(_.debounce, wait, immediate)); | ||
| return sample(sampler_(_.debounce, wait, immediate)) | ||
| } | ||
@@ -22,4 +21,4 @@ | ||
| return function(fn){ | ||
| return debounce(fn, wait, options); | ||
| }; | ||
| return debounce(fn, wait, options) | ||
| } | ||
| } | ||
@@ -29,19 +28,19 @@ | ||
| return function(xf){ | ||
| return new Sample(sampler, xf); | ||
| }; | ||
| return new Sample(sampler, xf) | ||
| } | ||
| } | ||
| function Sample(sampler, xf){ | ||
| this.xf = xf; | ||
| this._sample = sampler(xf.step.bind(xf)); | ||
| this.xf = xf | ||
| this._sample = sampler(xf.step.bind(xf)) | ||
| } | ||
| Sample.prototype.init = function(){ | ||
| return this.xf.init(); | ||
| }; | ||
| return this.xf.init() | ||
| } | ||
| Sample.prototype.result = function(result){ | ||
| return this.xf.result(result); | ||
| }; | ||
| return this.xf.result(result) | ||
| } | ||
| Sample.prototype.step = function(result, input) { | ||
| var res = this._sample(result, input); | ||
| return res !== undef ? res : result; | ||
| }; | ||
| }; | ||
| var res = this._sample(result, input) | ||
| return res !== void 0 ? res : result | ||
| } | ||
| } |
+3
-3
| { | ||
| "name": "underarm", | ||
| "version": "0.3.1", | ||
| "version": "0.3.2", | ||
| "description": "Underscore Transducer meets Reactive Programming", | ||
@@ -24,4 +24,4 @@ "main": "underarm.js", | ||
| "dependencies": { | ||
| "underscore-transducer": "~0.4.1", | ||
| "transduce-async": "~0.1.1", | ||
| "underscore-transducer": "~0.4.2", | ||
| "transduce-async": "~0.2.0", | ||
| "any-promise": "~0.1.0", | ||
@@ -28,0 +28,0 @@ "lodash-node": "~2.4.1" |
+1
-1
| module.exports = require('underscore-transducer/lib/load')([ | ||
| require('./lib/async')], | ||
| require('underscore-transducer/underscore-transducer.base')); | ||
| require('underscore-transducer/underscore-transducer.base')) |
+1
-1
@@ -5,2 +5,2 @@ module.exports = require('underscore-transducer/lib/load')([ | ||
| require('./lib/sample')], | ||
| require('underscore-transducer')); | ||
| require('underscore-transducer')) |
11910
-0.87%230
-1.29%+ Added
- Removed
Updated
Updated