@xylabs/hex
Advanced tools
Comparing version 3.3.2 to 3.3.3
@@ -138,13 +138,18 @@ // src/assert.ts | ||
function asAddress(value, assert) { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
try { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} catch (ex) { | ||
const error = ex; | ||
return assertError(void 0, assert, error.message); | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} | ||
@@ -151,0 +156,0 @@ |
@@ -138,13 +138,18 @@ // src/assert.ts | ||
function asAddress(value, assert) { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
try { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} catch (ex) { | ||
const error = ex; | ||
return assertError(void 0, assert, error.message); | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} | ||
@@ -151,0 +156,0 @@ |
@@ -138,13 +138,18 @@ // src/assert.ts | ||
function asAddress(value, assert) { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
try { | ||
let stringValue = void 0; | ||
switch (typeof value) { | ||
case "string": { | ||
stringValue = hexFromHexString(value, { prefix: false }); | ||
break; | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0; | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} catch (ex) { | ||
const error = ex; | ||
return assertError(void 0, assert, error.message); | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`); | ||
} | ||
@@ -151,0 +156,0 @@ |
@@ -42,7 +42,7 @@ { | ||
"dependencies": { | ||
"@xylabs/arraybuffer": "~3.3.2" | ||
"@xylabs/arraybuffer": "~3.3.3" | ||
}, | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^3.10.0", | ||
"@xylabs/tsconfig": "^3.10.0", | ||
"@xylabs/ts-scripts-yarn3": "^3.10.4", | ||
"@xylabs/tsconfig": "^3.10.4", | ||
"typescript": "^5.4.5" | ||
@@ -61,4 +61,4 @@ }, | ||
"sideEffects": false, | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"type": "module" | ||
} |
@@ -19,14 +19,19 @@ import { AssertConfig, assertError } from './assert' | ||
export function asAddress(value: unknown, assert?: AssertConfig): Address | undefined { | ||
let stringValue: string | undefined = undefined | ||
try { | ||
let stringValue: string | undefined = undefined | ||
switch (typeof value) { | ||
case 'string': { | ||
stringValue = hexFromHexString(value, { prefix: false }) | ||
break | ||
switch (typeof value) { | ||
case 'string': { | ||
stringValue = hexFromHexString(value, { prefix: false }) | ||
break | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined | ||
} | ||
} | ||
default: { | ||
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`) | ||
} catch (ex) { | ||
const error = ex as Error | ||
return assertError(undefined, assert, error.message) | ||
} | ||
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`) | ||
} |
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
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
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
225079
1644
Updated@xylabs/arraybuffer@~3.3.3