Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/defs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export declare function getFinalValue<T>(o: FinalValue<T>): T;
/**
* Alias for {@link finalValue}
*/
export declare const final = finalValue;
export declare const final: typeof finalValue;

/**
* Interface for a value that has been marked as multiple values.
Expand Down Expand Up @@ -169,30 +169,30 @@ export declare function clearFunctionList<
* @returns a `Many` containing the value
* @remarks `Many` is used to return multiple values from a regular (non-generator) function.
*/
export declare function toMany<T>(value: readonly Many<T>): Many<T>;
export declare function toMany<T>(value: Readonly<Many<T>>): Many<T>;
export declare function toMany(value: typeof none): Many<never>;
export declare function toMany<T>(value: readonly T): Many<T>;
export declare function toMany<T>(value: Readonly<T>): Many<T>;
/**
* Normalize a value by unbundling it if it is a `Many`.
* @param value the value to normalize
* @returns the normalized value
*/
export declare function normalizeMany(value: readonly unknown): unknown;
export declare function normalizeMany(value: Readonly<unknown>): unknown;
/**
* Combine two values into a `Many`.
* @param a the first value
* @param b the second value
* @returns a `Many` containing both values
*/
export declare function combineMany(a: typeof none, b: typeof none): Many<never>;
export declare function combineMany<T>(a: typeof none, b: readonly Many<T>): Many<T>;
export declare function combineMany<T>(a: readonly Many<T>, b: typeof none): Many<T>;
export declare function combineMany<T>(a: typeof none, b: readonly T): Many<T>;
export declare function combineMany<T>(a: readonly T, b: typeof none): Many<T>;
export declare function combineMany<T, U>(a: readonly Many<T>, b: readonly Many<U>): Many<T | U>;
export declare function combineMany<T, U>(a: readonly T, b: readonly Many<U>): Many<T | U>;
export declare function combineMany<T, U>(a: readonly Many<T>, b: readonly U): Many<T | U>;
export declare function combineMany<T, U>(a: readonly T, b: readonly U): Many<T | U>;
export declare function combineMany<T>(a: typeof none, b: Readonly<Many<T>>): Many<T>;
export declare function combineMany<T>(a: Readonly<Many<T>>, b: typeof none): Many<T>;
export declare function combineMany<T>(a: typeof none, b: Readonly<T>): Many<T>;
export declare function combineMany<T>(a: Readonly<T>, b: typeof none): Many<T>;
export declare function combineMany<T, U>(a: Readonly<Many<T>>, b: Readonly<Many<U>>): Many<T | U>;
export declare function combineMany<T, U>(a: Readonly<T>, b: Readonly<Many<U>>): Many<T | U>;
export declare function combineMany<T, U>(a: Readonly<Many<T>>, b: Readonly<U>): Many<T | U>;
export declare function combineMany<T, U>(a: Readonly<T>, b: Readonly<U>): Many<T | U>;
/**
* Combine two values into a `Many` mutably.
* @param a the first value
Expand All @@ -201,14 +201,14 @@ export declare function combineMany<T, U>(a: readonly T, b: readonly U): Many<T
* @remarks if `a` or `b` are `Many`, they can be modified in-place
*/
export declare function combineManyMut(a: typeof none, b: typeof none): Many<never>;
export declare function combineManyMut<T>(a: typeof none, b: readonly Many<T>): Many<T>;
export declare function combineManyMut<T>(a: readonly Many<T>, b: typeof none): Many<T>;
export declare function combineManyMut<T>(a: typeof none, b: readonly T): Many<T>;
export declare function combineManyMut<T>(a: readonly T, b: typeof none): Many<T>;
export declare function combineManyMut<T, U>(a: readonly Many<T>, b: readonly Many<U>): Many<T | U>;
export declare function combineManyMut<T, U>(a: readonly T, b: readonly Many<U>): Many<T | U>;
export declare function combineManyMut<T, U>(a: readonly Many<T>, b: readonly U): Many<T | U>;
export declare function combineManyMut<T, U>(a: readonly T, b: readonly U): Many<T | U>;
export declare function combineManyMut<T>(a: typeof none, b: Readonly<Many<T>>): Many<T>;
export declare function combineManyMut<T>(a: Readonly<Many<T>>, b: typeof none): Many<T>;
export declare function combineManyMut<T>(a: typeof none, b: Readonly<T>): Many<T>;
export declare function combineManyMut<T>(a: Readonly<T>, b: typeof none): Many<T>;
export declare function combineManyMut<T, U>(a: Readonly<Many<T>>, b: Readonly<Many<U>>): Many<T | U>;
export declare function combineManyMut<T, U>(a: Readonly<T>, b: Readonly<Many<U>>): Many<T | U>;
export declare function combineManyMut<T, U>(a: Readonly<Many<T>>, b: Readonly<U>): Many<T | U>;
export declare function combineManyMut<T, U>(a: Readonly<T>, b: Readonly<U>): Many<T | U>;

// generic utilities: unpacking types

