@rkmodules/rules 0.0.130 → 0.0.131

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
@@ -373,10 +373,13 @@ function forEachItem(tree, fn) {
373
373
  });
374
374
  });
375
375
  }
376
- function pushItem(tree, path, item) {
376
+ function ensureBranch(tree, path) {
377
377
  if (!tree[path]) {
378
378
  tree[path] = [];
379
379
  }
380
+ }
381
+ function pushItem(tree, path, item) {
382
+ ensureBranch(tree, path);
380
383
  tree[path].push(item);
381
384
  }
382
385
  /**
@@ -2476,6 +2479,8 @@ var explodeObject = {
2476
2479
  branch.forEach(function (obj, index) {
2477
2480
  if (!obj)
2478
2481
  return;
2482
+ if (typeof obj !== "object")
2483
+ obj = null;
2479
2484
  if (obj === null && params.removeEmpty)
2480
2485
  ;
2481
2486
  var props = obj || {};
@@ -2492,6 +2497,15 @@ var explodeObject = {
2492
2497
  });
2493
2498
  });
2494
2499
  });
2500
+ if (!params.removeEmpty) {
2501
+ // ensure the same branches exist in the output even if they are empty, so that the outputs don't change shape when empty branches are added or removed from the input
2502
+ Object.entries(outputs).forEach(function (_a) {
2503
+ var _b = __read(_a, 2); _b[0]; var tree = _b[1];
2504
+ forEachBranch(object, function (branch, path) {
2505
+ ensureBranch(tree, path);
2506
+ });
2507
+ });
2508
+ }
2495
2509
  return [2 /*return*/, outputs];
2496
2510
  });
2497
2511
  }); },
@@ -8170,6 +8184,7 @@ exports.Lib = Lib;
8170
8184
  exports.binaryOnTree = binaryOnTree;
8171
8185
  exports.binaryOnTreeBranch = binaryOnTreeBranch;
8172
8186
  exports.broadCast = broadCast;
8187
+ exports.ensureBranch = ensureBranch;
8173
8188
  exports.expandTree = expandTree;
8174
8189
  exports.forEachBranch = forEachBranch;
8175
8190
  exports.forEachItem = forEachItem;