Skip to content

Commit

Permalink
lib: remove circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
BridgeAR committed Aug 17, 2017
1 parent cd9f81d commit bf18fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
11 changes: 5 additions & 6 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
'use strict';

const { compare } = process.binding('buffer');
const util = require('util');
const { isSet, isMap } = process.binding('util');
const { isSet, isMap, isDate, isRegExp } = process.binding('util');
const { objectToString } = require('internal/util');
const errors = require('internal/errors');

Expand Down Expand Up @@ -186,11 +185,11 @@ function strictDeepEqual(actual, expected) {
// Skip testing the part below and continue in the callee function.
return;
}
if (util.isDate(actual)) {
if (isDate(actual)) {
if (actual.getTime() !== expected.getTime()) {
return false;
}
} else if (util.isRegExp(actual)) {
} else if (isRegExp(actual)) {
if (!areSimilarRegExps(actual, expected)) {
return false;
}
Expand Down Expand Up @@ -219,10 +218,10 @@ function looseDeepEqual(actual, expected) {
if (expected === null || typeof expected !== 'object') {
return false;
}
if (util.isDate(actual) && util.isDate(expected)) {
if (isDate(actual) && isDate(expected)) {
return actual.getTime() === expected.getTime();
}
if (util.isRegExp(actual) && util.isRegExp(expected)) {
if (isRegExp(actual) && isRegExp(expected)) {
return areSimilarRegExps(actual, expected);
}
const actualTag = objectToString(actual);
Expand Down
17 changes: 2 additions & 15 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const errors = require('internal/errors');
const { TextDecoder, TextEncoder } = require('internal/encoding');
const { isBuffer } = require('buffer').Buffer;

const { errname } = process.binding('uv');

Expand Down Expand Up @@ -1131,6 +1132,7 @@ module.exports = exports = {
inspect,
isArray: Array.isArray,
isBoolean,
isBuffer,
isNull,
isNullOrUndefined,
isNumber,
Expand Down Expand Up @@ -1162,18 +1164,3 @@ module.exports = exports = {
'util.puts is deprecated. Use console.log instead.',
'DEP0027')
};

// Avoid a circular dependency
var isBuffer;
Object.defineProperty(exports, 'isBuffer', {
configurable: true,
enumerable: true,
get() {
if (!isBuffer)
isBuffer = require('buffer').Buffer.isBuffer;
return isBuffer;
},
set(val) {
isBuffer = val;
}
});

0 comments on commit bf18fe1

Please sign in to comment.