From 5260ba980698c70fa8d7f187968dd663064bf577 Mon Sep 17 00:00:00 2001 From: Shen liang Date: Thu, 1 Dec 2016 09:07:03 +0800 Subject: [PATCH] add string support to fix the #508 --- src/util/longbits.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/longbits.js b/src/util/longbits.js index 305437152..601970d15 100644 --- a/src/util/longbits.js +++ b/src/util/longbits.js @@ -71,9 +71,14 @@ LongBits.fromNumber = function fromNumber(value) { * @returns {util.LongBits} Instance */ LongBits.from = function from(value) { - return typeof value === 'number' - ? LongBits.fromNumber(value) - : new LongBits(value.low >>> 0, value.high >>> 0); + var type = typeof value, result=zero; + if(type === 'number') + result = LongBits.fromNumber(value); + else if(type === 'string' && util.Long) + result = util.Long.fromString(value); + else + result = new LongBits(value.low >>> 0, value.high >>> 0); + return result; }; /**