lil-fp
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -6,4 +6,4 @@ export { a as Arr } from './arr-b35d40c1.js'; | ||
export { match, orElse, otherwise, when } from './logic.js'; | ||
export { o as Obj } from './obj-90c07fec.js'; | ||
export { o as Obj } from './obj-f1ad7d3a.js'; | ||
export { o as Opt } from './opt-27fbc4b4.js'; | ||
import './types.js'; |
@@ -137,2 +137,3 @@ "use strict"; | ||
assignTo: () => assignTo, | ||
bind: () => bind, | ||
compact: () => compact2, | ||
@@ -158,3 +159,6 @@ defaults: () => defaults, | ||
} | ||
var assignTo = (key) => (prev2) => fromEntries([[key, prev2]]), keys = (obj) => Object.keys(obj), filter2 = (f) => (obj) => fromEntries(Object.entries(obj).filter(([k, v]) => f(k, v))), compact2 = (obj) => filter2((_, v) => v != null)(obj), split = (...keys2) => (obj) => { | ||
var assignTo = (key) => (prev2) => fromEntries([[key, prev2]]), bind = (key, fn) => (obj) => cast({ | ||
...obj, | ||
[key]: fn(obj) | ||
}), keys = (obj) => Object.keys(obj), filter2 = (f) => (obj) => fromEntries(Object.entries(obj).filter(([k, v]) => f(k, v))), compact2 = (obj) => filter2((_, v) => v != null)(obj), split = (...keys2) => (obj) => { | ||
let descriptors = Object.getOwnPropertyDescriptors(obj), dKeys = Object.keys(descriptors), split2 = (k) => { | ||
@@ -161,0 +165,0 @@ let clone = {}; |
import './types.js'; | ||
export { a as assign, b as assignTo, d as compact, i as defaults, e as entries, c as filter, f as fromEntries, j as get, k as keys, m as map, g as merge, h as omit, p as pick, s as split } from './obj-90c07fec.js'; | ||
export { a as assign, b as assignTo, c as bind, g as compact, j as defaults, e as entries, d as filter, f as fromEntries, l as get, k as keys, m as map, h as merge, i as omit, p as pick, s as split } from './obj-f1ad7d3a.js'; |
@@ -22,2 +22,3 @@ "use strict"; | ||
assignTo: () => assignTo, | ||
bind: () => bind, | ||
compact: () => compact, | ||
@@ -52,3 +53,6 @@ defaults: () => defaults, | ||
} | ||
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 != null)(obj), split = (...keys2) => (obj) => { | ||
var assignTo = (key) => (prev) => fromEntries([[key, prev]]), bind = (key, fn) => (obj) => cast({ | ||
...obj, | ||
[key]: fn(obj) | ||
}), keys = (obj) => Object.keys(obj), filter = (f) => (obj) => fromEntries(Object.entries(obj).filter(([k, v]) => f(k, v))), compact = (obj) => filter((_, v) => v != null)(obj), split = (...keys2) => (obj) => { | ||
let descriptors = Object.getOwnPropertyDescriptors(obj), dKeys = Object.keys(descriptors), split2 = (k) => { | ||
@@ -107,2 +111,3 @@ let clone = {}; | ||
assignTo, | ||
bind, | ||
compact, | ||
@@ -109,0 +114,0 @@ defaults, |
@@ -15,2 +15,5 @@ type Dict = Record<string, any>; | ||
type Defaults<T extends Dict, K extends Partial<T>> = Simplify<Omit<T, keyof K> & Required<K>>; | ||
interface Bind { | ||
<T extends Dict, K extends string, U>(key: K, fn: (value: T) => U): (obj: T) => Assign<[T, Record<K, U>]>; | ||
} | ||
type Simplify<T> = T extends any ? { | ||
@@ -42,2 +45,2 @@ [K in keyof T]: T[K]; | ||
export { ArrayPath, Assign, Awaited, Compact, Defaults, Dict, Path, PathConcat, PathValue, Primitive, PromiseFactory, Simplify, Split, SplitProp }; | ||
export { ArrayPath, Assign, Awaited, Bind, Compact, Defaults, Dict, Path, PathConcat, PathValue, Primitive, PromiseFactory, Simplify, Split, SplitProp }; |
{ | ||
"name": "lil-fp", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "Functional programming utilities for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,2 +5,3 @@ import { cast } from './func' | ||
Assign, | ||
Bind, | ||
Compact, | ||
@@ -62,2 +63,11 @@ Defaults, | ||
/** | ||
* Returns a new object that specified key whose value is the result of calling the provided function | ||
*/ | ||
export const bind: Bind = (key, fn) => (obj) => | ||
cast({ | ||
...obj, | ||
[key]: fn(obj), | ||
}) | ||
/** | ||
* Returns the keys of an object | ||
@@ -64,0 +74,0 @@ */ |
@@ -30,2 +30,8 @@ export type Dict = Record<string, any> | ||
export interface Bind { | ||
<T extends Dict, K extends string, U>(key: K, fn: (value: T) => U): ( | ||
obj: T | ||
) => Assign<[T, Record<K, U>]> | ||
} | ||
export type Simplify<T> = T extends any ? { [K in keyof T]: T[K] } : T | ||
@@ -32,0 +38,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
87578
2661