@rkmodules/rules 0.0.96 → 0.0.98

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
@@ -257,9 +257,26 @@ function broadCast(value) {
257
257
  function getBranch(tree, path) {
258
258
  return tree[path];
259
259
  }
260
+ function getBranches(tree) {
261
+ return Object.values(tree);
262
+ }
260
263
  function getPaths(tree) {
261
264
  return Object.keys(tree);
262
265
  }
266
+ function forEachBranch(tree, fn) {
267
+ var paths = getPaths(tree);
268
+ paths.forEach(function (path, i) {
269
+ var branch = tree[path];
270
+ fn(branch, path, i);
271
+ });
272
+ }
273
+ function forEachItem(tree, fn) {
274
+ forEachBranch(tree, function (branch, path, pathIndex) {
275
+ branch.forEach(function (item, i) {
276
+ fn(item, path, pathIndex, i);
277
+ });
278
+ });
279
+ }
263
280
  /**
264
281
  * 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
265
282
  * @param tree
@@ -1560,7 +1577,9 @@ var listInput = {
1560
1577
  tree: mapTreeBranch(inputs.list || {}, function (branch) {
1561
1578
  if (!branch || branch.length === 0)
1562
1579
  return DISCARD;
1563
- var allLines = branch.flatMap(function (text) { return text.split("\n"); });
1580
+ var allLines = branch.flatMap(function (text) {
1581
+ return text.replace(/(^[\n\r]+)|([\n\r]+$)/, "").split("\n");
1582
+ });
1564
1583
  if (allLines.every(function (line) { return isBoolStr(line); })) {
1565
1584
  allLines = allLines.map(function (line) { return line.toLowerCase() === "true"; });
1566
1585
  }
@@ -7250,7 +7269,10 @@ exports.binaryOnTree = binaryOnTree;
7250
7269
  exports.binaryOnTreeBranch = binaryOnTreeBranch;
7251
7270
  exports.broadCast = broadCast;
7252
7271
  exports.expandTree = expandTree;
7272
+ exports.forEachBranch = forEachBranch;
7273
+ exports.forEachItem = forEachItem;
7253
7274
  exports.getBranch = getBranch;
7275
+ exports.getBranches = getBranches;
7254
7276
  exports.getPaths = getPaths;
7255
7277
  exports.getPositions = getPositions;
7256
7278
  exports.getReferences = getReferences;