diff --git a/modules/-all/index.ts b/modules/-all/index.ts index 8cd6e24..8d612d2 100644 --- a/modules/-all/index.ts +++ b/modules/-all/index.ts @@ -24,13 +24,13 @@ export { default as mapParallel } from '@promises/map-parallel'; export { default as mapSeries } from '@promises/map-series'; export { default as next } from '@promises/next'; export { default as parallel } from '@promises/parallel'; -export { default as promisify, PromisifyOptions } from '@promises/promisify'; +export { default as promisify, IPromisifyOptions } from '@promises/promisify'; export { default as reduceSeries } from '@promises/reduce-series'; export { default as reduceRightSeries } from '@promises/reduce-right-series'; export { default as rejectParallel } from '@promises/reject-parallel'; export { default as rejectSeries } from '@promises/reject-series'; export { default as reset } from '@promises/reset'; -export { default as retry, RetryOptions, RetryFilterInfo, RetryTimeInfo } from '@promises/retry'; +export { default as retry, IRetryOptions, IRetryFilterInfo, IRetryTimeInfo } from '@promises/retry'; export { default as series } from '@promises/series'; export { default as sleep } from '@promises/sleep'; export { default as someParallel } from '@promises/some-parallel'; diff --git a/modules/-constructor/index.ts b/modules/-constructor/index.ts index 6550cd1..ec6ae64 100644 --- a/modules/-constructor/index.ts +++ b/modules/-constructor/index.ts @@ -10,7 +10,7 @@ export { default as create } from '@promises/create'; export { default as delay } from '@promises/delay'; export { default as exec } from '@promises/exec'; export { default as isPromise } from '@promises/is-promise'; -export { default as promisify, PromisifyOptions } from '@promises/promisify'; +export { default as promisify, IPromisifyOptions } from '@promises/promisify'; export { default as parallel } from '@promises/parallel'; export { default as series } from '@promises/series'; export { default as timeout } from '@promises/timeout'; diff --git a/modules/-prototype/index.ts b/modules/-prototype/index.ts index 766a591..eb24e01 100644 --- a/modules/-prototype/index.ts +++ b/modules/-prototype/index.ts @@ -23,7 +23,7 @@ export { default as reduceRightSeries } from '@promises/reduce-right-series'; export { default as rejectParallel } from '@promises/reject-parallel'; export { default as rejectSeries } from '@promises/reject-series'; export { default as reset } from '@promises/reset'; -export { default as retry, RetryOptions, RetryFilterInfo, RetryTimeInfo } from '@promises/retry'; +export { default as retry, IRetryOptions, IRetryFilterInfo, IRetryTimeInfo } from '@promises/retry'; export { default as sleep } from '@promises/sleep'; export { default as someParallel } from '@promises/some-parallel'; export { default as someSeries } from '@promises/some-series'; diff --git a/modules/compose/index.ts b/modules/compose/index.ts index 02eb51a..c9fda6a 100644 --- a/modules/compose/index.ts +++ b/modules/compose/index.ts @@ -6,7 +6,7 @@ import Promises from '@promises/core'; import reduce from '@promises/reduce-series'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -21,15 +21,15 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise, fn6: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise, fn6: (value: OptionalPromise) => OptionalPromise, fn7: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise, fn6: (value: OptionalPromise) => OptionalPromise, fn7: (value: OptionalPromise) => OptionalPromise, fn8: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise, fn6: (value: OptionalPromise) => OptionalPromise, fn7: (value: OptionalPromise) => OptionalPromise, fn8: (value: OptionalPromise) => OptionalPromise, fn9: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; -function composeStatic(fn1: (value?: OptionalPromise) => OptionalPromise, fn2: (value: OptionalPromise) => OptionalPromise, fn3: (value: OptionalPromise) => OptionalPromise, fn4: (value: OptionalPromise) => OptionalPromise, fn5: (value: OptionalPromise) => OptionalPromise, fn6: (value: OptionalPromise) => OptionalPromise, fn7: (value: OptionalPromise) => OptionalPromise, fn8: (value: OptionalPromise) => OptionalPromise, fn9: (value: OptionalPromise) => OptionalPromise, fn10: (value: OptionalPromise) => OptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise, fn6: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise, fn6: (value: IOptionalPromise) => IOptionalPromise, fn7: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise, fn6: (value: IOptionalPromise) => IOptionalPromise, fn7: (value: IOptionalPromise) => IOptionalPromise, fn8: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise, fn6: (value: IOptionalPromise) => IOptionalPromise, fn7: (value: IOptionalPromise) => IOptionalPromise, fn8: (value: IOptionalPromise) => IOptionalPromise, fn9: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; +function composeStatic(fn1: (value?: IOptionalPromise) => IOptionalPromise, fn2: (value: IOptionalPromise) => IOptionalPromise, fn3: (value: IOptionalPromise) => IOptionalPromise, fn4: (value: IOptionalPromise) => IOptionalPromise, fn5: (value: IOptionalPromise) => IOptionalPromise, fn6: (value: IOptionalPromise) => IOptionalPromise, fn7: (value: IOptionalPromise) => IOptionalPromise, fn8: (value: IOptionalPromise) => IOptionalPromise, fn9: (value: IOptionalPromise) => IOptionalPromise, fn10: (value: IOptionalPromise) => IOptionalPromise): (value?: T) => Promises; function composeStatic(...functions) { return (value) => { return reduce(functions, (value, fn) => { diff --git a/modules/create/index.ts b/modules/create/index.ts index 7695111..52fda5e 100644 --- a/modules/create/index.ts +++ b/modules/create/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { IExecute } from '@promises/interfaces'; +import { IExecutor } from '@promises/interfaces'; /** * @example @@ -20,8 +20,8 @@ import { IExecute } from '@promises/interfaces'; * }); * ``` */ -function createStatic(execute: IExecute = (resolve) => resolve()): Promises { - return new Promises(execute); +function createStatic(executor: IExecutor = (resolve) => resolve()): Promises { + return new Promises(executor); } export default createStatic; diff --git a/modules/error/index.ts b/modules/error/index.ts index d17ca25..d6c1b96 100644 --- a/modules/error/index.ts +++ b/modules/error/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -25,7 +25,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function error(promises: OptionalPromise, value: any): Promises { +function error(promises: IOptionalPromise, value: any): Promises { return Promises.resolve(promises).then(() => { throw value; }) as Promises; diff --git a/modules/exec/index.ts b/modules/exec/index.ts index dda71f4..8b95225 100644 --- a/modules/exec/index.ts +++ b/modules/exec/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -20,7 +20,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function execStatic(fn: () => OptionalPromise): Promises { +function execStatic(fn: () => IOptionalPromise): Promises { return Promises.resolve().then(fn) as Promises; } diff --git a/modules/finally/index.ts b/modules/finally/index.ts index aff6c2a..c741233 100644 --- a/modules/finally/index.ts +++ b/modules/finally/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -25,7 +25,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function _finally(promise: OptionalPromise, fn: () => OptionalPromise): Promises { +function _finally(promise: IOptionalPromise, fn: () => IOptionalPromise): Promises { let onBoth = (value) => { let result = fn(); return Promise.resolve(result).then(() => value); @@ -57,6 +57,6 @@ declare module '@promises/core' { * }); * ``` */ - finally(this: Promises, fn: () => OptionalPromise): Promises; + finally(this: Promises, fn: () => IOptionalPromise): Promises; } } diff --git a/modules/interfaces/index.ts b/modules/interfaces/index.ts index 1702d58..51f436c 100644 --- a/modules/interfaces/index.ts +++ b/modules/interfaces/index.ts @@ -6,66 +6,66 @@ import Promises from '@promises/core'; -export type Dictionary = { [key: string]: T }; -export type OptionalPromise = PromiseLike | T; -export type OptionalPromiseArray = OptionalPromise>>; -export type OptionalPromiseDictionary = OptionalPromise>>; -export type IExecute = (resolve?: (value?: T) => void, reject?: (reason?: any) => void) => void; +export type IDictionary = { [key: string]: T }; +export type IOptionalPromise = PromiseLike | T; +export type IOptionalPromiseArray = IOptionalPromise>>; +export type IOptionalPromiseDictionary = IOptionalPromise>>; +export type IExecutor = (resolve?: (value?: T) => void, reject?: (reason?: any) => void) => void; export interface IForEach { - >(str: OptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (object: OptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + >(str: IOptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IForEachWrapper { - (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, array: T) => OptionalPromise): Promises; - (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, array: T) => IOptionalPromise): Promises; + (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IMap { - >(array: OptionalPromiseArray, iteratee?: (value: T[keyof T & number], index: number, array: T) => OptionalPromise): Promises; - , R>(array: OptionalPromiseArray, iteratee?: (value: T[keyof T & number], index: number, array: T) => OptionalPromise): Promises; - (object: OptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; - (object: OptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises>; + >(array: IOptionalPromiseArray, iteratee?: (value: T[keyof T & number], index: number, array: T) => IOptionalPromise): Promises; + , R>(array: IOptionalPromiseArray, iteratee?: (value: T[keyof T & number], index: number, array: T) => IOptionalPromise): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises>; } export interface IMapWrapper { - (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; - (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises>; + (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; + (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises>; } export interface IChecksBoolean { - >(str: OptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (object: OptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + >(str: IOptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IChecksBooleanWrapper { - >(this: Promises, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + >(this: Promises, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IFilter { - >(str: OptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (object: OptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + >(str: IOptionalPromise, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IFilterWrapper { - (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => OptionalPromise): Promises; - (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => OptionalPromise): Promises; + (this: Promises>, iteratee?: (value: T[keyof T & number], index: number, str: T) => IOptionalPromise): Promises; + (this: Promises, iteratee?: (value: T[keyof T], key: keyof T, object: T) => IOptionalPromise): Promises; } export interface IReduce { - >(str: OptionalPromise, iteratee?: (accumulator: T[keyof T & number], value: T[keyof T & number], index: number, str: T) => OptionalPromise, accumulator?: T[keyof T & number]): Promises; - , R>(str: OptionalPromise, iteratee?: (accumulator: R, value: T[keyof T & number], index: number, str: T) => OptionalPromise, accumulator?: R): Promises; - (object: OptionalPromiseDictionary, iteratee?: (accumulator: T[keyof T], value: T[keyof T], key: keyof T, object: T) => OptionalPromise, accumulator?: T[keyof T]): Promises; - (object: OptionalPromiseDictionary, iteratee?: (accumulator: R, value: T[keyof T], key: keyof T, object: T) => OptionalPromise, accumulator?: R): Promises; + >(str: IOptionalPromise, iteratee?: (accumulator: T[keyof T & number], value: T[keyof T & number], index: number, str: T) => IOptionalPromise, accumulator?: T[keyof T & number]): Promises; + , R>(str: IOptionalPromise, iteratee?: (accumulator: R, value: T[keyof T & number], index: number, str: T) => IOptionalPromise, accumulator?: R): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (accumulator: T[keyof T], value: T[keyof T], key: keyof T, object: T) => IOptionalPromise, accumulator?: T[keyof T]): Promises; + (object: IOptionalPromiseDictionary, iteratee?: (accumulator: R, value: T[keyof T], key: keyof T, object: T) => IOptionalPromise, accumulator?: R): Promises; } export interface IReduceWrapper { - (this: Promises>, iteratee?: (accumulator: T[keyof T & number], value: T[keyof T & number], index: number, str: T) => OptionalPromise, accumulator?: T[keyof T & number]): Promises; - (this: Promises>, iteratee?: (accumulator: R, value: T[keyof T & number], index: number, str: T) => OptionalPromise, accumulator?: R): Promises; - (this: Promises, iteratee?: (accumulator: T[keyof T], value: T[keyof T], key: keyof T, object: T) => OptionalPromise, accumulator?: T[keyof T]): Promises; - (this: Promises, iteratee?: (accumulator: R, value: T[keyof T], key: keyof T, object: T) => OptionalPromise, accumulator?: R): Promises; + (this: Promises>, iteratee?: (accumulator: T[keyof T & number], value: T[keyof T & number], index: number, str: T) => IOptionalPromise, accumulator?: T[keyof T & number]): Promises; + (this: Promises>, iteratee?: (accumulator: R, value: T[keyof T & number], index: number, str: T) => IOptionalPromise, accumulator?: R): Promises; + (this: Promises, iteratee?: (accumulator: T[keyof T], value: T[keyof T], key: keyof T, object: T) => IOptionalPromise, accumulator?: T[keyof T]): Promises; + (this: Promises, iteratee?: (accumulator: R, value: T[keyof T], key: keyof T, object: T) => IOptionalPromise, accumulator?: R): Promises; } diff --git a/modules/keys/index.ts b/modules/keys/index.ts index 50becac..cc442be 100644 --- a/modules/keys/index.ts +++ b/modules/keys/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; import _keys from '@promises/_keys'; /** @@ -20,8 +20,8 @@ import _keys from '@promises/_keys'; * }); * ``` */ -function keys(collection: OptionalPromise): Promises; -function keys(collection: OptionalPromise, fn: (keys: string[]) => OptionalPromise): Promises; +function keys(collection: IOptionalPromise): Promises; +function keys(collection: IOptionalPromise, fn: (keys: string[]) => IOptionalPromise): Promises; function keys(collection, fn = v => v) { let keys = _keys(collection); return Promises.resolve(keys).then(fn); @@ -46,6 +46,6 @@ declare module '@promises/core' { * ``` */ keys(this: Promises): Promises; - keys(this: Promises, fn: (keys: string[]) => OptionalPromise): Promises; + keys(this: Promises, fn: (keys: string[]) => IOptionalPromise): Promises; } } diff --git a/modules/next/index.ts b/modules/next/index.ts index c940836..805c895 100644 --- a/modules/next/index.ts +++ b/modules/next/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -25,7 +25,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function next(promise: OptionalPromise, value: OptionalPromise): Promises { +function next(promise: IOptionalPromise, value: IOptionalPromise): Promises { return Promises.resolve(promise).then(() => { return value; }) as Promises; @@ -55,6 +55,6 @@ declare module '@promises/core' { * }); * ``` */ - next(this: Promises, value: OptionalPromise): Promises; + next(this: Promises, value: IOptionalPromise): Promises; } } diff --git a/modules/parallel/index.ts b/modules/parallel/index.ts index c530c69..ce659ff 100644 --- a/modules/parallel/index.ts +++ b/modules/parallel/index.ts @@ -6,7 +6,7 @@ import Promises from '@promises/core'; import map from '@promises/map-parallel'; -import { OptionalPromise, Dictionary } from '@promises/interfaces'; +import { IOptionalPromise, IDictionary } from '@promises/interfaces'; /** * @example @@ -32,10 +32,10 @@ import { OptionalPromise, Dictionary } from '@promises/interfaces'; * // => { zero: 0, one: 1, two: 2} * ``` */ -function parallelStatic(array: (() => OptionalPromise)[]): Promises; -function parallelStatic>(array: (() => OptionalPromise)[]): Promises; -function parallelStatic(object: Dictionary<(() => OptionalPromise)>): Promises>; -function parallelStatic>(object: Dictionary<(() => OptionalPromise)>): Promises; +function parallelStatic(array: (() => IOptionalPromise)[]): Promises; +function parallelStatic>(array: (() => IOptionalPromise)[]): Promises; +function parallelStatic(object: IDictionary<(() => IOptionalPromise)>): Promises>; +function parallelStatic>(object: IDictionary<(() => IOptionalPromise)>): Promises; function parallelStatic(functions) { return map(functions, (fn) => fn()); } diff --git a/modules/promisify/index.ts b/modules/promisify/index.ts index 70d9745..1c58a37 100644 --- a/modules/promisify/index.ts +++ b/modules/promisify/index.ts @@ -5,9 +5,9 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; -export interface PromisifyOptions { +export interface IPromisifyOptions { context?: any; multi?: boolean; } @@ -29,28 +29,28 @@ export interface PromisifyOptions { * ``` */ function promisifyStatic(fn: (cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): () => Promises; -function promisifyStatic(fn: (p1: P1, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise, p10: OptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, cb: (error: any, ...result: R[keyof R & number][]) => void) => void, options: { multi: true, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise, p10: IOptionalPromise) => Promises; function promisifyStatic(fn: (cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): () => Promises; -function promisifyStatic(fn: (p1: P1, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise) => Promises; -function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise, p10: OptionalPromise) => Promises; -function promisifyStatic(fn, {multi, context}: PromisifyOptions = {}) { +function promisifyStatic(fn: (p1: P1, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise) => Promises; +function promisifyStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, cb: (error: any, result: R) => void) => void, options?: { multi?: false, context?: any }): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise, p10: IOptionalPromise) => Promises; +function promisifyStatic(fn, {multi, context}: IPromisifyOptions = {}) { return function (...args) { return Promises.all(args).then((args) => { return new Promises((resolve, reject) => { diff --git a/modules/reset/index.ts b/modules/reset/index.ts index fdebc17..9e26454 100644 --- a/modules/reset/index.ts +++ b/modules/reset/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -25,7 +25,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function reset(promise: OptionalPromise, value: OptionalPromise): Promises { +function reset(promise: IOptionalPromise, value: IOptionalPromise): Promises { return Promises.resolve(promise).then(() => value, () => value) as Promises; } @@ -53,6 +53,6 @@ declare module '@promises/core' { * }); * ``` */ - reset(this: Promises, value: OptionalPromise): Promises; + reset(this: Promises, value: IOptionalPromise): Promises; } } diff --git a/modules/retry/index.ts b/modules/retry/index.ts index b28a02a..28ad0a7 100644 --- a/modules/retry/index.ts +++ b/modules/retry/index.ts @@ -8,22 +8,22 @@ import Promises from '@promises/core'; import exec from '@promises/exec'; import timeout from '@promises/timeout'; import '@promises/timer'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; -export interface RetryOptions { +export interface IRetryOptions { times?: number; - interval?: number | ((info: RetryTimeInfo) => number); - timer?: number | ((info: RetryTimeInfo) => number); - filter?: (info: RetryFilterInfo) => boolean; + interval?: number | ((info: IRetryTimeInfo) => number); + timer?: number | ((info: IRetryTimeInfo) => number); + filter?: (info: IRetryFilterInfo) => boolean; } -export interface RetryTimeInfo { +export interface IRetryTimeInfo { counter: number; last: number; times: number; } -export interface RetryFilterInfo { +export interface IRetryFilterInfo { counter: number; error: any; times: number; @@ -44,7 +44,7 @@ export interface RetryFilterInfo { * }) * ``` */ -function retryStatic(fn: () => OptionalPromise, options?: RetryOptions): Promises { +function retryStatic(fn: () => IOptionalPromise, options?: IRetryOptions): Promises { let { times = 1, interval, timer, filter = (error) => true } = options || {} as any; return retryHelper(fn, { times, interval, timer, filter, counter: 1 }) as Promises; } diff --git a/modules/series/index.ts b/modules/series/index.ts index bd5f080..ba2556f 100644 --- a/modules/series/index.ts +++ b/modules/series/index.ts @@ -6,7 +6,7 @@ import Promises from '@promises/core'; import map from '@promises/map-series'; -import { OptionalPromise, Dictionary } from '@promises/interfaces'; +import { IOptionalPromise, IDictionary } from '@promises/interfaces'; /** * @example @@ -32,10 +32,10 @@ import { OptionalPromise, Dictionary } from '@promises/interfaces'; * // => ['zero', 'one', 'two'] * ``` */ -function seriesStatic(array: (() => OptionalPromise)[]): Promises; -function seriesStatic>(array: (() => OptionalPromise)[]): Promises; -function seriesStatic(object: Dictionary<(() => OptionalPromise)>): Promises>; -function seriesStatic>(object: Dictionary<(() => OptionalPromise)>): Promises; +function seriesStatic(array: (() => IOptionalPromise)[]): Promises; +function seriesStatic>(array: (() => IOptionalPromise)[]): Promises; +function seriesStatic(object: IDictionary<(() => IOptionalPromise)>): Promises>; +function seriesStatic>(object: IDictionary<(() => IOptionalPromise)>): Promises; function seriesStatic(functions) { return map(functions, (fn) => fn()); } diff --git a/modules/sleep/index.ts b/modules/sleep/index.ts index 2df16ab..0e00ea9 100644 --- a/modules/sleep/index.ts +++ b/modules/sleep/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -17,7 +17,7 @@ import { OptionalPromise } from '@promises/interfaces'; * }); * ``` */ -function sleep(value?: OptionalPromise, ms?: number): Promises { +function sleep(value?: IOptionalPromise, ms?: number): Promises { return Promises.resolve(value).then(() => new Promises((resolve) => { setTimeout(() => resolve(value), ms); })) as Promises; diff --git a/modules/spread/index.ts b/modules/spread/index.ts index 51fce66..24ca2af 100644 --- a/modules/spread/index.ts +++ b/modules/spread/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise, OptionalPromiseArray } from '@promises/interfaces'; +import { IOptionalPromise, IOptionalPromiseArray } from '@promises/interfaces'; /** * @example @@ -19,8 +19,8 @@ import { OptionalPromise, OptionalPromiseArray } from '@promises/interfaces'; * }); * ``` */ -function spread>(array: OptionalPromiseArray, fn: (...args: (T[keyof T & number])[]) => OptionalPromise): Promises; -function spread, R>(array: OptionalPromiseArray, fn: (...args: (T[keyof T & number])[]) => OptionalPromise): Promises; +function spread>(array: IOptionalPromiseArray, fn: (...args: (T[keyof T & number])[]) => IOptionalPromise): Promises; +function spread, R>(array: IOptionalPromiseArray, fn: (...args: (T[keyof T & number])[]) => IOptionalPromise): Promises; function spread(array, fn) { return (Promises as any).resolve(array).then((array) => { return Array.isArray(array) ? Promises.all(array) : Object(array); @@ -47,7 +47,7 @@ declare module '@promises/core' { * }) * ``` */ - spread(this: Promises>, fn: (...args: (T[keyof T & number])[]) => OptionalPromise): Promises; - spread(this: Promises>, fn: (...args: (T[keyof T & number])[]) => OptionalPromise): Promises; + spread(this: Promises>, fn: (...args: (T[keyof T & number])[]) => IOptionalPromise): Promises; + spread(this: Promises>, fn: (...args: (T[keyof T & number])[]) => IOptionalPromise): Promises; } } diff --git a/modules/timeout/index.ts b/modules/timeout/index.ts index e311d1d..e271ac4 100644 --- a/modules/timeout/index.ts +++ b/modules/timeout/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { IExecute } from '@promises/interfaces'; +import { IExecutor } from '@promises/interfaces'; /** * @example @@ -20,10 +20,10 @@ import { IExecute } from '@promises/interfaces'; * }); * ``` */ -function timeoutStatic(execute: IExecute, ms?: number): Promises { +function timeoutStatic(executor: IExecutor, ms?: number): Promises { return new Promises((resolve, reject) => { setTimeout(() => { - execute(resolve, reject); + executor(resolve, reject); }, ms); }); } diff --git a/modules/times-parallel/index.ts b/modules/times-parallel/index.ts index 417ede9..bc9ea80 100644 --- a/modules/times-parallel/index.ts +++ b/modules/times-parallel/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -29,7 +29,7 @@ import { OptionalPromise } from '@promises/interfaces'; * // => [9, 6, 3] * ``` */ -function timesParallelStatic(times: OptionalPromise, fn: (time: number) => OptionalPromise): Promises { +function timesParallelStatic(times: IOptionalPromise, fn: (time: number) => IOptionalPromise): Promises { return Promises.resolve(times).then((times) => { return new Promises((resolve, reject) => { let length: number = times; diff --git a/modules/times-series/index.ts b/modules/times-series/index.ts index e8765b0..9b8cfac 100644 --- a/modules/times-series/index.ts +++ b/modules/times-series/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -29,7 +29,7 @@ import { OptionalPromise } from '@promises/interfaces'; * // => [9, 6, 3] * ``` */ -function timesSeriesStatic(times: OptionalPromise, fn: (time: number) => OptionalPromise): Promises { +function timesSeriesStatic(times: IOptionalPromise, fn: (time: number) => IOptionalPromise): Promises { return Promises.resolve(times).then((times: number) => { let each = Promises.resolve(); let length: number = times; diff --git a/modules/wrap/index.ts b/modules/wrap/index.ts index 4c028e3..b3ecc57 100644 --- a/modules/wrap/index.ts +++ b/modules/wrap/index.ts @@ -5,7 +5,7 @@ */ import Promises from '@promises/core'; -import { OptionalPromise } from '@promises/interfaces'; +import { IOptionalPromise } from '@promises/interfaces'; /** * @example @@ -24,16 +24,16 @@ import { OptionalPromise } from '@promises/interfaces'; * ``` */ function wrapStatic(fn: () => R, context?: any): () => Promises; -function wrapStatic(fn: (p1: P1) => R, context?: any): (p1: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise) => Promises; -function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10) => R, context?: any): (p1: OptionalPromise, p2: OptionalPromise, p3: OptionalPromise, p4: OptionalPromise, p5: OptionalPromise, p6: OptionalPromise, p7: OptionalPromise, p8: OptionalPromise, p9: OptionalPromise, p10: OptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1) => R, context?: any): (p1: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise) => Promises; +function wrapStatic(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10) => R, context?: any): (p1: IOptionalPromise, p2: IOptionalPromise, p3: IOptionalPromise, p4: IOptionalPromise, p5: IOptionalPromise, p6: IOptionalPromise, p7: IOptionalPromise, p8: IOptionalPromise, p9: IOptionalPromise, p10: IOptionalPromise) => Promises; function wrapStatic(fn, context?) { return function (...args) { return Promises.all(args).then((args) => { diff --git a/test/for-each-parallel.spec.ts b/test/for-each-parallel.spec.ts index a17a380..ce86d41 100644 --- a/test/for-each-parallel.spec.ts +++ b/test/for-each-parallel.spec.ts @@ -1,11 +1,11 @@ import Promises from '@promises/core'; -import { Dictionary } from '@promises/interfaces'; +import { IDictionary } from '@promises/interfaces'; import forEachParallel from '@promises/for-each-parallel'; describe('forEachParallel', () => { it('should be parallel iterator on object with identity function and return the object', () => { - let object: Dictionary = { a: 1, b: 2, c: 3 }; - return forEachParallel(object).then((result: Dictionary) => { + let object: IDictionary = { a: 1, b: 2, c: 3 }; + return forEachParallel(object).then((result: IDictionary) => { expect(object).toBe(result); }); }); diff --git a/test/for-each-right-series.spec.ts b/test/for-each-right-series.spec.ts index f83f82c..8558be1 100644 --- a/test/for-each-right-series.spec.ts +++ b/test/for-each-right-series.spec.ts @@ -1,11 +1,11 @@ import Promises from '@promises/core'; -import { Dictionary } from '@promises/interfaces'; +import { IDictionary } from '@promises/interfaces'; import forEachRightSeries from '@promises/for-each-right-series'; describe('forEachRightSeries', () => { it('should be series iterator on object with identity function and return the object', () => { - let object: Dictionary = { a: 1, b: 2, c: 3 }; - return forEachRightSeries(object).then((result: Dictionary) => { + let object: IDictionary = { a: 1, b: 2, c: 3 }; + return forEachRightSeries(object).then((result: IDictionary) => { expect(object).toBe(result); }); }); diff --git a/test/for-each-series.spec.ts b/test/for-each-series.spec.ts index 2bbce7c..ed04d31 100644 --- a/test/for-each-series.spec.ts +++ b/test/for-each-series.spec.ts @@ -1,5 +1,5 @@ import Promises from '@promises/core'; -import { Dictionary } from '@promises/interfaces'; +import { IDictionary } from '@promises/interfaces'; import forEachSeries from '@promises/for-each-series'; describe('forEachSeries', () => { @@ -11,14 +11,14 @@ describe('forEachSeries', () => { }); it('should be series iterator on the object whit void iteratee and return the object without change', () => { - let object: Dictionary = { a: 0, b: 1, c: 2 }; + let object: IDictionary = { a: 0, b: 1, c: 2 }; let objectKeys = Object.keys(object); let count: number = 0; return forEachSeries(object, (value, key, object) => { expect(value).toBe(count); expect(key).toBe(objectKeys[count]); count++; - }).then((returnObject: Dictionary) => { + }).then((returnObject: IDictionary) => { expect(count).toBe(objectKeys.length); expect(returnObject).toBe(object); });