Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

object-filter

mmalecki501.3kMIT1.0.2

Array.prototype.filter for objects

object, filter

readme

objfilter

Build Status

Array.prototype.filter for objects.

Usage

var assert = require('assert');
var objfilter = require('../');

var o1 = {
  a: 1,
  b: -1,
  c: 0,
  d: 42
};

objfilter(o1, function (n) {
  return n > 0;
}); // => `{ a: 1, d: 42 }`

API

objfilter(obj, iterator, this)

  • obj (object) - object to filter on
  • iterator (function, required) - iterator function
  • this (optional) - this for iterator

Creates a new object with all the elements that pass the test implemented by iterator.