Permalink
Browse files

use `Array.isArray` for all such checks

  • Loading branch information...
1 parent 6377181 commit 6f0a64a3e39c8ce8a8f53b589197700acb0943a8 @davidchambers davidchambers committed Feb 3, 2013
Showing with 6 additions and 9 deletions.
  1. +2 −3 lib/cheerio.js
  2. +2 −3 lib/parse.js
  3. +2 −3 lib/render.js
View
5 lib/cheerio.js
@@ -7,7 +7,6 @@ var path = require('path'),
parse = require('./parse'),
evaluate = parse.evaluate,
updateDOM = parse.update,
- isArray = Array.isArray,
_ = require('underscore');
/*
@@ -47,7 +46,7 @@ var Cheerio = module.exports = function(selector, context, root) {
if (selector.cheerio) return selector;
// $(dom)
- if (selector.name || isArray(selector))
+ if (selector.name || Array.isArray(selector))
return this.make(selector, this);
// $(<html>)
@@ -124,7 +123,7 @@ var isHtml = function(str) {
Cheerio.prototype.make = function(dom, context) {
if (dom.cheerio) return dom;
- dom = (_.isArray(dom)) ? dom : [dom];
+ dom = (Array.isArray(dom)) ? dom : [dom];
return _.extend(context || new Cheerio(), dom, { length: dom.length });
};
View
5 lib/parse.js
@@ -3,8 +3,7 @@
*/
var htmlparser = require('htmlparser2'),
_ = require('underscore'),
- isTag = require('./utils').isTag,
- isArray = Array.isArray;
+ isTag = require('./utils').isTag;
/*
Parser
@@ -80,7 +79,7 @@ var connect = exports.connect = function(dom, parent) {
*/
var update = exports.update = function(arr, parent) {
// normalize
- arr = isArray(arr) ? arr : [arr];
+ if (!Array.isArray(arr)) arr = [arr];
// Update neighbors
for (var i = 0; i < arr.length; i++) {
View
5 lib/render.js
@@ -1,8 +1,7 @@
/*
Module dependencies
*/
-var _ = require('underscore'),
- isArray = Array.isArray;
+var _ = require('underscore');
/*
Boolean Attributes
@@ -65,7 +64,7 @@ var tagType = {
};
var render = module.exports = function(dom, opts) {
- dom = (isArray(dom) || dom.cheerio) ? dom : [dom];
+ if (!Array.isArray(dom) && !dom.cheerio) dom = [dom];
opts = opts || {};
var output = [],

0 comments on commit 6f0a64a

Please sign in to comment.