filter-keys.js
v0.4.1
Published
For each element in source `object` apply `iteratee` to (value, key, object). Include key in result array where return value is `true`.
Downloads
5
Readme
filter-keys
For each element in source
object
applyiteratee
to (value, key, object). Include key in result array where return value istrue
.
yarn
yarn add filter-keys
npm
npm install filter-keys --save
You may also directly download a release.
npm stats
Features
- Partial application is directly supported via currying (no need for
Function.prototype.bind
). - ES3, ES5, CommonJS, AMD, and legacy-global compatible.
- Haskell style Parameter Order (allows for pointfree programming style).
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