1.0.0 • Published 2 years ago

uinix-fp-prop v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

uinix-fp-prop

Build Coverage Downloads Size

uinix-fp object prop utility.


Install

This package is ESM-only and requires Node 12+.

npm install uinix-fp-prop

Use

prop is a curried function returning the value of the specified object property.

import {prop} from 'uinix-fp-prop';

const user = {
  firstName: 'Jesse',
  lastName: 'Pinkman',
};

prop('firstName')(user); // 'Jesse'
prop('lastName')(user); // 'Pinkman'
prop('age')(user); // undefined

const propFirstName = prop('firstName'); // curried

[user, user, user].map(propFirstName); ['Jesse', 'Jesse', 'Jesse'];

API

This package exports the following identifiers: prop. There is no default export.

prop(property)(object)

Parameters (Curried)
  • property (string) — An object property.
  • object (object) — The provided object.
Returns
  • any — The object value for the specified property.

License

MIT © Chris Zhou