Travis build: 1315 [cron]
This commit is contained in:
@ -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);"
|
||||
@ -1672,10 +1672,19 @@
|
||||
"prefix": "30s_isWeekday",
|
||||
"body": [
|
||||
"const isWeekday = (t = new Date()) => {",
|
||||
" return t.getDay() >= 1 && t.getDay() <= 5;",
|
||||
" return t.getDay() % 6 !== 0;",
|
||||
"};"
|
||||
],
|
||||
"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"
|
||||
"description": "Results in a boolean representation of a specific date.\n\nPass the specific date object firstly.\nUse `Date.getDay()` to check weekday by using a modulo operator and then returning a boolean"
|
||||
},
|
||||
"isWeekend": {
|
||||
"prefix": "30s_isWeekend",
|
||||
"body": [
|
||||
"const isWeekend = (t = new Date()) => {",
|
||||
" return t.getDay() % 6 === 0;",
|
||||
"};"
|
||||
],
|
||||
"description": "Results in a boolean representation of a specific date.\n\nPass the specific date object firstly.\nUse `Date.getDay()` to check weekend based on the day being returned as 0 - 6 using a modulo operation then return a boolean"
|
||||
},
|
||||
"isWritableStream": {
|
||||
"prefix": "30s_isWritableStream",
|
||||
@ -2531,9 +2540,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`)"
|
||||
|
||||
Reference in New Issue
Block a user