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

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

Added visualizations

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