1.0.0 • Published 5 years ago

remove-predicate v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Remove predicate Travis CI Build Status

Remove items from an object based on a predicate.

NPM Badge

Install

npm install remove-predicate

Usage

const removePredicate = require("remove-predicate");

removePredicate(
    {
        a: {
            _a: "a",
            b: 1
        },
        _b: ["b"]
    },
    (_value, key) => key.startsWith("_")
);
//=> { a: { b: 1 } }

API

removePredicate(obj, predicate)

obj

Type: object or array

The object or array to handle.

predicate

Type: (value, key) => boolean-convertable

The predicate to compare the items to.