tsducer
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

tsducer

npm GitHub Workflow Status

Example

import * as tsd from 'tsducer';

const xf = tsd.compose(
  tsd.filter((x: number) => x % 2 !== 0),
  tsd.map((x) => x * 2),
  tsd.map((x) => x.toString()),
  tsd.take(2)
);
const tTransform = tsd.transduce(xf, tsd.append, [] as string[]);
const iTransform = tsd.into([], xf);

tTransform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // -> ['2', '6']
iTransform([], xf)([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) // -> ['2', '6']
[...tsd.sequence(xf, [1 ,2, 3, 4, 5, 6, 7, 8, 9, 10])] // -> ['2', '6']

References

https://clojure.org/reference/transducers

Readme

Keywords

Package Sidebar

Install

npm i tsducer

Weekly Downloads

3

Version

0.2.3

License

MIT

Unpacked Size

15.5 kB

Total Files

24

Last publish

Collaborators

  • sumboid