@soratani-code/samtools 1.3.16 → 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/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/tools.d.ts +2 -0
- package/lib/tools.js +65 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -41,5 +41,6 @@ __exportStar(require("./type"), exports);
|
|
|
41
41
|
__exportStar(require("./delay"), exports);
|
|
42
42
|
__exportStar(require("./time"), exports);
|
|
43
43
|
__exportStar(require("./permission"), exports);
|
|
44
|
+
__exportStar(require("./tools"), exports);
|
|
44
45
|
var graph_1 = require("./graph");
|
|
45
46
|
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return __importDefault(graph_1).default; } });
|
package/lib/tools.d.ts
ADDED
package/lib/tools.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepDelete = exports.isDeepEqual = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const type_1 = require("./type");
|
|
6
|
+
function isDeepEqual(a, b) {
|
|
7
|
+
function isEqualKeys(keys, _keys) {
|
|
8
|
+
const sk = keys.sort();
|
|
9
|
+
const _sk = _keys.sort();
|
|
10
|
+
return (0, lodash_1.isEqual)(sk, _sk);
|
|
11
|
+
}
|
|
12
|
+
return (0, lodash_1.isEqualWith)(a, b, (n, o) => {
|
|
13
|
+
if ((0, type_1.type)(n) !== (0, type_1.type)(o))
|
|
14
|
+
return false;
|
|
15
|
+
if ((0, type_1.isObject)(n)) {
|
|
16
|
+
const nk = Object.keys(n);
|
|
17
|
+
const ok = Object.keys(o);
|
|
18
|
+
if (nk.length !== ok.length || !isEqualKeys(nk, ok))
|
|
19
|
+
return false;
|
|
20
|
+
return (0, lodash_1.every)(nk, (key) => isDeepEqual(n[key], o[key]));
|
|
21
|
+
}
|
|
22
|
+
if ((0, type_1.isArray)(n)) {
|
|
23
|
+
if (n.length !== o.length)
|
|
24
|
+
return false;
|
|
25
|
+
return (0, lodash_1.every)(n, (item, index) => {
|
|
26
|
+
return isDeepEqual(item, o[index]);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if ((0, type_1.isUndefined)(n))
|
|
30
|
+
return (0, type_1.isUndefined)(o);
|
|
31
|
+
if ((0, type_1.isNull)(n))
|
|
32
|
+
return (0, type_1.isNull)(o);
|
|
33
|
+
return (0, lodash_1.isEqual)(n, o);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
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;
|