revdev 0.116.0 → 0.117.0
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/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/link.d.ts +4 -0
- package/lib/utils/link.js +24 -0
- package/lib/utils/tests/link.test.d.ts +1 -0
- package/lib/utils/tests/link.test.js +25 -0
- package/package.json +1 -1
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkUtil = void 0;
|
|
4
|
+
var LinkUtil = /** @class */ (function () {
|
|
5
|
+
function LinkUtil() {
|
|
6
|
+
}
|
|
7
|
+
LinkUtil.parse = function (request) {
|
|
8
|
+
var parentId = request.parentId;
|
|
9
|
+
var children = [];
|
|
10
|
+
if (request.childId) {
|
|
11
|
+
var _a = request, childId = _a.childId, link_1 = _a.link;
|
|
12
|
+
var childIds = Array.isArray(childId) ? childId : [childId];
|
|
13
|
+
children = childIds.map(function (x) {
|
|
14
|
+
return { id: x, link: link_1 };
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else if (request.children) {
|
|
18
|
+
children = request.children;
|
|
19
|
+
}
|
|
20
|
+
return { parentId: parentId, children: children };
|
|
21
|
+
};
|
|
22
|
+
return LinkUtil;
|
|
23
|
+
}());
|
|
24
|
+
exports.LinkUtil = LinkUtil;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var link_1 = require("../link");
|
|
4
|
+
describe("LinkUtil", function () {
|
|
5
|
+
test("parse", function () {
|
|
6
|
+
expect(link_1.LinkUtil.parse({ parentId: "1", link: true, childId: "11" })).toMatchObject({
|
|
7
|
+
parentId: "1",
|
|
8
|
+
children: [{ link: true, id: "11" }],
|
|
9
|
+
});
|
|
10
|
+
expect(link_1.LinkUtil.parse({ parentId: "1", link: true, childId: ["11", "12"] })).toMatchObject({
|
|
11
|
+
parentId: "1",
|
|
12
|
+
children: [
|
|
13
|
+
{ link: true, id: "11" },
|
|
14
|
+
{ link: true, id: "12" },
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
expect(link_1.LinkUtil.parse({ parentId: "1", link: false, childId: ["11", "12"] })).toMatchObject({
|
|
18
|
+
parentId: "1",
|
|
19
|
+
children: [
|
|
20
|
+
{ link: false, id: "11" },
|
|
21
|
+
{ link: false, id: "12" },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|