@robert-brightline/checks 0.0.1
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 +21 -0
- package/README.md +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/checks.d.ts +41 -0
- package/dist/lib/checks.d.ts.map +1 -0
- package/dist/lib/checks.js +142 -0
- package/dist/lib/checks.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<img src="./assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
## @robert-brightline/checks
|
|
11
|
+
|
|
12
|
+
- [ ] add description for @robert-brightline/checks
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @robert-brightline/checks
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 💖 Support My Work
|
|
21
|
+
|
|
22
|
+
If you find my open-source contributions or the **@robert-brightline/checks** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
|
|
23
|
+
|
|
24
|
+
[]([object Object])
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🤝 Connect with Me
|
|
29
|
+
|
|
30
|
+
<p align="left">
|
|
31
|
+
<a href="mailto:robert.brightline+checks@gmail.com?subject=@robert-brightline/checks">
|
|
32
|
+
<img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
|
|
33
|
+
</a>
|
|
34
|
+
</p>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{test,spec}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/checks.js';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,uFAAuF;AACvF,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Any, Some } from '@robert-brightline/types';
|
|
2
|
+
export declare function isDefined<T>(value: Some<T>): value is T;
|
|
3
|
+
export declare function isUndefined<T>(value: Some<T>): value is undefined | null;
|
|
4
|
+
export declare function isEmptyString(value: Any): boolean;
|
|
5
|
+
export declare function isNonEmptyString(value: Any): boolean;
|
|
6
|
+
export declare function isNonEmptyArray(value: Any): boolean;
|
|
7
|
+
export declare function isEmptyArray(value: Any): boolean;
|
|
8
|
+
export declare function isObject(value: Any): boolean;
|
|
9
|
+
export declare function isNonEmptyObject(value: Any): boolean;
|
|
10
|
+
export declare function isEmptyObject(value: Any): boolean;
|
|
11
|
+
export declare function isFunction(value: Any): boolean;
|
|
12
|
+
export declare function isNumber(value: Any): boolean;
|
|
13
|
+
export declare function isBoolean(value: Any): boolean;
|
|
14
|
+
export declare function isString(value: Any): boolean;
|
|
15
|
+
export declare function isArray(value: Any): boolean;
|
|
16
|
+
export declare function isNull(value: Any): boolean;
|
|
17
|
+
export declare function isNotNull(value: Any): boolean;
|
|
18
|
+
export declare function isDate(value: Any): boolean;
|
|
19
|
+
export declare function isPromise(value: Any): boolean;
|
|
20
|
+
export declare function isSymbol(value: Any): boolean;
|
|
21
|
+
export declare function isBigInt(value: Any): boolean;
|
|
22
|
+
export declare function isIterable(value: Any): boolean;
|
|
23
|
+
export declare function isMap(value: Any): boolean;
|
|
24
|
+
export declare function isSet(value: Any): boolean;
|
|
25
|
+
export declare function isWeakMap(value: Any): boolean;
|
|
26
|
+
export declare function isWeakSet(value: Any): boolean;
|
|
27
|
+
export declare function isError(value: Any): boolean;
|
|
28
|
+
export declare function isRegExp(value: Any): boolean;
|
|
29
|
+
export declare function isTypedArray(value: Any): boolean;
|
|
30
|
+
export declare function isArrayBuffer(value: Any): boolean;
|
|
31
|
+
export declare function isDataView(value: Any): boolean;
|
|
32
|
+
export declare function isURL(value: Any): boolean;
|
|
33
|
+
export declare function isUUID(value: Any): boolean;
|
|
34
|
+
export declare function isEmail(value: Any): boolean;
|
|
35
|
+
export declare function isPhoneNumber(value: Any): boolean;
|
|
36
|
+
export declare function isJSON(value: Any): boolean;
|
|
37
|
+
export declare function definedOrThrow<T>(value: Some<T>, errorMessage?: string): T;
|
|
38
|
+
export declare function nonEmptyStringOrThrow(value: Any, errorMessage?: string): string;
|
|
39
|
+
export declare function nonEmptyArrayOrThrow<T>(value: Any, errorMessage?: string): T[];
|
|
40
|
+
export declare function nonEmptyObjectOrThrow<T extends object>(value: Any, errorMessage?: string): T;
|
|
41
|
+
//# sourceMappingURL=checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/lib/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAEvD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,SAAS,GAAG,IAAI,CAExE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEjD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEpD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEnD;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEhD;AACD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE5C;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEpD;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEjD;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAA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AC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE9C;AACD,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEzC;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAI1C;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAG3C;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAGjD;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAU1C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EACd,YAAY,SAA+B,GAC1C,CAAC,CAKH;AACD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,GAAG,EACV,YAAY,SAAoC,GAC/C,MAAM,CAKR;AACD,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,GAAG,EACV,YAAY,SAAmC,GAC9C,CAAC,EAAE,CAKL;AACD,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EACpD,KAAK,EAAE,GAAG,EACV,YAAY,SAAoC,GAC/C,CAAC,CAKH"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export function isDefined(value) {
|
|
2
|
+
return value !== undefined && value !== null;
|
|
3
|
+
}
|
|
4
|
+
export function isUndefined(value) {
|
|
5
|
+
return value === undefined || value === null;
|
|
6
|
+
}
|
|
7
|
+
export function isEmptyString(value) {
|
|
8
|
+
return value === '';
|
|
9
|
+
}
|
|
10
|
+
export function isNonEmptyString(value) {
|
|
11
|
+
return typeof value === 'string' && value.length > 0;
|
|
12
|
+
}
|
|
13
|
+
export function isNonEmptyArray(value) {
|
|
14
|
+
return Array.isArray(value) && value.length > 0;
|
|
15
|
+
}
|
|
16
|
+
export function isEmptyArray(value) {
|
|
17
|
+
return Array.isArray(value) && value.length === 0;
|
|
18
|
+
}
|
|
19
|
+
export function isObject(value) {
|
|
20
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
export function isNonEmptyObject(value) {
|
|
23
|
+
return isObject(value) && Object.keys(value).length > 0;
|
|
24
|
+
}
|
|
25
|
+
export function isEmptyObject(value) {
|
|
26
|
+
return isObject(value) && Object.keys(value).length === 0;
|
|
27
|
+
}
|
|
28
|
+
export function isFunction(value) {
|
|
29
|
+
return typeof value === 'function';
|
|
30
|
+
}
|
|
31
|
+
export function isNumber(value) {
|
|
32
|
+
return typeof value === 'number' && !isNaN(value);
|
|
33
|
+
}
|
|
34
|
+
export function isBoolean(value) {
|
|
35
|
+
return typeof value === 'boolean';
|
|
36
|
+
}
|
|
37
|
+
export function isString(value) {
|
|
38
|
+
return typeof value === 'string';
|
|
39
|
+
}
|
|
40
|
+
export function isArray(value) {
|
|
41
|
+
return Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
export function isNull(value) {
|
|
44
|
+
return value === null;
|
|
45
|
+
}
|
|
46
|
+
export function isNotNull(value) {
|
|
47
|
+
return value !== null;
|
|
48
|
+
}
|
|
49
|
+
export function isDate(value) {
|
|
50
|
+
return value instanceof Date && !isNaN(value.getTime());
|
|
51
|
+
}
|
|
52
|
+
export function isPromise(value) {
|
|
53
|
+
return value instanceof Promise;
|
|
54
|
+
}
|
|
55
|
+
export function isSymbol(value) {
|
|
56
|
+
return typeof value === 'symbol';
|
|
57
|
+
}
|
|
58
|
+
export function isBigInt(value) {
|
|
59
|
+
return typeof value === 'bigint';
|
|
60
|
+
}
|
|
61
|
+
export function isIterable(value) {
|
|
62
|
+
return value != null && typeof value[Symbol.iterator] === 'function';
|
|
63
|
+
}
|
|
64
|
+
export function isMap(value) {
|
|
65
|
+
return value instanceof Map;
|
|
66
|
+
}
|
|
67
|
+
export function isSet(value) {
|
|
68
|
+
return value instanceof Set;
|
|
69
|
+
}
|
|
70
|
+
export function isWeakMap(value) {
|
|
71
|
+
return value instanceof WeakMap;
|
|
72
|
+
}
|
|
73
|
+
export function isWeakSet(value) {
|
|
74
|
+
return value instanceof WeakSet;
|
|
75
|
+
}
|
|
76
|
+
export function isError(value) {
|
|
77
|
+
return value instanceof Error;
|
|
78
|
+
}
|
|
79
|
+
export function isRegExp(value) {
|
|
80
|
+
return value instanceof RegExp;
|
|
81
|
+
}
|
|
82
|
+
export function isTypedArray(value) {
|
|
83
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
84
|
+
}
|
|
85
|
+
export function isArrayBuffer(value) {
|
|
86
|
+
return value instanceof ArrayBuffer;
|
|
87
|
+
}
|
|
88
|
+
export function isDataView(value) {
|
|
89
|
+
return value instanceof DataView;
|
|
90
|
+
}
|
|
91
|
+
export function isURL(value) {
|
|
92
|
+
return value instanceof URL;
|
|
93
|
+
}
|
|
94
|
+
export function isUUID(value) {
|
|
95
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
96
|
+
return isNonEmptyString(value) && uuidRegex.test(value);
|
|
97
|
+
}
|
|
98
|
+
export function isEmail(value) {
|
|
99
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
100
|
+
return isNonEmptyString(value) && emailRegex.test(value);
|
|
101
|
+
}
|
|
102
|
+
export function isPhoneNumber(value) {
|
|
103
|
+
const phoneRegex = /^\+?[1-9]\d{1,14}$/;
|
|
104
|
+
return isNonEmptyString(value) && phoneRegex.test(value);
|
|
105
|
+
}
|
|
106
|
+
export function isJSON(value) {
|
|
107
|
+
if (!isNonEmptyString(value)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
JSON.parse(value);
|
|
112
|
+
return true;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function definedOrThrow(value, errorMessage = 'Value is undefined or null') {
|
|
118
|
+
if (isUndefined(value)) {
|
|
119
|
+
throw new Error(errorMessage);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
export function nonEmptyStringOrThrow(value, errorMessage = 'Value is not a non-empty string') {
|
|
124
|
+
if (!isNonEmptyString(value)) {
|
|
125
|
+
throw new Error(errorMessage);
|
|
126
|
+
}
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
export function nonEmptyArrayOrThrow(value, errorMessage = 'Value is not a non-empty array') {
|
|
130
|
+
if (!isNonEmptyArray(value)) {
|
|
131
|
+
throw new Error(errorMessage);
|
|
132
|
+
}
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
export function nonEmptyObjectOrThrow(value, errorMessage = 'Value is not a non-empty object') {
|
|
136
|
+
if (!isNonEmptyObject(value)) {
|
|
137
|
+
throw new Error(errorMessage);
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/checks.ts"],"sourcesContent":["import type { Any, Some } from '@robert-brightline/types';\n\nexport function isDefined<T>(value: Some<T>): value is T {\n return value !== undefined && value !== null;\n}\n\nexport function isUndefined<T>(value: Some<T>): value is undefined | null {\n return value === undefined || value === null;\n}\n\nexport function isEmptyString(value: Any): boolean {\n return value === '';\n}\n\nexport function isNonEmptyString(value: Any): boolean {\n return typeof value === 'string' && value.length > 0;\n}\n\nexport function isNonEmptyArray(value: Any): boolean {\n return Array.isArray(value) && value.length > 0;\n}\nexport function isEmptyArray(value: Any): boolean {\n return Array.isArray(value) && value.length === 0;\n}\nexport function isObject(value: Any): boolean {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\nexport function isNonEmptyObject(value: Any): boolean {\n return isObject(value) && Object.keys(value).length > 0;\n}\nexport function isEmptyObject(value: Any): boolean {\n return isObject(value) && Object.keys(value).length === 0;\n}\nexport function isFunction(value: Any): boolean {\n return typeof value === 'function';\n}\nexport function isNumber(value: Any): boolean {\n return typeof value === 'number' && !isNaN(value);\n}\nexport function isBoolean(value: Any): boolean {\n return typeof value === 'boolean';\n}\n\nexport function isString(value: Any): boolean {\n return typeof value === 'string';\n}\nexport function isArray(value: Any): boolean {\n return Array.isArray(value);\n}\nexport function isNull(value: Any): boolean {\n return value === null;\n}\nexport function isNotNull(value: Any): boolean {\n return value !== null;\n}\nexport function isDate(value: Any): boolean {\n return value instanceof Date && !isNaN(value.getTime());\n}\nexport function isPromise(value: Any): boolean {\n return value instanceof Promise;\n}\nexport function isSymbol(value: Any): boolean {\n return typeof value === 'symbol';\n}\nexport function isBigInt(value: Any): boolean {\n return typeof value === 'bigint';\n}\nexport function isIterable(value: Any): boolean {\n return value != null && typeof value[Symbol.iterator] === 'function';\n}\nexport function isMap(value: Any): boolean {\n return value instanceof Map;\n}\nexport function isSet(value: Any): boolean {\n return value instanceof Set;\n}\nexport function isWeakMap(value: Any): boolean {\n return value instanceof WeakMap;\n}\nexport function isWeakSet(value: Any): boolean {\n return value instanceof WeakSet;\n}\n\nexport function isError(value: Any): boolean {\n return value instanceof Error;\n}\nexport function isRegExp(value: Any): boolean {\n return value instanceof RegExp;\n}\nexport function isTypedArray(value: Any): boolean {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}\nexport function isArrayBuffer(value: Any): boolean {\n return value instanceof ArrayBuffer;\n}\nexport function isDataView(value: Any): boolean {\n return value instanceof DataView;\n}\nexport function isURL(value: Any): boolean {\n return value instanceof URL;\n}\nexport function isUUID(value: Any): boolean {\n const uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return isNonEmptyString(value) && uuidRegex.test(value);\n}\nexport function isEmail(value: Any): boolean {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return isNonEmptyString(value) && emailRegex.test(value);\n}\nexport function isPhoneNumber(value: Any): boolean {\n const phoneRegex = /^\\+?[1-9]\\d{1,14}$/;\n return isNonEmptyString(value) && phoneRegex.test(value);\n}\nexport function isJSON(value: Any): boolean {\n if (!isNonEmptyString(value)) {\n return false;\n }\n try {\n JSON.parse(value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function definedOrThrow<T>(\n value: Some<T>,\n errorMessage = 'Value is undefined or null',\n): T {\n if (isUndefined(value)) {\n throw new Error(errorMessage);\n }\n return value;\n}\nexport function nonEmptyStringOrThrow(\n value: Any,\n errorMessage = 'Value is not a non-empty string',\n): string {\n if (!isNonEmptyString(value)) {\n throw new Error(errorMessage);\n }\n return value;\n}\nexport function nonEmptyArrayOrThrow<T>(\n value: Any,\n errorMessage = 'Value is not a non-empty array',\n): T[] {\n if (!isNonEmptyArray(value)) {\n throw new Error(errorMessage);\n }\n return value;\n}\nexport function nonEmptyObjectOrThrow<T extends object>(\n value: Any,\n errorMessage = 'Value is not a non-empty object',\n): T {\n if (!isNonEmptyObject(value)) {\n throw new Error(errorMessage);\n }\n return value;\n}\n"],"names":["isDefined","value","undefined","isUndefined","isEmptyString","isNonEmptyString","length","isNonEmptyArray","Array","isArray","isEmptyArray","isObject","isNonEmptyObject","Object","keys","isEmptyObject","isFunction","isNumber","isNaN","isBoolean","isString","isNull","isNotNull","isDate","Date","getTime","isPromise","Promise","isSymbol","isBigInt","isIterable","Symbol","iterator","isMap","Map","isSet","Set","isWeakMap","WeakMap","isWeakSet","WeakSet","isError","Error","isRegExp","RegExp","isTypedArray","ArrayBuffer","isView","DataView","isArrayBuffer","isDataView","isURL","URL","isUUID","uuidRegex","test","isEmail","emailRegex","isPhoneNumber","phoneRegex","isJSON","JSON","parse","definedOrThrow","errorMessage","nonEmptyStringOrThrow","nonEmptyArrayOrThrow","nonEmptyObjectOrThrow"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAOpD,KAAU;IAC/B,MAAMqD,YACJ;IACF,OAAOjD,iBAAiBJ,UAAUqD,UAAUC,IAAI,CAACtD;AACnD;AACA,OAAO,SAASuD,QAAQvD,KAAU;IAChC,MAAMwD,aAAa;IACnB,OAAOpD,iBAAiBJ,UAAUwD,WAAWF,IAAI,CAACtD;AACpD;AACA,OAAO,SAASyD,cAAczD,KAAU;IACtC,MAAM0D,aAAa;IACnB,OAAOtD,iBAAiBJ,UAAU0D,WAAWJ,IAAI,CAACtD;AACpD;AACA,OAAO,SAAS2D,OAAO3D,KAAU;IAC/B,IAAI,CAACI,iBAAiBJ,QAAQ;QAC5B,OAAO;IACT;IACA,IAAI;QACF4D,KAAKC,KAAK,CAAC7D;QACX,OAAO;IACT,EAAE,UAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,SAAS8D,eACd9D,KAAc,EACd+D,eAAe,4BAA4B;IAE3C,IAAI7D,YAAYF,QAAQ;QACtB,MAAM,IAAIyC,MAAMsB;IAClB;IACA,OAAO/D;AACT;AACA,OAAO,SAASgE,sBACdhE,KAAU,EACV+D,eAAe,iCAAiC;IAEhD,IAAI,CAAC3D,iBAAiBJ,QAAQ;QAC5B,MAAM,IAAIyC,MAAMsB;IAClB;IACA,OAAO/D;AACT;AACA,OAAO,SAASiE,qBACdjE,KAAU,EACV+D,eAAe,gCAAgC;IAE/C,IAAI,CAACzD,gBAAgBN,QAAQ;QAC3B,MAAM,IAAIyC,MAAMsB;IAClB;IACA,OAAO/D;AACT;AACA,OAAO,SAASkE,sBACdlE,KAAU,EACV+D,eAAe,iCAAiC;IAEhD,IAAI,CAACpD,iBAAiBX,QAAQ;QAC5B,MAAM,IAAIyC,MAAMsB;IAClB;IACA,OAAO/D;AACT"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robert-brightline/checks",
|
|
3
|
+
"description": "- [ ] add project description",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "robert-brightline",
|
|
7
|
+
"email": "robert.brightline+checks@gmail.com"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/robert-brightline/robert-brightline.git/libs/checks",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"tag": "latest"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
""
|
|
16
|
+
],
|
|
17
|
+
"funding": [
|
|
18
|
+
{
|
|
19
|
+
"type": "cashapp",
|
|
20
|
+
"url": "https://cash.app/$puqlib"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": {
|
|
30
|
+
"@robert-brightline/source": "./src/index.ts",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"assets",
|
|
39
|
+
"!**/*.tsbuildinfo"
|
|
40
|
+
],
|
|
41
|
+
"nx": {
|
|
42
|
+
"sourceRoot": "libs/checks/src",
|
|
43
|
+
"targets": {
|
|
44
|
+
"build": {
|
|
45
|
+
"executor": "@nx/js:swc",
|
|
46
|
+
"outputs": [
|
|
47
|
+
"{options.outputPath}"
|
|
48
|
+
],
|
|
49
|
+
"options": {
|
|
50
|
+
"outputPath": "libs/checks/dist",
|
|
51
|
+
"main": "libs/checks/src/index.ts",
|
|
52
|
+
"tsConfig": "libs/checks/tsconfig.lib.json",
|
|
53
|
+
"skipTypeCheck": false,
|
|
54
|
+
"stripLeadingPaths": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@swc/helpers": "~0.5.11",
|
|
61
|
+
"@robert-brightline/types": "0.0.1"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"vitest": "^4.0.8"
|
|
65
|
+
}
|
|
66
|
+
}
|