1.0.1 • Published 10 months ago

get-by-field-name v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

get-by-field-name

Description

This is a very simple module that I have created for testing npm purpose. This module exports only one function called getByFieldName, that follows the currying function technical. It takes a field name as the only parameter and returns another function which takes an object and returns the value of the field name.

How to use

  • Assume that you have an array of people like this:
    const arr = [{ name: 'Tom', id: 1 }, {name: 'Alex', id: 2}]
  • And you want to get list of names, so you can easily use .map built-in function of array with getByFieldName as below:
    const listNames = arr.map(getByFieldName('name'))
1.0.1

10 months ago

1.0.0

10 months ago