@dhmk/utils
Advanced tools
Comparing version 0.0.2 to 0.0.3
export declare const noop: () => void; | ||
export interface Signal<T> { | ||
export declare type Signal<T> = T extends void ? { | ||
emit(): void; | ||
observe(onValue: () => void, onDispose?: () => void): () => void; | ||
} : { | ||
emit(value: T): void; | ||
observe(onValue: (value: T) => void, onDispose?: () => void): () => void; | ||
} | ||
export declare const signal: <T>() => Signal<T>; | ||
}; | ||
export declare const signal: <T = void>() => Signal<T>; | ||
export declare class AggregateError extends Error { | ||
@@ -12,9 +15,13 @@ readonly errors: ReadonlyArray<Error>; | ||
export declare const disposable: (...fns: Function[]) => () => void; | ||
export declare const sleep: (ms: number) => Promise<unknown>; | ||
export declare type Deferred<T> = Promise<T> & { | ||
resolve(value: T): void; | ||
reject(error: Error): void; | ||
}; | ||
export declare const sleep: (ms: number) => Promise<unknown>; | ||
export declare const deferred: <T>() => Deferred<T>; | ||
export declare const debounced: <T>(fn: (...args: T[]) => void, ms: number) => (...args: T[]) => void; | ||
export declare const throttled: <T>(fn: (...args: T[]) => void, ms: number) => (...args: T[]) => void; | ||
reject(error: Error): Deferred<T>; | ||
} & (T extends void ? { | ||
resolve(): Deferred<T>; | ||
} : { | ||
resolve(x: T): Deferred<T>; | ||
}); | ||
export declare const deferred: <T = void>() => Deferred<T>; | ||
export declare type Action = (...args: any[]) => void; | ||
export declare const debounced: <T extends Action>(fn: T, ms: number) => (...args: Parameters<T>) => void; | ||
export declare const throttled: <T extends Action>(fn: T, ms: number) => (...args: Parameters<T>) => void; |
@@ -49,4 +49,10 @@ export const noop = () => { }; | ||
const p = new Promise((res, rej) => { | ||
self.resolve = res; | ||
self.reject = rej; | ||
self.resolve = (x) => { | ||
res(x); | ||
return self; | ||
}; | ||
self.reject = (e) => { | ||
rej(e); | ||
return self; | ||
}; | ||
}); | ||
@@ -53,0 +59,0 @@ self.then = p.then.bind(p); |
{ | ||
"name": "@dhmk/utils", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A collection of frequently used functions", | ||
@@ -24,4 +24,5 @@ "keywords": [ | ||
"postversion": "git push && git push --tags", | ||
"build": "rm -rf lib && tsc", | ||
"test": "jest" | ||
"clean": "rm -rf lib", | ||
"build": "yarn clean && tsc", | ||
"test": "yarn clean && jest" | ||
}, | ||
@@ -28,0 +29,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7031
6
200