@rkmodules/rules 0.0.154 → 0.0.155

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.esm.js CHANGED
@@ -2629,9 +2629,9 @@ var setField = {
2629
2629
  newObject = nAryOnTree([object, key, value], function (_a) {
2630
2630
  var _b = __read(_a, 3), o = _b[0], k = _b[1], v = _b[2];
2631
2631
  var newObj = __assign({}, o);
2632
- if (o[k] !== undefined && !overwrite) {
2632
+ if (newObj[k] !== undefined && !overwrite) {
2633
2633
  // If the key already exists and overwrite is false, return the original object
2634
- return o;
2634
+ return newObj;
2635
2635
  }
2636
2636
  if (k !== undefined) {
2637
2637
  newObj[k] = v;
@@ -2645,6 +2645,61 @@ var setField = {
2645
2645
  }); },
2646
2646
  };
2647
2647
 
2648
+ var destructureObject = {
2649
+ name: "destructureObject",
2650
+ label: "Destructure Object",
2651
+ description: "Separates an object into a part with the specified fields and the rest",
2652
+ inputs: {
2653
+ object: "any",
2654
+ fields: { type: "string" },
2655
+ },
2656
+ params: {
2657
+ all: { type: "boolean", default: true, label: "all fields" },
2658
+ },
2659
+ outputs: {
2660
+ object: "any",
2661
+ exclusion: "any",
2662
+ },
2663
+ impl: function (_a, params_1) { return __awaiter(void 0, [_a, params_1], void 0, function (_b, params) {
2664
+ var split;
2665
+ var _c = _b.object, object = _c === void 0 ? {} : _c, _d = _b.fields, fields = _d === void 0 ? {} : _d;
2666
+ return __generator(this, function (_e) {
2667
+ if (params.all) {
2668
+ fields = mapTreeBranch(fields, function (items) {
2669
+ return [items];
2670
+ });
2671
+ }
2672
+ split = nAryOnTree([object, fields], function (_a) {
2673
+ var _b = __read(_a, 2), obj = _b[0], _c = _b[1], flds = _c === void 0 ? [] : _c;
2674
+ var newObj = {};
2675
+ var exclusion = {};
2676
+ if (typeof obj !== "object" || obj === null)
2677
+ return DISCARD;
2678
+ Object.entries(obj).forEach(function (_a) {
2679
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
2680
+ if (flds.includes(key)) {
2681
+ newObj[key] = value;
2682
+ }
2683
+ else {
2684
+ exclusion[key] = value;
2685
+ }
2686
+ });
2687
+ return [[newObj, exclusion]];
2688
+ }, true);
2689
+ return [2 /*return*/, {
2690
+ object: mapTree(split, function (_a) {
2691
+ var _b = __read(_a, 2), o = _b[0]; _b[1];
2692
+ return o;
2693
+ }),
2694
+ exclusion: mapTree(split, function (_a) {
2695
+ var _b = __read(_a, 2); _b[0]; var e = _b[1];
2696
+ return e;
2697
+ }),
2698
+ }];
2699
+ });
2700
+ }); },
2701
+ };
2702
+
2648
2703
  var _a$1;
2649
2704
  var primitives$1 = (_a$1 = {},
2650
2705
  _a$1[object.name] = object,
@@ -2654,6 +2709,7 @@ var primitives$1 = (_a$1 = {},
2654
2709
  _a$1[mergeObject.name] = mergeObject,
2655
2710
  _a$1[objectEntries.name] = objectEntries,
2656
2711
  _a$1[explodeObject.name] = explodeObject,
2712
+ _a$1[destructureObject.name] = destructureObject,
2657
2713
  _a$1);
2658
2714
 
2659
2715
  var INFERRED = "inferred";