Skip to content

Commit

Permalink
Change all 'instanceof Array' to 'Array.isArray(foo)'
Browse files Browse the repository at this point in the history
  • Loading branch information
smfreegard committed Jul 3, 2012
1 parent 7ba931e commit 9fc4209
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion connection.js
Expand Up @@ -272,7 +272,7 @@ Connection.prototype.respond = function(code, msg, func) {
code = msg.code;
msg = msg.reply;
}
if (!(typeof msg === 'object' && msg.constructor.name === 'Array')) {
if (!(Array.isArray(msg))) {
// msg not an array, make it so:
messages = [ '' + msg ];
} else {
Expand Down
4 changes: 2 additions & 2 deletions dsn.js
Expand Up @@ -76,8 +76,8 @@ function DSN(code, msg, def, subject, detail) {
this.det = (enum_status_codes[this.sub][detail]) ? detail : 0;
this.default_msg = enum_status_codes[this.sub][this.det];
// Handle multi-line replies
if (typeof(this.msg) === 'object' && this.msg.constructor === Array) {
this.reply = new Array;
if (Array.isArray(this.msg)) {
this.reply = [];
var m;
while (m = this.msg.shift()) {
this.reply.push([this.cls, this.sub, this.det].join('.') + ' ' + m);
Expand Down
2 changes: 1 addition & 1 deletion outbound.js
Expand Up @@ -107,7 +107,7 @@ exports.send_email = function () {
}

// Make sure to is an array
if (!(to instanceof Array)) {
if (!(Array.isArray(to))) {
// turn into an array
to = [ to ];
}
Expand Down
2 changes: 1 addition & 1 deletion smtp_client.js
Expand Up @@ -146,7 +146,7 @@ SMTPClient.prototype.start_data = function (data) {
if (data instanceof Function) {
this.send_data = data;
}
else if (data instanceof Array) {
else if (Array.isArray(data)) {
var data_marker = 0;
this.send_data = function () {
while (data_marker < data.length) {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/stub.js
@@ -1,7 +1,7 @@
module.exports = function (returnValue) {
function stub() {
stub.called = true;
if (Object.prototype.toString.call(stub.args) === '[object Array]') {
if (Array.isArray(stub.args)) {
stub.args.push(arguments);
}
else if (stub.args) {
Expand Down

0 comments on commit 9fc4209

Please sign in to comment.