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