cdxOo / omit

my variant of omitting object properties

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@cdxoo/omit

Creates shallow copy of a given object with the specified attributes removed.

Installation

npm install --save @cdxOo/omit

Usage

const omit = require('@cdxoo/dbscan');

let A = omit(
    [ 'a', 'c' ],
    { a: 1, b: 2, c: 3, d: 4 }
);
// => { b: 2, d: 4 }

let B = omit(
    {
        a: (value) => ( value < 2 ),
        c: true
    },
    { a: 1, b: 2, c: 3, d: 4 }
)
// => { b: 2, d: 4 }

let C = omit(
    (value, key) => ( value === null ),
    { a: 1, b: null, c: 3, d: null }
);
// => { a: 1, c: 3 }

let D = omit('a', { a: 1, b: 2 });
// => { b: 2 };
// this style only works for on a single attribute though

About

my variant of omitting object properties

License:MIT License


Languages

Language:JavaScript 100.0%