-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (41 loc) · 1.52 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
module.exports = deepOmitBy;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _recursiveIterator = require('recursive-iterator');
var _recursiveIterator2 = _interopRequireDefault(_recursiveIterator);
var _delObjectPath = require('del-object-path');
var _delObjectPath2 = _interopRequireDefault(_delObjectPath);
var _objectMerge = require('object-merge');
var _objectMerge2 = _interopRequireDefault(_objectMerge);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function deepOmitBy(object, callback) {
var results = (0, _objectMerge2.default)({}, object);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = new _recursiveIterator2.default(object)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var meta = _step.value;
var shouldOmit = callback(meta);
if (shouldOmit) {
(0, _delObjectPath2.default)(results, meta.path.join('.'));
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return results;
}