Travis build: 1302

This commit is contained in:
30secondsofcode
2019-07-19 10:14:56 +00:00
parent b18559ac37
commit bc0aa14697
23 changed files with 103 additions and 66 deletions

View File

@ -249,6 +249,7 @@ _30s.average(1, 2, 3);
* [`isAfterDate`](#isafterdate) * [`isAfterDate`](#isafterdate)
* [`isBeforeDate`](#isbeforedate) * [`isBeforeDate`](#isbeforedate)
* [`isSameDate`](#issamedate) * [`isSameDate`](#issamedate)
* [`isWeekday`](#isweekday)
* [`maxDate`](#maxdate) * [`maxDate`](#maxdate)
* [`minDate`](#mindate) * [`minDate`](#mindate)
* [`tomorrow`](#tomorrow) * [`tomorrow`](#tomorrow)
@ -679,7 +680,7 @@ const sum = pipeAsyncFunctions(
x => x + 3, x => x + 3,
async x => (await x) + 4 async x => (await x) + 4
); );
(async() => { (async () => {
console.log(await sum(5)); // 15 (after one second) console.log(await sum(5)); // 15 (after one second)
})(); })();
``` ```
@ -2329,9 +2330,9 @@ The `func` is invoked with three arguments (`value, index, array`).
const remove = (arr, func) => const remove = (arr, func) =>
Array.isArray(arr) Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => { ? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1); arr.splice(arr.indexOf(val), 1);
return acc.concat(val); return acc.concat(val);
}, []) }, [])
: []; : [];
``` ```
@ -4500,6 +4501,30 @@ isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true
<br>[⬆ Back to top](#contents) <br>[⬆ Back to top](#contents)
### isWeekday
Results in a boolean representation of a specific date.
Pass the specific date object firstly.
Use `Date.getDay()` to check weekday then return a boolean.
```js
const isWeekday = (t = new Date()) => {
return t.getDay() >= 1 && t.getDay() <= 5;
};
```
<details>
<summary>Examples</summary>
```js
isWeekday(); // true (if current date is 2019-07-19)
```
</details>
<br>[⬆ Back to top](#contents)
### maxDate ### maxDate
Returns the maximum of the given dates. Returns the maximum of the given dates.
@ -4764,6 +4789,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length'); const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true lengthIs4([1,2,3,4]); // true
@ -5640,8 +5666,8 @@ Throws an exception if `n` is a negative number.
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {
throw new TypeError('Negative numbers are not allowed!'); throw new TypeError('Negative numbers are not allowed!');
})() })()
: n <= 1 : n <= 1
? 1 ? 1
: n * factorial(n - 1); : n * factorial(n - 1);
@ -6978,11 +7004,11 @@ const deepMapKeys = (obj, f) =>
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object' : typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => { ? Object.keys(obj).reduce((acc, current) => {
const val = obj[current]; const val = obj[current];
acc[f(current)] = acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc; return acc;
}, {}) }, {})
: obj; : obj;
``` ```
@ -7056,9 +7082,9 @@ const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]
: Object.values(obj).reduce((acc, val) => { : Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc; if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target); if (typeof val === 'object') return dig(val, target);
}, undefined); }, undefined);
``` ```
<details> <details>

View File

@ -288,6 +288,7 @@
<li><a tags="date,utility,beginner" href="./date#isafterdate">isAfterDate</a></li> <li><a tags="date,utility,beginner" href="./date#isafterdate">isAfterDate</a></li>
<li><a tags="date,utility,beginner" href="./date#isbeforedate">isBeforeDate</a></li> <li><a tags="date,utility,beginner" href="./date#isbeforedate">isBeforeDate</a></li>
<li><a tags="date,utility,beginner" href="./date#issamedate">isSameDate</a></li> <li><a tags="date,utility,beginner" href="./date#issamedate">isSameDate</a></li>
<li><a tags="date,beginner" href="./date#isweekday">isWeekday</a></li>
<li><a tags="date,math,beginner" href="./date#maxdate">maxDate</a></li> <li><a tags="date,math,beginner" href="./date#maxdate">maxDate</a></li>
<li><a tags="date,math,beginner" href="./date#mindate">minDate</a></li> <li><a tags="date,math,beginner" href="./date#mindate">minDate</a></li>
<li><a tags="date,intermediate" href="./date#tomorrow">tomorrow</a></li> <li><a tags="date,intermediate" href="./date#tomorrow">tomorrow</a></li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -288,6 +288,7 @@
<li><a tags="date,utility,beginner" href="./date#isafterdate">isAfterDate</a></li> <li><a tags="date,utility,beginner" href="./date#isafterdate">isAfterDate</a></li>
<li><a tags="date,utility,beginner" href="./date#isbeforedate">isBeforeDate</a></li> <li><a tags="date,utility,beginner" href="./date#isbeforedate">isBeforeDate</a></li>
<li><a tags="date,utility,beginner" href="./date#issamedate">isSameDate</a></li> <li><a tags="date,utility,beginner" href="./date#issamedate">isSameDate</a></li>
<li><a tags="date,beginner" href="./date#isweekday">isWeekday</a></li>
<li><a tags="date,math,beginner" href="./date#maxdate">maxDate</a></li> <li><a tags="date,math,beginner" href="./date#maxdate">maxDate</a></li>
<li><a tags="date,math,beginner" href="./date#mindate">minDate</a></li> <li><a tags="date,math,beginner" href="./date#mindate">minDate</a></li>
<li><a tags="date,intermediate" href="./date#tomorrow">tomorrow</a></li> <li><a tags="date,intermediate" href="./date#tomorrow">tomorrow</a></li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length'); const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true lengthIs4([1,2,3,4]); // true

