@xylabs/typeof 4.0.1 → 4.0.3
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/neutral/index.mjs.map +1 -1
- package/package.json +31 -31
- package/src/ifTypeOf.ts +1 -1
- package/src/typeOf.ts +1 -1
- package/src/validateType.ts +1 -1
- package/xy.config.ts +2 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typeOf.ts","../../src/ifDefined.ts","../../src/ifTypeOf.ts","../../src/validateType.ts"],"sourcesContent":["import { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const typeOf = <T>(item: T): TypeOfTypes => {\n return Array.isArray(item) ? 'array' : typeof item\n}\n","import { typeOf } from './typeOf.ts'\n\nexport const ifDefined = <T>(value: T, func: (value: T) => void) => {\n switch (typeOf(value)) {\n case 'undefined':\n case 'null': {\n break\n }\n default: {\n func(value)\n return value\n }\n }\n}\n","import { typeOf } from './typeOf.ts'\nimport { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const ifTypeOf = <T, R>(typeName: TypeOfTypes, value: unknown, trueFunc: (value: T) => R, isFunc?: (value: T) => boolean) => {\n switch (typeOf(value)) {\n case typeName: {\n return !isFunc || isFunc(value as T) ? trueFunc(value as T) : undefined\n }\n }\n}\n","import { typeOf } from './typeOf.ts'\nimport { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const validateType = <T>(typeName: TypeOfTypes, value: T, optional = false): [T | undefined, Error[]] => {\n switch (typeOf(value)) {\n case typeName: {\n return [value, []]\n }\n default: {\n if (optional && typeOf(value) === 'undefined') {\n return [value, []]\n }\n return [undefined, [new Error(`value type is not '${typeName}:${typeof value}'`)]]\n }\n }\n}\n"],"mappings":";AAEO,IAAM,SAAS,CAAI,SAAyB;AACjD,SAAO,MAAM,QAAQ,IAAI,IAAI,UAAU,OAAO;AAChD;;;ACFO,IAAM,YAAY,CAAI,OAAU,SAA6B;AAClE,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX;AAAA,IACF;AAAA,IACA,SAAS;AACP,WAAK,KAAK;AACV,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;ACVO,IAAM,WAAW,CAAO,UAAuB,OAAgB,UAA2B,WAAmC;AAClI,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK,UAAU;AACb,aAAO,CAAC,UAAU,OAAO,KAAU,IAAI,SAAS,KAAU,IAAI;AAAA,IAChE;AAAA,EACF;AACF;;;ACNO,IAAM,eAAe,CAAI,UAAuB,OAAU,WAAW,UAAoC;AAC9G,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK,UAAU;AACb,aAAO,CAAC,OAAO,CAAC,CAAC;AAAA,IACnB;AAAA,IACA,SAAS;AACP,UAAI,YAAY,OAAO,KAAK,MAAM,aAAa;AAC7C,eAAO,CAAC,OAAO,CAAC,CAAC;AAAA,MACnB;AACA,aAAO,CAAC,QAAW,CAAC,IAAI,MAAM,sBAAsB,QAAQ,IAAI,OAAO,KAAK,GAAG,CAAC,CAAC;AAAA,IACnF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/typeOf.ts","../../src/ifDefined.ts","../../src/ifTypeOf.ts","../../src/validateType.ts"],"sourcesContent":["import type { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const typeOf = <T>(item: T): TypeOfTypes => {\n return Array.isArray(item) ? 'array' : typeof item\n}\n","import { typeOf } from './typeOf.ts'\n\nexport const ifDefined = <T>(value: T, func: (value: T) => void) => {\n switch (typeOf(value)) {\n case 'undefined':\n case 'null': {\n break\n }\n default: {\n func(value)\n return value\n }\n }\n}\n","import { typeOf } from './typeOf.ts'\nimport type { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const ifTypeOf = <T, R>(typeName: TypeOfTypes, value: unknown, trueFunc: (value: T) => R, isFunc?: (value: T) => boolean) => {\n switch (typeOf(value)) {\n case typeName: {\n return !isFunc || isFunc(value as T) ? trueFunc(value as T) : undefined\n }\n }\n}\n","import { typeOf } from './typeOf.ts'\nimport type { TypeOfTypes } from './TypeOfTypes.ts'\n\nexport const validateType = <T>(typeName: TypeOfTypes, value: T, optional = false): [T | undefined, Error[]] => {\n switch (typeOf(value)) {\n case typeName: {\n return [value, []]\n }\n default: {\n if (optional && typeOf(value) === 'undefined') {\n return [value, []]\n }\n return [undefined, [new Error(`value type is not '${typeName}:${typeof value}'`)]]\n }\n }\n}\n"],"mappings":";AAEO,IAAM,SAAS,CAAI,SAAyB;AACjD,SAAO,MAAM,QAAQ,IAAI,IAAI,UAAU,OAAO;AAChD;;;ACFO,IAAM,YAAY,CAAI,OAAU,SAA6B;AAClE,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX;AAAA,IACF;AAAA,IACA,SAAS;AACP,WAAK,KAAK;AACV,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;ACVO,IAAM,WAAW,CAAO,UAAuB,OAAgB,UAA2B,WAAmC;AAClI,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK,UAAU;AACb,aAAO,CAAC,UAAU,OAAO,KAAU,IAAI,SAAS,KAAU,IAAI;AAAA,IAChE;AAAA,EACF;AACF;;;ACNO,IAAM,eAAe,CAAI,UAAuB,OAAU,WAAW,UAAoC;AAC9G,UAAQ,OAAO,KAAK,GAAG;AAAA,IACrB,KAAK,UAAU;AACb,aAAO,CAAC,OAAO,CAAC,CAAC;AAAA,IACnB;AAAA,IACA,SAAS;AACP,UAAI,YAAY,OAAO,KAAK,MAAM,aAAa;AAC7C,eAAO,CAAC,OAAO,CAAC,CAAC;AAAA,MACnB;AACA,aAAO,CAAC,QAAW,CAAC,IAAI,MAAM,sBAAsB,QAAQ,IAAI,OAAO,KAAK,GAAG,CAAC,CAAC;AAAA,IACnF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/typeof",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
3
|
+
"version": "4.0.3",
|
|
4
|
+
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typeof",
|
|
7
|
+
"xylabs",
|
|
8
|
+
"utility",
|
|
9
|
+
"typescript",
|
|
10
|
+
"esm"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://xylabs.com",
|
|
8
13
|
"bugs": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
14
|
+
"url": "git+https://github.com/xylabs/sdk-js/issues",
|
|
15
|
+
"email": "support@xylabs.com"
|
|
11
16
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"@xylabs/tsconfig": "^4.0.0-rc.15",
|
|
16
|
-
"typescript": "^5.5.4"
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/xylabs/sdk-js.git"
|
|
17
20
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
21
|
+
"license": "LGPL-3.0-only",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "XY Labs Development Team",
|
|
24
|
+
"email": "support@xylabs.com",
|
|
25
|
+
"url": "https://xylabs.com"
|
|
20
26
|
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
21
29
|
"exports": {
|
|
22
30
|
".": {
|
|
23
31
|
"types": "./dist/neutral/index.d.ts",
|
|
@@ -27,23 +35,15 @@
|
|
|
27
35
|
},
|
|
28
36
|
"module": "dist/neutral/index.mjs",
|
|
29
37
|
"types": "dist/neutral/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0",
|
|
40
|
+
"@xylabs/tsconfig": "^4.0.0",
|
|
41
|
+
"typescript": "^5.5.4"
|
|
34
42
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"url": "https://github.com/xylabs/sdk-js.git"
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18"
|
|
38
45
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"utility",
|
|
43
|
-
"typescript",
|
|
44
|
-
"esm"
|
|
45
|
-
],
|
|
46
|
-
"sideEffects": false,
|
|
47
|
-
"version": "4.0.1",
|
|
48
|
-
"type": "module"
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
49
|
}
|
package/src/ifTypeOf.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { typeOf } from './typeOf.ts'
|
|
2
|
-
import { TypeOfTypes } from './TypeOfTypes.ts'
|
|
2
|
+
import type { TypeOfTypes } from './TypeOfTypes.ts'
|
|
3
3
|
|
|
4
4
|
export const ifTypeOf = <T, R>(typeName: TypeOfTypes, value: unknown, trueFunc: (value: T) => R, isFunc?: (value: T) => boolean) => {
|
|
5
5
|
switch (typeOf(value)) {
|
package/src/typeOf.ts
CHANGED
package/src/validateType.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { typeOf } from './typeOf.ts'
|
|
2
|
-
import { TypeOfTypes } from './TypeOfTypes.ts'
|
|
2
|
+
import type { TypeOfTypes } from './TypeOfTypes.ts'
|
|
3
3
|
|
|
4
4
|
export const validateType = <T>(typeName: TypeOfTypes, value: T, optional = false): [T | undefined, Error[]] => {
|
|
5
5
|
switch (typeOf(value)) {
|
package/xy.config.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
|
|
1
|
+
import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
|
|
2
2
|
const config: XyTsupConfig = {
|
|
3
3
|
compile: {
|
|
4
4
|
browser: {},
|
|
5
|
-
neutral: {
|
|
6
|
-
src: true,
|
|
7
|
-
},
|
|
5
|
+
neutral: { src: true },
|
|
8
6
|
node: {},
|
|
9
7
|
},
|
|
10
8
|
}
|