0.0.4 • Published 10 years ago

transy v0.0.4

Weekly downloads
1
License
MIT
Repository
-
Last release
10 years ago

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()
)
0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago