Skip to content

Commit

Permalink
formatting and style
Browse files Browse the repository at this point in the history
  • Loading branch information
cuth committed Mar 3, 2020
1 parent 230eaaa commit ea6022c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
38 changes: 18 additions & 20 deletions lib/type.js
Original file line number Diff line number Diff line change
@@ -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;
}, {});
58 changes: 32 additions & 26 deletions spec/pxtorem-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit ea6022c

Please sign in to comment.