mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-22 21:59:44 +03:00
Update isWithCode - allow string code
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.16.0-rc.23",
|
"version": "0.16.0-rc.24",
|
||||||
"description": "Orion Protocol SDK",
|
"description": "Orion Protocol SDK",
|
||||||
"main": "./lib/esm/index.js",
|
"main": "./lib/esm/index.js",
|
||||||
"module": "./lib/esm/index.js",
|
"module": "./lib/esm/index.js",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ type WithReason = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WithCodeError = Error & {
|
type WithCodeError = Error & {
|
||||||
code: number;
|
code: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type WithMessage = {
|
type WithMessage = {
|
||||||
@@ -41,9 +41,9 @@ export function hasProp<T extends Record<string, unknown>, K extends PropertyKey
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isWithCode(candidate: unknown): candidate is WithCodeError {
|
export function isWithCode(candidate: unknown): candidate is WithCodeError {
|
||||||
if (!isUnknownObject(candidate)) return false;
|
if (!isUnknownObject(candidate) || !hasProp(candidate, 'code')) return false;
|
||||||
const hasCodeProperty = hasProp(candidate, 'code') && typeof candidate.code === 'number';
|
const type = typeof candidate.code;
|
||||||
return hasCodeProperty;
|
return type === 'number' || type === 'string';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isWithReason(candidate: unknown): candidate is WithReason {
|
export function isWithReason(candidate: unknown): candidate is WithReason {
|
||||||
|
|||||||
Reference in New Issue
Block a user