@dhmk/utils
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -12,1 +12,22 @@ export function signal() { | ||
} | ||
// todo: signal improvement (multi args + customizable) | ||
// export type Listener<A extends any[]> = (...args: A) => void; | ||
// export type Signal<A extends any[]> = { | ||
// subscribe(fn: Listener<A>): () => void; | ||
// }; | ||
// export function signal<A extends any[] = []>({ | ||
// listeners = new Set<any>(), | ||
// emit = (fn: (...args: A) => void) => fn, | ||
// subscribe = (fn: (fn: Listener<A>) => () => void) => fn, | ||
// } = {}) { | ||
// const self: any = emit((...args: A) => | ||
// listeners.forEach((s) => s(...args)) | ||
// ); | ||
// self.subscribe = subscribe((fn: Listener<A>) => { | ||
// listeners.add(fn); | ||
// return () => { | ||
// listeners.delete(fn); | ||
// }; | ||
// }); | ||
// return self as ((...args: A) => void) & Signal<A>; | ||
// } |
@@ -13,4 +13,4 @@ export declare class Tag<T> { | ||
export declare type Overwrite<A, B> = Omit<A, keyof B> & B; | ||
declare type Primitive = undefined | null | boolean | string | number | Function | Date | RegExp; | ||
declare type NotPlainObject = Primitive | ReadonlyArray<any> | ReadonlySet<any> | ReadonlyMap<any, any>; | ||
export declare type Primitive = undefined | boolean | string | number | symbol | bigint; | ||
export declare type NotPlainObject = Primitive | null | Function | Date | RegExp | ReadonlyArray<any> | ReadonlySet<any> | ReadonlyMap<any, any>; | ||
export declare type DeepReadonly<T> = T extends Primitive ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer T> ? ReadonlySet<DeepReadonly<T>> : { | ||
@@ -17,0 +17,0 @@ readonly [P in keyof T]: DeepReadonly<T[P]>; |
@@ -16,1 +16,22 @@ "use strict"; | ||
exports.signal = signal; | ||
// todo: signal improvement (multi args + customizable) | ||
// export type Listener<A extends any[]> = (...args: A) => void; | ||
// export type Signal<A extends any[]> = { | ||
// subscribe(fn: Listener<A>): () => void; | ||
// }; | ||
// export function signal<A extends any[] = []>({ | ||
// listeners = new Set<any>(), | ||
// emit = (fn: (...args: A) => void) => fn, | ||
// subscribe = (fn: (fn: Listener<A>) => () => void) => fn, | ||
// } = {}) { | ||
// const self: any = emit((...args: A) => | ||
// listeners.forEach((s) => s(...args)) | ||
// ); | ||
// self.subscribe = subscribe((fn: Listener<A>) => { | ||
// listeners.add(fn); | ||
// return () => { | ||
// listeners.delete(fn); | ||
// }; | ||
// }); | ||
// return self as ((...args: A) => void) & Signal<A>; | ||
// } |
@@ -13,4 +13,4 @@ export declare class Tag<T> { | ||
export declare type Overwrite<A, B> = Omit<A, keyof B> & B; | ||
declare type Primitive = undefined | null | boolean | string | number | Function | Date | RegExp; | ||
declare type NotPlainObject = Primitive | ReadonlyArray<any> | ReadonlySet<any> | ReadonlyMap<any, any>; | ||
export declare type Primitive = undefined | boolean | string | number | symbol | bigint; | ||
export declare type NotPlainObject = Primitive | null | Function | Date | RegExp | ReadonlyArray<any> | ReadonlySet<any> | ReadonlyMap<any, any>; | ||
export declare type DeepReadonly<T> = T extends Primitive ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer T> ? ReadonlySet<DeepReadonly<T>> : { | ||
@@ -17,0 +17,0 @@ readonly [P in keyof T]: DeepReadonly<T[P]>; |
{ | ||
"name": "@dhmk/utils", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "A collection of frequently used functions and primitives", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
122144
2823