@soratani-code/samtools 1.3.17 → 1.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tools.d.ts +1 -0
- package/lib/tools.js +30 -1
- package/package.json +1 -1
package/lib/tools.d.ts
CHANGED
package/lib/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDeepEqual = void 0;
|
|
3
|
+
exports.deepDelete = exports.isDeepEqual = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const type_1 = require("./type");
|
|
6
6
|
function isDeepEqual(a, b) {
|
|
@@ -34,3 +34,32 @@ function isDeepEqual(a, b) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.isDeepEqual = isDeepEqual;
|
|
37
|
+
function deepDelete(data, path) {
|
|
38
|
+
const clone = (0, lodash_1.cloneDeep)(data);
|
|
39
|
+
if (!path || !(0, type_1.isString)(path))
|
|
40
|
+
return clone;
|
|
41
|
+
const paths = (0, lodash_1.filter)(path.split('.'), Boolean);
|
|
42
|
+
if (!paths.length)
|
|
43
|
+
return clone;
|
|
44
|
+
const key = paths.shift();
|
|
45
|
+
if ((0, type_1.isObject)(clone)) {
|
|
46
|
+
if (paths.length) {
|
|
47
|
+
clone[key] = deepDelete(clone[key], paths.join('.'));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
delete clone[key];
|
|
51
|
+
}
|
|
52
|
+
return clone;
|
|
53
|
+
}
|
|
54
|
+
if ((0, type_1.isArray)(clone)) {
|
|
55
|
+
if (paths.length) {
|
|
56
|
+
clone[key] = deepDelete(clone[key], paths.join('.'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
clone.splice(Number(key), 1);
|
|
60
|
+
}
|
|
61
|
+
return clone;
|
|
62
|
+
}
|
|
63
|
+
return clone;
|
|
64
|
+
}
|
|
65
|
+
exports.deepDelete = deepDelete;
|