@bouko/ts 0.1.4 → 0.1.5
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.d.ts +1 -0
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JsonMap, JsonValue } from "./types";
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export declare const safely: <T>(action: () => T) => T | undefined;
|
|
4
|
+
export declare const safelyThru: <T>(arr: T[], action: (item: T) => void) => void;
|
|
4
5
|
export declare const isJsonMap: (value: unknown) => value is JsonMap;
|
|
5
6
|
export declare const isJsonValue: (value: unknown) => value is JsonValue;
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,14 @@ export const safely = (action) => {
|
|
|
7
7
|
return undefined;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
+
export const safelyThru = (arr, action) => {
|
|
11
|
+
try {
|
|
12
|
+
arr.forEach(action);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error("Error in safelyForEach:", err);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
10
18
|
export const isJsonMap = (value) => {
|
|
11
19
|
if (typeof value !== "object" ||
|
|
12
20
|
value === null ||
|