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