From d5637e67c9d01763c2cb4c202413b4d5890e0486 Mon Sep 17 00:00:00 2001 From: Brendan Ashworth Date: Mon, 15 Jun 2015 21:52:06 -0700 Subject: [PATCH] buffer: fix cyclic dependency with util PR-URL: https://github.com/nodejs/io.js/pull/1988 Fixes: https://github.com/nodejs/io.js/issues/1987 Reviewed-By: Roman Reiss --- lib/buffer.js | 5 ++--- test/parallel/test-util.js | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 81fe904a8b76c0..619b735fe7e74b 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -3,7 +3,6 @@ const binding = process.binding('buffer'); const smalloc = process.binding('smalloc'); -const util = require('util'); const internalUtil = require('internal/util'); const alloc = smalloc.alloc; const truncate = smalloc.truncate; @@ -457,7 +456,7 @@ Buffer.prototype.fill = function fill(val, start, end) { // XXX remove in v0.13 -Buffer.prototype.get = util.deprecate(function get(offset) { +Buffer.prototype.get = internalUtil.deprecate(function get(offset) { offset = ~~offset; if (offset < 0 || offset >= this.length) throw new RangeError('index out of range'); @@ -466,7 +465,7 @@ Buffer.prototype.get = util.deprecate(function get(offset) { // XXX remove in v0.13 -Buffer.prototype.set = util.deprecate(function set(offset, v) { +Buffer.prototype.set = internalUtil.deprecate(function set(offset, v) { offset = ~~offset; if (offset < 0 || offset >= this.length) throw new RangeError('index out of range'); diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 2795d3ecd68662..79e104546b7f37 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -71,6 +71,10 @@ assert.equal(true, util.isPrimitive(Infinity)); assert.equal(true, util.isPrimitive(NaN)); assert.equal(true, util.isPrimitive(Symbol('symbol'))); +// isBuffer +assert.equal(false, util.isBuffer('foo')); +assert.equal(true, util.isBuffer(new Buffer('foo'))); + // _extend assert.deepEqual(util._extend({a:1}), {a:1}); assert.deepEqual(util._extend({a:1}, []), {a:1});