Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    reducedpublic

    reduced

    Some notes:

    • pull-style lazy sequences
    • a set of combinators for them
    • modelled after clojure/reducers
    • plays well with arrays, promises and other monads (theoretically)
    • see specs for docs

    Brief example:

    {equal} = require 'assert'
    {fold, take, repeat, reduced} = require 'reduced'
    
    # compute a sum of a seq
    sum = (seq) ->
      fold(seq, ((v, s) -> v + s), 0)
    
    # sum of a hundred of 1s
    sum100 = sum(take repeat(1), 100)
    
    reduced(sum100).then (v) ->
      equal v, 100
    

    reduced is a parametrized module (functor)

    You can use reduced with other types of monads — there's makeModule function which created another instance of reduced module.

    var reducedForStreams = reduced.makeModule(function(stream) {
      // make seq from a stream
    });
    

    That way reducedForStreams would have exactly the same function available as original reduce module but those functions will work only on streams.

    Keywords

    none

    install

    npm i reduced

    Downloadslast 7 days

    0

    version

    0.2.0

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar