Merge branch 'master' into master
This commit is contained in:
3
test/dayOfYear/dayOfYear.js
Normal file
3
test/dayOfYear/dayOfYear.js
Normal file
@ -0,0 +1,3 @@
|
||||
const dayOfYear = date =>
|
||||
Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
|
||||
module.exports = dayOfYear;
|
||||
6
test/dayOfYear/dayOfYear.test.js
Normal file
6
test/dayOfYear/dayOfYear.test.js
Normal file
@ -0,0 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const dayOfYear = require('./dayOfYear.js');
|
||||
|
||||
test('dayOfYear is a Function', () => {
|
||||
expect(dayOfYear).toBeInstanceOf(Function);
|
||||
});
|
||||
2
test/indentString/indentString.js
Normal file
2
test/indentString/indentString.js
Normal file
@ -0,0 +1,2 @@
|
||||
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
||||
module.exports = indentString;
|
||||
12
test/indentString/indentString.test.js
Normal file
12
test/indentString/indentString.test.js
Normal file
@ -0,0 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const indentString = require('./indentString.js');
|
||||
|
||||
test('indentString is a Function', () => {
|
||||
expect(indentString).toBeInstanceOf(Function);
|
||||
});
|
||||
test('indentString is a Function', () => {
|
||||
expect(indentString('Lorem\nIpsum', 2)).toBe(' Lorem\n Ipsum');
|
||||
});
|
||||
test('indentString is a Function', () => {
|
||||
expect(indentString('Lorem\nIpsum', 2, '_')).toBe('__Lorem\n__Ipsum');
|
||||
});
|
||||
2
test/isAfterDate/isAfterDate.js
Normal file
2
test/isAfterDate/isAfterDate.js
Normal file
@ -0,0 +1,2 @@
|
||||
const isAfterDate = (dateA, dateB) => dateA > dateB;
|
||||
module.exports = isAfterDate;
|
||||
12
test/isAfterDate/isAfterDate.test.js
Normal file
12
test/isAfterDate/isAfterDate.test.js
Normal file
@ -0,0 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isAfterDate = require('./isAfterDate.js');
|
||||
|
||||
test('isAfterDate is a Function', () => {
|
||||
expect(isAfterDate).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isAfterDate produces the correct result', () => {
|
||||
expect(isAfterDate(new Date(2010, 10, 21), new Date(2010, 10, 20))).toBeTruthy();
|
||||
});
|
||||
test('isBeforeDate produces the correct result', () => {
|
||||
expect(isAfterDate(new Date(2010, 10, 20), new Date(2010, 10, 21))).toBeFalsy();
|
||||
});
|
||||
2
test/isBeforeDate/isBeforeDate.js
Normal file
2
test/isBeforeDate/isBeforeDate.js
Normal file
@ -0,0 +1,2 @@
|
||||
const isBeforeDate = (dateA, dateB) => dateA < dateB;
|
||||
module.exports = isBeforeDate;
|
||||
13
test/isBeforeDate/isBeforeDate.test.js
Normal file
13
test/isBeforeDate/isBeforeDate.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const isBeforeDate = require('./isBeforeDate.js');
|
||||
|
||||
test('isBeforeDate is a Function', () => {
|
||||
expect(isBeforeDate).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isBeforeDate produces the correct result', () => {
|
||||
expect(isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21))).toBeTruthy();
|
||||
});
|
||||
test('isBeforeDate produces the correct result', () => {
|
||||
expect(isBeforeDate(new Date(2010, 10, 21), new Date(2010, 10, 20))).toBeFalsy();
|
||||
});
|
||||
|
||||
2
test/isSameDate/isSameDate.js
Normal file
2
test/isSameDate/isSameDate.js
Normal file
@ -0,0 +1,2 @@
|
||||
const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString();
|
||||
module.exports = isSameDate;
|
||||
12
test/isSameDate/isSameDate.test.js
Normal file
12
test/isSameDate/isSameDate.test.js
Normal file
@ -0,0 +1,12 @@
|
||||
const expect = require('expect');
|
||||
const isSameDate = require('./isSameDate.js');
|
||||
|
||||
test('isSameDate is a Function', () => {
|
||||
expect(isSameDate).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isSameDate produces the correct result', () => {
|
||||
expect(isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20))).toBeTruthy();
|
||||
});
|
||||
test('isSameDate produces the correct result', () => {
|
||||
expect(isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 21))).toBeFalsy();
|
||||
});
|
||||
@ -1,3 +1,2 @@
|
||||
const mask = (cc, num = 4, mask = '*') =>
|
||||
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
||||
const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask);
|
||||
module.exports = mask;
|
||||
|
||||
2
test/maxDate/maxDate.js
Normal file
2
test/maxDate/maxDate.js
Normal file
@ -0,0 +1,2 @@
|
||||
const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
|
||||
module.exports = maxDate;
|
||||
15
test/maxDate/maxDate.test.js
Normal file
15
test/maxDate/maxDate.test.js
Normal file
@ -0,0 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const maxDate = require('./maxDate.js');
|
||||
|
||||
test('maxDate is a Function', () => {
|
||||
expect(maxDate).toBeInstanceOf(Function);
|
||||
});
|
||||
test('maxDate produces the maximum date', () => {
|
||||
const array = [
|
||||
new Date(2017, 4, 13),
|
||||
new Date(2018, 2, 12),
|
||||
new Date(2016, 0, 10),
|
||||
new Date(2016, 0, 9)
|
||||
];
|
||||
expect(maxDate(array)).toEqual(new Date(2018, 2, 12));
|
||||
});
|
||||
2
test/minDate/minDate.js
Normal file
2
test/minDate/minDate.js
Normal file
@ -0,0 +1,2 @@
|
||||
const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
|
||||
module.exports = minDate;
|
||||
15
test/minDate/minDate.test.js
Normal file
15
test/minDate/minDate.test.js
Normal file
@ -0,0 +1,15 @@
|
||||
const expect = require('expect');
|
||||
const minDate = require('./minDate.js');
|
||||
|
||||
test('minDate is a Function', () => {
|
||||
expect(minDate).toBeInstanceOf(Function);
|
||||
});
|
||||
test('minDate produces the maximum date', () => {
|
||||
const array = [
|
||||
new Date(2017, 4, 13),
|
||||
new Date(2018, 2, 12),
|
||||
new Date(2016, 0, 10),
|
||||
new Date(2016, 0, 9)
|
||||
];
|
||||
expect(minDate(array)).toEqual(new Date(2016, 0, 9));
|
||||
});
|
||||
2
test/pipeLog/pipeLog.js
Normal file
2
test/pipeLog/pipeLog.js
Normal file
@ -0,0 +1,2 @@
|
||||
const pipeLog = data => console.log(data) || data;
|
||||
module.exports = pipeLog;
|
||||
6
test/pipeLog/pipeLog.test.js
Normal file
6
test/pipeLog/pipeLog.test.js
Normal file
@ -0,0 +1,6 @@
|
||||
const expect = require('expect');
|
||||
const pipeLog = require('./pipeLog.js');
|
||||
|
||||
test('pipeLog is a Function', () => {
|
||||
expect(pipeLog).toBeInstanceOf(Function);
|
||||
});
|
||||
6
test/shank/shank.js
Normal file
6
test/shank/shank.js
Normal file
@ -0,0 +1,6 @@
|
||||
const shank = (arr, index = 0, delCount = 0, ...elements) =>
|
||||
arr
|
||||
.slice(0, index)
|
||||
.concat(elements)
|
||||
.concat(arr.slice(index + delCount));
|
||||
module.exports = shank;
|
||||
22
test/shank/shank.test.js
Normal file
22
test/shank/shank.test.js
Normal file
@ -0,0 +1,22 @@
|
||||
const expect = require("expect");
|
||||
const shank = require("./shank.js");
|
||||
|
||||
test("shank is a Function", () => {
|
||||
expect(shank).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
const names = ['alpha', 'bravo', 'charlie'];
|
||||
|
||||
test("Returns an array with the added elements.", () => {
|
||||
expect(shank(names, 1, 0, 'delta')).toEqual(['alpha', 'delta', 'bravo', 'charlie']);
|
||||
});
|
||||
|
||||
test("Returns an array with the removed elements.", () => {
|
||||
expect(shank(names, 1, 1)).toEqual(['alpha', 'charlie']);
|
||||
});
|
||||
|
||||
test("Does not mutate the original array", () => {
|
||||
shank(names, 1, 0, 'delta');
|
||||
expect(names).toEqual(['alpha', 'bravo', 'charlie']);
|
||||
});
|
||||
|
||||
3429
test/testlog
3429
test/testlog
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user