diff options
author | James M Snell <jasnell@gmail.com> | 2017-06-19 16:06:02 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-07-24 07:24:53 -0700 |
commit | 355523fcfb3314f1ebc7e57342fb7b22c506f3fd (patch) | |
tree | 980676410c7d77fa90fdf0b720ed1150f411e509 /lib/assert.js | |
parent | 45b730ec42e5dc16ef4c76529a6ec0e979bfc83b (diff) | |
download | android-node-v8-355523fcfb3314f1ebc7e57342fb7b22c506f3fd.tar.gz android-node-v8-355523fcfb3314f1ebc7e57342fb7b22c506f3fd.tar.bz2 android-node-v8-355523fcfb3314f1ebc7e57342fb7b22c506f3fd.zip |
buffer: refactor module.exports, imports
* Move to more efficient module.exports pattern
* Refactor requires
* Eliminate circular dependency on internal/buffer
* Add names to some functions
* Fix circular dependency error in assert.js
PR-URL: https://github.com/nodejs/node/pull/13807
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib/assert.js')
-rw-r--r-- | lib/assert.js | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/assert.js b/lib/assert.js index e224118e1d..f7a3350db1 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -24,7 +24,6 @@ const { compare } = process.binding('buffer'); const util = require('util'); const { isSet, isMap } = process.binding('util'); const { objectToString } = require('internal/util'); -const { Buffer } = require('buffer'); const errors = require('internal/errors'); // The assert module provides functions that throw @@ -119,6 +118,7 @@ function areSimilarRegExps(a, b) { // barrier including the Buffer.from operation takes the advantage of the faster // compare otherwise. 300 was the number after which compare became faster. function areSimilarTypedArrays(a, b) { + const { from } = require('buffer').Buffer; const len = a.byteLength; if (len !== b.byteLength) { return false; @@ -131,12 +131,8 @@ function areSimilarTypedArrays(a, b) { } return true; } - return compare(Buffer.from(a.buffer, - a.byteOffset, - len), - Buffer.from(b.buffer, - b.byteOffset, - b.byteLength)) === 0; + return compare(from(a.buffer, a.byteOffset, len), + from(b.buffer, b.byteOffset, b.byteLength)) === 0; } function isFloatTypedArrayTag(tag) { |