From af9f4c5822a8df249b3187448f7b23ca7c943299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Thu, 26 Aug 2021 22:10:38 +0300 Subject: [PATCH] bytes: fix isBytes check --- packages/bytes/src.ts/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bytes/src.ts/index.ts b/packages/bytes/src.ts/index.ts index 8e0fcfe3e..304e6a71e 100644 --- a/packages/bytes/src.ts/index.ts +++ b/packages/bytes/src.ts/index.ts @@ -75,11 +75,11 @@ export function isBytes(value: any): value is Bytes { if (value.constructor === Uint8Array) { return true; } if (typeof(value) === "string") { return false; } - if (value.length == null) { return false; } + if (!Number.isInteger(value.length) || value.length < 0) { return false; } for (let i = 0; i < value.length; i++) { const v = value[i]; - if (typeof(v) !== "number" || v < 0 || v >= 256 || (v % 1)) { + if (!Number.isInteger(v) || v < 0 || v >= 256) { return false; } }