filter-keys.js

0.4.1 • Public • Published

filter-keys

For each element in source object apply iteratee to (value, key, object). Include key in result array where return value is true.

Build Status Code Climate js-standard-style

yarn
yarn add filter-keys
npm
npm install filter-keys --save

You may also directly download a release.

npm stats

npm NPM downloads Dependency Status

Features

  • Partial application is directly supported via currying.
  • ES3, ES5, CommonJS, AMD, and legacy-global compatible.
  • Haskell style Parameter Order.

API Example

require
var filterKeys = require('filter-keys')
full application
var object = {
  id: { required: false },
  title: { required: true },
  body: { required: true },
}
 
filterKeys(function (val) { return val.required }, object)
//=> [ 'title', 'body' ]
partial application
var object = {
  id: { required: false },
  title: { required: true },
  body: { required: true },
}
 
var filter = filterKeys(function (val) {
  return val.required
})
 
filter(object)
//=> [ 'title', 'body' ]

API

filterKeys(iteratee, object)

arguments
  • iteratee: (Function) iteratee function; applied to (value, key, object).
  • object: (Object) source object.
returns
  • (Function|[]) If partially applied, return unary function, otherwise, return result of full application.

Contributing

SEE: contributing.md

Licenses

GitHub license

Readme

Keywords

Package Sidebar

Install

npm i filter-keys.js

Weekly Downloads

7

Version

0.4.1

License

MIT

Unpacked Size

6.16 kB

Total Files

9

Last publish

Collaborators

  • wilmoore