Travis build: 1304 [cron]

This commit is contained in:
30secondsofcode
2019-07-19 16:16:05 +00:00
parent bc0aa14697
commit a7e50ac55f
7 changed files with 157 additions and 55 deletions

View File

@ -550,11 +550,11 @@
" ? obj.map(val => deepMapKeys(val, f))",
" : typeof obj === 'object'",
" ? Object.keys(obj).reduce((acc, current) => {",
" const val = obj[current];",
" acc[f(current)] =",
" const val = obj[current];",
" acc[f(current)] =",
" val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);",
" return acc;",
" }, {})",
" return acc;",
" }, {})",
" : obj;"
],
"description": "Deep maps an object keys.\n\nCreates an object with the same values as the provided object and keys generated by running the provided function for each key.\n\nUse `Object.keys(obj)` to iterate over the object's keys. \nUse `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`"
@ -631,9 +631,9 @@
" 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);"
],
"description": "Returns the target value in a nested JSON object, based on the given key.\n\nUse the `in` operator to check if `target` exists in `obj`.\nIf found, return the value of `obj[target]`, otherwise use `Object.values(obj)` and `Array.prototype.reduce()` to recursively call `dig` on each nested object until the first matching key/value pair is found"
},
@ -796,8 +796,8 @@
"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);"
@ -1668,6 +1668,15 @@
],
"description": "Checks if the provided string is a valid JSON.\n\nUse `JSON.parse()` and a `try... catch` block to check if the provided string is a valid JSON"
},
"isWeekday": {
"prefix": "30s_isWeekday",
"body": [
"const isWeekday = (t = new Date()) => {",
" return t.getDay() >= 1 && t.getDay() <= 5;",
"};"
],
"description": "Results in a boolean representation of a specific date.\n\nPass the specific date object firstly.\nUse `Date.getDay()` to check weekday then return a boolean"
},
"isWritableStream": {
"prefix": "30s_isWritableStream",
"body": [
@ -2522,9 +2531,9 @@
"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);",
" }, [])",
" : [];"
],
"description": "Removes elements from an array for which the given function returns `false`.\n\nUse `Array.prototype.filter()` to find array elements that return truthy values and `Array.prototype.reduce()` to remove elements using `Array.prototype.splice()`.\nThe `func` is invoked with three arguments (`value, index, array`)"
@ -3417,6 +3426,17 @@
],
"description": "Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`.\n\nUse `RegExp.test()` to check if the string evaluates to `y/yes` or `n/no`.\nOmit the second argument, `def` to set the default answer as `no`"
},
"yesterday": {
"prefix": "30s_yesterday",
"body": [
"const yesterday = () => {",
" let t = new Date();",
" t.setDate(t.getDate() - 1);",
" return t.toISOString().split('T')[0];",
"};"
],
"description": "Results in a string representation of yesterday's date.\n\nUse `new Date()` to get the current date, decrement by one using `Date.getDate()` and set the value to the result using `Date.setDate()`.\nUse `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format"
},
"zip": {
"prefix": "30s_zip",
"body": [