@ztimson/utils 0.27.5 → 0.27.6

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
@@ -1884,6 +1884,28 @@ ${opts.message || this.desc}`;
1884
1884
  const [vMajor, vMinor, vPatch] = vs.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1885
1885
  return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1886
1886
  }
1887
+ function consoleInterceptor(out = console, map) {
1888
+ const stderr = [], stdout = [];
1889
+ const cWrapper = (type) => (...args) => {
1890
+ if (out) out[type](...args);
1891
+ if (type == "error") stderr.push(...args);
1892
+ else stdout.push(...args);
1893
+ };
1894
+ return {
1895
+ debug: (map == null ? void 0 : map.debug) != "none" ? cWrapper((map == null ? void 0 : map.debug) || "debug") : () => {
1896
+ },
1897
+ log: (map == null ? void 0 : map.log) != "none" ? cWrapper((map == null ? void 0 : map.log) || "log") : () => {
1898
+ },
1899
+ info: (map == null ? void 0 : map.info) != "none" ? cWrapper((map == null ? void 0 : map.info) || "info") : () => {
1900
+ },
1901
+ warn: (map == null ? void 0 : map.warn) != "none" ? cWrapper((map == null ? void 0 : map.warn) || "warn") : () => {
1902
+ },
1903
+ error: (map == null ? void 0 : map.error) != "none" ? cWrapper((map == null ? void 0 : map.error) || "error") : () => {
1904
+ },
1905
+ stderr,
1906
+ stdout
1907
+ };
1908
+ }
1887
1909
  function escapeRegex(value) {
1888
1910
  return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1889
1911
  }
@@ -2469,6 +2491,7 @@ ${opts.message || this.desc}`;
2469
2491
  exports2.caseInsensitiveSort = caseInsensitiveSort;
2470
2492
  exports2.clean = clean;
2471
2493
  exports2.compareVersions = compareVersions;
2494
+ exports2.consoleInterceptor = consoleInterceptor;
2472
2495
  exports2.contrast = contrast;
2473
2496
  exports2.createJwt = createJwt;
2474
2497
  exports2.dayOfWeek = dayOfWeek;