Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/transducers

Package Overview
Dependencies
Maintainers
1
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/transducers - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

iter/constantly.d.ts

12

index.d.ts

@@ -33,2 +33,3 @@ export * from "./api";

export * from "./xform/drop";
export * from "./xform/duplicate";
export * from "./xform/filter";

@@ -43,2 +44,3 @@ export * from "./xform/flatten-with";

export * from "./xform/map-indexed";
export * from "./xform/map-nth";
export * from "./xform/map";

@@ -52,3 +54,2 @@ export * from "./xform/mapcat";

export * from "./xform/rename";
export * from "./xform/repeat";
export * from "./xform/sample";

@@ -74,1 +75,10 @@ export * from "./xform/scan";

export * from "./func/swizzler";
export * from "./iter/constantly";
export * from "./iter/cycle";
export * from "./iter/iterate";
export * from "./iter/pairs";
export * from "./iter/range";
export * from "./iter/repeat";
export * from "./iter/repeatedly";
export * from "./iter/reverse";
export * from "./iter/tuples";

@@ -38,2 +38,3 @@ "use strict";

__export(require("./xform/drop"));
__export(require("./xform/duplicate"));
__export(require("./xform/filter"));

@@ -48,2 +49,3 @@ __export(require("./xform/flatten-with"));

__export(require("./xform/map-indexed"));
__export(require("./xform/map-nth"));
__export(require("./xform/map"));

@@ -57,3 +59,2 @@ __export(require("./xform/mapcat"));

__export(require("./xform/rename"));
__export(require("./xform/repeat"));
__export(require("./xform/sample"));

@@ -79,1 +80,10 @@ __export(require("./xform/scan"));

__export(require("./func/swizzler"));
__export(require("./iter/constantly"));
__export(require("./iter/cycle"));
__export(require("./iter/iterate"));
__export(require("./iter/pairs"));
__export(require("./iter/range"));
__export(require("./iter/repeat"));
__export(require("./iter/repeatedly"));
__export(require("./iter/reverse"));
__export(require("./iter/tuples"));

18

package.json
{
"name": "@thi.ng/transducers",
"version": "0.7.0",
"version": "0.8.0",
"description": "Lightweight transducer implementations for ES6 / TypeScript",

@@ -11,7 +11,7 @@ "main": "index.js",

"scripts": {
"build": "rm -rf build && tsc --declaration && cp package.json build && cp *.md build",
"build": "rm -rf build && tsc --declaration && cp package.json build",
"doc": "node_modules/.bin/typedoc --mode modules --out doc src",
"test": "tsc -p test && mocha build.test/test/*.js",
"clean": "rm -rf build build.test doc node_modules && yarn install",
"pub": "yarn run build && (cd build && yarn publish --access public)"
"pub": "yarn run build && cp *.md LICENSE build && (cd build && yarn publish --access public)"
},

@@ -25,3 +25,13 @@ "devDependencies": {

"@thi.ng/api": "^1.1.1"
}
},
"keywords": [
"ES6",
"typescript",
"transducer",
"reducer",
"generator",
"iterator",
"functional",
"pipeline"
]
}

@@ -5,7 +5,12 @@ # @thi.ng/transducers

Lightweight transducer implementations for ES6 / TypeScript (8KB minified, full lib).
Lightweight transducer implementations for ES6 / TypeScript (19KB minified, full lib).
The library provides 36 transducers and 18 reducers for composing data
transformation pipelines (more to come).
Currently, the library provides altogether 65+ transducers, reducers and
generators for composing data transformation pipelines.
The overall concept and many of the functions offered here are directly
inspired by the original Clojure implementation by Rich Hickey, though the
implementation does differ and several generally highly useful operators
have been added, with more are to come.
Please see the [@thi.ng/iterators](https://github.com/thi-ng/iterators) &

@@ -15,2 +20,7 @@ [@thi.ng/csp](https://github.com/thi-ng/csp) partner modules for related

Having said this, since 0.8.0 this project largely supersedes the
[@thi.ng/iterators](https://github.com/thi-ng/iterators) library for most use
cases and offers are more powerful API and potentially faster execution of
composed transformations (due to lack of ES generator overheads).
## Installation

@@ -24,2 +34,5 @@

Almost all functions can be imported selectively, but for development purposes
full module re-exports are defined.
```typescript

@@ -284,12 +297,23 @@ // full import

Returns new transducer composed from given transducers. Data flow is from left
to right. Offers fast paths for up to 10 args. If more are given, composition
is done dynamically via for loop.
#### `compR(rfn: Reducer<any, any>, fn: (acc, x) => any): Reducer<any, any>`
Helper function to build reducers.
#### `iterator<A, B>(tx: Transducer<A, B>, xs: Iterable<A>): IterableIterator<B>`
#### `juxt(f1, f2, ...)`
Similar to `transduce()`, but emits results as ES6 iterator (and hence doesn't use a reduction function).
#### `reduce<A, B>(rfn: Reducer<A, B>, acc: A, xs: Iterable<B>): A`
Reduces iterable using given reducer and optional initial accumulator/result.
#### `transduce<A, B, C>(tx: Transducer<A, B>, rfn: Reducer<C, B>, acc: C, xs: Iterable<A>): C`
Transforms iterable using given transducer and combines results with given
reducer and optional initial accumulator/result.
### Transducers

@@ -313,2 +337,4 @@

#### `duplicate<T>(n?: number): Transducer<T, T>`
#### `filter<T>(pred: Predicate<T>): Transducer<T, T>`

@@ -318,3 +344,3 @@

#### `flattenOnly<T>(pred: Predicate<T>): Transducer<T | Iterable<T>, T>`
#### `flattenWith<T>(fn: (x: T) => Iterable<T>): Transducer<T | Iterable<T>, T>`

@@ -337,2 +363,6 @@ #### `indexed<T>(): Transducer<T, [number, T]>`

#### `mapNth<A, B>(n: number, offset: number, fn: (x: A) => B): Transducer<A, B>`
#### `movingAverage(n: number): Transducer<number, number>`
#### `partition<T>(size: number, step?: number, all?: boolean): Transducer<T, T[]>`

@@ -346,4 +376,2 @@

#### `repeat<T>(n: number): Transducer<T, T>`
#### `sample<T>(prob: number): Transducer<T, T>`

@@ -361,4 +389,8 @@

#### `swizzle<T>(order: PropertyKey[]): Transducer<T, any>`
#### `take<T>(n: number): Transducer<T, T>`
#### `takeLast<T>(n: number): Transducer<T, T>`
#### `takeNth<T>(n: number): Transducer<T, T>`

@@ -404,2 +436,22 @@

### Generators / Iterators
#### `constantly<T>(x: T): IterableIterator<T>`
#### `cycle<T>(input: Iterable<T>): IterableIterator<T>`
#### `iterate<T>(fn: (x: T) => T, seed: T): IterableIterator<T>`
#### `pairs(x: any): IterableIterator<[string, any]>`
#### `range(from?: number, to?: number, step?: number): IterableIterator<number>`
#### `repeat<T>(x: T, n?: number): IterableIterator<T>`
#### `repeatedly<T>(fn: () => T, n?: number): IterableIterator<T>`
#### `reverse<T>(input: Iterable<T>): IterableIterator<any>`
#### `tuples(...src: Iterable<any>[]): IterableIterator<any[]>`
## Authors

@@ -406,0 +458,0 @@ - Karsten Schmidt

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc