uinix-fp-props
v1.1.2
Published
uinix fp object props utility
Downloads
3
Readme
uinix-fp-props
uinix-fp
object props utility.
Install
This package is ESM-only and requires Node 12+.
npm install uinix-fp-props
Use
props
is a curried function returning the value of the specified object property path.
import {prop} from 'uinix-fp-props';
const x = {
a: {
b: {
c: 'C',
d: 'D',
}
},
'a.b': 'AB',
};
props('a.b.c')(x); // 'C'
props('a.b.d')(x); // 'D'
props('a')(x); // x.a
props('a.b')(x); // 'AB' (direct property path takes precendence)
props('x.y.z')(x); // undefined
const propsABC = props('a.b.c'); // curried
propsABC(x); // 'C'
API
This package exports the following identifiers: props
. There is no default export.
props(k, options)(x) => y
Parameters (curried)
k
(string
)
An object property path. Supports accessing nested object properties through the convenient "dot" notation.
X
(object
)
The provided object.
Returns
v
(any
)
The object value for the specified property.