| import { | ||
| isFunc, | ||
| isObj | ||
| } from "./chunk-3XTOLKPS.mjs"; | ||
| import { | ||
| __export | ||
| } from "./chunk-LLLY6SAS.mjs"; | ||
| // src/obj.ts | ||
| var obj_exports = {}; | ||
| __export(obj_exports, { | ||
| assign: () => assign, | ||
| assignTo: () => assignTo, | ||
| bind: () => bind, | ||
| cast: () => cast, | ||
| clone: () => clone, | ||
| compact: () => compact, | ||
| defaults: () => defaults, | ||
| entries: () => entries, | ||
| filter: () => filter, | ||
| from: () => from, | ||
| fromEntries: () => fromEntries, | ||
| get: () => get, | ||
| keys: () => keys, | ||
| map: () => map, | ||
| merge: () => merge, | ||
| omit: () => omit, | ||
| pick: () => pick, | ||
| split: () => split | ||
| }); | ||
| var fromEntries = (entries2) => Object.fromEntries(entries2), map = (f) => (obj) => fromEntries(Object.entries(obj).map(([k, v]) => f(k, v))), entries = (obj) => Object.entries(obj), from = (key) => (value) => fromEntries([[key, value]]); | ||
| function assign(v) { | ||
| return (obj) => ({ | ||
| ...obj, | ||
| ...isFunc(v) ? v(obj) : v | ||
| }); | ||
| } | ||
| var assignTo = (key) => (prev) => fromEntries([[key, prev]]), keys = (obj) => Object.keys(obj), filter = (f) => (obj) => fromEntries(Object.entries(obj).filter(([k, v]) => f(k, v))), compact = (obj) => filter((_, v) => v !== void 0)(obj), split = (...keys2) => (obj) => { | ||
| let descriptors = Object.getOwnPropertyDescriptors(obj), dKeys = Object.keys(descriptors), split2 = (k) => { | ||
| let clone2 = {}; | ||
| for (let i = 0; i < k.length; i++) { | ||
| let key = k[i]; | ||
| descriptors[key] && (Object.defineProperty(clone2, key, descriptors[key]), delete descriptors[key]); | ||
| } | ||
| return clone2; | ||
| }, fn = (key) => split2(Array.isArray(key) ? key : dKeys.filter(key)); | ||
| return keys2.map(fn).concat(split2(dKeys)); | ||
| }, clone = (obj) => structuredClone(obj); | ||
| function merge(...args) { | ||
| return (obj) => { | ||
| if (!args.length) | ||
| return obj; | ||
| for (let i = 1; i < args.length; i++) { | ||
| let source = { ...args[i] }; | ||
| for (let key in source) { | ||
| let targValue = obj[key], srcValue = source[key]; | ||
| isObj(targValue) && isObj(srcValue) ? obj[key] = merge(srcValue)(targValue) : obj[key] = srcValue; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
| } | ||
| var omit = (keys2) => (obj) => { | ||
| let clone2 = { ...obj }; | ||
| for (let i = 0; i < keys2.length; i++) | ||
| delete clone2[keys2[i]]; | ||
| return clone2; | ||
| }, cast = (v) => v, pick = (keys2) => (obj) => { | ||
| let clone2 = {}; | ||
| for (let i = 0; i < keys2.length; i++) | ||
| clone2[keys2[i]] = obj[keys2[i]]; | ||
| return clone2; | ||
| }, bind = (key, fn) => (obj) => cast({ | ||
| ...obj, | ||
| [key]: fn(obj[key]) | ||
| }), defaults = (defaults2) => (obj) => cast({ | ||
| ...defaults2, | ||
| ...obj | ||
| }), get = (key, fallback) => (obj) => { | ||
| let keys2 = key.split("."), i = 0; | ||
| for (; obj[keys2[i]]; ) | ||
| obj = obj[keys2[i]], i++; | ||
| return obj ?? fallback; | ||
| }; | ||
| export { | ||
| fromEntries, | ||
| map, | ||
| entries, | ||
| from, | ||
| assign, | ||
| assignTo, | ||
| keys, | ||
| filter, | ||
| compact, | ||
| split, | ||
| clone, | ||
| merge, | ||
| omit, | ||
| cast, | ||
| pick, | ||
| bind, | ||
| defaults, | ||
| get, | ||
| obj_exports | ||
| }; |
| import { Dict, Assign, SplitProp, Simplify, Path } from './types.js'; | ||
| declare const fromEntries: <T extends Dict>(entries: IterableIterator<[string, T[keyof T]]> | Iterable<[string, T[keyof T]]>) => T; | ||
| declare const map: <T extends Dict>(f: (key: string, value: T[keyof T]) => [string, T[keyof T]]) => (obj: T) => T; | ||
| declare const entries: <T extends Dict>(obj: T) => [keyof T, T[keyof T]][]; | ||
| declare const from: <K extends string, T>(key: K) => (value: T) => Record<K, T>; | ||
| declare function assign<T extends Dict, K extends Dict>(v: K | ((obj: T) => K)): (obj: T) => Assign<[T, K]>; | ||
| declare const assignTo: <K extends string, T extends Dict>(key: K) => (prev: T) => Record<K, T>; | ||
| declare const keys: <T extends Dict>(obj: T) => (keyof T)[]; | ||
| declare const filter: <T extends Dict>(f: (key: keyof T, value: T[keyof T]) => boolean) => (obj: T) => T; | ||
| declare const compact: <T extends Dict>(obj: T) => { [K in keyof T]: T[K] extends undefined ? never : T[K]; }; | ||
| declare const split: <T extends Dict, K extends [SplitProp<T>, ...SplitProp<T>[]]>(...keys: K) => (obj: T) => [...{ [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never; }, Omit<T, K[number][number]>]; | ||
| declare const clone: <T extends Dict>(obj: T) => T; | ||
| declare function merge<T, U>(source: U): (target: T) => Assign<[T, U]>; | ||
| declare function merge<T, U, V>(target: T): (source: U, source2: V) => Assign<[T, U, V]>; | ||
| declare function merge<T, U, V, W>(target: T): (source: U, source2: V, source3: W) => Assign<[T, U, V, W]>; | ||
| declare function merge<T, U, V, W, X>(target: T): (source: U, source2: V, source3: W, source4: X) => Assign<[T, U, V, W, X]>; | ||
| declare const omit: <T extends Dict, K extends keyof T>(keys: K[]) => (obj: T) => Simplify<Omit<T, K>>; | ||
| declare const cast: <T>(v: any) => T; | ||
| declare const pick: <T extends Dict, K extends keyof T>(keys: K[]) => (obj: T) => Simplify<Pick<T, K>>; | ||
| interface Bind { | ||
| <T extends Dict, K extends string, U>(key: K, fn: (value: T) => U): (obj: T) => Assign<[T, Record<K, U>]>; | ||
| } | ||
| declare const bind: Bind; | ||
| declare const defaults: <T extends Dict, K extends Partial<T>>(defaults: K) => (obj: T) => Simplify<Omit<T, keyof K> & Required<K>>; | ||
| declare const get: <T extends Dict, K extends Path<T>, V>(key: K, fallback?: V | undefined) => (obj: T) => V | T[K]; | ||
| declare const obj_assign: typeof assign; | ||
| declare const obj_assignTo: typeof assignTo; | ||
| declare const obj_bind: typeof bind; | ||
| declare const obj_cast: typeof cast; | ||
| declare const obj_clone: typeof clone; | ||
| declare const obj_compact: typeof compact; | ||
| declare const obj_defaults: typeof defaults; | ||
| declare const obj_entries: typeof entries; | ||
| declare const obj_filter: typeof filter; | ||
| declare const obj_from: typeof from; | ||
| declare const obj_fromEntries: typeof fromEntries; | ||
| declare const obj_get: typeof get; | ||
| declare const obj_keys: typeof keys; | ||
| declare const obj_map: typeof map; | ||
| declare const obj_merge: typeof merge; | ||
| declare const obj_omit: typeof omit; | ||
| declare const obj_pick: typeof pick; | ||
| declare const obj_split: typeof split; | ||
| declare namespace obj { | ||
| export { | ||
| obj_assign as assign, | ||
| obj_assignTo as assignTo, | ||
| obj_bind as bind, | ||
| obj_cast as cast, | ||
| obj_clone as clone, | ||
| obj_compact as compact, | ||
| obj_defaults as defaults, | ||
| obj_entries as entries, | ||
| obj_filter as filter, | ||
| obj_from as from, | ||
| obj_fromEntries as fromEntries, | ||
| obj_get as get, | ||
| obj_keys as keys, | ||
| obj_map as map, | ||
| obj_merge as merge, | ||
| obj_omit as omit, | ||
| obj_pick as pick, | ||
| obj_split as split, | ||
| }; | ||
| } | ||
| export { from as a, assign as b, assignTo as c, filter as d, entries as e, fromEntries as f, compact as g, clone as h, merge as i, omit as j, keys as k, cast as l, map as m, bind as n, obj as o, pick as p, defaults as q, get as r, split as s }; |
+1
-1
| export { a as Arr } from './arr-baeb89ce.js'; | ||
| export { b as Bool } from './bool-38e9ed29.js'; | ||
| export { done, flow, log, memo, pipe, tap } from './func.js'; | ||
| export { o as Obj } from './obj-cd6ce7e4.js'; | ||
| export { o as Obj } from './obj-164f8b14.js'; | ||
| export { isArr, isBool, isFunc, isNum, isObj, isStr } from './is.js'; | ||
@@ -6,0 +6,0 @@ export { alt, match, otherwise, when } from './logic.js'; |
+11
-1
@@ -105,2 +105,3 @@ "use strict"; | ||
| compact: () => compact2, | ||
| defaults: () => defaults, | ||
| entries: () => entries, | ||
@@ -110,2 +111,3 @@ filter: () => filter2, | ||
| fromEntries: () => fromEntries, | ||
| get: () => get, | ||
| keys: () => keys, | ||
@@ -168,3 +170,11 @@ map: () => map2, | ||
| [key]: fn(obj[key]) | ||
| }); | ||
| }), defaults = (defaults2) => (obj) => cast({ | ||
| ...defaults2, | ||
| ...obj | ||
| }), get = (key, fallback) => (obj) => { | ||
| let keys2 = key.split("."), i = 0; | ||
| for (; obj[keys2[i]]; ) | ||
| obj = obj[keys2[i]], i++; | ||
| return obj ?? fallback; | ||
| }; | ||
@@ -171,0 +181,0 @@ // src/logic.ts |
+1
-1
@@ -15,3 +15,3 @@ import { | ||
| obj_exports | ||
| } from "./chunk-XRUMGOGV.mjs"; | ||
| } from "./chunk-G5PPAI5Y.mjs"; | ||
| import { | ||
@@ -18,0 +18,0 @@ isArr, |
+1
-1
| import './types.js'; | ||
| export { b as assign, c as assignTo, n as bind, l as cast, h as clone, g as compact, e as entries, d as filter, a as from, f as fromEntries, k as keys, m as map, i as merge, j as omit, p as pick, s as split } from './obj-cd6ce7e4.js'; | ||
| export { b as assign, c as assignTo, n as bind, l as cast, h as clone, g as compact, q as defaults, e as entries, d as filter, a as from, f as fromEntries, r as get, k as keys, m as map, i as merge, j as omit, p as pick, s as split } from './obj-164f8b14.js'; |
+13
-1
@@ -26,2 +26,3 @@ "use strict"; | ||
| compact: () => compact, | ||
| defaults: () => defaults, | ||
| entries: () => entries, | ||
@@ -31,2 +32,3 @@ filter: () => filter, | ||
| fromEntries: () => fromEntries, | ||
| get: () => get, | ||
| keys: () => keys, | ||
@@ -90,3 +92,11 @@ map: () => map, | ||
| [key]: fn(obj[key]) | ||
| }); | ||
| }), defaults = (defaults2) => (obj) => cast({ | ||
| ...defaults2, | ||
| ...obj | ||
| }), get = (key, fallback) => (obj) => { | ||
| let keys2 = key.split("."), i = 0; | ||
| for (; obj[keys2[i]]; ) | ||
| obj = obj[keys2[i]], i++; | ||
| return obj ?? fallback; | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
@@ -100,2 +110,3 @@ 0 && (module.exports = { | ||
| compact, | ||
| defaults, | ||
| entries, | ||
@@ -105,2 +116,3 @@ filter, | ||
| fromEntries, | ||
| get, | ||
| keys, | ||
@@ -107,0 +119,0 @@ map, |
+5
-1
@@ -8,2 +8,3 @@ import { | ||
| compact, | ||
| defaults, | ||
| entries, | ||
@@ -13,2 +14,3 @@ filter, | ||
| fromEntries, | ||
| get, | ||
| keys, | ||
@@ -20,3 +22,3 @@ map, | ||
| split | ||
| } from "./chunk-XRUMGOGV.mjs"; | ||
| } from "./chunk-G5PPAI5Y.mjs"; | ||
| import "./chunk-3XTOLKPS.mjs"; | ||
@@ -31,2 +33,3 @@ import "./chunk-LLLY6SAS.mjs"; | ||
| compact, | ||
| defaults, | ||
| entries, | ||
@@ -36,2 +39,3 @@ filter, | ||
| fromEntries, | ||
| get, | ||
| keys, | ||
@@ -38,0 +42,0 @@ map, |
+18
-1
@@ -22,3 +22,20 @@ type Dict = Record<string, any>; | ||
| ] ? Simplify<Assign<Rest, Merge<Target, Next>>> : T extends [...infer Rest, infer Next] ? Simplify<Merge<Assign<Rest, Target>, Next>> : T extends [] ? Simplify<Target> : T extends (infer I)[] ? Simplify<Merge<Target, I>> : Simplify<Target>; | ||
| type Primitive = null | undefined | string | number | boolean | symbol | bigint; | ||
| type ArrayKey = number; | ||
| type IsTuple<T extends readonly any[]> = number extends T['length'] ? false : true; | ||
| type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]>; | ||
| type PathConcat<TKey extends string | number, TValue> = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue>}`; | ||
| type Path<T> = T extends readonly (infer V)[] ? IsTuple<T> extends true ? { | ||
| [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]>; | ||
| }[TupleKeys<T>] : PathConcat<ArrayKey, V> : { | ||
| [K in keyof T]-?: PathConcat<K & string, T[K]>; | ||
| }[keyof T]; | ||
| type ArrayPathConcat<TKey extends string | number, TValue> = TValue extends Primitive ? never : TValue extends readonly (infer U)[] ? U extends Primitive ? never : `${TKey}` | `${TKey}.${ArrayPath<TValue>}` : `${TKey}.${ArrayPath<TValue>}`; | ||
| type ArrayPath<T> = T extends readonly (infer V)[] ? IsTuple<T> extends true ? { | ||
| [K in TupleKeys<T>]-?: ArrayPathConcat<K & string, T[K]>; | ||
| }[TupleKeys<T>] : ArrayPathConcat<ArrayKey, V> : { | ||
| [K in keyof T]-?: ArrayPathConcat<K & string, T[K]>; | ||
| }[keyof T]; | ||
| type PathValue<T, TPath extends Path<T> | ArrayPath<T>> = T extends any ? TPath extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends readonly (infer V)[] ? PathValue<V, R & Path<V>> : never : never : TPath extends keyof T ? T[TPath] : TPath extends `${ArrayKey}` ? T extends readonly (infer V)[] ? V : never : never : never; | ||
| export { Assign, Awaited, Compact, Dict, PromiseFactory, Simplify, Split, SplitProp }; | ||
| export { ArrayPath, Assign, Awaited, Compact, Dict, Path, PathConcat, PathValue, Primitive, PromiseFactory, Simplify, Split, SplitProp }; |
+1
-1
| { | ||
| "name": "lil-fp", | ||
| "version": "1.1.9", | ||
| "version": "1.2.0", | ||
| "description": "Functional programming utilities for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
+33
-1
| import { isFunc, isObj } from './is' | ||
| import { Compact, Dict, Assign, Split, SplitProp, Simplify } from './types' | ||
| import { | ||
| Assign, | ||
| Compact, | ||
| Dict, | ||
| Path, | ||
| Simplify, | ||
| Split, | ||
| SplitProp, | ||
| } from './types' | ||
@@ -136,1 +144,25 @@ export const fromEntries = <T extends Dict>( | ||
| }) | ||
| type Defaults<T extends Dict, K extends Partial<T>> = Simplify< | ||
| Omit<T, keyof K> & Required<K> | ||
| > | ||
| export const defaults = | ||
| <T extends Dict, K extends Partial<T>>(defaults: K) => | ||
| (obj: T): Defaults<T, K> => | ||
| cast({ | ||
| ...defaults, | ||
| ...obj, | ||
| }) | ||
| export const get = | ||
| <T extends Dict, K extends Path<T>, V>(key: K, fallback?: V) => | ||
| (obj: T): T[K] | V => { | ||
| let keys = key.split('.') | ||
| let i = 0 | ||
| while (obj[keys[i]]) { | ||
| obj = obj[keys[i]] | ||
| i++ | ||
| } | ||
| return (obj ?? fallback) as any | ||
| } |
+73
-0
@@ -42,1 +42,74 @@ export type Dict = Record<string, any> | ||
| : Simplify<Target> | ||
| export type Primitive = | ||
| | null | ||
| | undefined | ||
| | string | ||
| | number | ||
| | boolean | ||
| | symbol | ||
| | bigint | ||
| type ArrayKey = number | ||
| type IsTuple<T extends readonly any[]> = number extends T['length'] | ||
| ? false | ||
| : true | ||
| type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]> | ||
| export type PathConcat< | ||
| TKey extends string | number, | ||
| TValue | ||
| > = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue>}` | ||
| export type Path<T> = T extends readonly (infer V)[] | ||
| ? IsTuple<T> extends true | ||
| ? { | ||
| [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]> | ||
| }[TupleKeys<T>] | ||
| : PathConcat<ArrayKey, V> | ||
| : { | ||
| [K in keyof T]-?: PathConcat<K & string, T[K]> | ||
| }[keyof T] | ||
| type ArrayPathConcat< | ||
| TKey extends string | number, | ||
| TValue | ||
| > = TValue extends Primitive | ||
| ? never | ||
| : TValue extends readonly (infer U)[] | ||
| ? U extends Primitive | ||
| ? never | ||
| : `${TKey}` | `${TKey}.${ArrayPath<TValue>}` | ||
| : `${TKey}.${ArrayPath<TValue>}` | ||
| export type ArrayPath<T> = T extends readonly (infer V)[] | ||
| ? IsTuple<T> extends true | ||
| ? { | ||
| [K in TupleKeys<T>]-?: ArrayPathConcat<K & string, T[K]> | ||
| }[TupleKeys<T>] | ||
| : ArrayPathConcat<ArrayKey, V> | ||
| : { | ||
| [K in keyof T]-?: ArrayPathConcat<K & string, T[K]> | ||
| }[keyof T] | ||
| export type PathValue<T, TPath extends Path<T> | ArrayPath<T>> = T extends any | ||
| ? TPath extends `${infer K}.${infer R}` | ||
| ? K extends keyof T | ||
| ? R extends Path<T[K]> | ||
| ? PathValue<T[K], R> | ||
| : never | ||
| : K extends `${ArrayKey}` | ||
| ? T extends readonly (infer V)[] | ||
| ? PathValue<V, R & Path<V>> | ||
| : never | ||
| : never | ||
| : TPath extends keyof T | ||
| ? T[TPath] | ||
| : TPath extends `${ArrayKey}` | ||
| ? T extends readonly (infer V)[] | ||
| ? V | ||
| : never | ||
| : never | ||
| : never |
| import { | ||
| isFunc, | ||
| isObj | ||
| } from "./chunk-3XTOLKPS.mjs"; | ||
| import { | ||
| __export | ||
| } from "./chunk-LLLY6SAS.mjs"; | ||
| // src/obj.ts | ||
| var obj_exports = {}; | ||
| __export(obj_exports, { | ||
| assign: () => assign, | ||
| assignTo: () => assignTo, | ||
| bind: () => bind, | ||
| cast: () => cast, | ||
| clone: () => clone, | ||
| compact: () => compact, | ||
| entries: () => entries, | ||
| filter: () => filter, | ||
| from: () => from, | ||
| fromEntries: () => fromEntries, | ||
| keys: () => keys, | ||
| map: () => map, | ||
| merge: () => merge, | ||
| omit: () => omit, | ||
| pick: () => pick, | ||
| split: () => split | ||
| }); | ||
| var fromEntries = (entries2) => Object.fromEntries(entries2), map = (f) => (obj) => fromEntries(Object.entries(obj).map(([k, v]) => f(k, v))), entries = (obj) => Object.entries(obj), from = (key) => (value) => fromEntries([[key, value]]); | ||
| function assign(v) { | ||
| return (obj) => ({ | ||
| ...obj, | ||
| ...isFunc(v) ? v(obj) : v | ||
| }); | ||
| } | ||
| var assignTo = (key) => (prev) => fromEntries([[key, prev]]), keys = (obj) => Object.keys(obj), filter = (f) => (obj) => fromEntries(Object.entries(obj).filter(([k, v]) => f(k, v))), compact = (obj) => filter((_, v) => v !== void 0)(obj), split = (...keys2) => (obj) => { | ||
| let descriptors = Object.getOwnPropertyDescriptors(obj), dKeys = Object.keys(descriptors), split2 = (k) => { | ||
| let clone2 = {}; | ||
| for (let i = 0; i < k.length; i++) { | ||
| let key = k[i]; | ||
| descriptors[key] && (Object.defineProperty(clone2, key, descriptors[key]), delete descriptors[key]); | ||
| } | ||
| return clone2; | ||
| }, fn = (key) => split2(Array.isArray(key) ? key : dKeys.filter(key)); | ||
| return keys2.map(fn).concat(split2(dKeys)); | ||
| }, clone = (obj) => structuredClone(obj); | ||
| function merge(...args) { | ||
| return (obj) => { | ||
| if (!args.length) | ||
| return obj; | ||
| for (let i = 1; i < args.length; i++) { | ||
| let source = { ...args[i] }; | ||
| for (let key in source) { | ||
| let targValue = obj[key], srcValue = source[key]; | ||
| isObj(targValue) && isObj(srcValue) ? obj[key] = merge(srcValue)(targValue) : obj[key] = srcValue; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
| } | ||
| var omit = (keys2) => (obj) => { | ||
| let clone2 = { ...obj }; | ||
| for (let i = 0; i < keys2.length; i++) | ||
| delete clone2[keys2[i]]; | ||
| return clone2; | ||
| }, cast = (v) => v, pick = (keys2) => (obj) => { | ||
| let clone2 = {}; | ||
| for (let i = 0; i < keys2.length; i++) | ||
| clone2[keys2[i]] = obj[keys2[i]]; | ||
| return clone2; | ||
| }, bind = (key, fn) => (obj) => cast({ | ||
| ...obj, | ||
| [key]: fn(obj[key]) | ||
| }); | ||
| export { | ||
| fromEntries, | ||
| map, | ||
| entries, | ||
| from, | ||
| assign, | ||
| assignTo, | ||
| keys, | ||
| filter, | ||
| compact, | ||
| split, | ||
| clone, | ||
| merge, | ||
| omit, | ||
| cast, | ||
| pick, | ||
| bind, | ||
| obj_exports | ||
| }; |
| import { Dict, Assign, SplitProp, Simplify } from './types.js'; | ||
| declare const fromEntries: <T extends Dict>(entries: IterableIterator<[string, T[keyof T]]> | Iterable<[string, T[keyof T]]>) => T; | ||
| declare const map: <T extends Dict>(f: (key: string, value: T[keyof T]) => [string, T[keyof T]]) => (obj: T) => T; | ||
| declare const entries: <T extends Dict>(obj: T) => [keyof T, T[keyof T]][]; | ||
| declare const from: <K extends string, T>(key: K) => (value: T) => Record<K, T>; | ||
| declare function assign<T extends Dict, K extends Dict>(v: K | ((obj: T) => K)): (obj: T) => Assign<[T, K]>; | ||
| declare const assignTo: <K extends string, T extends Dict>(key: K) => (prev: T) => Record<K, T>; | ||
| declare const keys: <T extends Dict>(obj: T) => (keyof T)[]; | ||
| declare const filter: <T extends Dict>(f: (key: keyof T, value: T[keyof T]) => boolean) => (obj: T) => T; | ||
| declare const compact: <T extends Dict>(obj: T) => { [K in keyof T]: T[K] extends undefined ? never : T[K]; }; | ||
| declare const split: <T extends Dict, K extends [SplitProp<T>, ...SplitProp<T>[]]>(...keys: K) => (obj: T) => [...{ [P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never; }, Omit<T, K[number][number]>]; | ||
| declare const clone: <T extends Dict>(obj: T) => T; | ||
| declare function merge<T, U>(source: U): (target: T) => Assign<[T, U]>; | ||
| declare function merge<T, U, V>(target: T): (source: U, source2: V) => Assign<[T, U, V]>; | ||
| declare function merge<T, U, V, W>(target: T): (source: U, source2: V, source3: W) => Assign<[T, U, V, W]>; | ||
| declare function merge<T, U, V, W, X>(target: T): (source: U, source2: V, source3: W, source4: X) => Assign<[T, U, V, W, X]>; | ||
| declare const omit: <T extends Dict, K extends keyof T>(keys: K[]) => (obj: T) => Simplify<Omit<T, K>>; | ||
| declare const cast: <T>(v: any) => T; | ||
| declare const pick: <T extends Dict, K extends keyof T>(keys: K[]) => (obj: T) => Simplify<Pick<T, K>>; | ||
| interface Bind { | ||
| <T extends Dict, K extends string, U>(key: K, fn: (value: T) => U): (obj: T) => Assign<[T, Record<K, U>]>; | ||
| } | ||
| declare const bind: Bind; | ||
| declare const obj_assign: typeof assign; | ||
| declare const obj_assignTo: typeof assignTo; | ||
| declare const obj_bind: typeof bind; | ||
| declare const obj_cast: typeof cast; | ||
| declare const obj_clone: typeof clone; | ||
| declare const obj_compact: typeof compact; | ||
| declare const obj_entries: typeof entries; | ||
| declare const obj_filter: typeof filter; | ||
| declare const obj_from: typeof from; | ||
| declare const obj_fromEntries: typeof fromEntries; | ||
| declare const obj_keys: typeof keys; | ||
| declare const obj_map: typeof map; | ||
| declare const obj_merge: typeof merge; | ||
| declare const obj_omit: typeof omit; | ||
| declare const obj_pick: typeof pick; | ||
| declare const obj_split: typeof split; | ||
| declare namespace obj { | ||
| export { | ||
| obj_assign as assign, | ||
| obj_assignTo as assignTo, | ||
| obj_bind as bind, | ||
| obj_cast as cast, | ||
| obj_clone as clone, | ||
| obj_compact as compact, | ||
| obj_entries as entries, | ||
| obj_filter as filter, | ||
| obj_from as from, | ||
| obj_fromEntries as fromEntries, | ||
| obj_keys as keys, | ||
| obj_map as map, | ||
| obj_merge as merge, | ||
| obj_omit as omit, | ||
| obj_pick as pick, | ||
| obj_split as split, | ||
| }; | ||
| } | ||
| export { from as a, assign as b, assignTo as c, filter as d, entries as e, fromEntries as f, compact as g, clone as h, merge as i, omit as j, keys as k, cast as l, map as m, bind as n, obj as o, pick as p, split as s }; |
72530
7.86%2147
7.78%