@bouko/ts 0.1.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/dist/index.d.ts +6 -0
- package/dist/index.js +16 -0
- package/package.json +25 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type JsonMap = {
|
|
2
|
+
[key: string]: JsonValue | JsonValue[];
|
|
3
|
+
};
|
|
4
|
+
export type JsonValue = string | number | boolean | null | undefined | JsonMap;
|
|
5
|
+
export declare const isJsonMap: (value: unknown) => value is JsonMap;
|
|
6
|
+
export declare const isJsonValue: (value: unknown) => value is JsonValue;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const isJsonMap = (value) => {
|
|
2
|
+
if (typeof value !== "object" ||
|
|
3
|
+
value === null ||
|
|
4
|
+
Array.isArray(value))
|
|
5
|
+
return false;
|
|
6
|
+
return Object.entries(value)
|
|
7
|
+
.every(([_, v]) => isJsonValue(v) ||
|
|
8
|
+
(Array.isArray(v) &&
|
|
9
|
+
v.every(isJsonValue)));
|
|
10
|
+
};
|
|
11
|
+
export const isJsonValue = (value) => (typeof value === "string" ||
|
|
12
|
+
typeof value === "number" ||
|
|
13
|
+
typeof value === "boolean" ||
|
|
14
|
+
value === null ||
|
|
15
|
+
value === undefined ||
|
|
16
|
+
isJsonMap(value));
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"name": "@bouko/ts",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"description": "",
|
|
16
|
+
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc"
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
"dependencies": {},
|
|
22
|
+
|
|
23
|
+
"devDependencies": {}
|
|
24
|
+
|
|
25
|
+
}
|