From 6592aee9ecc5d67a638e329460af61fd4cf2fbe3 Mon Sep 17 00:00:00 2001 From: Peter Hayes Date: Fri, 24 Jun 2016 12:59:38 -0700 Subject: [PATCH] fix lint --- index.js | 24 +++++++++++++----------- test/index.js | 2 -- util.js | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index c948fd6..f6ff865 100644 --- a/index.js +++ b/index.js @@ -11,21 +11,23 @@ var getDefaults = function(){ return defaults; }; -if(!Array.isArray) { +if (!Array.isArray) { Array.isArray = function (arg) { - return Object.prototype.toString.call(arg) == '[object Array]'; + return Object.prototype.toString.call(arg) === '[object Array]'; }; } var objectEach = function(obj, cb){ - for(var k in obj){ - cb(obj[k], k); + for (var k in obj){ + if (obj.hasOwnProperty(k)) { + cb(obj[k], k); + } } }; var argsArray = function(obj){ - if (!obj) return []; - if (Array.isArray(obj)) return slice.call(obj); + if (!obj) { return []; } + if (Array.isArray(obj)) { return obj.slice() ; } var args = []; objectEach(obj, function(v, k){ args[k] = v; @@ -38,8 +40,8 @@ var arrLast = function(arr){ }; var arrFlatten = function(input, output) { - if (!output) output = []; - for(var i = 0; i < input.length; i++){ + if (!output) { output = []; } + for (var i = 0; i < input.length; i++){ var value = input[i]; if (Array.isArray(value)) { arrFlatten(value, output); @@ -172,7 +174,7 @@ UrlGrey.prototype.query = function(mergeObject){ // read the object out var oldQuery = querystring.parse(this.queryString()); objectEach(mergeObject, function(v, k){ - if (v == null || v === false){ + if (v === null || v === false){ delete oldQuery[k]; } else { oldQuery[k] = v; @@ -203,7 +205,7 @@ UrlGrey.prototype.rawQuery = function(mergeObject){ // read the object out var oldQuery = querystring.parse(this.queryString()); objectEach(mergeObject, function(v, k){ - if (v == null || v === false){ + if (v === null || v === false){ delete oldQuery[k]; } else { oldQuery[k] = v; @@ -329,7 +331,7 @@ UrlGrey.prototype.toString = function(){ var retval = this.protocol() + '://'; if (this.protocol() !== 'file'){ var userinfo = p.username + ':' + p.password; - if (userinfo != ':'){ + if (userinfo !== ':'){ retval += userinfo + '@'; } retval += p.hostname; diff --git a/test/index.js b/test/index.js index 922aaa0..d7ed273 100644 --- a/test/index.js +++ b/test/index.js @@ -6,8 +6,6 @@ if (!isBrowser){ var urlgrey = require('../index'); } -var expect = chai.expect(); - describe("urlgrey", function(){ describe("chainability", function(){ it("doesn't over-write the original url", function(){ diff --git a/util.js b/util.js index 071097a..62bcccb 100644 --- a/util.js +++ b/util.js @@ -1,12 +1,12 @@ var isObject = function (o){ - return (typeof o == "object") && + return (typeof o === "object") && (o !== null) && (Object.prototype.toString.call(o) === '[object Object]'); }; exports.isObject = isObject; exports.isString = function(o){ - return Object.prototype.toString.call(o) == '[object String]'; + return Object.prototype.toString.call(o) === '[object String]'; }; exports.isArray = function(o){ return Object.prototype.toString.call(o) === "[object Array]"; @@ -39,7 +39,7 @@ exports.keys = function (object) { if ('ab'.substr(-1) !== 'b') { exports.substr = function (str, start, length) { // did we get a negative start, calculate how much it is from the beginning of the string - if (start < 0) start = str.length + start; + if (start < 0) { start = str.length + start; } // call the original function return str.substr(start, length); @@ -52,7 +52,7 @@ if ('ab'.substr(-1) !== 'b') { // Array.prototype.map is supported in IE9 exports.map = function map(xs, fn) { - if (xs.map) return xs.map(fn); + if (xs.map) { return xs.map(fn); } var out = new Array(xs.length); for (var i = 0; i < xs.length; i++) { out[i] = fn(xs[i], i, xs);