@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.mjs CHANGED
@@ -1880,6 +1880,28 @@ function compareVersions(target, vs) {
1880
1880
  const [vMajor, vMinor, vPatch] = vs.split(".").map((v) => +v.replace(/[^0-9]/g, ""));
1881
1881
  return tMajor > vMajor || tMinor > vMinor || tPatch > vPatch ? 1 : tMajor < vMajor || tMinor < vMinor || tPatch < vPatch ? -1 : 0;
1882
1882
  }
1883
+ function consoleInterceptor(out = console, map) {
1884
+ const stderr = [], stdout = [];
1885
+ const cWrapper = (type) => (...args) => {
1886
+ if (out) out[type](...args);
1887
+ if (type == "error") stderr.push(...args);
1888
+ else stdout.push(...args);
1889
+ };
1890
+ return {
1891
+ debug: (map == null ? void 0 : map.debug) != "none" ? cWrapper((map == null ? void 0 : map.debug) || "debug") : () => {
1892
+ },
1893
+ log: (map == null ? void 0 : map.log) != "none" ? cWrapper((map == null ? void 0 : map.log) || "log") : () => {
1894
+ },
1895
+ info: (map == null ? void 0 : map.info) != "none" ? cWrapper((map == null ? void 0 : map.info) || "info") : () => {
1896
+ },
1897
+ warn: (map == null ? void 0 : map.warn) != "none" ? cWrapper((map == null ? void 0 : map.warn) || "warn") : () => {
1898
+ },
1899
+ error: (map == null ? void 0 : map.error) != "none" ? cWrapper((map == null ? void 0 : map.error) || "error") : () => {
1900
+ },
1901
+ stderr,
1902
+ stdout
1903
+ };
1904
+ }
1883
1905
  function escapeRegex(value) {
1884
1906
  return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
1885
1907
  }
@@ -2466,6 +2488,7 @@ export {
2466
2488
  caseInsensitiveSort,
2467
2489
  clean,
2468
2490
  compareVersions,
2491
+ consoleInterceptor,
2469
2492
  contrast,
2470
2493
  createJwt,
2471
2494
  dayOfWeek,