@serum-enterprises/json 2.0.1 → 3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JSON
2
2
 
3
- Type-Safe drop-in replacement for the native JSON Object
3
+ Type-Safe drop-in replacement for the native JSON
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,22 +11,23 @@ npm install --save @serum-enterprises/json
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import * as JSON from '@serum-enterprises/json';
14
+ import {JSON} from '@serum-enterprises/json';
15
15
 
16
- const data: JSON.JSON = { name: 'John Doe', age: 25 };
16
+ const data: JSON = { name: 'John Doe', age: 25 };
17
+ const name: JSON.String = data.name;
17
18
 
18
- function verify(data: JSON.JSON): boolean {
19
+ function verify(data: JSON): boolean {
19
20
  if(!JSON.isObject(data))
20
21
  return false;
21
22
 
22
- if(!JSON.isString(data.name) || !JSON.isInteger(data.age))
23
+ if(!JSON.isString(data.name) || !JSON.isInteger(data.age))
23
24
  return false;
24
25
 
25
26
  return true;
26
27
  }
27
28
 
28
29
  if(verify(data)) {
29
- console.log(`Data is correct: `);
30
+ console.log(`Data for ${name} is correct: `);
30
31
  console.log(JSON.stringify(data, null, 2));
31
32
  }
32
33
  ```
@@ -35,6 +36,8 @@ if(verify(data)) {
35
36
 
36
37
  Please check [JSON.d.ts](./types/JSON.d.ts) for the full API.
37
38
 
39
+ Please also note that functions prefixed with `_` are potentially mutating their Input.
40
+
38
41
  ## LICENSE
39
42
 
40
43
  MIT License
package/build/index.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSON = void 0;
4
+ var JSON;
5
+ (function (JSON) {
6
+ function isNull(value) {
7
+ return value === null;
8
+ }
9
+ JSON.isNull = isNull;
10
+ function isBoolean(value) {
11
+ return typeof value === 'boolean';
12
+ }
13
+ JSON.isBoolean = isBoolean;
14
+ function isNumber(value) {
15
+ // Using Number.isFinite here as NaN, Infinity and -Infinity are not valid JSON Numbers
16
+ return Number.isFinite(value);
17
+ }
18
+ JSON.isNumber = isNumber;
19
+ function isInteger(value) {
20
+ // Using Number.isSafeInteger here as JS Numbers are 64-bit floating point numbers and not all integers can be represented accurately
21
+ return Number.isSafeInteger(value);
22
+ }
23
+ JSON.isInteger = isInteger;
24
+ function isString(value) {
25
+ return typeof value === 'string';
26
+ }
27
+ JSON.isString = isString;
28
+ function isShallowArray(value) {
29
+ return Array.isArray(value);
30
+ }
31
+ JSON.isShallowArray = isShallowArray;
32
+ function isArray(value) {
33
+ return isShallowArray(value) && value.every((v) => isJSON(v));
34
+ }
35
+ JSON.isArray = isArray;
36
+ function isShallowObject(value) {
37
+ // Using Object.prototype.toString.call here as it is the most reliable way to check if something is an Object
38
+ return (Object.prototype.toString.call(value) === '[object Object]');
39
+ }
40
+ JSON.isShallowObject = isShallowObject;
41
+ function isObject(value) {
42
+ return isShallowObject(value) && Object.values(value).every((v) => isJSON(v));
43
+ }
44
+ JSON.isObject = isObject;
45
+ function isPrimitive(value) {
46
+ return isBoolean(value) || isNumber(value) || isString(value);
47
+ }
48
+ JSON.isPrimitive = isPrimitive;
49
+ function isShallowContainer(value) {
50
+ return isShallowArray(value) || isShallowObject(value);
51
+ }
52
+ JSON.isShallowContainer = isShallowContainer;
53
+ function isContainer(value) {
54
+ return isArray(value) || isObject(value);
55
+ }
56
+ JSON.isContainer = isContainer;
57
+ function isShallowJSON(value) {
58
+ return isNull(value) || isPrimitive(value) || isShallowArray(value) || isShallowObject(value);
59
+ }
60
+ JSON.isShallowJSON = isShallowJSON;
61
+ function isJSON(value) {
62
+ return isNull(value) || isPrimitive(value) || isContainer(value);
63
+ }
64
+ JSON.isJSON = isJSON;
65
+ function clone(value) {
66
+ // Using Shallow Checks here as it is expected that value is JSON anyway, and this function is recursive anyway
67
+ if (isShallowObject(value))
68
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v)]));
69
+ else if (isShallowArray(value))
70
+ return value.map((v) => clone(v));
71
+ else
72
+ return value;
73
+ }
74
+ JSON.clone = clone;
75
+ // Compatibility Method for the native JSON.parse
76
+ function parse(value) {
77
+ return globalThis.JSON.parse(value);
78
+ }
79
+ JSON.parse = parse;
80
+ // Compatibility Method for the native JSON.stringify
81
+ function stringify(value) {
82
+ return globalThis.JSON.stringify(value);
83
+ }
84
+ JSON.stringify = stringify;
85
+ })(JSON || (exports.JSON = JSON = {}));
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@serum-enterprises/json",
3
- "version": "2.0.1",
3
+ "version": "3.1.0",
4
4
  "engines": {
5
- "node": ">=14.0.0"
5
+ "node": ">=24.0.0"
6
6
  },
7
- "description": "Type-Safe drop-in replacement for the native JSON Object",
8
- "main": "./build/JSON.js",
9
- "types": "./types/JSON.d.ts",
7
+ "description": "Type-Safe drop-in replacement for native JSON",
8
+ "main": "./build/index.js",
9
+ "types": "./types/index.d.ts",
10
10
  "scripts": {
11
11
  "build": "tsc",
12
12
  "test": "jest"
@@ -0,0 +1,39 @@
1
+ export declare namespace JSON {
2
+ type Null = null;
3
+ type Boolean = boolean;
4
+ type Number = number;
5
+ type Integer = number;
6
+ type String = string;
7
+ type Array = JSON[];
8
+ type ShallowArray = unknown[];
9
+ type Object = {
10
+ [key: string]: JSON;
11
+ };
12
+ type ShallowObject = {
13
+ [key: string]: unknown;
14
+ };
15
+ type Primitive = Boolean | Number | String;
16
+ type Container = Array | Object;
17
+ type JSON = Null | Primitive | Container;
18
+ function isNull(value: unknown): value is Null;
19
+ function isBoolean(value: unknown): value is Boolean;
20
+ function isNumber(value: unknown): value is Number;
21
+ function isInteger(value: unknown): value is Integer;
22
+ function isString(value: unknown): value is String;
23
+ function isShallowArray(value: unknown): value is ShallowArray;
24
+ function isArray(value: unknown): value is Array;
25
+ function isShallowObject(value: unknown): value is ShallowObject;
26
+ function isObject(value: unknown): value is Object;
27
+ function isPrimitive(value: unknown): value is Primitive;
28
+ function isShallowContainer(value: unknown): value is unknown[] | {
29
+ [key: string]: unknown;
30
+ };
31
+ function isContainer(value: unknown): value is Container;
32
+ function isShallowJSON(value: unknown): value is Null | Boolean | Number | String | unknown[] | {
33
+ [key: string]: unknown;
34
+ };
35
+ function isJSON(value: unknown): value is JSON;
36
+ function clone<T extends JSON = JSON>(value: T): T;
37
+ function parse(value: string): JSON;
38
+ function stringify(value: JSON): string;
39
+ }
package/build/JSON.js DELETED
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNull = isNull;
4
- exports.isBoolean = isBoolean;
5
- exports.isNumber = isNumber;
6
- exports.isInteger = isInteger;
7
- exports.isString = isString;
8
- exports.isShallowArray = isShallowArray;
9
- exports.isArray = isArray;
10
- exports.isShallowObject = isShallowObject;
11
- exports.isObject = isObject;
12
- exports.isPrimitive = isPrimitive;
13
- exports.isShallowContainer = isShallowContainer;
14
- exports.isContainer = isContainer;
15
- exports.isShallowJSON = isShallowJSON;
16
- exports.isJSON = isJSON;
17
- exports.clone = clone;
18
- exports.parse = parse;
19
- exports.stringify = stringify;
20
- function isNull(value) {
21
- return value === null;
22
- }
23
- function isBoolean(value) {
24
- return typeof value === 'boolean';
25
- }
26
- function isNumber(value) {
27
- // Using Number.isFinite here as NaN, Infinity and -Infinity are not valid JSON Numbers
28
- return Number.isFinite(value);
29
- }
30
- function isInteger(value) {
31
- // Using Number.isSafeInteger here as JS Numbers are 64-bit floating point numbers and not all integers can be represented accurately
32
- return Number.isSafeInteger(value);
33
- }
34
- function isString(value) {
35
- return typeof value === 'string';
36
- }
37
- function isShallowArray(value) {
38
- return Array.isArray(value);
39
- }
40
- function isArray(value) {
41
- return isShallowArray(value) && value.every((v) => isJSON(v));
42
- }
43
- function isShallowObject(value) {
44
- // Using Object.prototype.toString.call here as it is the most reliable way to check if something is an Object
45
- return (Object.prototype.toString.call(value) === '[object Object]');
46
- }
47
- function isObject(value) {
48
- return isShallowObject(value) && Object.values(value).every((v) => isJSON(v));
49
- }
50
- function isPrimitive(value) {
51
- return isBoolean(value) || isNumber(value) || isString(value);
52
- }
53
- function isShallowContainer(value) {
54
- return isShallowArray(value) || isShallowObject(value);
55
- }
56
- function isContainer(value) {
57
- return isArray(value) || isObject(value);
58
- }
59
- function isShallowJSON(value) {
60
- return isNull(value) || isPrimitive(value) || isShallowArray(value) || isShallowObject(value);
61
- }
62
- function isJSON(value) {
63
- return isNull(value) || isPrimitive(value) || isContainer(value);
64
- }
65
- function clone(value) {
66
- // Using Shallow Checks here as it is expected that value is JSON anyway, and this function is recursive anyway
67
- if (isShallowObject(value))
68
- return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v)]));
69
- else if (isShallowArray(value))
70
- return value.map((v) => clone(v));
71
- else
72
- return value;
73
- }
74
- // Compatibility Method for the native JSON.parse
75
- function parse(value) {
76
- return globalThis.JSON.parse(value);
77
- }
78
- // Compatibility Method for the native JSON.stringify
79
- function stringify(value) {
80
- return globalThis.JSON.stringify(value);
81
- }
package/src/JSON.ts DELETED
@@ -1,91 +0,0 @@
1
- export type Null = null;
2
- export type Boolean = boolean;
3
- export type Number = number;
4
- export type Integer = number;
5
- export type String = string;
6
- export type Array = JSON[];
7
- export type ShallowArray = unknown[];
8
- export type Object = { [key: string]: JSON };
9
- export type ShallowObject = { [key: string]: unknown };
10
- export type Primitive = Boolean | Number | String;
11
- export type Container = Array | Object;
12
- export type JSON = Null | Primitive | Container;
13
-
14
- export function isNull(value: unknown): value is Null {
15
- return value === null;
16
- }
17
-
18
- export function isBoolean(value: unknown): value is Boolean {
19
- return typeof value === 'boolean';
20
- }
21
-
22
- export function isNumber(value: unknown): value is Number {
23
- // Using Number.isFinite here as NaN, Infinity and -Infinity are not valid JSON Numbers
24
- return Number.isFinite(value);
25
- }
26
-
27
- export function isInteger(value: unknown): value is Integer {
28
- // Using Number.isSafeInteger here as JS Numbers are 64-bit floating point numbers and not all integers can be represented accurately
29
- return Number.isSafeInteger(value);
30
- }
31
-
32
- export function isString(value: unknown): value is String {
33
- return typeof value === 'string';
34
- }
35
-
36
- export function isShallowArray(value: unknown): value is ShallowArray {
37
- return Array.isArray(value);
38
- }
39
-
40
- export function isArray(value: unknown): value is Array {
41
- return isShallowArray(value) && value.every((v) => isJSON(v));
42
- }
43
-
44
- export function isShallowObject(value: unknown): value is ShallowObject {
45
- // Using Object.prototype.toString.call here as it is the most reliable way to check if something is an Object
46
- return (Object.prototype.toString.call(value) === '[object Object]');
47
- }
48
-
49
- export function isObject(value: unknown): value is Object {
50
- return isShallowObject(value) && Object.values(value).every((v) => isJSON(v));
51
- }
52
-
53
- export function isPrimitive(value: unknown): value is Primitive {
54
- return isBoolean(value) || isNumber(value) || isString(value);
55
- }
56
-
57
- export function isShallowContainer(value: unknown): value is unknown[] | { [key: string]: unknown } {
58
- return isShallowArray(value) || isShallowObject(value);
59
- }
60
-
61
- export function isContainer(value: unknown): value is Container {
62
- return isArray(value) || isObject(value);
63
- }
64
-
65
- export function isShallowJSON(value: unknown): value is Null | Boolean | Number | String | unknown[] | { [key: string]: unknown } {
66
- return isNull(value) || isPrimitive(value) || isShallowArray(value) || isShallowObject(value);
67
- }
68
-
69
- export function isJSON(value: unknown): value is JSON {
70
- return isNull(value) || isPrimitive(value) || isContainer(value);
71
- }
72
-
73
- export function clone<T extends JSON = JSON>(value: T): T {
74
- // Using Shallow Checks here as it is expected that value is JSON anyway, and this function is recursive anyway
75
- if (isShallowObject(value))
76
- return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v as JSON)])) as T;
77
- else if (isShallowArray(value))
78
- return value.map((v) => clone(v)) as T;
79
- else
80
- return value;
81
- }
82
-
83
- // Compatibility Method for the native JSON.parse
84
- export function parse(value: string): JSON {
85
- return globalThis.JSON.parse(value);
86
- }
87
-
88
- // Compatibility Method for the native JSON.stringify
89
- export function stringify(value: JSON): string {
90
- return globalThis.JSON.stringify(value);
91
- }
@@ -1,131 +0,0 @@
1
- const JSON = require('../build/JSON');
2
-
3
- describe('Testing JSON', () => {
4
- test('Testing JSON.isNull', () => {
5
- expect(JSON.isNull(null)).toBe(true);
6
- expect(JSON.isNull(undefined)).toBe(false);
7
- expect(JSON.isNull("Hello World")).toBe(false);
8
- });
9
-
10
- test('Testing JSON.isBoolean', () => {
11
- expect(JSON.isBoolean(true)).toBe(true);
12
- expect(JSON.isBoolean(false)).toBe(true);
13
- expect(JSON.isBoolean("Hello World")).toBe(false);
14
- });
15
-
16
- test('Testing JSON.isNumber', () => {
17
- expect(JSON.isNumber(42)).toBe(true);
18
- expect(JSON.isNumber(Infinity)).toBe(false);
19
- expect(JSON.isNumber(NaN)).toBe(false);
20
- });
21
-
22
- test('Testing JSON.isInteger', () => {
23
- expect(JSON.isInteger(42)).toBe(true);
24
- expect(JSON.isInteger(42.1)).toBe(false);
25
- expect(JSON.isInteger(Number.MAX_SAFE_INTEGER + 1)).toBe(false);
26
- });
27
-
28
- test('Testing JSON.isString', () => {
29
- expect(JSON.isString("Hello World")).toBe(true);
30
- expect(JSON.isString(42)).toBe(false);
31
- });
32
-
33
- test('Testing JSON.isShallowArray', () => {
34
- expect(JSON.isShallowArray([null, 1, "Hello", { key: "World" }])).toBe(true);
35
- expect(JSON.isShallowArray([null, 1, "Hello World", undefined])).toBe(true);
36
- expect(JSON.isShallowArray({})).toBe(false);
37
- });
38
-
39
- test('Testing JSON.isArray', () => {
40
- expect(JSON.isArray([null, 1, "Hello", { key: "World" }])).toBe(true);
41
- expect(JSON.isArray([null, 1, "Hello World", undefined])).toBe(false);
42
- expect(JSON.isArray({})).toBe(false);
43
- });
44
-
45
- test('Testing JSON.isShallowObject', () => {
46
- expect(JSON.isShallowObject({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
47
- expect(JSON.isShallowObject({ key: undefined })).toBe(true);
48
- expect(JSON.isShallowObject([])).toBe(false);
49
- });
50
-
51
- test('Testing JSON.isObject', () => {
52
- expect(JSON.isObject({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
53
- expect(JSON.isObject({ key: undefined })).toBe(false);
54
- expect(JSON.isShallowObject([])).toBe(false);
55
- });
56
-
57
- test('Testing JSON.isPrimitive', () => {
58
- expect(JSON.isPrimitive(null)).toBe(false);
59
- expect(JSON.isPrimitive(true)).toBe(true);
60
- expect(JSON.isPrimitive(42)).toBe(true);
61
- expect(JSON.isPrimitive("Hello World")).toBe(true);
62
- expect(JSON.isPrimitive([])).toBe(false);
63
- expect(JSON.isPrimitive({})).toBe(false);
64
- });
65
-
66
- test('Testing JSON.isShallowContainer', () => {
67
- expect(JSON.isShallowContainer(null)).toBe(false);
68
- expect(JSON.isShallowContainer(true)).toBe(false);
69
- expect(JSON.isShallowContainer(42)).toBe(false);
70
- expect(JSON.isShallowContainer("Hello World")).toBe(false);
71
- expect(JSON.isShallowContainer([null, 1, "Hello", { key: "World" }])).toBe(true);
72
- expect(JSON.isShallowContainer([null, 1, "Hello World", undefined])).toBe(true);
73
- expect(JSON.isShallowContainer({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
74
- expect(JSON.isShallowContainer({ key: undefined })).toBe(true);
75
- });
76
-
77
- test('Testing JSON.isContainer', () => {
78
- expect(JSON.isContainer(null)).toBe(false);
79
- expect(JSON.isContainer(true)).toBe(false);
80
- expect(JSON.isContainer(42)).toBe(false);
81
- expect(JSON.isContainer("Hello World")).toBe(false);
82
- expect(JSON.isContainer([null, 1, "Hello", { key: "World" }])).toBe(true);
83
- expect(JSON.isContainer([null, 1, "Hello World", undefined])).toBe(false);
84
- expect(JSON.isContainer({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
85
- expect(JSON.isContainer({ key: undefined })).toBe(false);
86
- });
87
-
88
- test('Testing JSON.isShallowJSON', () => {
89
- expect(JSON.isShallowJSON(null)).toBe(true);
90
- expect(JSON.isShallowJSON(true)).toBe(true);
91
- expect(JSON.isShallowJSON(42)).toBe(true);
92
- expect(JSON.isShallowJSON("Hello World")).toBe(true);
93
- expect(JSON.isShallowJSON([null, 1, "Hello", { key: "World" }])).toBe(true);
94
- expect(JSON.isShallowJSON([null, 1, "Hello World", undefined])).toBe(true);
95
- expect(JSON.isShallowJSON({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
96
- expect(JSON.isShallowJSON({ key: undefined })).toBe(true);
97
- });
98
-
99
- test('Testing JSON.isJSON', () => {
100
- expect(JSON.isJSON(null)).toBe(true);
101
- expect(JSON.isJSON(true)).toBe(true);
102
- expect(JSON.isJSON(42)).toBe(true);
103
- expect(JSON.isJSON("Hello World")).toBe(true);
104
- expect(JSON.isJSON([null, 1, "Hello", { key: "World" }])).toBe(true);
105
- expect(JSON.isJSON([null, 1, "Hello World", undefined])).toBe(false);
106
- expect(JSON.isJSON({ key: "Hello World", nested: { anotherKey: null } })).toBe(true);
107
- expect(JSON.isJSON({ key: undefined })).toBe(false);
108
- });
109
-
110
- test('Testing JSON.clone', () => {
111
- const obj = { key: "Hello World", nested: [1, 2, { deep: true }] };
112
- const clonedObj = JSON.clone(obj);
113
-
114
- expect(clonedObj).toEqual(obj);
115
- expect(clonedObj).not.toBe(obj);
116
- expect(clonedObj.nested).not.toBe(obj.nested);
117
- expect(clonedObj.nested[2]).not.toBe(obj.nested[2]);
118
- });
119
-
120
- test('Testing JSON.stringify', () => {
121
- const data = { key: "Hello World", nested: [1, 2, { deep: true }] };
122
-
123
- expect(JSON.stringify(data)).toBe('{"key":"Hello World","nested":[1,2,{"deep":true}]}');
124
- });
125
-
126
- test('Testing JSON.parse', () => {
127
- const data = '{"key":"Hello World","nested":[1,2,{"deep":true}]}'
128
-
129
- expect(JSON.parse(data)).toStrictEqual({ key: "Hello World", nested: [1, 2, { deep: true }] });
130
- });
131
- });
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2024", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
4
- "module": "Node16", /* Specify what module code is generated. */
5
- "rootDir": "./src", /* Specify the root folder within your source files. */
6
- "outDir": "./build", /* Specify an output folder for all emitted files. */
7
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
8
- "declarationDir": "./types", /* Specify the output directory for generated declaration files. */
9
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
10
- /* Type Checking */
11
- "strict": true, /* Enable all strict type-checking options. */
12
- "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
13
- "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
14
- "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
15
- "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
16
- "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
17
- "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
18
- "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
19
- "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
20
- "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
21
- "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
22
- "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
23
- "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
24
- "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
25
- "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
26
- "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
27
- "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
28
- }
29
- }
package/types/JSON.d.ts DELETED
@@ -1,37 +0,0 @@
1
- export type Null = null;
2
- export type Boolean = boolean;
3
- export type Number = number;
4
- export type Integer = number;
5
- export type String = string;
6
- export type Array = JSON[];
7
- export type ShallowArray = unknown[];
8
- export type Object = {
9
- [key: string]: JSON;
10
- };
11
- export type ShallowObject = {
12
- [key: string]: unknown;
13
- };
14
- export type Primitive = Boolean | Number | String;
15
- export type Container = Array | Object;
16
- export type JSON = Null | Primitive | Container;
17
- export declare function isNull(value: unknown): value is Null;
18
- export declare function isBoolean(value: unknown): value is Boolean;
19
- export declare function isNumber(value: unknown): value is Number;
20
- export declare function isInteger(value: unknown): value is Integer;
21
- export declare function isString(value: unknown): value is String;
22
- export declare function isShallowArray(value: unknown): value is ShallowArray;
23
- export declare function isArray(value: unknown): value is Array;
24
- export declare function isShallowObject(value: unknown): value is ShallowObject;
25
- export declare function isObject(value: unknown): value is Object;
26
- export declare function isPrimitive(value: unknown): value is Primitive;
27
- export declare function isShallowContainer(value: unknown): value is unknown[] | {
28
- [key: string]: unknown;
29
- };
30
- export declare function isContainer(value: unknown): value is Container;
31
- export declare function isShallowJSON(value: unknown): value is Null | Boolean | Number | String | unknown[] | {
32
- [key: string]: unknown;
33
- };
34
- export declare function isJSON(value: unknown): value is JSON;
35
- export declare function clone<T extends JSON = JSON>(value: T): T;
36
- export declare function parse(value: string): JSON;
37
- export declare function stringify(value: JSON): string;