https://github.com/Gozala/reducers
Revision 4e743321440a426d44c6ce03c05339e73c4517a5 authored by Irakli Gozalishvili on 24 October 2012, 19:47:47 UTC, committed by Irakli Gozalishvili on 24 October 2012, 19:47:47 UTC
1 parent c393dc3
Tip revision: 4e743321440a426d44c6ce03c05339e73c4517a5 authored by Irakli Gozalishvili on 24 October 2012, 19:47:47 UTC
Version 0.1.2
Version 0.1.2
Tip revision: 4e74332
sequential.js
/*jshint asi: true undef: true es5: true node: true browser: true devel: true
forin: true latedef: false globalstrict: true */
'use strict';
var reducible = require("./reducible")
var reduce = require("./reduce")
var eventual = require("eventual/decorate")
function sequential(source) {
/**
Takes `source` sequence and returns decorated version which intercepts
into reduction such that any transformation on the result will have
guaranteed sequential order. This decorator is useful with functions
like `flatten` and `expand` when order of items in resulting sequences
is desired to be index based rather then time based. Note that this
will buffer items that are delivered earlier then their order so keep
that in mind and use it with extra care.
**/
return reducible(source, function(_, next, initial) {
return reduce(source, eventual(function(result, value) {
return next(result, value)
}), initial)
})
}
module.exports = sequential
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...