@xylabs/object
Advanced tools
Comparing version 4.4.23 to 4.4.24
@@ -8,3 +8,4 @@ import type { TypedObject } from '@xylabs/typeof'; | ||
}; | ||
createOptional: <T extends TypedObject>(typeCheck: TypeCheck<T>) => <TType extends T>(value: import("@xylabs/promise").AnyNonPromise) => TType | undefined; | ||
}; | ||
//# sourceMappingURL=AsObjectFactory.d.ts.map |
@@ -15,3 +15,4 @@ import type { AssertExMessageFunc } from '@xylabs/assert'; | ||
}; | ||
createOptional: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => <TType extends T>(value: AnyNonPromise) => TType | undefined; | ||
}; | ||
//# sourceMappingURL=AsTypeFactory.d.ts.map |
{ | ||
"name": "@xylabs/object", | ||
"version": "4.4.23", | ||
"version": "4.4.24", | ||
"description": "Primary SDK for using XYO Protocol 2.0", | ||
@@ -32,6 +32,6 @@ "homepage": "https://xyo.network", | ||
"dependencies": { | ||
"@xylabs/assert": "^4.4.23", | ||
"@xylabs/logger": "^4.4.23", | ||
"@xylabs/promise": "^4.4.23", | ||
"@xylabs/typeof": "^4.4.23" | ||
"@xylabs/assert": "^4.4.24", | ||
"@xylabs/logger": "^4.4.24", | ||
"@xylabs/promise": "^4.4.24", | ||
"@xylabs/typeof": "^4.4.24" | ||
}, | ||
@@ -38,0 +38,0 @@ "devDependencies": { |
@@ -10,2 +10,5 @@ import type { TypedObject } from '@xylabs/typeof' | ||
}, | ||
createOptional: <T extends TypedObject>(typeCheck: TypeCheck<T>) => { | ||
return AsTypeFactory.createOptional<T>(typeCheck) | ||
}, | ||
} |
@@ -25,10 +25,3 @@ import type { AssertExMessageFunc } from '@xylabs/assert' | ||
): TType | undefined { | ||
if (value === undefined) { | ||
return undefined | ||
} | ||
if (value === null) { | ||
return undefined | ||
} | ||
if (value === undefined || value === null) return undefined | ||
if (isPromise(value)) { | ||
@@ -53,2 +46,12 @@ throw new TypeError('un-awaited promises may not be sent to "as" functions') | ||
}, | ||
createOptional: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => { | ||
function func<TType extends T>(value: AnyNonPromise): TType | undefined { | ||
if (value === undefined || value === null) return undefined | ||
if (isPromise(value)) { | ||
throw new TypeError('un-awaited promises may not be sent to "as" functions') | ||
} | ||
return typeCheck(value) ? (value as TType) : undefined | ||
} | ||
return func | ||
}, | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139044
1336
Updated@xylabs/assert@^4.4.24
Updated@xylabs/logger@^4.4.24
Updated@xylabs/promise@^4.4.24
Updated@xylabs/typeof@^4.4.24