uinix-fp-props
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

uinix-fp-props

Build Coverage Downloads Size

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.

License

MIT © Chris Zhou

Readme

Keywords

Package Sidebar

Install

npm i uinix-fp-props

Weekly Downloads

2

Version

1.1.2

License

MIT

Unpacked Size

3.68 kB

Total Files

4

Last publish

Collaborators

  • chrisrzhou