@rkmodules/rules 0.0.154 → 0.0.156
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/dist/index.cjs.js +115 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +115 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Primitives/Json/destructureObject.d.ts +2 -0
- package/dist/lib/Primitives/List/destructureList.d.ts +2 -0
- package/dist/lib/Primitives/List/listSlice.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1867,12 +1867,69 @@ var coalesce = {
|
|
|
1867
1867
|
}); },
|
|
1868
1868
|
};
|
|
1869
1869
|
|
|
1870
|
+
var destructureList = {
|
|
1871
|
+
name: "destructureList",
|
|
1872
|
+
label: "Destructure List",
|
|
1873
|
+
description: "Separates an list into a part with the specified values and the rest",
|
|
1874
|
+
inputs: {
|
|
1875
|
+
list: "any",
|
|
1876
|
+
items: { type: "any" },
|
|
1877
|
+
},
|
|
1878
|
+
params: {
|
|
1879
|
+
// all: { type: "boolean", default: true, label: "all fields" },
|
|
1880
|
+
},
|
|
1881
|
+
outputs: {
|
|
1882
|
+
included: "any",
|
|
1883
|
+
excluded: "any",
|
|
1884
|
+
matches: "boolean",
|
|
1885
|
+
},
|
|
1886
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
1887
|
+
var split;
|
|
1888
|
+
var _c = _b.list, list = _c === void 0 ? {} : _c, _d = _b.items, items = _d === void 0 ? {} : _d;
|
|
1889
|
+
return __generator(this, function (_e) {
|
|
1890
|
+
split = nAryOnTreeBranch([list, items], function (_a) {
|
|
1891
|
+
var _b = __read(_a, 2), _c = _b[0], list = _c === void 0 ? [] : _c, _d = _b[1], items = _d === void 0 ? [] : _d;
|
|
1892
|
+
var included = [];
|
|
1893
|
+
var excluded = [];
|
|
1894
|
+
var matches = [];
|
|
1895
|
+
console.log("Destructuring list", list, items);
|
|
1896
|
+
list.forEach(function (value) {
|
|
1897
|
+
var m = items.includes(value);
|
|
1898
|
+
matches.push(m);
|
|
1899
|
+
if (m) {
|
|
1900
|
+
included.push(value);
|
|
1901
|
+
}
|
|
1902
|
+
else {
|
|
1903
|
+
excluded.push(value);
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
return [[included, excluded, matches]];
|
|
1907
|
+
});
|
|
1908
|
+
return [2 /*return*/, {
|
|
1909
|
+
included: mapTree(split, function (_a) {
|
|
1910
|
+
var _b = __read(_a, 1), l = _b[0];
|
|
1911
|
+
return l;
|
|
1912
|
+
}),
|
|
1913
|
+
excluded: mapTree(split, function (_a) {
|
|
1914
|
+
var _b = __read(_a, 2); _b[0]; var e = _b[1];
|
|
1915
|
+
return e;
|
|
1916
|
+
}),
|
|
1917
|
+
matches: mapTree(split, function (_a) {
|
|
1918
|
+
var _b = __read(_a, 3); _b[0]; _b[1]; var m = _b[2];
|
|
1919
|
+
return m;
|
|
1920
|
+
}),
|
|
1921
|
+
}];
|
|
1922
|
+
});
|
|
1923
|
+
}); },
|
|
1924
|
+
};
|
|
1925
|
+
|
|
1870
1926
|
var _a$6;
|
|
1871
1927
|
var primitives$6 = (_a$6 = {},
|
|
1872
1928
|
_a$6[listInput.name] = listInput,
|
|
1873
1929
|
_a$6[listItem.name] = listItem,
|
|
1874
1930
|
_a$6[listLength.name] = listLength,
|
|
1875
1931
|
_a$6[filterList.name] = filterList,
|
|
1932
|
+
_a$6[destructureList.name] = destructureList,
|
|
1876
1933
|
_a$6[relativeItem.name] = relativeItem,
|
|
1877
1934
|
_a$6[relativeItems.name] = relativeItems,
|
|
1878
1935
|
_a$6[concat.name] = concat,
|
|
@@ -2631,9 +2688,9 @@ var setField = {
|
|
|
2631
2688
|
newObject = nAryOnTree([object, key, value], function (_a) {
|
|
2632
2689
|
var _b = __read(_a, 3), o = _b[0], k = _b[1], v = _b[2];
|
|
2633
2690
|
var newObj = __assign({}, o);
|
|
2634
|
-
if (
|
|
2691
|
+
if (newObj[k] !== undefined && !overwrite) {
|
|
2635
2692
|
// If the key already exists and overwrite is false, return the original object
|
|
2636
|
-
return
|
|
2693
|
+
return newObj;
|
|
2637
2694
|
}
|
|
2638
2695
|
if (k !== undefined) {
|
|
2639
2696
|
newObj[k] = v;
|
|
@@ -2647,6 +2704,61 @@ var setField = {
|
|
|
2647
2704
|
}); },
|
|
2648
2705
|
};
|
|
2649
2706
|
|
|
2707
|
+
var destructureObject = {
|
|
2708
|
+
name: "destructureObject",
|
|
2709
|
+
label: "Destructure Object",
|
|
2710
|
+
description: "Separates an object into a part with the specified fields and the rest",
|
|
2711
|
+
inputs: {
|
|
2712
|
+
object: "any",
|
|
2713
|
+
fields: { type: "string" },
|
|
2714
|
+
},
|
|
2715
|
+
params: {
|
|
2716
|
+
all: { type: "boolean", default: true, label: "all fields" },
|
|
2717
|
+
},
|
|
2718
|
+
outputs: {
|
|
2719
|
+
included: "any",
|
|
2720
|
+
excluded: "any",
|
|
2721
|
+
},
|
|
2722
|
+
impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
|
|
2723
|
+
var split;
|
|
2724
|
+
var _c = _b.object, object = _c === void 0 ? {} : _c, _d = _b.fields, fields = _d === void 0 ? {} : _d;
|
|
2725
|
+
return __generator(this, function (_e) {
|
|
2726
|
+
if (params.all) {
|
|
2727
|
+
fields = mapTreeBranch(fields, function (items) {
|
|
2728
|
+
return [items];
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
split = nAryOnTree([object, fields], function (_a) {
|
|
2732
|
+
var _b = __read(_a, 2), obj = _b[0], _c = _b[1], flds = _c === void 0 ? [] : _c;
|
|
2733
|
+
var included = {};
|
|
2734
|
+
var excluded = {};
|
|
2735
|
+
if (typeof obj !== "object" || obj === null)
|
|
2736
|
+
return DISCARD;
|
|
2737
|
+
Object.entries(obj).forEach(function (_a) {
|
|
2738
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
2739
|
+
if (flds.includes(key)) {
|
|
2740
|
+
included[key] = value;
|
|
2741
|
+
}
|
|
2742
|
+
else {
|
|
2743
|
+
excluded[key] = value;
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
return [[included, excluded]];
|
|
2747
|
+
}, true);
|
|
2748
|
+
return [2 /*return*/, {
|
|
2749
|
+
included: mapTree(split, function (_a) {
|
|
2750
|
+
var _b = __read(_a, 2), i = _b[0]; _b[1];
|
|
2751
|
+
return i;
|
|
2752
|
+
}),
|
|
2753
|
+
excluded: mapTree(split, function (_a) {
|
|
2754
|
+
var _b = __read(_a, 2); _b[0]; var e = _b[1];
|
|
2755
|
+
return e;
|
|
2756
|
+
}),
|
|
2757
|
+
}];
|
|
2758
|
+
});
|
|
2759
|
+
}); },
|
|
2760
|
+
};
|
|
2761
|
+
|
|
2650
2762
|
var _a$1;
|
|
2651
2763
|
var primitives$1 = (_a$1 = {},
|
|
2652
2764
|
_a$1[object.name] = object,
|
|
@@ -2656,6 +2768,7 @@ var primitives$1 = (_a$1 = {},
|
|
|
2656
2768
|
_a$1[mergeObject.name] = mergeObject,
|
|
2657
2769
|
_a$1[objectEntries.name] = objectEntries,
|
|
2658
2770
|
_a$1[explodeObject.name] = explodeObject,
|
|
2771
|
+
_a$1[destructureObject.name] = destructureObject,
|
|
2659
2772
|
_a$1);
|
|
2660
2773
|
|
|
2661
2774
|
var INFERRED = "inferred";
|