View File

@ -13,11 +13,11 @@ const deepMapKeys = (obj, f) =>
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object' : typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => { ? Object.keys(obj).reduce((acc, current) => {
const val = obj[current]; const val = obj[current];
acc[f(current)] = acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc; return acc;
}, {}) }, {})
: obj; : obj;
``` ```

View File

@ -10,9 +10,9 @@ const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]
: Object.values(obj).reduce((acc, val) => { : Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc; if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target); if (typeof val === 'object') return dig(val, target);
}, undefined); }, undefined);
``` ```
```js ```js

View File

@ -11,8 +11,8 @@ Throws an exception if `n` is a negative number.
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {
throw new TypeError('Negative numbers are not allowed!'); throw new TypeError('Negative numbers are not allowed!');
})() })()
: n <= 1 : n <= 1
? 1 ? 1
: n * factorial(n - 1); : n * factorial(n - 1);

View File

@ -17,7 +17,7 @@ const sum = pipeAsyncFunctions(
x => x + 3, x => x + 3,
async x => (await x) + 4 async x => (await x) + 4
); );
(async() => { (async () => {
console.log(await sum(5)); // 15 (after one second) console.log(await sum(5)); // 15 (after one second)
})(); })();
``` ```

View File

@ -9,9 +9,9 @@ The `func` is invoked with three arguments (`value, index, array`).
const remove = (arr, func) => const remove = (arr, func) =>
Array.isArray(arr) Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => { ? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1); arr.splice(arr.indexOf(val), 1);
return acc.concat(val); return acc.concat(val);
}, []) }, [])
: []; : [];
``` ```

View File

@ -245,11 +245,11 @@ const deepMapKeys = (obj, f) =>
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object' : typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => { ? Object.keys(obj).reduce((acc, current) => {
const val = obj[current]; const val = obj[current];
acc[f(current)] = acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc; return acc;
}, {}) }, {})
: obj; : obj;
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
const defer = (fn, ...args) => setTimeout(fn, 1, ...args); const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
@ -272,9 +272,9 @@ const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]
: Object.values(obj).reduce((acc, val) => { : Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc; if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target); if (typeof val === 'object') return dig(val, target);
}, undefined); }, undefined);
const digitize = n => [...`${n}`].map(i => parseInt(i)); const digitize = n => [...`${n}`].map(i => parseInt(i));
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
const drop = (arr, n = 1) => arr.slice(n); const drop = (arr, n = 1) => arr.slice(n);
@ -347,8 +347,8 @@ const extendHex = shortHex =>
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {
throw new TypeError('Negative numbers are not allowed!'); throw new TypeError('Negative numbers are not allowed!');
})() })()
: n <= 1 : n <= 1
? 1 ? 1
: n * factorial(n - 1); : n * factorial(n - 1);
@ -658,6 +658,9 @@ const isValidJSON = str => {
return false; return false;
} }
}; };
const isWeekday = (t = new Date()) => {
return t.getDay() >= 1 && t.getDay() <= 5;
};
const isWritableStream = val => const isWritableStream = val =>
val !== null && val !== null &&
typeof val === 'object' && typeof val === 'object' &&
@ -1004,9 +1007,9 @@ const reject = (pred, array) => array.filter((...args) => !pred(...args));
const remove = (arr, func) => const remove = (arr, func) =>
Array.isArray(arr) Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => { ? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1); arr.splice(arr.indexOf(val), 1);
return acc.concat(val); return acc.concat(val);
}, []) }, [])
: []; : [];
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
const renameKeys = (keysMap, obj) => const renameKeys = (keysMap, obj) =>
@ -1541,4 +1544,4 @@ const speechSynthesis = message => {
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
module.exports = {CSVToArray,CSVToJSON,JSONToFile,JSONtoCSV,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,counter,createDirIfNotExists,createElement,createEventHub,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,forOwn,forOwnRight,formToObject,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,inRange,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWritableStream,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reduceSuccessive,reduceWhich,reducedFilter,reject,remove,removeNonASCII,renameKeys,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toHash,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,toggleClass,tomorrow,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,JSONToDate,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum} module.exports = {CSVToArray,CSVToJSON,JSONToFile,JSONtoCSV,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,counter,createDirIfNotExists,createElement,createEventHub,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,forOwn,forOwnRight,formToObject,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,inRange,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWeekday,isWritableStream,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reduceSuccessive,reduceWhich,reducedFilter,reject,remove,removeNonASCII,renameKeys,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toHash,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,toggleClass,tomorrow,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,JSONToDate,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum}