Add semicolon for tdd exports
This commit is contained in:
@ -61,7 +61,7 @@ snippetFiles
|
|||||||
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
||||||
|
|
||||||
// Export template for snippetName.js
|
// Export template for snippetName.js
|
||||||
const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName}`.trim();
|
const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName};`.trim();
|
||||||
|
|
||||||
// Export template for snippetName.test.js which generates a example test & other information
|
// Export template for snippetName.test.js which generates a example test & other information
|
||||||
const exportTest = [
|
const exportTest = [
|
||||||
|
|||||||
@ -2,4 +2,4 @@ const JSONToDate = arr => {
|
|||||||
const dt = new Date(parseInt(arr.toString().substr(6)));
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
};
|
};
|
||||||
module.exports = JSONToDate
|
module.exports = JSONToDate;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const JSONToFile = (obj, filename) =>
|
const JSONToFile = (obj, filename) =>
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
module.exports = JSONToFile
|
module.exports = JSONToFile;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
module.exports = RGBToHex
|
module.exports = RGBToHex;
|
||||||
@ -7,4 +7,4 @@ args
|
|||||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||||
.replace(/\?/g, '&')
|
.replace(/\?/g, '&')
|
||||||
.replace('&', '?');
|
.replace('&', '?');
|
||||||
module.exports = URLJoin
|
module.exports = URLJoin;
|
||||||
@ -2,4 +2,4 @@ const UUIDGeneratorBrowser = () =>
|
|||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
);
|
);
|
||||||
module.exports = UUIDGeneratorBrowser
|
module.exports = UUIDGeneratorBrowser;
|
||||||
@ -3,4 +3,4 @@ const UUIDGeneratorNode = () =>
|
|||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
);
|
);
|
||||||
module.exports = UUIDGeneratorNode
|
module.exports = UUIDGeneratorNode;
|
||||||
@ -8,4 +8,4 @@ acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
module.exports = anagrams
|
module.exports = anagrams;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const arrayToHtmlList = (arr, listID) =>
|
const arrayToHtmlList = (arr, listID) =>
|
||||||
arr.map(item => (document.querySelector('#' + listID).innerHTML += `<li>${item}</li>`));
|
arr.map(item => (document.querySelector('#' + listID).innerHTML += `<li>${item}</li>`));
|
||||||
module.exports = arrayToHtmlList
|
module.exports = arrayToHtmlList;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
|
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
|
||||||
module.exports = ary
|
module.exports = ary;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const atob = str => new Buffer(str, 'base64').toString('binary');
|
const atob = str => new Buffer(str, 'base64').toString('binary');
|
||||||
module.exports = atob
|
module.exports = atob;
|
||||||
@ -5,4 +5,4 @@ return fn(args);
|
|||||||
return e instanceof Error ? e : new Error(e);
|
return e instanceof Error ? e : new Error(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = attempt
|
module.exports = attempt;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length;
|
const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length;
|
||||||
module.exports = average
|
module.exports = average;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
const averageBy = (arr, fn) =>
|
const averageBy = (arr, fn) =>
|
||||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
|
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
|
||||||
arr.length;
|
arr.length;
|
||||||
module.exports = averageBy
|
module.exports = averageBy;
|
||||||
@ -5,4 +5,4 @@ if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1);
|
|||||||
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
|
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
|
||||||
return mid;
|
return mid;
|
||||||
}
|
}
|
||||||
module.exports = binarySearch
|
module.exports = binarySearch;
|
||||||
@ -2,4 +2,4 @@ const bind = (fn, context, ...args) =>
|
|||||||
function() {
|
function() {
|
||||||
return fn.apply(context, args.concat(...arguments));
|
return fn.apply(context, args.concat(...arguments));
|
||||||
};
|
};
|
||||||
module.exports = bind
|
module.exports = bind;
|
||||||
@ -7,4 +7,4 @@ return f.apply(obj);
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
module.exports = bindAll
|
module.exports = bindAll;
|
||||||
@ -2,4 +2,4 @@ const bindKey = (context, fn, ...args) =>
|
|||||||
function() {
|
function() {
|
||||||
return context[fn].apply(context, args.concat(...arguments));
|
return context[fn].apply(context, args.concat(...arguments));
|
||||||
};
|
};
|
||||||
module.exports = bindKey
|
module.exports = bindKey;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
const bottomVisible = () =>
|
const bottomVisible = () =>
|
||||||
document.documentElement.clientHeight + window.scrollY >=
|
document.documentElement.clientHeight + window.scrollY >=
|
||||||
(document.documentElement.scrollHeight || document.documentElement.clientHeight);
|
(document.documentElement.scrollHeight || document.documentElement.clientHeight);
|
||||||
module.exports = bottomVisible
|
module.exports = bottomVisible;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const btoa = str => new Buffer(str, 'binary').toString('base64');
|
const btoa = str => new Buffer(str, 'binary').toString('base64');
|
||||||
module.exports = btoa
|
module.exports = btoa;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const byteSize = str => new Blob([str]).size;
|
const byteSize = str => new Blob([str]).size;
|
||||||
module.exports = byteSize
|
module.exports = byteSize;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const call = (key, ...args) => context => context[key](...args);
|
const call = (key, ...args) => context => context[key](...args);
|
||||||
module.exports = call
|
module.exports = call;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const capitalize = ([first, ...rest], lowerRest = false) =>
|
const capitalize = ([first, ...rest], lowerRest = false) =>
|
||||||
first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
|
first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
|
||||||
module.exports = capitalize
|
module.exports = capitalize;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
||||||
module.exports = capitalizeEveryWord
|
module.exports = capitalizeEveryWord;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const castArray = val => (Array.isArray(val) ? val : [val]);
|
const castArray = val => (Array.isArray(val) ? val : [val]);
|
||||||
module.exports = castArray
|
module.exports = castArray;
|
||||||
@ -3,4 +3,4 @@ let curr = 0;
|
|||||||
const next = () => fns[curr++](next);
|
const next = () => fns[curr++](next);
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
module.exports = chainAsync
|
module.exports = chainAsync;
|
||||||
@ -2,4 +2,4 @@ const chunk = (arr, size) =>
|
|||||||
Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
|
Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
|
||||||
arr.slice(i * size, i * size + size)
|
arr.slice(i * size, i * size + size)
|
||||||
);
|
);
|
||||||
module.exports = chunk
|
module.exports = chunk;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
|
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
|
||||||
module.exports = clampNumber
|
module.exports = clampNumber;
|
||||||
@ -8,4 +8,4 @@ delete obj[key];
|
|||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
module.exports = cleanObj
|
module.exports = cleanObj;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
||||||
module.exports = cloneRegExp
|
module.exports = cloneRegExp;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
|
const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
|
||||||
module.exports = coalesce
|
module.exports = coalesce;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const coalesceFactory = valid => (...args) => args.find(valid);
|
const coalesceFactory = valid => (...args) => args.find(valid);
|
||||||
module.exports = coalesceFactory
|
module.exports = coalesceFactory;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1);
|
const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1);
|
||||||
module.exports = collatz
|
module.exports = collatz;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const collectInto = fn => (...args) => fn(args);
|
const collectInto = fn => (...args) => fn(args);
|
||||||
module.exports = collectInto
|
module.exports = collectInto;
|
||||||
@ -16,4 +16,4 @@ bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
|
|||||||
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
||||||
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
||||||
});
|
});
|
||||||
module.exports = colorize
|
module.exports = colorize;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const compact = arr => arr.filter(Boolean);
|
const compact = arr => arr.filter(Boolean);
|
||||||
module.exports = compact
|
module.exports = compact;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
|
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
|
||||||
module.exports = compose
|
module.exports = compose;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
||||||
module.exports = composeRight
|
module.exports = composeRight;
|
||||||
@ -15,4 +15,4 @@ document.getSelection().removeAllRanges();
|
|||||||
document.getSelection().addRange(selected);
|
document.getSelection().addRange(selected);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = copyToClipboard
|
module.exports = copyToClipboard;
|
||||||
@ -3,4 +3,4 @@ arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) =>
|
|||||||
acc[val] = (acc[val] || 0) + 1;
|
acc[val] = (acc[val] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
module.exports = countBy
|
module.exports = countBy;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);
|
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);
|
||||||
module.exports = countOccurrences
|
module.exports = countOccurrences;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
|
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
|
||||||
module.exports = countVowels
|
module.exports = countVowels;
|
||||||
@ -3,4 +3,4 @@ const el = document.createElement('div');
|
|||||||
el.innerHTML = str;
|
el.innerHTML = str;
|
||||||
return el.firstElementChild;
|
return el.firstElementChild;
|
||||||
};
|
};
|
||||||
module.exports = createElement
|
module.exports = createElement;
|
||||||
@ -12,4 +12,4 @@ const i = (this.hub[event] || []).findIndex(h => h === handler);
|
|||||||
if (i > -1) this.hub[event].splice(i, 1);
|
if (i > -1) this.hub[event].splice(i, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
module.exports = createEventHub
|
module.exports = createEventHub;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const currentURL = () => window.location.href;
|
const currentURL = () => window.location.href;
|
||||||
module.exports = currentURL
|
module.exports = currentURL;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const curry = (fn, arity = fn.length, ...args) =>
|
const curry = (fn, arity = fn.length, ...args) =>
|
||||||
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
||||||
module.exports = curry
|
module.exports = curry;
|
||||||
@ -7,4 +7,4 @@ clearTimeout(inDebounce);
|
|||||||
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
module.exports = debounce
|
module.exports = debounce;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const decapitalize = ([first, ...rest], upperRest = false) =>
|
const decapitalize = ([first, ...rest], upperRest = false) =>
|
||||||
first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));
|
first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));
|
||||||
module.exports = decapitalize
|
module.exports = decapitalize;
|
||||||
@ -5,4 +5,4 @@ key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[ke
|
|||||||
);
|
);
|
||||||
return clone;
|
return clone;
|
||||||
};
|
};
|
||||||
module.exports = deepClone
|
module.exports = deepClone;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
|
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
|
||||||
module.exports = deepFlatten
|
module.exports = deepFlatten;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
||||||
module.exports = defaults
|
module.exports = defaults;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
|
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
|
||||||
module.exports = defer
|
module.exports = defer;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
|
const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
|
||||||
module.exports = delay
|
module.exports = delay;
|
||||||
@ -2,4 +2,4 @@ const detectDeviceType = () =>
|
|||||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
||||||
? 'Mobile'
|
? 'Mobile'
|
||||||
: 'Desktop';
|
: 'Desktop';
|
||||||
module.exports = detectDeviceType
|
module.exports = detectDeviceType;
|
||||||
@ -2,4 +2,4 @@ const difference = (a, b) => {
|
|||||||
const s = new Set(b);
|
const s = new Set(b);
|
||||||
return a.filter(x => !s.has(x));
|
return a.filter(x => !s.has(x));
|
||||||
};
|
};
|
||||||
module.exports = difference
|
module.exports = difference;
|
||||||
@ -2,4 +2,4 @@ const differenceBy = (a, b, fn) => {
|
|||||||
const s = new Set(b.map(v => fn(v)));
|
const s = new Set(b.map(v => fn(v)));
|
||||||
return a.filter(x => !s.has(fn(x)));
|
return a.filter(x => !s.has(fn(x)));
|
||||||
};
|
};
|
||||||
module.exports = differenceBy
|
module.exports = differenceBy;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
|
const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
|
||||||
module.exports = differenceWith
|
module.exports = differenceWith;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const digitize = n => [...`${n}`].map(i => parseInt(i));
|
const digitize = n => [...`${n}`].map(i => parseInt(i));
|
||||||
module.exports = digitize
|
module.exports = digitize;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
|
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
|
||||||
module.exports = distance
|
module.exports = distance;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const drop = (arr, n = 1) => arr.slice(n);
|
const drop = (arr, n = 1) => arr.slice(n);
|
||||||
module.exports = drop
|
module.exports = drop;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const dropRight = (arr, n = 1) => arr.slice(0, -n);
|
const dropRight = (arr, n = 1) => arr.slice(0, -n);
|
||||||
module.exports = dropRight
|
module.exports = dropRight;
|
||||||
@ -2,4 +2,4 @@ const dropRightWhile = (arr, func) => {
|
|||||||
while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);
|
while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
module.exports = dropRightWhile
|
module.exports = dropRightWhile;
|
||||||
@ -2,4 +2,4 @@ const dropWhile = (arr, func) => {
|
|||||||
while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);
|
while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
module.exports = dropWhile
|
module.exports = dropWhile;
|
||||||
@ -6,4 +6,4 @@ return partiallyVisible
|
|||||||
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
||||||
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
||||||
};
|
};
|
||||||
module.exports = elementIsVisibleInViewport
|
module.exports = elementIsVisibleInViewport;
|
||||||
@ -16,4 +16,4 @@ j++;
|
|||||||
}
|
}
|
||||||
return ratings;
|
return ratings;
|
||||||
};
|
};
|
||||||
module.exports = elo
|
module.exports = elo;
|
||||||
@ -8,4 +8,4 @@ let keys = Object.keys(a);
|
|||||||
if (keys.length !== Object.keys(b).length) return false;
|
if (keys.length !== Object.keys(b).length) return false;
|
||||||
return keys.every(k => equals(a[k], b[k]));
|
return keys.every(k => equals(a[k], b[k]));
|
||||||
};
|
};
|
||||||
module.exports = equals
|
module.exports = equals;
|
||||||
@ -10,4 +10,4 @@ tag =>
|
|||||||
'"': '"'
|
'"': '"'
|
||||||
}[tag] || tag)
|
}[tag] || tag)
|
||||||
);
|
);
|
||||||
module.exports = escapeHTML
|
module.exports = escapeHTML;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
module.exports = escapeRegExp
|
module.exports = escapeRegExp;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
|
const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
|
||||||
module.exports = everyNth
|
module.exports = everyNth;
|
||||||
@ -5,4 +5,4 @@ shortHex
|
|||||||
.split('')
|
.split('')
|
||||||
.map(x => x + x)
|
.map(x => x + x)
|
||||||
.join('');
|
.join('');
|
||||||
module.exports = extendHex
|
module.exports = extendHex;
|
||||||
@ -4,4 +4,4 @@ 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);
|
: n <= 1 ? 1 : n * factorial(n - 1);
|
||||||
module.exports = factorial
|
module.exports = factorial;
|
||||||
@ -17,4 +17,4 @@ return acc;
|
|||||||
}, []);
|
}, []);
|
||||||
return primes ? array.filter(isPrime) : array;
|
return primes ? array.filter(isPrime) : array;
|
||||||
};
|
};
|
||||||
module.exports = factors
|
module.exports = factors;
|
||||||
@ -3,4 +3,4 @@ Array.from({ length: n }).reduce(
|
|||||||
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
module.exports = fibonacci
|
module.exports = fibonacci;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const fibonacciCountUntilNum = num =>
|
const fibonacciCountUntilNum = num =>
|
||||||
Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||||
module.exports = fibonacciCountUntilNum
|
module.exports = fibonacciCountUntilNum;
|
||||||
@ -5,4 +5,4 @@ return Array.from({ length: n }).reduce(
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
module.exports = fibonacciUntilNum
|
module.exports = fibonacciUntilNum;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
||||||
module.exports = filterNonUnique
|
module.exports = filterNonUnique;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
||||||
module.exports = findKey
|
module.exports = findKey;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
|
const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
|
||||||
module.exports = findLast
|
module.exports = findLast;
|
||||||
@ -3,4 +3,4 @@ arr
|
|||||||
.map((val, i) => [i, val])
|
.map((val, i) => [i, val])
|
||||||
.filter(val => fn(val[1], val[0], arr))
|
.filter(val => fn(val[1], val[0], arr))
|
||||||
.slice(-1)[0][0];
|
.slice(-1)[0][0];
|
||||||
module.exports = findLastIndex
|
module.exports = findLastIndex;
|
||||||
@ -2,4 +2,4 @@ const findLastKey = (obj, fn) =>
|
|||||||
Object.keys(obj)
|
Object.keys(obj)
|
||||||
.reverse()
|
.reverse()
|
||||||
.find(key => fn(obj[key], key, obj));
|
.find(key => fn(obj[key], key, obj));
|
||||||
module.exports = findLastKey
|
module.exports = findLastKey;
|
||||||
@ -2,4 +2,4 @@ const flatten = (arr, depth = 1) =>
|
|||||||
depth != 1
|
depth != 1
|
||||||
? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), [])
|
? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), [])
|
||||||
: arr.reduce((a, v) => a.concat(v), []);
|
: arr.reduce((a, v) => a.concat(v), []);
|
||||||
module.exports = flatten
|
module.exports = flatten;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const flip = fn => (first, ...rest) => fn(...rest, first);
|
const flip = fn => (first, ...rest) => fn(...rest, first);
|
||||||
module.exports = flip
|
module.exports = flip;
|
||||||
@ -3,4 +3,4 @@ arr
|
|||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach(callback);
|
.forEach(callback);
|
||||||
module.exports = forEachRight
|
module.exports = forEachRight;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||||
module.exports = forOwn
|
module.exports = forOwn;
|
||||||
@ -2,4 +2,4 @@ const forOwnRight = (obj, fn) =>
|
|||||||
Object.keys(obj)
|
Object.keys(obj)
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach(key => fn(obj[key], key, obj));
|
.forEach(key => fn(obj[key], key, obj));
|
||||||
module.exports = forOwnRight
|
module.exports = forOwnRight;
|
||||||
@ -12,4 +12,4 @@ return Object.entries(time)
|
|||||||
.map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))
|
.map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
module.exports = formatDuration
|
module.exports = formatDuration;
|
||||||
@ -3,4 +3,4 @@ str
|
|||||||
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
||||||
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
|
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
module.exports = fromCamelCase
|
module.exports = fromCamelCase;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const functionName = fn => (console.debug(fn.name), fn);
|
const functionName = fn => (console.debug(fn.name), fn);
|
||||||
module.exports = functionName
|
module.exports = functionName;
|
||||||
@ -3,4 +3,4 @@ const functions = (obj, inherited = false) =>
|
|||||||
? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
|
? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
|
||||||
: Object.keys(obj)
|
: Object.keys(obj)
|
||||||
).filter(key => typeof obj[key] === 'function');
|
).filter(key => typeof obj[key] === 'function');
|
||||||
module.exports = functions
|
module.exports = functions;
|
||||||
@ -2,4 +2,4 @@ const gcd = (...arr) => {
|
|||||||
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||||
return [...arr].reduce((a, b) => _gcd(a, b));
|
return [...arr].reduce((a, b) => _gcd(a, b));
|
||||||
};
|
};
|
||||||
module.exports = gcd
|
module.exports = gcd;
|
||||||
@ -2,4 +2,4 @@ const geometricProgression = (end, start = 1, step = 2) =>
|
|||||||
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
(v, i) => start * step ** i
|
(v, i) => start * step ** i
|
||||||
);
|
);
|
||||||
module.exports = geometricProgression
|
module.exports = geometricProgression;
|
||||||
@ -6,4 +6,4 @@ s
|
|||||||
.filter(t => t !== '')
|
.filter(t => t !== '')
|
||||||
.reduce((prev, cur) => prev && prev[cur], from)
|
.reduce((prev, cur) => prev && prev[cur], from)
|
||||||
);
|
);
|
||||||
module.exports = get
|
module.exports = get;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
|
const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
|
||||||
module.exports = getColonTimeFromDate
|
module.exports = getColonTimeFromDate;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
||||||
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||||
module.exports = getDaysDiffBetweenDates
|
module.exports = getDaysDiffBetweenDates;
|
||||||
@ -2,4 +2,4 @@ const getMeridiemSuffixOfInteger = num =>
|
|||||||
num === 0 || num === 24
|
num === 0 || num === 24
|
||||||
? 12 + 'am'
|
? 12 + 'am'
|
||||||
: num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';
|
: num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';
|
||||||
module.exports = getMeridiemSuffixOfInteger
|
module.exports = getMeridiemSuffixOfInteger;
|
||||||
@ -2,4 +2,4 @@ const getScrollPosition = (el = window) => ({
|
|||||||
x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,
|
x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,
|
||||||
y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop
|
y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop
|
||||||
});
|
});
|
||||||
module.exports = getScrollPosition
|
module.exports = getScrollPosition;
|
||||||
@ -1,2 +1,2 @@
|
|||||||
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
|
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
|
||||||
module.exports = getStyle
|
module.exports = getStyle;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
const getType = v =>
|
const getType = v =>
|
||||||
v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
|
v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
|
||||||
module.exports = getType
|
module.exports = getType;
|
||||||
@ -3,4 +3,4 @@ const getURLParameters = url =>
|
|||||||
(a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),
|
(a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
module.exports = getURLParameters
|
module.exports = getURLParameters;
|
||||||
@ -3,4 +3,4 @@ arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) =>
|
|||||||
acc[val] = (acc[val] || []).concat(arr[i]);
|
acc[val] = (acc[val] || []).concat(arr[i]);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
module.exports = groupBy
|
module.exports = groupBy;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user