|
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 | |
|---|
| 1 | import { keysIn } from './keysIn.mjs';
|
|---|
| 2 | import { range } from '../../math/range.mjs';
|
|---|
| 3 | import { getSymbolsIn } from '../_internal/getSymbolsIn.mjs';
|
|---|
| 4 | import { identity } from '../function/identity.mjs';
|
|---|
| 5 | import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|---|
| 6 | import { isSymbol } from '../predicate/isSymbol.mjs';
|
|---|
| 7 | import { iteratee } from '../util/iteratee.mjs';
|
|---|
| 8 |
|
|---|
| 9 | function 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 |
|
|---|
| 28 | export { omitBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.