@stryke/zod 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/LICENSE +201 -0
- package/README.md +300 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +4 -0
- package/dist/is-zod-type.cjs +35 -0
- package/dist/is-zod-type.d.cts +30 -0
- package/dist/is-zod-type.d.cts.map +1 -0
- package/dist/is-zod-type.d.mts +30 -0
- package/dist/is-zod-type.d.mts.map +1 -0
- package/dist/is-zod-type.mjs +34 -0
- package/dist/is-zod-type.mjs.map +1 -0
- package/dist/schema.cjs +33 -0
- package/dist/schema.d.cts +22 -0
- package/dist/schema.d.cts.map +1 -0
- package/dist/schema.d.mts +22 -0
- package/dist/schema.d.mts.map +1 -0
- package/dist/schema.mjs +32 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/type-checks/src/get-object-tag.cjs +15 -0
- package/dist/type-checks/src/get-object-tag.mjs +15 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/is-empty.cjs +20 -0
- package/dist/type-checks/src/is-empty.mjs +21 -0
- package/dist/type-checks/src/is-empty.mjs.map +1 -0
- package/dist/type-checks/src/is-non-null-object.cjs +16 -0
- package/dist/type-checks/src/is-non-null-object.mjs +17 -0
- package/dist/type-checks/src/is-non-null-object.mjs.map +1 -0
- package/dist/type-checks/src/is-null.cjs +12 -0
- package/dist/type-checks/src/is-null.mjs +12 -0
- package/dist/type-checks/src/is-null.mjs.map +1 -0
- package/dist/type-checks/src/is-object.cjs +19 -0
- package/dist/type-checks/src/is-object.mjs +20 -0
- package/dist/type-checks/src/is-object.mjs.map +1 -0
- package/dist/type-checks/src/is-plain-object.cjs +63 -0
- package/dist/type-checks/src/is-plain-object.mjs +64 -0
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set-object.cjs +19 -0
- package/dist/type-checks/src/is-set-object.mjs +20 -0
- package/dist/type-checks/src/is-set-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set.cjs +19 -0
- package/dist/type-checks/src/is-set.mjs +20 -0
- package/dist/type-checks/src/is-set.mjs.map +1 -0
- package/dist/type-checks/src/is-undefined.cjs +8 -0
- package/dist/type-checks/src/is-undefined.mjs +8 -0
- package/dist/type-checks/src/is-undefined.mjs.map +1 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +20 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +20 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isSetObject } from "./type-checks/src/is-set-object.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/is-zod-type.ts
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if a given value is a Zod schema of version 3.
|
|
6
|
+
*
|
|
7
|
+
* @param type - The value to check.
|
|
8
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
function isZod3Type(type) {
|
|
11
|
+
return isSetObject(type) && "_def" in type && "typeName" in type._def;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type guard to check if a given value is a Zod schema of version 4.
|
|
15
|
+
*
|
|
16
|
+
* @param type - The value to check.
|
|
17
|
+
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
function isZod4Type(type) {
|
|
20
|
+
return isSetObject(type) && "_zod" in type && "def" in type._zod;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
24
|
+
*
|
|
25
|
+
* @param type - The value to check.
|
|
26
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
27
|
+
*/
|
|
28
|
+
function isZodType(type) {
|
|
29
|
+
return isZod3Type(type) || isZod4Type(type);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { isZod3Type, isZod4Type, isZodType };
|
|
34
|
+
//# sourceMappingURL=is-zod-type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-zod-type.mjs","names":[],"sources":["../src/is-zod-type.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type * as z3 from \"zod/v3\";\nimport type * as z4 from \"zod/v4/core\";\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { ZodType } from \"./types\";\n\n/**\n * Type guard to check if a given value is a Zod schema of version 3.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod schema, false otherwise.\n */\nexport function isZod3Type(type: unknown): type is z3.ZodTypeAny {\n return (\n isSetObject(type) &&\n \"_def\" in type &&\n \"typeName\" in (type as z3.ZodTypeAny)._def\n );\n}\n\n/**\n * Type guard to check if a given value is a Zod schema of version 4.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod v4 schema, false otherwise.\n */\nexport function isZod4Type(type: unknown): type is z4.$ZodType {\n return (\n isSetObject(type) && \"_zod\" in type && \"def\" in (type as z4.$ZodType)._zod\n );\n}\n\n/**\n * Type guard to check if a given value is a Zod schema of either version 3 or 4.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod schema, false otherwise.\n */\nexport function isZodType(type: unknown): type is ZodType {\n return isZod3Type(type) || isZod4Type(type);\n}\n"],"mappings":";;;;;;;;;AA8BA,SAAgB,WAAW,MAAsC;AAC/D,QACE,YAAY,KAAK,IACjB,UAAU,QACV,cAAe,KAAuB;;;;;;;;AAU1C,SAAgB,WAAW,MAAoC;AAC7D,QACE,YAAY,KAAK,IAAI,UAAU,QAAQ,SAAU,KAAqB;;;;;;;;AAU1E,SAAgB,UAAU,MAAgC;AACxD,QAAO,WAAW,KAAK,IAAI,WAAW,KAAK"}
|
package/dist/schema.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_is_zod_type = require('./is-zod-type.cjs');
|
|
3
|
+
let zod_to_json_schema = require("zod-to-json-schema");
|
|
4
|
+
let zod_v4_core = require("zod/v4/core");
|
|
5
|
+
zod_v4_core = require_rolldown_runtime.__toESM(zod_v4_core);
|
|
6
|
+
|
|
7
|
+
//#region src/schema.ts
|
|
8
|
+
/**
|
|
9
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
12
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
13
|
+
* @returns The extracted JSON Schema.
|
|
14
|
+
*/
|
|
15
|
+
function extractJsonSchema(type, target = "draft-07") {
|
|
16
|
+
if (require_is_zod_type.isZod3Type(type)) {
|
|
17
|
+
const result = (0, zod_to_json_schema.zodToJsonSchema)(type, {
|
|
18
|
+
$refStrategy: "root",
|
|
19
|
+
definitionPath: "$defs",
|
|
20
|
+
target: target === "draft-07" ? "jsonSchema7" : "jsonSchema2019-09"
|
|
21
|
+
});
|
|
22
|
+
if (!result) throw new Error("Failed to extract JSON Schema from Zod v3 schema");
|
|
23
|
+
return result;
|
|
24
|
+
} else if (require_is_zod_type.isZod4Type(type)) return zod_v4_core.toJSONSchema(type, {
|
|
25
|
+
target: target === "draft-07" ? "draft-07" : "draft-2020-12",
|
|
26
|
+
unrepresentable: "any",
|
|
27
|
+
reused: "ref"
|
|
28
|
+
});
|
|
29
|
+
else throw new Error("Unsupported Zod schema version");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.extractJsonSchema = extractJsonSchema;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ZodType } from "./types.cjs";
|
|
2
|
+
import * as z4 from "zod/v4/core";
|
|
3
|
+
import * as zod_to_json_schema0 from "zod-to-json-schema";
|
|
4
|
+
|
|
5
|
+
//#region src/schema.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
11
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
12
|
+
* @returns The extracted JSON Schema.
|
|
13
|
+
*/
|
|
14
|
+
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
15
|
+
$schema?: string | undefined;
|
|
16
|
+
definitions?: {
|
|
17
|
+
[key: string]: zod_to_json_schema0.JsonSchema7Type;
|
|
18
|
+
} | undefined;
|
|
19
|
+
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { extractJsonSchema };
|
|
22
|
+
//# sourceMappingURL=schema.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.cts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA8BA;;;;iBAAgB,iBAAA,OACR;;;mBAAO,mBAAA,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ZodType } from "./types.mjs";
|
|
2
|
+
import * as zod_to_json_schema0 from "zod-to-json-schema";
|
|
3
|
+
import * as z4 from "zod/v4/core";
|
|
4
|
+
|
|
5
|
+
//#region src/schema.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
11
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
12
|
+
* @returns The extracted JSON Schema.
|
|
13
|
+
*/
|
|
14
|
+
declare function extractJsonSchema(type: ZodType, target?: "draft-07" | "draft-2020-12"): (object & {
|
|
15
|
+
$schema?: string | undefined;
|
|
16
|
+
definitions?: {
|
|
17
|
+
[key: string]: zod_to_json_schema0.JsonSchema7Type;
|
|
18
|
+
} | undefined;
|
|
19
|
+
}) | z4.ZodStandardJSONSchemaPayload<z4.$ZodType<unknown, unknown, z4.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { extractJsonSchema };
|
|
22
|
+
//# sourceMappingURL=schema.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA8BA;;;;iBAAgB,iBAAA,OACR;;;mBAAO,mBAAA,CAAA"}
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isZod3Type, isZod4Type } from "./is-zod-type.mjs";
|
|
2
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
|
+
import * as z4 from "zod/v4/core";
|
|
4
|
+
|
|
5
|
+
//#region src/schema.ts
|
|
6
|
+
/**
|
|
7
|
+
* Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.
|
|
8
|
+
*
|
|
9
|
+
* @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.
|
|
10
|
+
* @param target - The JSON Schema draft version to target. Defaults to "draft-07".
|
|
11
|
+
* @returns The extracted JSON Schema.
|
|
12
|
+
*/
|
|
13
|
+
function extractJsonSchema(type, target = "draft-07") {
|
|
14
|
+
if (isZod3Type(type)) {
|
|
15
|
+
const result = zodToJsonSchema(type, {
|
|
16
|
+
$refStrategy: "root",
|
|
17
|
+
definitionPath: "$defs",
|
|
18
|
+
target: target === "draft-07" ? "jsonSchema7" : "jsonSchema2019-09"
|
|
19
|
+
});
|
|
20
|
+
if (!result) throw new Error("Failed to extract JSON Schema from Zod v3 schema");
|
|
21
|
+
return result;
|
|
22
|
+
} else if (isZod4Type(type)) return z4.toJSONSchema(type, {
|
|
23
|
+
target: target === "draft-07" ? "draft-07" : "draft-2020-12",
|
|
24
|
+
unrepresentable: "any",
|
|
25
|
+
reused: "ref"
|
|
26
|
+
});
|
|
27
|
+
else throw new Error("Unsupported Zod schema version");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { extractJsonSchema };
|
|
32
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport * as z4 from \"zod/v4/core\";\nimport { isZod3Type, isZod4Type } from \"./is-zod-type\";\nimport type { ZodType } from \"./types\";\n\n/**\n * Extracts a JSON Schema from a given Zod schema, supporting both version 3 and version 4 of Zod.\n *\n * @param type - The Zod schema to extract the JSON Schema from. Can be either a Zod v3 or v4 schema.\n * @param target - The JSON Schema draft version to target. Defaults to \"draft-07\".\n * @returns The extracted JSON Schema.\n */\nexport function extractJsonSchema(\n type: ZodType,\n target: \"draft-07\" | \"draft-2020-12\" = \"draft-07\"\n) {\n if (isZod3Type(type)) {\n const result = zodToJsonSchema(type, {\n $refStrategy: \"root\",\n definitionPath: \"$defs\",\n target: target === \"draft-07\" ? \"jsonSchema7\" : \"jsonSchema2019-09\"\n });\n if (!result) {\n throw new Error(\"Failed to extract JSON Schema from Zod v3 schema\");\n }\n\n return result;\n } else if (isZod4Type(type)) {\n return z4.toJSONSchema(type, {\n target: target === \"draft-07\" ? \"draft-07\" : \"draft-2020-12\",\n // eslint-disable-next-line @cspell/spellchecker\n unrepresentable: \"any\",\n reused: \"ref\"\n });\n } else {\n throw new Error(\"Unsupported Zod schema version\");\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgB,kBACd,MACA,SAAuC,YACvC;AACA,KAAI,WAAW,KAAK,EAAE;EACpB,MAAM,SAAS,gBAAgB,MAAM;GACnC,cAAc;GACd,gBAAgB;GAChB,QAAQ,WAAW,aAAa,gBAAgB;GACjD,CAAC;AACF,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,mDAAmD;AAGrE,SAAO;YACE,WAAW,KAAK,CACzB,QAAO,GAAG,aAAa,MAAM;EAC3B,QAAQ,WAAW,aAAa,aAAa;EAE7C,iBAAiB;EACjB,QAAQ;EACT,CAAC;KAEF,OAAM,IAAI,MAAM,iCAAiC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../type-checks/src/get-object-tag.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gets the `toStringTag` of `obj`.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The obj to query.
|
|
7
|
+
* @returns Returns the `toStringTag`.
|
|
8
|
+
*/
|
|
9
|
+
const getObjectTag = (value) => {
|
|
10
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
11
|
+
return Object.prototype.toString.call(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.getObjectTag = getObjectTag;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../type-checks/src/get-object-tag.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets the `toStringTag` of `obj`.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The obj to query.
|
|
6
|
+
* @returns Returns the `toStringTag`.
|
|
7
|
+
*/
|
|
8
|
+
const getObjectTag = (value) => {
|
|
9
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
10
|
+
return Object.prototype.toString.call(value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getObjectTag };
|
|
15
|
+
//# sourceMappingURL=get-object-tag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_is_null = require('./is-null.cjs');
|
|
2
|
+
const require_is_undefined = require('./is-undefined.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../type-checks/src/is-empty.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to type check
|
|
9
|
+
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
+
*/
|
|
11
|
+
const isEmpty = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.isEmpty = isEmpty;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isNull } from "./is-null.mjs";
|
|
2
|
+
import { isUndefined } from "./is-undefined.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../type-checks/src/is-empty.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to type check
|
|
9
|
+
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
+
*/
|
|
11
|
+
const isEmpty = (value) => {
|
|
12
|
+
try {
|
|
13
|
+
return isUndefined(value) || isNull(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { isEmpty };
|
|
21
|
+
//# sourceMappingURL=is-empty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_is_object = require('./is-object.cjs');
|
|
2
|
+
const require_is_set = require('./is-set.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to type check
|
|
9
|
+
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
+
*/
|
|
11
|
+
const isNonNullObject = (value) => {
|
|
12
|
+
return require_is_set.isSet(value) && require_is_object.isObject(value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.isNonNullObject = isNonNullObject;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isObject } from "./is-object.mjs";
|
|
2
|
+
import { isSet } from "./is-set.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../type-checks/src/is-non-null-object.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to type check
|
|
9
|
+
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
+
*/
|
|
11
|
+
const isNonNullObject = (value) => {
|
|
12
|
+
return isSet(value) && isObject(value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isNonNullObject };
|
|
17
|
+
//# sourceMappingURL=is-non-null-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-non-null-object.mjs","names":[],"sources":["../../../../type-checks/src/is-non-null-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isObject } from \"./is-object\";\nimport { isSet } from \"./is-set\";\n\n/**\n * Check if the provided value's type is `Object` and is not `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n */\nexport const isNonNullObject = (value: any): value is NonNullable<object> => {\n return isSet(value) && isObject(value);\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,mBAAmB,UAA6C;AAC3E,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,UAAU,UAAkC;AACvD,KAAI;AACF,SAAO,UAAU;SACX;AACN,SAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is `Object`
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
+
*/
|
|
10
|
+
const isObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || require_is_plain_object.isPlainObject(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.isObject = isObject;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isPlainObject } from "./is-plain-object.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is `Object`
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
+
*/
|
|
10
|
+
const isObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isObject };
|
|
20
|
+
//# sourceMappingURL=is-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.mjs","names":[],"sources":["../../../../type-checks/src/is-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-unsafe-function-type */\n/* eslint-disable ts/no-unsafe-call */\n\nimport type { NativeClass } from \"@stryke/types/base\";\nimport { isPlainObject } from \"./is-plain-object\";\n\n// Prepare\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n\n/** Is ES6+ class */\nexport function isNativeClass(value?: any): value is NativeClass {\n // NOTE TO DEVELOPER: If any of this changes, isClass must also be updated\n return (\n typeof value === \"function\" && isNativeClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is a conventional class\n *\n * @remarks\n * Is Conventional Class\n * Looks for function with capital first letter MyClass\n * First letter is the 9th character\n * If changed, isClass must also be updated\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is a conventional class\n */\nexport function isConventionalClass(value?: any): value is Function {\n return (\n typeof value === \"function\" &&\n isConventionalClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport function isClass(value?: any): value is Function | NativeClass; // only guarantee of truth type, not of validity\nexport function isClass(value?: any): boolean {\n return typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport const isObject = (value: unknown): value is object => {\n try {\n return (\n typeof value === \"object\" ||\n (Boolean(value) && value?.constructor === Object) ||\n isPlainObject(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AAyEA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,OAAO,UAAU,YAChB,QAAQ,MAAM,IAAI,OAAO,gBAAgB,UAC1C,cAAc,MAAM;SAEhB;AACN,SAAO"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-plain-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
+
* and has a `typeof` result of "object".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isObjectLike({})
|
|
11
|
+
* // => true
|
|
12
|
+
*
|
|
13
|
+
* isObjectLike([1, 2, 3])
|
|
14
|
+
* // => true
|
|
15
|
+
*
|
|
16
|
+
* isObjectLike(Function)
|
|
17
|
+
* // => false
|
|
18
|
+
*
|
|
19
|
+
* isObjectLike(null)
|
|
20
|
+
* // => false
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to check.
|
|
24
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
+
*/
|
|
26
|
+
const isObjectLike = (obj) => {
|
|
27
|
+
return typeof obj === "object" && obj !== null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* function Foo() {
|
|
35
|
+
* this.a = 1
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* isPlainObject(new Foo)
|
|
39
|
+
* // => false
|
|
40
|
+
*
|
|
41
|
+
* isPlainObject([1, 2, 3])
|
|
42
|
+
* // => false
|
|
43
|
+
*
|
|
44
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
+
* // => true
|
|
46
|
+
*
|
|
47
|
+
* isPlainObject(Object.create(null))
|
|
48
|
+
* // => true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param obj - The value to check.
|
|
52
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
+
*/
|
|
54
|
+
const isPlainObject = (obj) => {
|
|
55
|
+
if (!isObjectLike(obj) || require_get_object_tag.getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
+
let proto = obj;
|
|
58
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.isPlainObject = isPlainObject;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-plain-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
+
* and has a `typeof` result of "object".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isObjectLike({})
|
|
11
|
+
* // => true
|
|
12
|
+
*
|
|
13
|
+
* isObjectLike([1, 2, 3])
|
|
14
|
+
* // => true
|
|
15
|
+
*
|
|
16
|
+
* isObjectLike(Function)
|
|
17
|
+
* // => false
|
|
18
|
+
*
|
|
19
|
+
* isObjectLike(null)
|
|
20
|
+
* // => false
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to check.
|
|
24
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
+
*/
|
|
26
|
+
const isObjectLike = (obj) => {
|
|
27
|
+
return typeof obj === "object" && obj !== null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* function Foo() {
|
|
35
|
+
* this.a = 1
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* isPlainObject(new Foo)
|
|
39
|
+
* // => false
|
|
40
|
+
*
|
|
41
|
+
* isPlainObject([1, 2, 3])
|
|
42
|
+
* // => false
|
|
43
|
+
*
|
|
44
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
+
* // => true
|
|
46
|
+
*
|
|
47
|
+
* isPlainObject(Object.create(null))
|
|
48
|
+
* // => true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param obj - The value to check.
|
|
52
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
+
*/
|
|
54
|
+
const isPlainObject = (obj) => {
|
|
55
|
+
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
+
let proto = obj;
|
|
58
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { isPlainObject };
|
|
64
|
+
//# sourceMappingURL=is-plain-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,gBAAgB,QAAiB;AAC5C,QAAO,OAAO,QAAQ,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B5C,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_is_non_null_object = require('./is-non-null-object.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-set-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is an object with some fields set
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
+
*/
|
|
10
|
+
const isSetObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return require_is_non_null_object.isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.isSetObject = isSetObject;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isNonNullObject } from "./is-non-null-object.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-set-object.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provided value's type is an object with some fields set
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
+
*/
|
|
10
|
+
const isSetObject = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isSetObject };
|
|
20
|
+
//# sourceMappingURL=is-set-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-set-object.mjs","names":[],"sources":["../../../../type-checks/src/is-set-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNonNullObject } from \"./is-non-null-object\";\n\n/**\n * Check if the provided value's type is an object with some fields set\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is an object with some fields se\n */\nexport const isSetObject = (value: unknown): value is NonNullable<object> => {\n try {\n return isNonNullObject(value) && Object.keys(value).length > 0;\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,eAAe,UAAiD;AAC3E,KAAI;AACF,SAAO,gBAAgB,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS;SACvD;AACN,SAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_is_empty = require('./is-empty.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-set.ts
|
|
4
|
+
/**
|
|
5
|
+
* The inverse of the `isEmpty` function
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
+
*/
|
|
10
|
+
const isSet = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return !require_is_empty.isEmpty(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.isSet = isSet;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isEmpty } from "./is-empty.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../type-checks/src/is-set.ts
|
|
4
|
+
/**
|
|
5
|
+
* The inverse of the `isEmpty` function
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to type check
|
|
8
|
+
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
+
*/
|
|
10
|
+
const isSet = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return !isEmpty(value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isSet };
|
|
20
|
+
//# sourceMappingURL=is-set.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,SAAS,UAAkD;AACtE,KAAI;AACF,SAAO,CAAC,QAAQ,MAAM;SAChB;AACN,SAAO"}
|