Merge remote-tracking branch 'origin/master'
This commit is contained in:
27
README.md
27
README.md
@ -375,6 +375,7 @@ average(1, 2, 3);
|
|||||||
* [`hexToRGB`](#hextorgb-)
|
* [`hexToRGB`](#hextorgb-)
|
||||||
* [`httpGet`](#httpget)
|
* [`httpGet`](#httpget)
|
||||||
* [`httpPost`](#httppost)
|
* [`httpPost`](#httppost)
|
||||||
|
* [`nthArg`](#ntharg)
|
||||||
* [`parseCookie`](#parsecookie)
|
* [`parseCookie`](#parsecookie)
|
||||||
* [`prettyBytes`](#prettybytes)
|
* [`prettyBytes`](#prettybytes)
|
||||||
* [`randomHexColorCode`](#randomhexcolorcode)
|
* [`randomHexColorCode`](#randomhexcolorcode)
|
||||||
@ -6396,6 +6397,32 @@ Logs: {
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### nthArg
|
||||||
|
|
||||||
|
Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned.
|
||||||
|
|
||||||
|
Use `Array.slice()` to get the desired argument at index `n`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const nthArg = n => (...args) => args.slice(n)[0];
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
const third = nthArg(2);
|
||||||
|
third(1, 2, 3); // 3
|
||||||
|
third(1, 2); // undefined
|
||||||
|
const last = nthArg(-1);
|
||||||
|
last(1, 2, 3, 4, 5); // 5
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### parseCookie
|
### parseCookie
|
||||||
|
|
||||||
Parse an HTTP Cookie header string and return an object of all cookie name-value pairs.
|
Parse an HTTP Cookie header string and return an object of all cookie name-value pairs.
|
||||||
|
|||||||
137
dist/_30s.es5.js
vendored
137
dist/_30s.es5.js
vendored
File diff suppressed because one or more lines are too long
2
dist/_30s.es5.min.js
vendored
2
dist/_30s.es5.min.js
vendored
File diff suppressed because one or more lines are too long
63
dist/_30s.esm.js
vendored
63
dist/_30s.esm.js
vendored
@ -62,6 +62,8 @@ const capitalize = ([first, ...rest], lowerRest = false) =>
|
|||||||
|
|
||||||
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
||||||
|
|
||||||
|
const castArray = val => (Array.isArray(val) ? val : [val]);
|
||||||
|
|
||||||
const chainAsync = fns => {
|
const chainAsync = fns => {
|
||||||
let curr = 0;
|
let curr = 0;
|
||||||
const next = () => fns[curr++](next);
|
const next = () => fns[curr++](next);
|
||||||
@ -161,6 +163,14 @@ const curry = (fn, arity = fn.length, ...args) =>
|
|||||||
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(''));
|
||||||
|
|
||||||
|
const deepClone = obj => {
|
||||||
|
let clone = Object.assign({}, obj);
|
||||||
|
Object.keys(clone).forEach(
|
||||||
|
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
|
||||||
|
);
|
||||||
|
return clone;
|
||||||
|
};
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
||||||
@ -269,8 +279,15 @@ const fibonacci = n =>
|
|||||||
|
|
||||||
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
||||||
|
|
||||||
|
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
||||||
|
|
||||||
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
||||||
|
|
||||||
|
const findLastKey = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.find(key => fn(obj[key], key, obj));
|
||||||
|
|
||||||
const flatten = (arr, depth = 1) =>
|
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), [])
|
||||||
@ -470,9 +487,11 @@ const intersection = (a, b) => {
|
|||||||
return a.filter(x => s.has(x));
|
return a.filter(x => s.has(x));
|
||||||
};
|
};
|
||||||
|
|
||||||
const invertKeyValues = obj =>
|
const invertKeyValues = (obj, fn) =>
|
||||||
Object.keys(obj).reduce((acc, key) => {
|
Object.keys(obj).reduce((acc, key) => {
|
||||||
acc[obj[key]] = key;
|
const val = fn ? fn(obj[key]) : obj[key];
|
||||||
|
acc[val] = acc[val] || [];
|
||||||
|
acc[val].push(key);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
@ -492,6 +511,8 @@ const isBoolean = val => typeof val === 'boolean';
|
|||||||
|
|
||||||
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
||||||
|
|
||||||
|
const isEmpty = val => val == null || !(Object.keys(val) || val).length;
|
||||||
|
|
||||||
const isEven = num => num % 2 === 0;
|
const isEven = num => num % 2 === 0;
|
||||||
|
|
||||||
const isFunction = val => typeof val === 'function';
|
const isFunction = val => typeof val === 'function';
|
||||||
@ -506,6 +527,8 @@ const isNumber = val => typeof val === 'number';
|
|||||||
|
|
||||||
const isObject = obj => obj === Object(obj);
|
const isObject = obj => obj === Object(obj);
|
||||||
|
|
||||||
|
const isObjectLike = val => val !== null && typeof val === 'object';
|
||||||
|
|
||||||
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
|
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
|
||||||
|
|
||||||
const isPrime = num => {
|
const isPrime = num => {
|
||||||
@ -602,6 +625,17 @@ const mapValues = (obj, fn) =>
|
|||||||
const mask = (cc, num = 4, mask = '*') =>
|
const mask = (cc, num = 4, mask = '*') =>
|
||||||
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
||||||
|
|
||||||
|
const matches = (obj, source) =>
|
||||||
|
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
|
||||||
|
|
||||||
|
const matchesWith = (obj, source, fn) =>
|
||||||
|
Object.keys(source).every(
|
||||||
|
key =>
|
||||||
|
obj.hasOwnProperty(key) && fn
|
||||||
|
? fn(obj[key], source[key], key, obj, source)
|
||||||
|
: obj[key] == source[key]
|
||||||
|
);
|
||||||
|
|
||||||
const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||||
|
|
||||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
@ -637,6 +671,8 @@ const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
|||||||
|
|
||||||
const negate = func => (...args) => !func(...args);
|
const negate = func => (...args) => !func(...args);
|
||||||
|
|
||||||
|
const nthArg = n => (...args) => args.slice(n)[0];
|
||||||
|
|
||||||
const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];
|
const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];
|
||||||
|
|
||||||
const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
|
const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
|
||||||
@ -715,6 +751,8 @@ const orderBy = (arr, props, orders) =>
|
|||||||
}, 0)
|
}, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
|
||||||
|
|
||||||
const palindrome = str => {
|
const palindrome = str => {
|
||||||
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
||||||
return (
|
return (
|
||||||
@ -1022,7 +1060,13 @@ const toSnakeCase = str =>
|
|||||||
|
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
|
|
||||||
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
|
t.getDate()
|
||||||
|
).padStart(2, '0')}`;
|
||||||
|
};
|
||||||
|
|
||||||
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
|
|
||||||
@ -1069,6 +1113,17 @@ const zip = (...arrays) => {
|
|||||||
const zipObject = (props, values) =>
|
const zipObject = (props, values) =>
|
||||||
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
||||||
|
|
||||||
var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,atob,average,averageBy,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defaults,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
|
const zipWith = (...arrays) => {
|
||||||
|
const length = arrays.length;
|
||||||
|
let fn = length > 1 ? arrays[length - 1] : undefined;
|
||||||
|
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
||||||
|
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||||
|
const result = Array.from({ length: maxLength }).map((_, i) => {
|
||||||
|
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
||||||
|
});
|
||||||
|
return fn ? result.map(arr => fn(...arr)) : result;
|
||||||
|
};
|
||||||
|
|
||||||
|
var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,atob,average,averageBy,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepClone,deepFlatten,defaults,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,palindrome,parseCookie,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,zipWith,}
|
||||||
|
|
||||||
export default imports;
|
export default imports;
|
||||||
|
|||||||
63
dist/_30s.js
vendored
63
dist/_30s.js
vendored
@ -68,6 +68,8 @@ const capitalize = ([first, ...rest], lowerRest = false) =>
|
|||||||
|
|
||||||
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
||||||
|
|
||||||
|
const castArray = val => (Array.isArray(val) ? val : [val]);
|
||||||
|
|
||||||
const chainAsync = fns => {
|
const chainAsync = fns => {
|
||||||
let curr = 0;
|
let curr = 0;
|
||||||
const next = () => fns[curr++](next);
|
const next = () => fns[curr++](next);
|
||||||
@ -167,6 +169,14 @@ const curry = (fn, arity = fn.length, ...args) =>
|
|||||||
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(''));
|
||||||
|
|
||||||
|
const deepClone = obj => {
|
||||||
|
let clone = Object.assign({}, obj);
|
||||||
|
Object.keys(clone).forEach(
|
||||||
|
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
|
||||||
|
);
|
||||||
|
return clone;
|
||||||
|
};
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
||||||
@ -275,8 +285,15 @@ const fibonacci = n =>
|
|||||||
|
|
||||||
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
||||||
|
|
||||||
|
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
||||||
|
|
||||||
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
||||||
|
|
||||||
|
const findLastKey = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.find(key => fn(obj[key], key, obj));
|
||||||
|
|
||||||
const flatten = (arr, depth = 1) =>
|
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), [])
|
||||||
@ -476,9 +493,11 @@ const intersection = (a, b) => {
|
|||||||
return a.filter(x => s.has(x));
|
return a.filter(x => s.has(x));
|
||||||
};
|
};
|
||||||
|
|
||||||
const invertKeyValues = obj =>
|
const invertKeyValues = (obj, fn) =>
|
||||||
Object.keys(obj).reduce((acc, key) => {
|
Object.keys(obj).reduce((acc, key) => {
|
||||||
acc[obj[key]] = key;
|
const val = fn ? fn(obj[key]) : obj[key];
|
||||||
|
acc[val] = acc[val] || [];
|
||||||
|
acc[val].push(key);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
@ -498,6 +517,8 @@ const isBoolean = val => typeof val === 'boolean';
|
|||||||
|
|
||||||
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
||||||
|
|
||||||
|
const isEmpty = val => val == null || !(Object.keys(val) || val).length;
|
||||||
|
|
||||||
const isEven = num => num % 2 === 0;
|
const isEven = num => num % 2 === 0;
|
||||||
|
|
||||||
const isFunction = val => typeof val === 'function';
|
const isFunction = val => typeof val === 'function';
|
||||||
@ -512,6 +533,8 @@ const isNumber = val => typeof val === 'number';
|
|||||||
|
|
||||||
const isObject = obj => obj === Object(obj);
|
const isObject = obj => obj === Object(obj);
|
||||||
|
|
||||||
|
const isObjectLike = val => val !== null && typeof val === 'object';
|
||||||
|
|
||||||
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
|
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
|
||||||
|
|
||||||
const isPrime = num => {
|
const isPrime = num => {
|
||||||
@ -608,6 +631,17 @@ const mapValues = (obj, fn) =>
|
|||||||
const mask = (cc, num = 4, mask = '*') =>
|
const mask = (cc, num = 4, mask = '*') =>
|
||||||
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
||||||
|
|
||||||
|
const matches = (obj, source) =>
|
||||||
|
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
|
||||||
|
|
||||||
|
const matchesWith = (obj, source, fn) =>
|
||||||
|
Object.keys(source).every(
|
||||||
|
key =>
|
||||||
|
obj.hasOwnProperty(key) && fn
|
||||||
|
? fn(obj[key], source[key], key, obj, source)
|
||||||
|
: obj[key] == source[key]
|
||||||
|
);
|
||||||
|
|
||||||
const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||||
|
|
||||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
@ -643,6 +677,8 @@ const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
|||||||
|
|
||||||
const negate = func => (...args) => !func(...args);
|
const negate = func => (...args) => !func(...args);
|
||||||
|
|
||||||
|
const nthArg = n => (...args) => args.slice(n)[0];
|
||||||
|
|
||||||
const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];
|
const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];
|
||||||
|
|
||||||
const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
|
const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
|
||||||
@ -721,6 +757,8 @@ const orderBy = (arr, props, orders) =>
|
|||||||
}, 0)
|
}, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
|
||||||
|
|
||||||
const palindrome = str => {
|
const palindrome = str => {
|
||||||
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
||||||
return (
|
return (
|
||||||
@ -1028,7 +1066,13 @@ const toSnakeCase = str =>
|
|||||||
|
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
|
|
||||||
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
|
t.getDate()
|
||||||
|
).padStart(2, '0')}`;
|
||||||
|
};
|
||||||
|
|
||||||
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
|
|
||||||
@ -1075,7 +1119,18 @@ const zip = (...arrays) => {
|
|||||||
const zipObject = (props, values) =>
|
const zipObject = (props, values) =>
|
||||||
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
||||||
|
|
||||||
var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,atob,average,averageBy,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defaults,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
|
const zipWith = (...arrays) => {
|
||||||
|
const length = arrays.length;
|
||||||
|
let fn = length > 1 ? arrays[length - 1] : undefined;
|
||||||
|
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
||||||
|
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||||
|
const result = Array.from({ length: maxLength }).map((_, i) => {
|
||||||
|
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
||||||
|
});
|
||||||
|
return fn ? result.map(arr => fn(...arr)) : result;
|
||||||
|
};
|
||||||
|
|
||||||
|
var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,atob,average,averageBy,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepClone,deepFlatten,defaults,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,palindrome,parseCookie,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,zipWith,}
|
||||||
|
|
||||||
return imports;
|
return imports;
|
||||||
|
|
||||||
|
|||||||
2
dist/_30s.min.js
vendored
2
dist/_30s.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
test/castArray/castArray.js
Normal file
2
test/castArray/castArray.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const castArray = val => (Array.isArray(val) ? val : [val]);
|
||||||
|
module.exports = castArray
|
||||||
13
test/castArray/castArray.test.js
Normal file
13
test/castArray/castArray.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const castArray = require('./castArray.js');
|
||||||
|
|
||||||
|
test('Testing castArray', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof castArray === 'function', 'castArray is a Function');
|
||||||
|
//t.deepEqual(castArray(args..), 'Expected');
|
||||||
|
//t.equal(castArray(args..), 'Expected');
|
||||||
|
//t.false(castArray(args..), 'Expected');
|
||||||
|
//t.throws(castArray(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
8
test/deepClone/deepClone.js
Normal file
8
test/deepClone/deepClone.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const deepClone = obj => {
|
||||||
|
let clone = Object.assign({}, obj);
|
||||||
|
Object.keys(clone).forEach(
|
||||||
|
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
|
||||||
|
);
|
||||||
|
return clone;
|
||||||
|
};
|
||||||
|
module.exports = deepClone
|
||||||
13
test/deepClone/deepClone.test.js
Normal file
13
test/deepClone/deepClone.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const deepClone = require('./deepClone.js');
|
||||||
|
|
||||||
|
test('Testing deepClone', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof deepClone === 'function', 'deepClone is a Function');
|
||||||
|
//t.deepEqual(deepClone(args..), 'Expected');
|
||||||
|
//t.equal(deepClone(args..), 'Expected');
|
||||||
|
//t.false(deepClone(args..), 'Expected');
|
||||||
|
//t.throws(deepClone(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
2
test/findKey/findKey.js
Normal file
2
test/findKey/findKey.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
||||||
|
module.exports = findKey
|
||||||
13
test/findKey/findKey.test.js
Normal file
13
test/findKey/findKey.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const findKey = require('./findKey.js');
|
||||||
|
|
||||||
|
test('Testing findKey', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof findKey === 'function', 'findKey is a Function');
|
||||||
|
//t.deepEqual(findKey(args..), 'Expected');
|
||||||
|
//t.equal(findKey(args..), 'Expected');
|
||||||
|
//t.false(findKey(args..), 'Expected');
|
||||||
|
//t.throws(findKey(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
5
test/findLastKey/findLastKey.js
Normal file
5
test/findLastKey/findLastKey.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const findLastKey = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.find(key => fn(obj[key], key, obj));
|
||||||
|
module.exports = findLastKey
|
||||||
13
test/findLastKey/findLastKey.test.js
Normal file
13
test/findLastKey/findLastKey.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const findLastKey = require('./findLastKey.js');
|
||||||
|
|
||||||
|
test('Testing findLastKey', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof findLastKey === 'function', 'findLastKey is a Function');
|
||||||
|
//t.deepEqual(findLastKey(args..), 'Expected');
|
||||||
|
//t.equal(findLastKey(args..), 'Expected');
|
||||||
|
//t.false(findLastKey(args..), 'Expected');
|
||||||
|
//t.throws(findLastKey(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
@ -1,6 +1,8 @@
|
|||||||
const invertKeyValues = obj =>
|
const invertKeyValues = (obj, fn) =>
|
||||||
Object.keys(obj).reduce((acc, key) => {
|
Object.keys(obj).reduce((acc, key) => {
|
||||||
acc[obj[key]] = key;
|
const val = fn ? fn(obj[key]) : obj[key];
|
||||||
|
acc[val] = acc[val] || [];
|
||||||
|
acc[val].push(key);
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
module.exports = invertKeyValues
|
module.exports = invertKeyValues
|
||||||
2
test/isEmpty/isEmpty.js
Normal file
2
test/isEmpty/isEmpty.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const isEmpty = val => val == null || !(Object.keys(val) || val).length;
|
||||||
|
module.exports = isEmpty
|
||||||
13
test/isEmpty/isEmpty.test.js
Normal file
13
test/isEmpty/isEmpty.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const isEmpty = require('./isEmpty.js');
|
||||||
|
|
||||||
|
test('Testing isEmpty', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof isEmpty === 'function', 'isEmpty is a Function');
|
||||||
|
//t.deepEqual(isEmpty(args..), 'Expected');
|
||||||
|
//t.equal(isEmpty(args..), 'Expected');
|
||||||
|
//t.false(isEmpty(args..), 'Expected');
|
||||||
|
//t.throws(isEmpty(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
2
test/isObjectLike/isObjectLike.js
Normal file
2
test/isObjectLike/isObjectLike.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const isObjectLike = val => val !== null && typeof val === 'object';
|
||||||
|
module.exports = isObjectLike
|
||||||
13
test/isObjectLike/isObjectLike.test.js
Normal file
13
test/isObjectLike/isObjectLike.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const isObjectLike = require('./isObjectLike.js');
|
||||||
|
|
||||||
|
test('Testing isObjectLike', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof isObjectLike === 'function', 'isObjectLike is a Function');
|
||||||
|
//t.deepEqual(isObjectLike(args..), 'Expected');
|
||||||
|
//t.equal(isObjectLike(args..), 'Expected');
|
||||||
|
//t.false(isObjectLike(args..), 'Expected');
|
||||||
|
//t.throws(isObjectLike(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
3
test/matches/matches.js
Normal file
3
test/matches/matches.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const matches = (obj, source) =>
|
||||||
|
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
|
||||||
|
module.exports = matches
|
||||||
13
test/matches/matches.test.js
Normal file
13
test/matches/matches.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const matches = require('./matches.js');
|
||||||
|
|
||||||
|
test('Testing matches', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof matches === 'function', 'matches is a Function');
|
||||||
|
//t.deepEqual(matches(args..), 'Expected');
|
||||||
|
//t.equal(matches(args..), 'Expected');
|
||||||
|
//t.false(matches(args..), 'Expected');
|
||||||
|
//t.throws(matches(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
8
test/matchesWith/matchesWith.js
Normal file
8
test/matchesWith/matchesWith.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const matchesWith = (obj, source, fn) =>
|
||||||
|
Object.keys(source).every(
|
||||||
|
key =>
|
||||||
|
obj.hasOwnProperty(key) && fn
|
||||||
|
? fn(obj[key], source[key], key, obj, source)
|
||||||
|
: obj[key] == source[key]
|
||||||
|
);
|
||||||
|
module.exports = matchesWith
|
||||||
13
test/matchesWith/matchesWith.test.js
Normal file
13
test/matchesWith/matchesWith.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const matchesWith = require('./matchesWith.js');
|
||||||
|
|
||||||
|
test('Testing matchesWith', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof matchesWith === 'function', 'matchesWith is a Function');
|
||||||
|
//t.deepEqual(matchesWith(args..), 'Expected');
|
||||||
|
//t.equal(matchesWith(args..), 'Expected');
|
||||||
|
//t.false(matchesWith(args..), 'Expected');
|
||||||
|
//t.throws(matchesWith(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
2
test/nthArg/nthArg.js
Normal file
2
test/nthArg/nthArg.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const nthArg = n => (...args) => args.slice(n)[0];
|
||||||
|
module.exports = nthArg
|
||||||
13
test/nthArg/nthArg.test.js
Normal file
13
test/nthArg/nthArg.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const nthArg = require('./nthArg.js');
|
||||||
|
|
||||||
|
test('Testing nthArg', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof nthArg === 'function', 'nthArg is a Function');
|
||||||
|
//t.deepEqual(nthArg(args..), 'Expected');
|
||||||
|
//t.equal(nthArg(args..), 'Expected');
|
||||||
|
//t.false(nthArg(args..), 'Expected');
|
||||||
|
//t.throws(nthArg(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
2
test/over/over.js
Normal file
2
test/over/over.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
|
||||||
|
module.exports = over
|
||||||
13
test/over/over.test.js
Normal file
13
test/over/over.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const over = require('./over.js');
|
||||||
|
|
||||||
|
test('Testing over', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof over === 'function', 'over is a Function');
|
||||||
|
//t.deepEqual(over(args..), 'Expected');
|
||||||
|
//t.equal(over(args..), 'Expected');
|
||||||
|
//t.false(over(args..), 'Expected');
|
||||||
|
//t.throws(over(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
74
test/testlog
74
test/testlog
@ -1,4 +1,4 @@
|
|||||||
Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
Test log for: Tue Jan 23 2018 20:11:47 GMT+0000 (UTC)
|
||||||
|
|
||||||
> 30-seconds-of-code@0.0.1 test /home/travis/build/Chalarangelo/30-seconds-of-code
|
> 30-seconds-of-code@0.0.1 test /home/travis/build/Chalarangelo/30-seconds-of-code
|
||||||
> tape test/**/*.test.js | tap-spec
|
> tape test/**/*.test.js | tap-spec
|
||||||
@ -98,6 +98,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ capitalizeEveryWord is a Function
|
✔ capitalizeEveryWord is a Function
|
||||||
✔ Capitalizes the first letter of every word in a string
|
✔ Capitalizes the first letter of every word in a string
|
||||||
|
|
||||||
|
Testing castArray
|
||||||
|
|
||||||
|
✔ castArray is a Function
|
||||||
|
|
||||||
Testing chainAsync
|
Testing chainAsync
|
||||||
|
|
||||||
✔ chainAsync is a Function
|
✔ chainAsync is a Function
|
||||||
@ -200,6 +204,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
|
|
||||||
✔ decapitalize is a Function
|
✔ decapitalize is a Function
|
||||||
|
|
||||||
|
Testing deepClone
|
||||||
|
|
||||||
|
✔ deepClone is a Function
|
||||||
|
|
||||||
Testing deepFlatten
|
Testing deepFlatten
|
||||||
|
|
||||||
✔ deepFlatten is a Function
|
✔ deepFlatten is a Function
|
||||||
@ -320,10 +328,18 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ filterNonUnique is a Function
|
✔ filterNonUnique is a Function
|
||||||
✔ Filters out the non-unique values in an array
|
✔ Filters out the non-unique values in an array
|
||||||
|
|
||||||
|
Testing findKey
|
||||||
|
|
||||||
|
✔ findKey is a Function
|
||||||
|
|
||||||
Testing findLast
|
Testing findLast
|
||||||
|
|
||||||
✔ findLast is a Function
|
✔ findLast is a Function
|
||||||
|
|
||||||
|
Testing findLastKey
|
||||||
|
|
||||||
|
✔ findLastKey is a Function
|
||||||
|
|
||||||
Testing flatten
|
Testing flatten
|
||||||
|
|
||||||
✔ flatten is a Function
|
✔ flatten is a Function
|
||||||
@ -528,7 +544,17 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
Testing invertKeyValues
|
Testing invertKeyValues
|
||||||
|
|
||||||
✔ invertKeyValues is a Function
|
✔ invertKeyValues is a Function
|
||||||
✔ Inverts the key-value pairs of an object
|
|
||||||
|
✖ Inverts the key-value pairs of an object
|
||||||
|
-------------------------------------------
|
||||||
|
operator: deepEqual
|
||||||
|
expected: |-
|
||||||
|
{ 20: 'age', John: 'name' }
|
||||||
|
actual: |-
|
||||||
|
{ 20: [ 'age' ], John: [ 'name' ] }
|
||||||
|
at: Test.test (/home/travis/build/Chalarangelo/30-seconds-of-code/test/invertKeyValues/invertKeyValues.test.js:8:4)
|
||||||
|
stack: |-
|
||||||
|
|
||||||
|
|
||||||
Testing is
|
Testing is
|
||||||
|
|
||||||
@ -570,6 +596,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ isDivisible is a Function
|
✔ isDivisible is a Function
|
||||||
✔ The number 6 is divisible by 3
|
✔ The number 6 is divisible by 3
|
||||||
|
|
||||||
|
Testing isEmpty
|
||||||
|
|
||||||
|
✔ isEmpty is a Function
|
||||||
|
|
||||||
Testing isEven
|
Testing isEven
|
||||||
|
|
||||||
✔ isEven is a Function
|
✔ isEven is a Function
|
||||||
@ -617,6 +647,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ isObject({ a:1 }) is a object
|
✔ isObject({ a:1 }) is a object
|
||||||
✔ isObject(true) is not a object
|
✔ isObject(true) is not a object
|
||||||
|
|
||||||
|
Testing isObjectLike
|
||||||
|
|
||||||
|
✔ isObjectLike is a Function
|
||||||
|
|
||||||
Testing isPlainObject
|
Testing isPlainObject
|
||||||
|
|
||||||
✔ isPlainObject is a Function
|
✔ isPlainObject is a Function
|
||||||
@ -769,6 +803,14 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ Replaces all but the last num of characters with the specified mask character
|
✔ Replaces all but the last num of characters with the specified mask character
|
||||||
✔ Replaces all but the last num of characters with the specified mask character
|
✔ Replaces all but the last num of characters with the specified mask character
|
||||||
|
|
||||||
|
Testing matches
|
||||||
|
|
||||||
|
✔ matches is a Function
|
||||||
|
|
||||||
|
Testing matchesWith
|
||||||
|
|
||||||
|
✔ matchesWith is a Function
|
||||||
|
|
||||||
Testing maxBy
|
Testing maxBy
|
||||||
|
|
||||||
✔ maxBy is a Function
|
✔ maxBy is a Function
|
||||||
@ -808,6 +850,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ negate is a Function
|
✔ negate is a Function
|
||||||
✔ Negates a predicate function
|
✔ Negates a predicate function
|
||||||
|
|
||||||
|
Testing nthArg
|
||||||
|
|
||||||
|
✔ nthArg is a Function
|
||||||
|
|
||||||
Testing nthElement
|
Testing nthElement
|
||||||
|
|
||||||
✔ nthElement is a Function
|
✔ nthElement is a Function
|
||||||
@ -858,6 +904,10 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ Returns a sorted array of objects ordered by properties and orders.
|
✔ Returns a sorted array of objects ordered by properties and orders.
|
||||||
✔ Returns a sorted array of objects ordered by properties and orders.
|
✔ Returns a sorted array of objects ordered by properties and orders.
|
||||||
|
|
||||||
|
Testing over
|
||||||
|
|
||||||
|
✔ over is a Function
|
||||||
|
|
||||||
Testing palindrome
|
Testing palindrome
|
||||||
|
|
||||||
✔ palindrome is a Function
|
✔ palindrome is a Function
|
||||||
@ -1296,9 +1346,23 @@ Test log for: Mon Jan 22 2018 20:11:29 GMT+0000 (UTC)
|
|||||||
✔ zipObject(string) throws an error
|
✔ zipObject(string) throws an error
|
||||||
✔ zipObject(test, string) throws an error
|
✔ zipObject(test, string) throws an error
|
||||||
|
|
||||||
|
Testing zipWith
|
||||||
|
|
||||||
total: 563
|
✔ zipWith is a Function
|
||||||
passing: 563
|
|
||||||
duration: 314ms
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Failed Tests: There was 1 failure
|
||||||
|
|
||||||
|
Testing invertKeyValues
|
||||||
|
|
||||||
|
✖ Inverts the key-value pairs of an object
|
||||||
|
|
||||||
|
|
||||||
|
total: 574
|
||||||
|
passing: 573
|
||||||
|
failing: 1
|
||||||
|
duration: 440ms
|
||||||
|
|
||||||
|
|
||||||
|
undefined
|
||||||
@ -1,2 +1,8 @@
|
|||||||
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
|
t.getDate()
|
||||||
|
).padStart(2, '0')}`;
|
||||||
|
};
|
||||||
module.exports = tomorrow
|
module.exports = tomorrow
|
||||||
11
test/zipWith/zipWith.js
Normal file
11
test/zipWith/zipWith.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const zipWith = (...arrays) => {
|
||||||
|
const length = arrays.length;
|
||||||
|
let fn = length > 1 ? arrays[length - 1] : undefined;
|
||||||
|
fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined;
|
||||||
|
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||||
|
const result = Array.from({ length: maxLength }).map((_, i) => {
|
||||||
|
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
||||||
|
});
|
||||||
|
return fn ? result.map(arr => fn(...arr)) : result;
|
||||||
|
};
|
||||||
|
module.exports = zipWith
|
||||||
13
test/zipWith/zipWith.test.js
Normal file
13
test/zipWith/zipWith.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const zipWith = require('./zipWith.js');
|
||||||
|
|
||||||
|
test('Testing zipWith', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof zipWith === 'function', 'zipWith is a Function');
|
||||||
|
//t.deepEqual(zipWith(args..), 'Expected');
|
||||||
|
//t.equal(zipWith(args..), 'Expected');
|
||||||
|
//t.false(zipWith(args..), 'Expected');
|
||||||
|
//t.throws(zipWith(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user