@rkmodules/rules 0.0.97 → 0.0.99

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
@@ -263,6 +263,32 @@ function getBranches(tree) {
263
263
  function getPaths(tree) {
264
264
  return Object.keys(tree);
265
265
  }
266
+ function getItem(tree, path, index) {
267
+ var branch = getBranch(tree, path);
268
+ if (branch) {
269
+ return branch[index];
270
+ }
271
+ }
272
+ function forEachBranch(tree, fn) {
273
+ var paths = getPaths(tree);
274
+ paths.forEach(function (path, i) {
275
+ var branch = tree[path];
276
+ fn(branch, path, i);
277
+ });
278
+ }
279
+ function forEachItem(tree, fn) {
280
+ forEachBranch(tree, function (branch, path, pathIndex) {
281
+ branch.forEach(function (item, i) {
282
+ fn(item, path, pathIndex, i);
283
+ });
284
+ });
285
+ }
286
+ function pushItem(tree, path, item) {
287
+ if (!tree[path]) {
288
+ tree[path] = [];
289
+ }
290
+ tree[path].push(item);
291
+ }
266
292
  /**
267
293
  * maps a tree, the tree branches are flatmapped, so if an array is returned for each item in the list, a flat list is returned
268
294
  * @param tree
@@ -7255,8 +7281,11 @@ exports.binaryOnTree = binaryOnTree;
7255
7281
  exports.binaryOnTreeBranch = binaryOnTreeBranch;
7256
7282
  exports.broadCast = broadCast;
7257
7283
  exports.expandTree = expandTree;
7284
+ exports.forEachBranch = forEachBranch;
7285
+ exports.forEachItem = forEachItem;
7258
7286
  exports.getBranch = getBranch;
7259
7287
  exports.getBranches = getBranches;
7288
+ exports.getItem = getItem;
7260
7289
  exports.getPaths = getPaths;
7261
7290
  exports.getPositions = getPositions;
7262
7291
  exports.getReferences = getReferences;
@@ -7275,6 +7304,7 @@ exports.nAryOnTreeBranch = nAryOnTreeBranch;
7275
7304
  exports.normalizeVarDef = normalizeVarDef;
7276
7305
  exports.parseReference = parseReference;
7277
7306
  exports.primitives = primitives;
7307
+ exports.pushItem = pushItem;
7278
7308
  exports.sameShape = sameShape;
7279
7309
  exports.simplifyTree = simplifyTree$1;
7280
7310
  exports.toArray = toArray;