ts declarations
This commit is contained in:
parent
ab6c644a87
commit
87b6b67390
3 changed files with 206 additions and 2 deletions
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -11,7 +11,8 @@
|
|||
"devDependencies": {
|
||||
"@apeleghq/esbuild-plugin-closure-compiler": "^1.0.8",
|
||||
"esbuild": "^0.25.3",
|
||||
"folktest": "git+https://git.kitsu.cafe/rowan/folktest.git"
|
||||
"folktest": "git+https://git.kitsu.cafe/rowan/folktest.git",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@apeleghq/esbuild-plugin-closure-compiler": {
|
||||
|
@ -814,6 +815,20 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"devDependencies": {
|
||||
"@apeleghq/esbuild-plugin-closure-compiler": "^1.0.8",
|
||||
"esbuild": "^0.25.3",
|
||||
"folktest": "git+https://git.kitsu.cafe/rowan/folktest.git"
|
||||
"folktest": "git+https://git.kitsu.cafe/rowan/folktest.git",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
|
|
188
src/index.d.ts
vendored
Normal file
188
src/index.d.ts
vendored
Normal file
|
@ -0,0 +1,188 @@
|
|||
type Nullable<T> = T | null | undefined;
|
||||
export interface Predicate<T> {
|
||||
(value: Nullable<T>, index: number): boolean;
|
||||
}
|
||||
export interface Reducer<T, U = T> {
|
||||
(accumulator: U, value: Nullable<T>, index: number): U;
|
||||
}
|
||||
export interface Morphism<T, U = T> {
|
||||
(value: Nullable<T>, index: number): U;
|
||||
}
|
||||
export interface IEnumerator<T> {
|
||||
get current(): Nullable<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
}
|
||||
export interface IEnumerable<T> {
|
||||
enumerator(): IEnumerator<T>;
|
||||
}
|
||||
export interface IEnumeratorFactory<T> {
|
||||
(iterator: Iterator<T>): IEnumerator<T>;
|
||||
}
|
||||
export declare function isIterable(value: any): value is Iterable<any>;
|
||||
export declare function isIterator(value: any): value is Iterator<any>;
|
||||
export declare function isBuffer(value: any): value is ArrayBufferLike;
|
||||
export declare function isArrayLike(value: any): value is ArrayLike<any>;
|
||||
export declare class IteratorEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterator;
|
||||
private _consumed;
|
||||
private _current;
|
||||
get current(): Nullable<T>;
|
||||
constructor(iterator: Iterator<T>);
|
||||
static from<T>(iterator: Iterator<T>): IteratorEnumerator<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T>;
|
||||
return(value?: any): IteratorResult<T, any>;
|
||||
throw(e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
export declare class CachedIteratorEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterator;
|
||||
private _cache;
|
||||
private _index;
|
||||
get current(): Nullable<T>;
|
||||
constructor(iterator: Iterator<T>);
|
||||
static from<T>(iterator: Iterator<T>): CachedIteratorEnumerator<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T, any>;
|
||||
throw(e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
export declare class IterableEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
private _iterable;
|
||||
private _factory;
|
||||
private _enumerator;
|
||||
get current(): Nullable<T>;
|
||||
constructor(iterable: Iterable<T>, factory?: IEnumeratorFactory<T>);
|
||||
static fromIterable<T>(iterable: Iterable<T>, factory?: IEnumeratorFactory<T>): IEnumerator<T>;
|
||||
moveNext(): boolean;
|
||||
_createIterator(): Iterator<T>;
|
||||
_createEnumerator(): IEnumerator<T>;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any>;
|
||||
return?(value?: any): IteratorResult<T, any>;
|
||||
throw?(e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
type ArrayType<T extends ArrayLike<any> | ArrayBufferView> = T extends ArrayLike<infer U> ? U : T extends ArrayBufferTypes ? number : never;
|
||||
export declare class ArrayEnumerator<T> implements IEnumerator<T>, Iterator<T>, Iterable<T> {
|
||||
private _array;
|
||||
private _index;
|
||||
get current(): Nullable<T>;
|
||||
constructor(array: ArrayLike<T>);
|
||||
static from<A extends ArrayLike<any> | ArrayBufferView>(array: A): ArrayEnumerator<ArrayType<A>>;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
setIndex(index: number): void;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any>;
|
||||
return?(_value?: any): IteratorResult<T, any>;
|
||||
throw?(_e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
export declare class Enumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
protected _enumerator: IEnumerator<T>;
|
||||
protected _index: number;
|
||||
get current(): Nullable<T>;
|
||||
constructor(enumerator: IEnumerator<T>);
|
||||
static fromIterable<T>(iterable: Iterable<T>): IEnumerator<T>;
|
||||
static fromIterator<T>(iterator: Iterator<T>, cache?: boolean): IEnumerator<T>;
|
||||
static toIterator<T>(enumerator: IEnumerator<T>): Iterator<T>;
|
||||
[Symbol.iterator](): Iterator<unknown, any, any>;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any>;
|
||||
return?(_value?: any): IteratorResult<T, any>;
|
||||
throw?(_e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
export declare class HelperEnumerator<T> implements IEnumerator<T>, Iterator<T> {
|
||||
protected _enumerator: IEnumerator<T>;
|
||||
protected _index: number;
|
||||
get current(): Nullable<T>;
|
||||
constructor(enumerator: IEnumerator<T>);
|
||||
static toIterator<T>(enumerator: IEnumerator<T>): Iterator<T>;
|
||||
[Symbol.iterator](): Iterator<unknown, any, any>;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
next(...[_value]: [] | [any]): IteratorResult<T, any>;
|
||||
return?(_value?: any): IteratorResult<T, any>;
|
||||
throw?(_e?: any): IteratorResult<T, any>;
|
||||
}
|
||||
export declare class DropEnumerator<T> extends HelperEnumerator<T> {
|
||||
private _limit;
|
||||
constructor(enumerator: IEnumerator<T>, limit: number);
|
||||
moveNext(): boolean;
|
||||
}
|
||||
export declare class FilterEnumerator<T> extends HelperEnumerator<T> {
|
||||
private _filter;
|
||||
constructor(enumerator: IEnumerator<T>, filter: Predicate<T>);
|
||||
moveNext(): boolean;
|
||||
}
|
||||
export declare class FlatMapEnumerator<T, U = T> implements IEnumerator<U> {
|
||||
private _enumerator;
|
||||
private _flatMap;
|
||||
private _inner?;
|
||||
private _index;
|
||||
constructor(enumerator: IEnumerator<T>, flatMap: Morphism<T, IEnumerator<U>>);
|
||||
get current(): Nullable<U>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
}
|
||||
export declare class MapEnumerator<T, U = T> implements IEnumerator<U> {
|
||||
private _enumerator;
|
||||
private _map;
|
||||
private _current;
|
||||
private _index;
|
||||
get current(): U;
|
||||
constructor(enumerator: IEnumerator<T>, map: Morphism<T, U>);
|
||||
toIterator<U>(): Iterator<U>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
}
|
||||
export declare class TakeEnumerator<T> extends HelperEnumerator<T> {
|
||||
private _limit;
|
||||
constructor(enumerator: IEnumerator<T>, limit: number);
|
||||
moveNext(): boolean;
|
||||
}
|
||||
export declare class FusedEnumerator<T> implements IEnumerator<T> {
|
||||
private _enumerators;
|
||||
private _index;
|
||||
get current(): Nullable<T>;
|
||||
constructor(enumerators: IEnumerator<T>[]);
|
||||
private _cur;
|
||||
private _done;
|
||||
toIterator<T>(): Iterator<T>;
|
||||
moveNext(): boolean;
|
||||
reset(): void;
|
||||
}
|
||||
export declare class Enumerable<T> implements IEnumerable<T>, Iterable<T> {
|
||||
protected _enumerator: IEnumerator<T>;
|
||||
constructor(enumerator: IEnumerator<T>);
|
||||
static from<T>(value: IEnumerable<T> | IEnumerator<T> | Iterable<T> | Iterator<T>): Enumerable<T>;
|
||||
static isEnumerable<T>(value: object): value is Enumerable<T>;
|
||||
static isEnumerator<T>(value: object): value is IEnumerator<T>;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
at(index: number): Nullable<T>;
|
||||
atOrDefault(index: number, defaultValue: T): T;
|
||||
atOrElse(index: number, defaultValue: () => T): T;
|
||||
concat(other: IEnumerable<T>): IEnumerable<T>;
|
||||
drop(limit: number): Enumerable<T>;
|
||||
enumerator(): IEnumerator<T>;
|
||||
every(predicate: Predicate<T>): boolean;
|
||||
filter(predicate: Predicate<T>): IEnumerable<T>;
|
||||
flatMap<U>(fn: Morphism<T, IEnumerator<U>>): IEnumerable<U>;
|
||||
map<U>(fn: Morphism<T, U>): IEnumerable<U>;
|
||||
some(predicate: Predicate<T>): boolean;
|
||||
take(limit: number): IEnumerable<T>;
|
||||
}
|
||||
export declare class ArrayEnumerble<T> extends Enumerable<T> {
|
||||
at(index: number): Nullable<T>;
|
||||
}
|
||||
export {};
|
Loading…
Add table
Reference in a new issue