object-prototype-filter
v1.0.1
Published
Prototype filter function for objects
Downloads
6
Maintainers
Readme
object-prototype-filter
This is a set of supplementary prototype additions to the Object class that provide filtration
funcitons analogous to that of Array.prototype.filter()
.
Installation
NPM
npm install --save object-prototype-filter
Bower
bower install --save object-prototype-filter
Manual
<script src="path/to/directory/object-prototype-filter.js"></script>
Usage
This supplement adds the following prototype methods to the Object class:
Object.prototype.filterValues(callback)
- Creates a new object with all entries that pass the test implemented by the provided function.callback(key, object, thisArg)
Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise, taking two arguments:
key
the current key being processed in the object.
object
the object filter was called upon.
thisArg
Optional. Value to use as this when executing callback.return A new objet with the elements that pass the test.
Development
npm run build
- Build and minify
License
This project is licensed under the MIT License - see the LICENSE.txt file for details