@ztimson/utils 0.27.6 → 0.27.8

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 CHANGED
@@ -271,6 +271,9 @@ ${opts.message || this.desc}`;
271
271
  });
272
272
  });
273
273
  }
274
+ function objectMap(obj, fn2) {
275
+ return Object.entries(obj).map(([key, value]) => [key, fn2(key, value)]).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
276
+ }
274
277
  function JSONAttemptParse(json) {
275
278
  try {
276
279
  return JSON.parse(json);
@@ -1885,11 +1888,12 @@ ${opts.message || this.desc}`;
1885
1888
  return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1886
1889
  }
1887
1890
  function consoleInterceptor(out = console, map) {
1888
- const stderr = [], stdout = [];
1891
+ const logs = { debug: [], log: [], info: [], warn: [], error: [], stderr: [], stdout: [] };
1889
1892
  const cWrapper = (type) => (...args) => {
1890
1893
  if (out) out[type](...args);
1891
- if (type == "error") stderr.push(...args);
1892
- else stdout.push(...args);
1894
+ logs[type].push(...args);
1895
+ if (type == "error") logs.stderr.push(...args);
1896
+ else logs.stdout.push(...args);
1893
1897
  };
1894
1898
  return {
1895
1899
  debug: (map == null ? void 0 : map.debug) != "none" ? cWrapper((map == null ? void 0 : map.debug) || "debug") : () => {
@@ -1902,8 +1906,7 @@ ${opts.message || this.desc}`;
1902
1906
  },
1903
1907
  error: (map == null ? void 0 : map.error) != "none" ? cWrapper((map == null ? void 0 : map.error) || "error") : () => {
1904
1908
  },
1905
- stderr,
1906
- stdout
1909
+ output: logs
1907
1910
  };
1908
1911
  }
1909
1912
  function escapeRegex(value) {
@@ -2534,6 +2537,7 @@ ${opts.message || this.desc}`;
2534
2537
  exports2.mixin = mixin;
2535
2538
  exports2.month = month;
2536
2539
  exports2.numSuffix = numSuffix;
2540
+ exports2.objectMap = objectMap;
2537
2541
  exports2.pad = pad;
2538
2542
  exports2.parseUrl = parseUrl;
2539
2543
  exports2.pascalCase = pascalCase;