0.0.3 • Published 5 years ago

@sullux/fp-light-get v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

home

fp-light-get

npm i @sullux/fp-light-get source test

The purpose of the get helper is to provide a functional way to retrieve properties from an input object.

get

get(pathParts: (string | number) | (string | number)[], source: any): any

The get function is useful for traversing a property path. The path parts can be strings or numbers. This supports retrieving properties and array elements.

const { get } = require('@sullux/fp-light-get')

const object = { foo: [41, 42] }

get(['foo', 1], object) // 42

The get helper can be useful in functional composition. The following is a more complete example of the getfunction.

const { call } = require('@sullux/fp-light-call')
const { get } = require('@sullux/fp-light-get')

const random0To31 = () =>
  Math.floor(Math.random() * 36)

const randomString = length =>
  Array(length)
    .fill()
    .map(random0To31)
    .map(get('toString'))
    .map(call(36))
    .join('')
0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago