|
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 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const keysIn = require('./keysIn.js');
|
|---|
| 6 | const range = require('../../math/range.js');
|
|---|
| 7 | const getSymbolsIn = require('../_internal/getSymbolsIn.js');
|
|---|
| 8 | const identity = require('../function/identity.js');
|
|---|
| 9 | const isArrayLike = require('../predicate/isArrayLike.js');
|
|---|
| 10 | const isSymbol = require('../predicate/isSymbol.js');
|
|---|
| 11 | const iteratee = require('../util/iteratee.js');
|
|---|
| 12 |
|
|---|
| 13 | function 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 |
|
|---|
| 32 | exports.omitBy = omitBy;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.