diff --git a/lib/type.js b/lib/type.js index 5e01f7e..dda695f 100644 --- a/lib/type.js +++ b/lib/type.js @@ -1,23 +1,21 @@ -var type = function (s) { - return Object.prototype.toString.call(s).slice(8, -1).toLowerCase(); -}; +const type = s => + Object.prototype.toString + .call(s) + .slice(8, -1) + .toLowerCase(); -var types = [ - 'String', - 'Array', - 'Undefined', - 'Boolean', - 'Number', - 'Function', - 'Symbol', - 'Object' +const types = [ + "String", + "Array", + "Undefined", + "Boolean", + "Number", + "Function", + "Symbol", + "Object" ]; -types.forEach(function (str) { - type['is' + str] = function (val) { - return type(val) === str.toLowerCase(); - }; -}); - -module.exports = type; - +module.exports = types.reduce((acc, str) => { + acc["is" + str] = val => type(val) === str.toLowerCase(); + return acc; +}, {}); diff --git a/spec/pxtorem-spec.js b/spec/pxtorem-spec.js index ff422d4..2e4f63f 100644 --- a/spec/pxtorem-spec.js +++ b/spec/pxtorem-spec.js @@ -495,30 +495,36 @@ describe("filter-prop-list", function() { }); }); -describe('exclude', function () { - it('should ignore file path with exclude RegEx', function () { - var options = { - exclude: /exclude/i - }; - var processed = postcss(pxtorem(options)).process(basicCSS, { from: 'exclude/path' }).css; - expect(processed).toBe(basicCSS); - }); - - it('should not ignore file path with exclude String', function () { - var options = { - exclude: 'exclude' - }; - var processed = postcss(pxtorem(options)).process(basicCSS, { from: 'exclude/path' }).css; - expect(processed).toBe(basicCSS); - }); - - it('should not ignore file path with exclude function', function () { - var options = { - exclude: function (file) { - return file.indexOf('exclude') !== -1; - } - }; - var processed = postcss(pxtorem(options)).process(basicCSS, { from: 'exclude/path' }).css; - expect(processed).toBe(basicCSS); - }); +describe("exclude", function() { + it("should ignore file path with exclude RegEx", function() { + var options = { + exclude: /exclude/i + }; + var processed = postcss(pxtorem(options)).process(basicCSS, { + from: "exclude/path" + }).css; + expect(processed).toBe(basicCSS); + }); + + it("should not ignore file path with exclude String", function() { + var options = { + exclude: "exclude" + }; + var processed = postcss(pxtorem(options)).process(basicCSS, { + from: "exclude/path" + }).css; + expect(processed).toBe(basicCSS); + }); + + it("should not ignore file path with exclude function", function() { + var options = { + exclude: function(file) { + return file.indexOf("exclude") !== -1; + } + }; + var processed = postcss(pxtorem(options)).process(basicCSS, { + from: "exclude/path" + }).css; + expect(processed).toBe(basicCSS); + }); });