Linted everything, removed semistandard
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
const deepFreeze = obj =>
|
||||
Object.keys(obj).forEach(
|
||||
prop =>
|
||||
!obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
|
||||
!(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
|
||||
) || Object.freeze(obj);
|
||||
module.exports = deepFreeze;
|
||||
|
||||
@ -2,7 +2,7 @@ const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
: Object.values(obj).reduce((acc, val) => {
|
||||
if (acc !== undefined) return acc;
|
||||
if (typeof val === 'object') return dig(val, target);
|
||||
}, undefined);
|
||||
if (acc !== undefined) return acc;
|
||||
if (typeof val === 'object') return dig(val, target);
|
||||
}, undefined);
|
||||
module.exports = dig;
|
||||
|
||||
@ -3,9 +3,9 @@ const elo = ([...ratings], kFactor = 32, selfRating) => {
|
||||
const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400));
|
||||
const newRating = (rating, i) =>
|
||||
(selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a));
|
||||
if (ratings.length === 2) {
|
||||
if (ratings.length === 2)
|
||||
return [newRating(a, 1), newRating(b, 0)];
|
||||
}
|
||||
|
||||
for (let i = 0, len = ratings.length; i < len; i++) {
|
||||
let j = i;
|
||||
while (j < len - 1) {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const factorial = n =>
|
||||
n < 0
|
||||
? (() => {
|
||||
throw new TypeError('Negative numbers are not allowed!');
|
||||
})()
|
||||
throw new TypeError('Negative numbers are not allowed!');
|
||||
})()
|
||||
: n <= 1
|
||||
? 1
|
||||
: n * factorial(n - 1);
|
||||
|
||||
@ -15,4 +15,4 @@ test("getImages returns an Array", () => {
|
||||
test("getImages removes duplicates from images Array", () => {
|
||||
expect(getImages(TEST_HTML, false).length).toBeLessThanOrEqual(getImages(TEST_HTML, true).length);
|
||||
expect(getImages(TEST_HTML, true)).toEqual(expect.arrayContaining(getImages(TEST_HTML, false)));
|
||||
});\n
|
||||
});
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null;
|
||||
const isPrimitive = val => Object(val) !== val;
|
||||
module.exports = isPrimitive;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const remove = (arr, func) =>
|
||||
Array.isArray(arr)
|
||||
? arr.filter(func).reduce((acc, val) => {
|
||||
arr.splice(arr.indexOf(val), 1);
|
||||
return acc.concat(val);
|
||||
}, [])
|
||||
arr.splice(arr.indexOf(val), 1);
|
||||
return acc.concat(val);
|
||||
}, [])
|
||||
: [];
|
||||
module.exports = remove;
|
||||
|
||||
2
test/squareSum/squareSum.js
Normal file
2
test/squareSum/squareSum.js
Normal file
@ -0,0 +1,2 @@
|
||||
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||
module.exports = squareSum;
|
||||
6
test/squareSum/squareSum.test.js
Normal file
6
test/squareSum/squareSum.test.js
Normal file
@ -0,0 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const squareSum = require('./squareSum.js');
|
||||
|
||||
test('squareSum is a Function', () => {
|
||||
expect(squareSum).toBeInstanceOf(Function);
|
||||
});
|
||||
@ -14,7 +14,7 @@ const throttle = (fn, wait) => {
|
||||
fn.apply(context, args);
|
||||
lastTime = Date.now();
|
||||
}
|
||||
}, wait - (Date.now() - lastTime));
|
||||
}, Math.max(wait - (Date.now() - lastTime), 0));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user