From da2c434f12f082696d9af78ca209d5a7c9005c73 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 4 Jun 2019 09:29:10 -0400 Subject: [PATCH] fix(Decimal128): throw error when passing a string to Decimal128 constructor --- lib/decimal128.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/decimal128.js b/lib/decimal128.js index ac816a90..33607c72 100644 --- a/lib/decimal128.js +++ b/lib/decimal128.js @@ -154,6 +154,9 @@ function invalidErr(string, message) { * @return {Double} */ function Decimal128(bytes) { + if (typeof bytes === 'string') { + throw new Error('Decimal128 constructor expects a Buffer parameter. Use `Decimal128.fromString()` to load a Decimal128 from a string'); + } this.bytes = bytes; }