@opencreek/ext
Advanced tools
Comparing version 2.7.3 to 2.7.4--canary.37.8708724432.0
@@ -10,2 +10,3 @@ type PairSplit<T> = T extends [infer F, infer L] ? [Chain<F>, Chain<L>] : never; | ||
} ? Chain<U> : Chain<T>; | ||
export declare function objChain<K extends string | number | symbol, T>(value: Partial<Record<K, T>>): ObjectChain<K, T, Partial<Record<K, T>>>; | ||
export declare function objChain<K extends string | number | symbol, T>(value: Record<K, T> | ObjectChain<K, T> | Chain<readonly [K, T]>): ObjectChain<K, T>; | ||
@@ -17,6 +18,6 @@ export declare function objChain<_K extends string | number | symbol, _T>(value: undefined | null): undefined; | ||
export declare function chain<T>(value: ReadonlyArray<T> | Chain<T> | Iterable<T> | undefined | null): Chain<T> | undefined; | ||
export declare class ObjectChain<K extends string | number | symbol, T> { | ||
export declare class ObjectChain<K extends string | number | symbol, T, Rec extends Partial<Record<K, T>> = Record<K, T>> { | ||
private val; | ||
constructor(val: Record<K, T>); | ||
value(): Record<K, T>; | ||
constructor(val: Rec); | ||
value(): Rec; | ||
keys(): Chain<K>; | ||
@@ -23,0 +24,0 @@ values(): Chain<T>; |
{ | ||
"name": "@opencreek/ext", | ||
"version": "2.7.3", | ||
"version": "2.7.4--canary.37.8708724432.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -46,2 +46,5 @@ import { | ||
export function objChain<K extends string | number | symbol, T>( | ||
value: Partial<Record<K, T>>, | ||
): ObjectChain<K, T, Partial<Record<K, T>>> | ||
export function objChain<K extends string | number | symbol, T>( | ||
value: Record<K, T> | ObjectChain<K, T> | Chain<readonly [K, T]>, | ||
@@ -63,2 +66,3 @@ ): ObjectChain<K, T> | ||
| Record<K, T> | ||
| Partial<Record<K, T>> | ||
| ObjectChain<K, T> | ||
@@ -68,3 +72,3 @@ | Chain<readonly [K, T]> | ||
| null, | ||
): ObjectChain<K, T> | undefined { | ||
): ObjectChain<K, T, Partial<Record<K, T>>> | undefined { | ||
if (value == null) return undefined | ||
@@ -76,6 +80,5 @@ if (value instanceof ObjectChain) { | ||
if (value instanceof Chain) { | ||
return new ObjectChain(Object.fromEntries(value.value())) as ObjectChain< | ||
K, | ||
T | ||
> | ||
return new ObjectChain( | ||
Object.fromEntries(value.value()) as Record<K, T>, | ||
) as ObjectChain<K, T> | ||
} | ||
@@ -103,6 +106,10 @@ | ||
export class ObjectChain<K extends string | number | symbol, T> { | ||
constructor(private val: Record<K, T>) {} | ||
export class ObjectChain< | ||
K extends string | number | symbol, | ||
T, | ||
Rec extends Partial<Record<K, T>> = Record<K, T>, | ||
> { | ||
constructor(private val: Rec) {} | ||
value(): Record<K, T> { | ||
value(): Rec { | ||
return this.val | ||
@@ -151,3 +158,5 @@ } | ||
return new ObjectChain(Object.fromEntries(mapped)) as ObjectChain<U, V> | ||
return new ObjectChain( | ||
Object.fromEntries(mapped) as Record<U, V>, | ||
) as ObjectChain<U, V> | ||
} | ||
@@ -161,3 +170,5 @@ | ||
return new ObjectChain(Object.fromEntries(filtered)) as ObjectChain<K, T> | ||
return new ObjectChain( | ||
Object.fromEntries(filtered) as Record<K, T>, | ||
) as ObjectChain<K, T> | ||
} | ||
@@ -171,3 +182,5 @@ | ||
return new ObjectChain(Object.fromEntries(filtered)) as ObjectChain<K, T> | ||
return new ObjectChain( | ||
Object.fromEntries(filtered) as Record<K, T>, | ||
) as ObjectChain<K, T> | ||
} | ||
@@ -181,3 +194,5 @@ | ||
return new ObjectChain(Object.fromEntries(filtered)) as ObjectChain<K, T> | ||
return new ObjectChain( | ||
Object.fromEntries(filtered) as Record<K, T>, | ||
) as ObjectChain<K, T> | ||
} | ||
@@ -184,0 +199,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
239680
4312
2