filter-keys.js

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

Usage no npm install needed!

<script type="module">
  import filterKeysJs from 'https://cdn.skypack.dev/filter-keys.js';
</script>

README

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

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