Skip to content

Commit 495a2cc

Browse files
Merge branch 'master' of github.com:alexgorbatchev/node-browser-builtins
2 parents 5592543 + 5719cc6 commit 495a2cc

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

builtin/assert.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ assert.AssertionError = function AssertionError(options) {
3737
Error.captureStackTrace(this, stackStartFunction);
3838
}
3939
};
40+
41+
// assert.AssertionError instanceof Error
4042
util.inherits(assert.AssertionError, Error);
4143

4244
function replacer(key, value) {
@@ -73,10 +75,6 @@ assert.AssertionError.prototype.toString = function() {
7375
}
7476
};
7577

76-
// assert.AssertionError instanceof Error
77-
78-
assert.AssertionError.__proto__ = Error.prototype;
79-
8078
// At present only the three keys mentioned above are used and
8179
// understood by the spec. Implementations or sub modules can pass
8280
// other keys to the AssertionError's constructor - they will be

builtin/util.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ exports.inspect = function(obj, showHidden, depth, colors) {
4141
'regexp': 'red' }[styleType];
4242

4343
if (style) {
44-
return '\033[' + styles[style][0] + 'm' + str +
45-
'\033[' + styles[style][1] + 'm';
44+
return '\u001b[' + styles[style][0] + 'm' + str +
45+
'\u001b[' + styles[style][1] + 'm';
4646
} else {
4747
return str;
4848
}
@@ -227,24 +227,18 @@ exports.inspect = function(obj, showHidden, depth, colors) {
227227

228228

229229
function isArray(ar) {
230-
return ar instanceof Array ||
231-
Array.isArray(ar) ||
232-
(ar && ar !== Object.prototype && isArray(ar.__proto__));
230+
return Array.isArray(ar) ||
231+
(typeof ar === 'object' && Object.prototype.toString.call(ar) === '[object Array]');
233232
}
234233

235234

236235
function isRegExp(re) {
237-
return re instanceof RegExp ||
238-
(typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]');
236+
typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]';
239237
}
240238

241239

242240
function isDate(d) {
243-
if (d instanceof Date) return true;
244-
if (typeof d !== 'object') return false;
245-
var properties = Date.prototype && Object_getOwnPropertyNames(Date.prototype);
246-
var proto = d.__proto__ && Object_getOwnPropertyNames(d.__proto__);
247-
return JSON.stringify(proto) === JSON.stringify(properties);
241+
return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]';
248242
}
249243

250244
function pad(n) {

0 commit comments

Comments
 (0)