Remove asynciterator typings (#45946)

This commit is contained in:
Ruben Taelman 2020-07-11 03:56:07 +02:00 committed by GitHub
parent bbe969c2cd
commit 53dab9420a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 372 deletions

View File

@ -192,6 +192,12 @@
"sourceRepoURL": "https://github.com/scriby/asyncblock",
"asOfVersion": "2.2.11"
},
{
"libraryName": "asynciterator",
"typingsPackageName": "asynciterator",
"sourceRepoURL": "https://github.com/RubenVerborgh/AsyncIterator/",
"asOfVersion": "3.0.0"
},
{
"libraryName": "aurelia-knockout",
"typingsPackageName": "aurelia-knockout",

View File

@ -1,147 +0,0 @@
import { ArrayIterator, AsyncIterator, BufferedIterator, ClonedIterator, EmptyIterator, IntegerIterator,
MultiTransformIterator, SingletonIterator, SimpleTransformIterator, TransformIterator } from "asynciterator";
import * as fs from "fs";
function test_asynciterator() {
// We can't instantiate an abstract class.
const it1: AsyncIterator<number> = <any> {};
const read1: number = it1.read();
it1.each((data: number) => console.log(data));
it1.each((data: number) => console.log(data), {});
it1.close();
const it2: AsyncIterator<string> = <any> {};
const read2: string = it2.read();
it2.each((data: string) => console.log(data));
it2.each((data: string) => console.log(data), {});
it2.close();
const it3: AsyncIterator<AsyncIterator<string>> = <any> {};
const read3: AsyncIterator<string> = it3.read();
it3.each((data: AsyncIterator<string>) => data.each((data: string) => console.log(data)));
it3.each((data: AsyncIterator<string>) => data.each((data: string) => console.log(data), {}), {});
it3.close();
const readable2: boolean = it1.readable;
const closed2: boolean = it1.closed;
const ended2: boolean = it1.ended;
it1.setProperty('name1', 123);
it2.setProperty('name2', 'someValue');
const p1: number = it1.getProperty('name1');
const p2: string = it1.getProperty('name2');
it1.getProperty('name1', (value: number) => console.log(value));
it1.getProperty('name2', (value: string) => console.log(value));
const ps1: {[id: string]: any} = it1.getProperties();
it1.setProperties({ name1: 1234, name2: 'someOtherValue' });
it1.copyProperties(it2, [ 'name1', 'name2' ]);
const str: string = it1.toString();
const stit1: SimpleTransformIterator<number, string> = it1.transform();
const stit1_: SimpleTransformIterator<number, string> = it1.transform({
transform: (item, done) => {
if (item === 0) {
done();
} else {
done('' + item);
}
},
});
const stit2: SimpleTransformIterator<number, string> = it1.map((number: number) => 'i' + number);
const stit3: AsyncIterator<string> = it1.map((number: number) => 'i' + number);
const stit4: AsyncIterator<number> = it2.map(parseInt);
const stit5: AsyncIterator<number> = it1.map((number: number) => number + 1);
const stit6: AsyncIterator<number> = it1.filter((number: number) => number < 10);
const stit7: AsyncIterator<number> = it1.prepend([0, 1, 2]);
const stit8: AsyncIterator<number> = it1.append([0, 1, 2]);
const stit9: AsyncIterator<number> = it1.surround([0, 1, 2], [0, 1, 2]);
const stit10: AsyncIterator<number> = it1.skip(2);
const stit11: AsyncIterator<number> = it1.take(2);
const stit12: AsyncIterator<number> = it1.range(2, 20);
const stit13: AsyncIterator<number> = it1.clone();
const intit1: IntegerIterator = AsyncIterator.range(10, 100, 1);
const intit2: IntegerIterator = AsyncIterator.range(10, 100);
const intit3: IntegerIterator = AsyncIterator.range(10);
const intit4: IntegerIterator = AsyncIterator.range();
const wrapit = AsyncIterator.wrap(fs.createReadStream('stream.txt'));
}
function test_emptyiterator() {
const it1: AsyncIterator<number> = new EmptyIterator();
const it2: AsyncIterator<string> = new EmptyIterator();
}
function test_singletoniterator() {
const it1: AsyncIterator<number> = new SingletonIterator(3);
const it2: AsyncIterator<string> = new SingletonIterator('a');
}
function test_arrayiterator() {
const it1: AsyncIterator<number> = new ArrayIterator([1, 2, 3]);
const it2: AsyncIterator<string> = new ArrayIterator(['a', 'b', 'c']);
}
function test_integeriterator() {
const it1: IntegerIterator = new IntegerIterator();
const it2: AsyncIterator<number> = new IntegerIterator({});
const it3: AsyncIterator<number> = new IntegerIterator({ start: 0 });
const it4: AsyncIterator<number> = new IntegerIterator({ end: 100 });
const it5: AsyncIterator<number> = new IntegerIterator({ step: 10 });
}
function test_bufferediterator() {
const it1: BufferedIterator<number> = new BufferedIterator();
const it2: AsyncIterator<number> = new BufferedIterator({});
const it3: AsyncIterator<number> = new BufferedIterator({ maxBufferSize: 10 });
const it4: AsyncIterator<number> = new BufferedIterator({ autoStart: true });
}
function test_transformiterator() {
const it1: TransformIterator<number, string> = new TransformIterator<number, string>();
const it2: AsyncIterator<string> = new TransformIterator<number, string>();
const it3: AsyncIterator<number> = new TransformIterator<string, number>(it1);
const it4: AsyncIterator<number> = new TransformIterator<string, number>(it1, {});
const it5: AsyncIterator<number> = new TransformIterator<string, number>(it1, { optional: true });
const it6: AsyncIterator<number> = new TransformIterator<string, number>({ source: it1 });
const source: AsyncIterator<number> = it1.source;
}
function test_simpletransformiterator() {
const it1: SimpleTransformIterator<number, string> = new SimpleTransformIterator<number, string>();
const it2: TransformIterator<number, string> = new SimpleTransformIterator<number, string>();
const it3: AsyncIterator<string> = new SimpleTransformIterator<number, string>();
const it4: AsyncIterator<number> = new SimpleTransformIterator<string, number>(it1);
const it5: AsyncIterator<number> = new SimpleTransformIterator<string, number>(it1, {});
const it6: AsyncIterator<number> = new SimpleTransformIterator<string, number>({});
const it7: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ optional: true });
const it8: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ source: it1 });
const it9: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ offset: 2 });
const it10: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ limit: 2 });
const it11: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ prepend: [0, 1, 2] });
const it12: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ append: [0, 1, 2] });
const it13: AsyncIterator<number> = new SimpleTransformIterator<number, number>(
{ filter: (val: number) => val > 10 });
const it14: AsyncIterator<number> = new SimpleTransformIterator<number, number>({ map: (val: number) => val + 1 });
const it15: AsyncIterator<number> = new SimpleTransformIterator<number, number>(
{ transform: (val: number, cb: (result: number) => void) => cb(val + 1) });
}
function test_multitransformiterator() {
const it1: MultiTransformIterator<number, string> = new MultiTransformIterator<number, string>();
const it2: TransformIterator<number, string> = new MultiTransformIterator<number, string>();
const it3: AsyncIterator<string> = new MultiTransformIterator<number, string>();
const it4: AsyncIterator<number> = new MultiTransformIterator<string, number>(it1);
const it5: AsyncIterator<number> = new MultiTransformIterator<string, number>(it1, {});
const it6: AsyncIterator<number> = new MultiTransformIterator<string, number>({});
const it7: AsyncIterator<number> = new MultiTransformIterator<string, number>({ optional: true });
const it8: AsyncIterator<number> = new MultiTransformIterator<string, number>({ source: it1 });
}
function test_clonediterator() {
const it1: ClonedIterator<number> = new ClonedIterator<number>();
const it2: ClonedIterator<number> = new ClonedIterator<number>(it1);
}

