/object-prototype-filter

Object prototype supplementary filtration functions

Primary LanguageJavaScriptMIT LicenseMIT

object-prototype-filter
CohesionFirst JavaCommons MIT License npm version

This is a set of supplementary prototype additions to the Object class that provide filtration functions analogous to that of Array.prototype.filter().

Comments and Issues

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:

  1. 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