uinix-fp-props
Version:
uinix fp object props utility
85 lines (60 loc) • 2.07 kB
Markdown
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][bundle-size-badge]][bundle-size]
[`uinix-fp`][uinix-fp] object props utility.
---
This package is [ESM-only][] and requires Node 12+.
```sh
npm install uinix-fp-props
```
`props` is a curried function returning the value of the specified object property path.
```js
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'
```
This package exports the following identifiers: `props`. There is no default export.
An object property path. Supports accessing nested object properties through the convenient "dot" notation.
The provided object.
The object value for the specified property.
[][license] © [Chris Zhou][author]
<!-- project -->
[]: https://github.com/chrisrzhou
[]: https://github.com/uinix-js/uinix-fp/blob/main/license
[]: https://github.com/uinix-js/uinix-fp/actions
[]: https://github.com/uinix-js/uinix-fp/workflows/main/badge.svg
[]: https://codecov.io/github/uinix-js/uinix-fp
[]: https://img.shields.io/codecov/c/github/uinix-js/uinix-fp.svg
[]: https://www.npmjs.com/package/uinix-fp-props
[]: https://img.shields.io/npm/dm/uinix-fp-props.svg
[]: https://bundlephobia.com/result?p=uinix-fp-props
[]: https://img.shields.io/bundlephobia/minzip/uinix-fp-props.svg
<!-- defs -->
[]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[]: https://github.com/uinix-js/uinix-fp