From 914cdf7456a1e1359bb6d186c3d85be0f7a7d108 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 25 Nov 2013 01:16:16 -0800 Subject: [PATCH] make toJSON() use node 0.12 behavior; make test reliable --- index.js | 5 ++++- test/basic.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dca0103..5426938 100644 --- a/index.js +++ b/index.js @@ -264,7 +264,10 @@ function BufferToString (encoding, start, end) { } function BufferToJSON () { - return Array.prototype.slice.call(this, 0) + return { + type: 'Buffer', + data: Array.prototype.slice.call(this, 0) + } } // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) diff --git a/test/basic.js b/test/basic.js index f53e7fc..8075b61 100644 --- a/test/basic.js +++ b/test/basic.js @@ -38,7 +38,7 @@ test('buffer toJSON()', function (t) { var data = [1, 2, 3, 4] t.deepEqual( new B(data).toJSON(), - new Buffer(data).toJSON() + { type: 'Buffer', data: [1,2,3,4] } ) t.end() }) -- 2.34.1