DUCEN - The Transducer Engine
This package is an extension of transducers.js library. The following features have been added:
- flow types
- additional transducers: sort, group, groupBy
- additional utility functions: reducer, transducer, process
- transducer recipes
- incremental processing of updates
Installation
npm install ducen
Example
Transducer recipe:
var compile = ;var seq = ; // Define a transducer recipevar recipe = op: 'MAP' x + 1 op: 'FILTER' x % 2 === 0 op: 'SORT' a - b op: 'TAKE' 5 op: 'REDUCE' 0 total + input total ; // Compile the recipe into a tranducervar xf = ; // Transform input with the compiled transducervar input = 11 10 9 8 7 6 5 4 3 2 1;var output = ;// [30]
With flow types:
;; ;; // Define a transducer recipelet recipe: TransducerRecipe<number number> = op: 'MAP' fn: x: number: x + 1 op: 'FILTER' fn: x: number: x % 2 === 0 op: 'SORT' fn: a: number b: number: a - b op: 'TAKE' 5 op: 'REDUCE' 0 total + input total ; // Compile the recipe into a tranducerconst xf: Transducer<number number Array<number>> = ; // Transform input with the compiled transducerconst input: Array<number> = 11 10 9 8 7 6 5 4 3 2 1;const output: Array<number> = ;// [30]
Development
Setup:
git clone https://github.com/applitopia/ducen.gitcd ducennpm install
Lint:
npm run lint
Build:
npm run build
Test:
npm test
Lint, Build, & Test:
npm run all
Update Dependencies:
npm update --save
License
MIT