Expand Down Expand Up @@ -236,7 +236,7 @@ export type UnpackType<T> = T extends Many<infer U>
/**
* Unpacking the return type of a function as a combination of {@link UnpackType} and {@link UnpackReturnType}.
*/
export type OutputType<F extends function> = UnpackType<UnpackReturnType<F>>;
export type OutputType<F extends (...args: readonly any[]) => unknown> = UnpackType<UnpackReturnType<F>>;

// generic utilities: working with tuples

Expand Down
2 changes: 1 addition & 1 deletion src/gen.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Arg0, Ret, AsFlatList, Fn} from './defs';

export = gen;
export default gen;

/**
* Returns a type, which was expected from a list item.
Expand Down
69 changes: 33 additions & 36 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import {
import gen from './gen';
import asStream from './asStream';

export = chain;

/**
* Represents a typed duplex stream as a pair of readable and writable streams.
*/
Expand Down Expand Up @@ -238,7 +236,7 @@ declare function dataSource<F>(
* @remarks This is the main function of this library.
*/
declare function chain<L extends readonly unknown[]>(
...fns: ChainList<Arg0<L>, L>,
fns: ChainList<Arg0<L>, L>,
options?: ChainOptions
): ChainOutput<Arg0<L>, Ret<L>>;

Expand All @@ -247,36 +245,35 @@ declare function chainUnchecked<W = any, R = any>(
options?: ChainOptions
): ChainOutput<W, R>;

declare namespace chain {
export {
none,
stop,
Stop,
finalSymbol,
finalValue,
final,
isFinalValue,
getFinalValue,
manySymbol,
many,
isMany,
getManyValues,
getFunctionList,
flushSymbol,
flushable,
isFlushable,
fListSymbol,
isFunctionList,
setFunctionList,
clearFunctionList,
toMany,
normalizeMany,
combineMany,
combineManyMut,
chain,
chainUnchecked,
gen,
asStream,
dataSource
};
}
export default chain;
export {
none,
stop,
Stop,
finalSymbol,
finalValue,
final,
isFinalValue,
getFinalValue,
manySymbol,
many,
isMany,
getManyValues,
getFunctionList,
flushSymbol,
flushable,
isFlushable,
fListSymbol,
isFunctionList,
setFunctionList,
clearFunctionList,
toMany,
normalizeMany,
combineMany,
combineManyMut,
chain,
chainUnchecked,
gen,
asStream,
dataSource
};
24 changes: 6 additions & 18 deletions src/typed-streams.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,28 @@ import {Duplex, Readable, Transform, Writable} from 'node:stream';
* Technical class to add input/output types to duplex streams.
*/
export declare class TypedDuplex<W = any, R = W> extends Duplex {
__streamTypeR(): R {
return null as R;
}
__streamTypeW(): W {
return null as W;
}
__streamTypeR(): R
__streamTypeW(): W
}

/**
* Technical class to add output type to readable streams.
*/
export declare class TypedReadable<R = any> extends Readable {
__streamTypeR(): R {
return null as R;
}
__streamTypeR(): R
}

/**
* Technical class to add input/output types to transform streams.
*/
export declare class TypedTransform<W = any, R = W> extends Transform {
__streamTypeR(): R {
return null as R;
}
__streamTypeW(): W {
return null as W;
}
__streamTypeR(): R
__streamTypeW(): W
}

/**
* Technical class to add input type to writable streams.
*/
export declare class TypedWritable<W = any> extends Writable {
__streamTypeW(): W {
return null as W;
}
__streamTypeW(): W
}
2 changes: 1 addition & 1 deletion src/utils/readableFrom.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="node" />

import {Readable, ReadableOptions} from 'node:stream';
import {ReadableOptions} from 'node:stream';
import {TypedReadable} from '../typed-streams';

export = readableFrom;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/reduceStream.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="node" />

import {Writable, WritableOptions} from 'stream';
import {WritableOptions} from 'stream';
import {TypedWritable} from '../typed-streams';

export = reduceStream;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/take.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export = take;
*/
declare function take<T = any>(
n: number,
finalValue?: typeof none | typeof stop = none

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot put a default value in a declare function

finalValue?: typeof none | typeof stop
): (value: T) => T | typeof finalValue;
6 changes: 3 additions & 3 deletions src/utils/takeWhile.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {none, stop} from './defs';
import {none, stop} from '../defs';

export = takeWhile;

Expand All @@ -10,9 +10,9 @@ export = takeWhile;
*/
declare function takeWhile<T>(
fn: (value: T) => boolean,
finalValue?: typeof none | typeof stop = none
finalValue?: typeof none | typeof stop
): (value: unknown) => T | typeof finalValue;
declare function takeWhile<T>(
fn: (value: T) => Promise<boolean>,
finalValue?: typeof none | typeof stop = none
finalValue?: typeof none | typeof stop
): (value: unknown) => Promise<T | typeof finalValue>;
2 changes: 1 addition & 1 deletion src/utils/takeWithSkip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export = takeWithSkip;
declare function takeWithSkip<T = any>(
n: number,
skip?: number,
finalValue?: typeof none | typeof stop = none
finalValue?: typeof none | typeof stop
): (value: T) => T | typeof finalValue;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": false /* Skip type checking all .d.ts files. */
}
}