source: node_modules/es-toolkit/dist/compat/object/omitBy.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const keysIn = require('./keysIn.js');
6const range = require('../../math/range.js');
7const getSymbolsIn = require('../_internal/getSymbolsIn.js');
8const identity = require('../function/identity.js');
9const isArrayLike = require('../predicate/isArrayLike.js');
10const isSymbol = require('../predicate/isSymbol.js');
11const iteratee = require('../util/iteratee.js');
12
13function omitBy(object, shouldOmit) {
14 if (object == null) {
15 return {};
16 }
17 const result = {};
18 const predicate = iteratee.iteratee(shouldOmit ?? identity.identity);
19 const keys = isArrayLike.isArrayLike(object)
20 ? range.range(0, object.length)
21 : [...keysIn.keysIn(object), ...getSymbolsIn.getSymbolsIn(object)];
22 for (let i = 0; i < keys.length; i++) {
23 const key = (isSymbol.isSymbol(keys[i]) ? keys[i] : keys[i].toString());
24 const value = object[key];
25 if (!predicate(value, key, object)) {
26 result[key] = value;
27 }
28 }
29 return result;
30}
31
32exports.omitBy = omitBy;
Note: See TracBrowser for help on using the repository browser.