https://github.com/Gozala/reducers
Tip revision: 291e0255e28ba6c015b69cc8556a287f9c873b9e authored by Irakli Gozalishvili on 25 October 2012, 06:36:51 UTC
Version 0.1.4
Version 0.1.4
Tip revision: 291e025
drop-while.js
"use strict";
var transform = require("./transform")
var transformer = require("./transformer")
function dropWhile(source, predicate) {
/**
Returns a sequence of the items in `source` starting from the first
item for which `predicate(item)` returns `false`.
## Example
var numbers = dropWhile([ 2, 7, 10, 23 ], function(value) {
return value < 10
})
print(numbers) // => <stream 10 23 />
**/
return transformer(source, function(source) {
var active = true
return transform(source, function(next, value, result) {
return active && (active = predicate(value)) ? result :
next(value, result)
})
})
}
module.exports = dropWhile