asynciterator
Advanced tools
Comparing version
@@ -274,3 +274,3 @@ /** | ||
*/ | ||
map<D>(map: (item: T) => D, self?: any): AsyncIterator<D>; | ||
map<D>(map: MapFunction<T, D>, self?: any): AsyncIterator<D>; | ||
/** | ||
@@ -415,3 +415,26 @@ Return items from this iterator that match the filter. | ||
/** | ||
A iterator that maintains an internal buffer of items. | ||
* A synchronous mapping function from one element to another. | ||
* A return value of `null` means that nothing should be emitted for a particular item. | ||
*/ | ||
export declare type MapFunction<S, D = S> = (item: S) => D | null; | ||
/** Function that maps an element to itself. */ | ||
export declare function identity<S>(item: S): typeof item; | ||
/** | ||
An iterator that synchronously transforms every item from its source | ||
by applying a mapping function. | ||
@extends module:asynciterator.AsyncIterator | ||
*/ | ||
export declare class MappingIterator<S, D = S> extends AsyncIterator<D> { | ||
protected readonly _map: MapFunction<S, D>; | ||
protected readonly _source: InternalSource<S>; | ||
protected readonly _destroySource: boolean; | ||
/** | ||
* Applies the given mapping to the source iterator. | ||
*/ | ||
constructor(source: AsyncIterator<S>, map?: MapFunction<S, D>, options?: SourcedIteratorOptions); | ||
read(): D | null; | ||
protected _end(destroy: boolean): void; | ||
} | ||
/** | ||
An iterator that maintains an internal buffer of items. | ||
This class serves as a base class for other iterators | ||
@@ -433,6 +456,3 @@ with a typically complex item generation process. | ||
*/ | ||
constructor({ maxBufferSize, autoStart }?: { | ||
maxBufferSize?: number | undefined; | ||
autoStart?: boolean | undefined; | ||
}); | ||
constructor({ maxBufferSize, autoStart }?: BufferedIteratorOptions); | ||
/** | ||
@@ -753,2 +773,5 @@ The maximum number of items to preload in the internal buffer. | ||
export declare function range(start: number, end: number, step?: number): IntegerIterator; | ||
export interface SourcedIteratorOptions { | ||
destroySource?: boolean; | ||
} | ||
export interface BufferedIteratorOptions { | ||
@@ -758,6 +781,5 @@ maxBufferSize?: number; | ||
} | ||
export interface TransformIteratorOptions<S> extends BufferedIteratorOptions { | ||
export interface TransformIteratorOptions<S> extends SourcedIteratorOptions, BufferedIteratorOptions { | ||
source?: SourceExpression<S>; | ||
optional?: boolean; | ||
destroySource?: boolean; | ||
} | ||
@@ -764,0 +786,0 @@ export interface TransformOptions<S, D> extends TransformIteratorOptions<S> { |
{ | ||
"name": "asynciterator", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"description": "An asynchronous iterator library for advanced object pipelines.", | ||
"author": "Ruben Verborgh <ruben@verborgh.org>", | ||
"author": "Ruben Verborgh <ruben@verborgh.org> (https://ruben.verborgh.org/)", | ||
"contributors": [ | ||
"Ruben Taelman <ruben.taelman@ugent.be> (https://www.rubensworks.net/)", | ||
"Jesse Wright <jmwright.045@gmail.com> (https://github.com/jeswr/)", | ||
"Jacopo Scazzosi <jacopo@scazzosi.com> (https://jacoscaz.com/)" | ||
], | ||
"license": "MIT", | ||
"repository": "RubenVerborgh/AsyncIterator", | ||
"type": "module", | ||
@@ -34,8 +41,6 @@ "main": "dist/asynciterator.cjs", | ||
"mocha": "c8 mocha", | ||
"lint": "eslint asynciterator.ts test", | ||
"lint": "eslint asynciterator.ts test perf", | ||
"docs": "npm run build:module && npm run jsdoc", | ||
"jsdoc": "jsdoc -c jsdoc.json" | ||
}, | ||
"license": "MIT", | ||
"repository": "RubenVerborgh/AsyncIterator", | ||
"devDependencies": { | ||
@@ -42,0 +47,0 @@ "@babel/cli": "^7.10.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
197535
3.44%4581
4%