From 1b8782644cba1a3be1242172ffa24572a040b883 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Mon, 19 Aug 2019 15:16:02 +0000 Subject: [PATCH] Travis build: 1378 --- README.md | 50 +++++++++++++------------- snippets/checkProp.md | 1 + snippets/deepClone.md | 4 +-- snippets/deepMapKeys.md | 4 +-- snippets/dig.md | 6 ++-- snippets/factorial.md | 8 ++--- snippets/getMeridiemSuffixOfInteger.md | 8 ++--- snippets/join.md | 4 +-- snippets/pipeAsyncFunctions.md | 2 +- snippets/remove.md | 6 ++-- snippets/size.md | 8 ++--- test/_30s.js | 48 ++++++++++++------------- 12 files changed, 75 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 2ede343a4..f6844bc8d 100644 --- a/README.md +++ b/README.md @@ -675,7 +675,7 @@ const sum = pipeAsyncFunctions( x => x + 3, async x => (await x) + 4 ); -(async() => { +(async () => { console.log(await sum(5)); // 15 (after one second) })(); ``` @@ -1722,8 +1722,8 @@ const join = (arr, separator = ',', end = separator) => i === arr.length - 2 ? acc + val + end : i === arr.length - 1 - ? acc + val - : acc + val + separator, + ? acc + val + : acc + val + separator, '' ); ``` @@ -2260,9 +2260,9 @@ The `func` is invoked with three arguments (`value, index, array`). const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) : []; ``` @@ -4269,10 +4269,10 @@ const getMeridiemSuffixOfInteger = num => num === 0 || num === 24 ? 12 + 'am' : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; + ? 12 + 'pm' + : num < 12 + ? (num % 12) + 'am' + : (num % 12) + 'pm'; ```
@@ -5484,11 +5484,11 @@ Throws an exception if `n` is a negative number. const factorial = n => n < 0 ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() + throw new TypeError('Negative numbers are not allowed!'); + })() : n <= 1 - ? 1 - : n * factorial(n - 1); + ? 1 + : n * factorial(n - 1); ```
@@ -6676,8 +6676,8 @@ const deepClone = obj => { return Array.isArray(obj) && obj.length ? (clone.length = obj.length) && Array.from(clone) : Array.isArray(obj) - ? Array.from(obj) - : clone; + ? Array.from(obj) + : clone; }; ``` @@ -6765,13 +6765,13 @@ const deepMapKeys = (obj, f) => Array.isArray(obj) ? obj.map(val => deepMapKeys(val, f)) : typeof obj === 'object' - ? Object.keys(obj).reduce((acc, current) => { + ? Object.keys(obj).reduce((acc, current) => { const val = obj[current]; acc[f(current)] = val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); return acc; }, {}) - : obj; + : obj; ```
@@ -6842,9 +6842,9 @@ const dig = (obj, target) => target in obj ? obj[target] : Object.values(obj).reduce((acc, val) => { - if (acc !== undefined) return acc; - if (typeof val === 'object') return dig(val, target); - }, undefined); + if (acc !== undefined) return acc; + if (typeof val === 'object') return dig(val, target); + }, undefined); ```
@@ -7552,10 +7552,10 @@ const size = val => Array.isArray(val) ? val.length : val && typeof val === 'object' - ? val.size || val.length || Object.keys(val).length - : typeof val === 'string' - ? new Blob([val]).size - : 0; + ? val.size || val.length || Object.keys(val).length + : typeof val === 'string' + ? new Blob([val]).size + : 0; ```
diff --git a/snippets/checkProp.md b/snippets/checkProp.md index 238149549..722dd4f2a 100644 --- a/snippets/checkProp.md +++ b/snippets/checkProp.md @@ -13,6 +13,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); ```js + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/snippets/deepClone.md b/snippets/deepClone.md index 9edfd363f..c2f4755c5 100644 --- a/snippets/deepClone.md +++ b/snippets/deepClone.md @@ -18,8 +18,8 @@ const deepClone = obj => { return Array.isArray(obj) && obj.length ? (clone.length = obj.length) && Array.from(clone) : Array.isArray(obj) - ? Array.from(obj) - : clone; + ? Array.from(obj) + : clone; }; ``` diff --git a/snippets/deepMapKeys.md b/snippets/deepMapKeys.md index e9561091d..e07084847 100644 --- a/snippets/deepMapKeys.md +++ b/snippets/deepMapKeys.md @@ -14,13 +14,13 @@ const deepMapKeys = (obj, f) => Array.isArray(obj) ? obj.map(val => deepMapKeys(val, f)) : typeof obj === 'object' - ? Object.keys(obj).reduce((acc, current) => { + ? Object.keys(obj).reduce((acc, current) => { const val = obj[current]; acc[f(current)] = val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); return acc; }, {}) - : obj; + : obj; ``` ```js diff --git a/snippets/dig.md b/snippets/dig.md index 4484cdd6f..16c08bebe 100644 --- a/snippets/dig.md +++ b/snippets/dig.md @@ -13,9 +13,9 @@ const dig = (obj, target) => target in obj ? obj[target] : Object.values(obj).reduce((acc, val) => { - if (acc !== undefined) return acc; - if (typeof val === 'object') return dig(val, target); - }, undefined); + if (acc !== undefined) return acc; + if (typeof val === 'object') return dig(val, target); + }, undefined); ``` ```js diff --git a/snippets/factorial.md b/snippets/factorial.md index 461dbd4f1..0b1413c15 100644 --- a/snippets/factorial.md +++ b/snippets/factorial.md @@ -14,11 +14,11 @@ Throws an exception if `n` is a negative number. const factorial = n => n < 0 ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() + throw new TypeError('Negative numbers are not allowed!'); + })() : n <= 1 - ? 1 - : n * factorial(n - 1); + ? 1 + : n * factorial(n - 1); ``` ```js diff --git a/snippets/getMeridiemSuffixOfInteger.md b/snippets/getMeridiemSuffixOfInteger.md index 1d9c01ee0..c460f5644 100644 --- a/snippets/getMeridiemSuffixOfInteger.md +++ b/snippets/getMeridiemSuffixOfInteger.md @@ -12,10 +12,10 @@ const getMeridiemSuffixOfInteger = num => num === 0 || num === 24 ? 12 + 'am' : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; + ? 12 + 'pm' + : num < 12 + ? (num % 12) + 'am' + : (num % 12) + 'pm'; ``` ```js diff --git a/snippets/join.md b/snippets/join.md index 89d1f7a72..6df3c9145 100644 --- a/snippets/join.md +++ b/snippets/join.md @@ -17,8 +17,8 @@ const join = (arr, separator = ',', end = separator) => i === arr.length - 2 ? acc + val + end : i === arr.length - 1 - ? acc + val - : acc + val + separator, + ? acc + val + : acc + val + separator, '' ); ``` diff --git a/snippets/pipeAsyncFunctions.md b/snippets/pipeAsyncFunctions.md index 7c65d2101..4904b600a 100644 --- a/snippets/pipeAsyncFunctions.md +++ b/snippets/pipeAsyncFunctions.md @@ -20,7 +20,7 @@ const sum = pipeAsyncFunctions( x => x + 3, async x => (await x) + 4 ); -(async() => { +(async () => { console.log(await sum(5)); // 15 (after one second) })(); ``` \ No newline at end of file diff --git a/snippets/remove.md b/snippets/remove.md index 1bc9b3abb..1b3b066a1 100644 --- a/snippets/remove.md +++ b/snippets/remove.md @@ -12,9 +12,9 @@ The `func` is invoked with three arguments (`value, index, array`). const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) : []; ``` diff --git a/snippets/size.md b/snippets/size.md index d5bb31cab..43cad604d 100644 --- a/snippets/size.md +++ b/snippets/size.md @@ -16,10 +16,10 @@ const size = val => Array.isArray(val) ? val.length : val && typeof val === 'object' - ? val.size || val.length || Object.keys(val).length - : typeof val === 'string' - ? new Blob([val]).size - : 0; + ? val.size || val.length || Object.keys(val).length + : typeof val === 'string' + ? new Blob([val]).size + : 0; ``` ```js diff --git a/test/_30s.js b/test/_30s.js index 2ae6a0bbe..1b9033f7a 100644 --- a/test/_30s.js +++ b/test/_30s.js @@ -198,8 +198,8 @@ const deepClone = obj => { return Array.isArray(obj) && obj.length ? (clone.length = obj.length) && Array.from(clone) : Array.isArray(obj) - ? Array.from(obj) - : clone; + ? Array.from(obj) + : clone; }; const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); const deepFreeze = obj => @@ -211,13 +211,13 @@ const deepMapKeys = (obj, f) => Array.isArray(obj) ? obj.map(val => deepMapKeys(val, f)) : typeof obj === 'object' - ? Object.keys(obj).reduce((acc, current) => { + ? Object.keys(obj).reduce((acc, current) => { const val = obj[current]; acc[f(current)] = val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val); return acc; }, {}) - : obj; + : obj; const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); const defer = (fn, ...args) => setTimeout(fn, 1, ...args); const degreesToRads = deg => (deg * Math.PI) / 180.0; @@ -239,9 +239,9 @@ const dig = (obj, target) => target in obj ? obj[target] : Object.values(obj).reduce((acc, val) => { - if (acc !== undefined) return acc; - if (typeof val === 'object') return dig(val, target); - }, undefined); + if (acc !== undefined) return acc; + if (typeof val === 'object') return dig(val, target); + }, undefined); const digitize = n => [...`${n}`].map(i => parseInt(i)); const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); const drop = (arr, n = 1) => arr.slice(n); @@ -314,11 +314,11 @@ const extendHex = shortHex => const factorial = n => n < 0 ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() + throw new TypeError('Negative numbers are not allowed!'); + })() : n <= 1 - ? 1 - : n * factorial(n - 1); + ? 1 + : n * factorial(n - 1); const fibonacci = n => Array.from({ length: n }).reduce( (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), @@ -419,10 +419,10 @@ const getMeridiemSuffixOfInteger = num => num === 0 || num === 24 ? 12 + 'am' : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; + ? 12 + 'pm' + : num < 12 + ? (num % 12) + 'am' + : (num % 12) + 'pm'; const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop @@ -643,8 +643,8 @@ const join = (arr, separator = ',', end = separator) => i === arr.length - 2 ? acc + val + end : i === arr.length - 1 - ? acc + val - : acc + val + separator, + ? acc + val + : acc + val + separator, '' ); const JSONtoCSV = (arr, columns, delimiter = ',') => @@ -989,9 +989,9 @@ const reject = (pred, array) => array.filter((...args) => !pred(...args)); const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) : []; const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); const renameKeys = (keysMap, obj) => @@ -1069,10 +1069,10 @@ const size = val => Array.isArray(val) ? val.length : val && typeof val === 'object' - ? val.size || val.length || Object.keys(val).length - : typeof val === 'string' - ? new Blob([val]).size - : 0; + ? val.size || val.length || Object.keys(val).length + : typeof val === 'string' + ? new Blob([val]).size + : 0; const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const smoothScroll = element => document.querySelector(element).scrollIntoView({