@akanjs/common 0.9.56 → 0.9.58-canary.0

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/cjs/Logger.js CHANGED
@@ -152,7 +152,7 @@ class Logger {
152
152
  const contentMsg = this.#colorize(content, logLevel);
153
153
  const timeDiffMsg = clc.yellow(`+${now.diff(Logger.#startAt, "ms")}ms`);
154
154
  if (typeof window === "undefined")
155
- process[writeStreamType].write(
155
+ process[writeStreamType]?.write(
156
156
  `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
157
157
  `
158
158
  );
package/cjs/pathGet.js CHANGED
@@ -20,7 +20,10 @@ __export(pathGet_exports, {
20
20
  pathGet: () => pathGet
21
21
  });
22
22
  module.exports = __toCommonJS(pathGet_exports);
23
- const pathGet = (path, obj, separator = ".") => {
23
+ const pathGet = (path, obj, separator = ".", fallback = null) => {
24
24
  const properties = Array.isArray(path) ? path : path.split(separator);
25
- return properties.reduce((prev, curr) => prev[curr], obj);
25
+ return properties.reduce(
26
+ (prev, curr) => prev[curr] ?? fallback,
27
+ obj
28
+ );
26
29
  };
package/esm/Logger.js CHANGED
@@ -120,7 +120,7 @@ class Logger {
120
120
  const contentMsg = this.#colorize(content, logLevel);
121
121
  const timeDiffMsg = clc.yellow(`+${now.diff(Logger.#startAt, "ms")}ms`);
122
122
  if (typeof window === "undefined")
123
- process[writeStreamType].write(
123
+ process[writeStreamType]?.write(
124
124
  `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
125
125
  `
126
126
  );
package/esm/pathGet.js CHANGED
@@ -1,6 +1,9 @@
1
- const pathGet = (path, obj, separator = ".") => {
1
+ const pathGet = (path, obj, separator = ".", fallback = null) => {
2
2
  const properties = Array.isArray(path) ? path : path.split(separator);
3
- return properties.reduce((prev, curr) => prev[curr], obj);
3
+ return properties.reduce(
4
+ (prev, curr) => prev[curr] ?? fallback,
5
+ obj
6
+ );
4
7
  };
5
8
  export {
6
9
  pathGet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/common",
3
- "version": "0.9.56",
3
+ "version": "0.9.58-canary.0",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/pathGet.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const pathGet: (path: string | (string | number)[], obj: any, separator?: string) => unknown;
1
+ export declare const pathGet: (path: string | (string | number)[], obj: any, separator?: string, fallback?: any) => unknown;