View File

@ -1,184 +0,0 @@
// Type definitions for asynciterator 1.1
// Project: https://github.com/rubenverborgh/AsyncIterator#readme
// Definitions by: Ruben Taelman <https://github.com/rubensworks>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
import { EventEmitter } from "events";
export abstract class AsyncIterator<T> implements EventEmitter {
static STATES: ['INIT', 'OPEN', 'CLOSING', 'CLOSED', 'ENDED'];
static INIT: 0;
static OPEN: 1;
static CLOSING: 2;
static CLOSED: 3;
static ENDED: 4;
_state: number;
_readable: boolean;
_destination?: AsyncIterator<any>;
readable: boolean;
closed: boolean;
ended: boolean;
constructor();
read(): T;
each(callback: (data: T) => void, self?: any): void;
close(): void;
_changeState(newState: number, eventAsync?: boolean): void;
private _hasListeners(eventName: string | symbol): boolean;
// tslint:disable-next-line ban-types
private _addSingleListener(eventName: string | symbol, listener: Function): void;
_end(): void;
getProperty(propertyName: string, callback?: (value: any) => void): any;
setProperty(propertyName: string, value: any): void;
getProperties(): {[id: string]: any};
setProperties(properties: {[id: string]: any}): void;
copyProperties(source: AsyncIterator<any>, propertyNames: string[]): void;
toString(): string;
_toStringDetails(): string;
transform<T2>(options?: SimpleTransformIteratorOptions<T, T2>): SimpleTransformIterator<T, T2>;
map<T2>(mapper: (item: T) => T2, self?: object): SimpleTransformIterator<T, T2>;
filter(filter: (item: T) => boolean, self?: object): SimpleTransformIterator<T, T>;
prepend(items: T[]): SimpleTransformIterator<T, T>;
append<T>(items: T[]): SimpleTransformIterator<T, T>;
surround<T>(prepend: T[], append: T[]): SimpleTransformIterator<T, T>;
skip<T>(offset: number): SimpleTransformIterator<T, T>;
take<T>(limit: number): SimpleTransformIterator<T, T>;
range<T>(start: number, end: number): SimpleTransformIterator<T, T>;
clone(): ClonedIterator<T>;
static range(start?: number, end?: number, step?: number): IntegerIterator;
// From EventEmitter
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string | symbol): Array<() => void>;
rawListeners(event: string | symbol): Array<() => void>;
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(type: string | symbol): number;
// Added in Node 6...
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
static wrap<S>(source?: AsyncIterator<S> | TransformIteratorOptions<S> | NodeJS.ReadableStream, options?: TransformIteratorOptions<S>): TransformIterator<S, any>;
}
export class EmptyIterator<T> extends AsyncIterator<T> {
_state: 4;
}
export class SingletonIterator<T> extends AsyncIterator<T> {
constructor(item?: T);
}
export class ArrayIterator<T> extends AsyncIterator<T> {
constructor(items?: T[]);
}
export interface IntegerIteratorOptions {
step?: number;
end?: number;
start?: number;
}
export class IntegerIterator extends AsyncIterator<number> {
_step: number;
_last: number;
_next: number;
constructor(options?: IntegerIteratorOptions);
}
export interface BufferedIteratorOptions {
maxBufferSize?: number;
autoStart?: boolean;
}
export class BufferedIterator<T> extends AsyncIterator<T> {
maxBufferSize: number;
_pushedCount: number;
_buffer: T[];
_init(autoStart: boolean): void;
_begin(done: () => void): void;
_read(count: number, done: () => void): void;
_push(item: T): void;
_fillBuffer(): void;
_completeClose(): void;
_flush(done: () => void): void;
constructor(options?: BufferedIteratorOptions);
}
export interface TransformIteratorOptions<S> extends BufferedIteratorOptions {
optional?: boolean;
source?: AsyncIterator<S>;
}
export class TransformIterator<S, T> extends BufferedIterator<T> {
_optional: boolean;
source: AsyncIterator<S>;
_validateSource(source: AsyncIterator<S>, allowDestination?: boolean): void;
_transform(item: S, done: (result?: T) => void): void;
_closeWhenDone(): void;
constructor(source?: AsyncIterator<S> | TransformIteratorOptions<S>, options?: TransformIteratorOptions<S>);
}
export interface SimpleTransformIteratorOptions<S, T> extends TransformIteratorOptions<S> {
offset?: number;
limit?: number;
prepend?: T[];
append?: T[];
filter?(item: S): boolean;
map?(item: S): T;
transform?(item: S, callback: (result?: T) => void): void;
}
export class SimpleTransformIterator<S, T> extends TransformIterator<S, T> {
_offset: number;
_limit: number;
_prepender?: ArrayIterator<T>;
_appender?: ArrayIterator<T>;
_filter?(item: S): boolean;
_map?(item: S): T;
_transform(item: S, done: (result?: T) => void): void;
_insert(inserter: AsyncIterator<S>, done: () => void): void;
constructor(source?: AsyncIterator<S> | SimpleTransformIteratorOptions<S, T>,
options?: SimpleTransformIteratorOptions<S, T>);
}
export class MultiTransformIterator<S, T> extends TransformIterator<S, T> {
_transformerQueue: S[];
_createTransformer(element: S): AsyncIterator<T>;
constructor(source?: AsyncIterator<S> | TransformIteratorOptions<S>, options?: TransformIteratorOptions<S>);
}
export class ClonedIterator<T> extends TransformIterator<T, T> {
_readPosition: number;
constructor(source?: AsyncIterator<T>);
}

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"asynciterator-tests.ts"
]
}

View File

@ -1,18 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-angle-bracket-type-assertion": false,
"npm-naming": [
true,
{
"errors": [
[
"NeedsExportEquals",
false
]
],
"mode": "code"
}
]
}
}