Sha256: 2a4305014e4f87496fdd87f9faf9df5e8eefce29f77bbc8ab52ea5cf54dcc339

Contents?: true

Size: 664 Bytes

Versions: 5

Compression:

Stored size: 664 Bytes

Contents

"use strict";

var reducer = require("./reducer")
var end = require("reducible/end")


var takeWhile = reducer(function takeWhile(predicate, next, value, result) {
  /**
  Returns a sequence of successive items from `source` while `predicate(item)`
  returns `true`. `predicate` must be free of side-effects.

  ## Example

  var digits = takeWhile([ 2, 7, 10, 23 ], function(x) { return x < 10 })
  print(digits)   // => < 2 7 >
  **/
  return predicate(value) ? next(value, result) :
         // Predicate returned `false` just pass `end`. Reducer will take
         // care of returning `reduced(result)` back.
         next(end)
})

module.exports = takeWhile

Version data entries

5 entries across 2 versions & 1 rubygems

Version Path
ruby-wisp-source-0.8.0 vendor/interactivate/node_modules/interactivate/node_modules/reducers/take-while.js
ruby-wisp-source-0.8.0 vendor/node_modules/wisp/interactivate/node_modules/interactivate/node_modules/reducers/take-while.js
ruby-wisp-source-0.7.0 vendor/interactivate/node_modules/interactivate/node_modules/reducers/take-while.js
ruby-wisp-source-0.7.0 vendor/node_modules/wisp/interactivate/node_modules/interactivate/node_modules/reducers/take-while.js
ruby-wisp-source-0.7.0 vendor/try/node_modules/~wisp/interactivate/node_modules/interactivate/node_modules/reducers/take-while.js