@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.mjs CHANGED
@@ -267,6 +267,9 @@ function mixin(target, constructors) {
267
267
  });
268
268
  });
269
269
  }
270
+ function objectMap(obj, fn2) {
271
+ return Object.entries(obj).map(([key, value]) => [key, fn2(key, value)]).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
272
+ }
270
273
  function JSONAttemptParse(json) {
271
274
  try {
272
275
  return JSON.parse(json);
@@ -1881,11 +1884,12 @@ function compareVersions(target, vs) {
1881
1884
  return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1882
1885
  }
1883
1886
  function consoleInterceptor(out = console, map) {
1884
- const stderr = [], stdout = [];
1887
+ const logs = { debug: [], log: [], info: [], warn: [], error: [], stderr: [], stdout: [] };
1885
1888
  const cWrapper = (type) => (...args) => {
1886
1889
  if (out) out[type](...args);
1887
- if (type == "error") stderr.push(...args);
1888
- else stdout.push(...args);
1890
+ logs[type].push(...args);
1891
+ if (type == "error") logs.stderr.push(...args);
1892
+ else logs.stdout.push(...args);
1889
1893
  };
1890
1894
  return {
1891
1895
  debug: (map == null ? void 0 : map.debug) != "none" ? cWrapper((map == null ? void 0 : map.debug) || "debug") : () => {
@@ -1898,8 +1902,7 @@ function consoleInterceptor(out = console, map) {
1898
1902
  },
1899
1903
  error: (map == null ? void 0 : map.error) != "none" ? cWrapper((map == null ? void 0 : map.error) || "error") : () => {
1900
1904
  },
1901
- stderr,
1902
- stdout
1905
+ output: logs
1903
1906
  };
1904
1907
  }
1905
1908
  function escapeRegex(value) {
@@ -2531,6 +2534,7 @@ export {
2531
2534
  mixin,
2532
2535
  month,
2533
2536
  numSuffix,
2537
+ objectMap,
2534
2538
  pad,
2535
2539
  parseUrl,
2536
2540
  pascalCase,