transy

    0.0.4 • Public • Published

    transy

    Composable transform functions which could be reused for Array, Event, Stream, Channel, etc.

    Inspiration

    It's based on clojure's transduce. Some awesome posts explained it in Javascript worth reading:

    Install

    npm install transy
    

    Example

    var ty = require('transy')
     
    function inc(x) {
        return x + 1
    }
     
    function isEven(x) {
        return x % 2 === 0
    }
     
    var xform = ty.compose(
        ty.take(5),
        ty.map(inc),
        ty.filter(isEven),
        ty.reverse()
    )
     
    console.log(ty.array(xform, [1, 2, 3, 4, 5, 6, 7]))
     
    // => [ 6, 4, 2 ]

    Note

    To be frankly, the transy is kind of a subset of transducer since it used less info than tranduce, therefore, you should be able to convert any transy function to transducer.

    API Document

    compose

    var ty = require('transy')
     
    ty.compose(
        ty.map(),
        ty.filter(),
        ty.map()
    )

    chain

    var ty = require('transy')
     
    ty.chain(c => c
        .map()
        .filter()
        .map()
    )

    Keywords

    none

    Install

    npm i transy

    DownloadsWeekly Downloads

    2

    Version

    0.0.4

    License

    MIT

    Last publish

    Collaborators

    • gyson