@xyo-network/typeof 5.3.20 → 5.3.24
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/package.json +10 -7
- package/src/TypeOfTypes.ts +0 -2
- package/src/ifDefined.ts +0 -17
- package/src/ifTypeOf.ts +0 -18
- package/src/index.ts +0 -5
- package/src/typeOf.ts +0 -8
- package/src/validateType.ts +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/typeof",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.24",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,18 +30,21 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src",
|
|
34
33
|
"!**/*.bench.*",
|
|
35
34
|
"!**/*.spec.*",
|
|
36
|
-
"!**/*.test.*"
|
|
35
|
+
"!**/*.test.*",
|
|
36
|
+
"README.md"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@xylabs/ts-scripts-
|
|
41
|
-
"@xylabs/
|
|
39
|
+
"@types/node": "^25.5.0",
|
|
40
|
+
"@xylabs/ts-scripts-common": "~7.6.16",
|
|
41
|
+
"@xylabs/ts-scripts-pnpm": "~7.6.16",
|
|
42
|
+
"@xylabs/tsconfig": "~7.6.16",
|
|
43
|
+
"acorn": "^8.16.0",
|
|
44
|
+
"esbuild": "^0.28.0",
|
|
42
45
|
"typescript": "~5.9.3"
|
|
43
46
|
},
|
|
44
47
|
"publishConfig": {
|
|
45
48
|
"access": "public"
|
|
46
49
|
}
|
|
47
|
-
}
|
|
50
|
+
}
|
package/src/TypeOfTypes.ts
DELETED
package/src/ifDefined.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
/* eslint-disable sonarjs/deprecation */
|
|
3
|
-
import { typeOf } from './typeOf.ts'
|
|
4
|
-
|
|
5
|
-
/** @deprecated use @xylabs/typeof or zod */
|
|
6
|
-
export const ifDefined = <T>(value: T, function_: (value: T) => void): T | undefined => {
|
|
7
|
-
switch (typeOf(value)) {
|
|
8
|
-
case 'undefined':
|
|
9
|
-
case 'null': {
|
|
10
|
-
break
|
|
11
|
-
}
|
|
12
|
-
default: {
|
|
13
|
-
function_(value)
|
|
14
|
-
return value
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/ifTypeOf.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
/* eslint-disable sonarjs/deprecation */
|
|
3
|
-
import { typeOf } from './typeOf.ts'
|
|
4
|
-
import type { TypeOfTypes } from './TypeOfTypes.ts'
|
|
5
|
-
|
|
6
|
-
/** @deprecated use @xylabs/typeof or zod */
|
|
7
|
-
export const ifTypeOf = <T, R>(
|
|
8
|
-
typeName: TypeOfTypes,
|
|
9
|
-
value: unknown,
|
|
10
|
-
trueFunction: (value: T) => R,
|
|
11
|
-
isFunction?: (value: T) => boolean,
|
|
12
|
-
): R | undefined => {
|
|
13
|
-
switch (typeOf(value)) {
|
|
14
|
-
case typeName: {
|
|
15
|
-
return !isFunction || isFunction(value as T) ? trueFunction(value as T) : undefined
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/index.ts
DELETED
package/src/typeOf.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
/* eslint-disable sonarjs/deprecation */
|
|
3
|
-
import type { TypeOfTypes } from './TypeOfTypes.ts'
|
|
4
|
-
|
|
5
|
-
/** @deprecated use @xylabs/typeof or zod */
|
|
6
|
-
export const typeOf = <T>(item: T): TypeOfTypes => {
|
|
7
|
-
return Array.isArray(item) ? 'array' : typeof item
|
|
8
|
-
}
|
package/src/validateType.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
/* eslint-disable sonarjs/deprecation */
|
|
3
|
-
import { typeOf } from './typeOf.ts'
|
|
4
|
-
import type { TypeOfTypes } from './TypeOfTypes.ts'
|
|
5
|
-
|
|
6
|
-
/** @deprecated use @xylabs/typeof or zod */
|
|
7
|
-
export const validateType = <T>(typeName: TypeOfTypes, value: T, optional = false): [T | undefined, Error[]] => {
|
|
8
|
-
switch (typeOf(value)) {
|
|
9
|
-
case typeName: {
|
|
10
|
-
return [value, []]
|
|
11
|
-
}
|
|
12
|
-
default: {
|
|
13
|
-
if (optional && typeOf(value) === 'undefined') {
|
|
14
|
-
return [value, []]
|
|
15
|
-
}
|
|
16
|
-
return [undefined, [new Error(`value type is not '${typeName}:${typeof value}'`)]]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|