Permalink
Browse files

Change all 'instanceof Array' to 'Array.isArray(foo)'

  • Loading branch information...
1 parent 7ba931e commit 9fc42093ba2f0d85cd080c0c94fe4c18efa920fb @smfreegard smfreegard committed Jul 3, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 connection.js
  2. +2 −2 dsn.js
  3. +1 −1 outbound.js
  4. +1 −1 smtp_client.js
  5. +1 −1 tests/fixtures/stub.js
View
2 connection.js
@@ -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 {
View
4 dsn.js
@@ -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);
View
2 outbound.js
@@ -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 ];
}
View
2 smtp_client.js
@@ -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) {
View
2 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) {

0 comments on commit 9fc4209

Please sign in to comment.