time-to-botec/js/node_modules/@stdlib/utils/omit-by
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

omitBy

Return a partial object copy excluding properties for which a predicate (function) returns a truthy value.

Usage

var omitBy = require( '@stdlib/utils/omit-by' );

omitBy( obj, predicate )

Returns a partial object copy excluding properties for which a predicate returns a truthy value.

function predicate( key, value ) {
    return ( value > 1 );
}

var obj1 = {
    'a': 1,
    'b': 2,
    'c': 3
};

var obj2 = omitBy( obj1, predicate );
// returns { 'a': 1 }

Notes

  • The function returns a shallow copy.
  • The function only copies own properties. Hence, the function never copies inherited properties.

Examples

var omitBy = require( '@stdlib/utils/omit-by' );

function predicate( key, value ) {
    return ( typeof value === 'number' );
}

var obj1 = {
    'a': '1',
    'b': 2,
    'c': NaN,
    'd': null
};

var obj2 = omitBy( obj1, predicate );
// returns { 'a': '1', 'd': null }