@rkmodules/rules 0.0.155 → 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 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,
@@ -2659,8 +2716,8 @@ var destructureObject = {
2659
2716
  all: { type: "boolean", default: true, label: "all fields" },
2660
2717
  },
2661
2718
  outputs: {
2662
- object: "any",
2663
- exclusion: "any",
2719
+ included: "any",
2720
+ excluded: "any",
2664
2721
  },
2665
2722
  impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
2666
2723
  var split;
@@ -2673,27 +2730,27 @@ var destructureObject = {
2673
2730
  }
2674
2731
  split = nAryOnTree([object, fields], function (_a) {
2675
2732
  var _b = __read(_a, 2), obj = _b[0], _c = _b[1], flds = _c === void 0 ? [] : _c;
2676
- var newObj = {};
2677
- var exclusion = {};
2733
+ var included = {};
2734
+ var excluded = {};
2678
2735
  if (typeof obj !== "object" || obj === null)
2679
2736
  return DISCARD;
2680
2737
  Object.entries(obj).forEach(function (_a) {
2681
2738
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
2682
2739
  if (flds.includes(key)) {
2683
- newObj[key] = value;
2740
+ included[key] = value;
2684
2741
  }
2685
2742
  else {
2686
- exclusion[key] = value;
2743
+ excluded[key] = value;
2687
2744
  }
2688
2745
  });
2689
- return [[newObj, exclusion]];
2746
+ return [[included, excluded]];
2690
2747
  }, true);
2691
2748
  return [2 /*return*/, {
2692
- object: mapTree(split, function (_a) {
2693
- var _b = __read(_a, 2), o = _b[0]; _b[1];
2694
- return o;
2749
+ included: mapTree(split, function (_a) {
2750
+ var _b = __read(_a, 2), i = _b[0]; _b[1];
2751
+ return i;
2695
2752
  }),
2696
- exclusion: mapTree(split, function (_a) {
2753
+ excluded: mapTree(split, function (_a) {
2697
2754
  var _b = __read(_a, 2); _b[0]; var e = _b[1];
2698
2755
  return e;
2699
2756
  }),