From 1497770a553ff61e50eeae2579c61255b768a565 Mon Sep 17 00:00:00 2001 From: LiShengguo Date: Fri, 25 Aug 2017 11:06:03 +0800 Subject: [PATCH 1/2] support for long.js writeLong(Long.fromValue(7)) --- lib/v2/encoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/v2/encoder.js b/lib/v2/encoder.js index be7dcc6..b2b8102 100644 --- a/lib/v2/encoder.js +++ b/lib/v2/encoder.js @@ -142,7 +142,7 @@ proto.writeInt = function (val) { * ``` */ proto.writeLong = function (val) { - if (typeof val !== 'number' && utility.isSafeNumberString(val)) { + if (typeof val !== 'number' && utility.isSafeNumberString(val + '')) { val = Number(val); } From 83f65312735baa305d48ffba4ccc09432fe628dd Mon Sep 17 00:00:00 2001 From: lsg Date: Thu, 19 Oct 2017 15:24:20 +0800 Subject: [PATCH 2/2] test case from Long.fromNumber(0) --- test/long.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/long.test.js b/test/long.test.js index 1ce594f..c43a517 100644 --- a/test/long.test.js +++ b/test/long.test.js @@ -46,6 +46,10 @@ describe('long.test.js', function () { hessian.encode(java.long(0)), new Buffer(['L'.charCodeAt(0), 0, 0, 0, 0, 0, 0, 0, 0]) ); + assert.deepEqual( + hessian.encode(Long.fromNumber(0)), + new Buffer(['L'.charCodeAt(0), 0, 0, 0, 0, 0, 0, 0, 0]) + ); }); it('should write and read equal java impl', function () {