Housekeeping, fix security vulnerabilities
This commit is contained in:
@@ -528,9 +528,8 @@
|
||||
"prefix": "30s_deepFreeze",
|
||||
"body": [
|
||||
"const deepFreeze = obj =>",
|
||||
" Object.keys(obj).forEach(",
|
||||
" prop =>",
|
||||
" !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])",
|
||||
" Object.keys(obj).forEach(prop =>",
|
||||
" !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])",
|
||||
" ) || Object.freeze(obj);"
|
||||
],
|
||||
"description": "Deep freezes an object.\n\nCalls `Object.freeze(obj)` recursively on all unfrozen properties of passed object that are `instanceof` object.\n"
|
||||
@@ -552,12 +551,12 @@
|
||||
" ? 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);",
|
||||
" val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);",
|
||||
" 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`.\n"
|
||||
"description": "Deep maps an object's keys.\n\nCreates an object with the same values as the provided object and keys generated by running the provided function for each key.\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`.\n"
|
||||
},
|
||||
"defaults": {
|
||||
"prefix": "30s_defaults",
|
||||
@@ -1861,11 +1860,10 @@
|
||||
"prefix": "30s_matchesWith",
|
||||
"body": [
|
||||
"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]",
|
||||
" Object.keys(source).every(key =>",
|
||||
" obj.hasOwnProperty(key) && fn",
|
||||
" ? fn(obj[key], source[key], key, obj, source)",
|
||||
" : obj[key] == source[key]",
|
||||
" );"
|
||||
],
|
||||
"description": "Compares two objects to determine if the first one contains equivalent property values to the second one, based on a provided function.\n\nUse `Object.keys(source)` to get all the keys of the second object, then `Array.prototype.every()`, `Object.hasOwnProperty()` and the provided function to determine if all keys exist in the first object and have equivalent values.\nIf no function is provided, the values will be compared using the equality operator.\n"
|
||||
@@ -2348,7 +2346,7 @@
|
||||
" func(...args, (err, result) => (err ? reject(err) : resolve(result)))",
|
||||
" );"
|
||||
],
|
||||
"description": "Converts an asynchronous function to return a promise.\n\nUse currying to return a function returning a `Promise` that calls the original function.\nUse the `...rest` operator to pass in all the parameters.\n\n*In Node 8+, you can use [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original)*\n"
|
||||
"description": "Converts an asynchronous function to return a promise.\n\n*In Node 8+, you can use [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original)*\n\nUse currying to return a function returning a `Promise` that calls the original function.\nUse the `...rest` operator to pass in all the parameters.\n"
|
||||
},
|
||||
"pull": {
|
||||
"prefix": "30s_pull",
|
||||
@@ -2360,7 +2358,7 @@
|
||||
" pulled.forEach(v => arr.push(v));",
|
||||
"};"
|
||||
],
|
||||
"description": "Mutates the original array to filter out the values specified.\n\nUse `Array.prototype.filter()` and `Array.prototype.includes()` to pull out the values that are not needed.\nUse `Array.prototype.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.prototype.push()` to re-populate it with only the pulled values.\n\n_(For a snippet that does not mutate the original array see [`without`](#without))_\n"
|
||||
"description": "Mutates the original array to filter out the values specified.\n\nUse `Array.prototype.filter()` and `Array.prototype.includes()` to pull out the values that are not needed.\nUse `Array.prototype.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.prototype.push()` to re-populate it with only the pulled values.\n"
|
||||
},
|
||||
"pullAtIndex": {
|
||||
"prefix": "30s_pullAtIndex",
|
||||
@@ -2745,7 +2743,7 @@
|
||||
" ? new Blob([val]).size",
|
||||
" : 0;"
|
||||
],
|
||||
"description": "Get size of arrays, objects or strings.\n\nGet type of `val` (`array`, `object` or `string`). \nUse `length` property for arrays.\nUse `length` or `size` value if available or number of keys for objects.\nUse `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `val` for strings.\n\nSplit strings into array of characters with `split('')` and return its length.\n"
|
||||
"description": "Get size of arrays, objects or strings.\n\nGet type of `val` (`array`, `object` or `string`). \nUse `length` property for arrays.\nUse `length` or `size` value if available or number of keys for objects.\nUse `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `val` for strings.\nSplit strings into array of characters with `split('')` and return its length.\n"
|
||||
},
|
||||
"sleep": {
|
||||
"prefix": "30s_sleep",
|
||||
@@ -3411,7 +3409,7 @@
|
||||
"body": [
|
||||
"const without = (arr, ...args) => arr.filter(v => !args.includes(v));"
|
||||
],
|
||||
"description": "Filters out the elements of an array, that have one of the specified values.\n\nUse `Array.prototype.filter()` to create an array excluding(using `!Array.includes()`) all given values.\n\n_(For a snippet that mutates the original array see [`pull`](#pull))_\n"
|
||||
"description": "Filters out the elements of an array, that have one of the specified values.\n\nUse `Array.prototype.filter()` to create an array excluding(using `!Array.includes()`) all given values.\n"
|
||||
},
|
||||
"words": {
|
||||
"prefix": "30s_words",
|
||||
@@ -3471,9 +3469,8 @@
|
||||
"body": [
|
||||
"const zipWith = (...array) => {",
|
||||
" const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;",
|
||||
" return Array.from(",
|
||||
" { length: Math.max(...array.map(a => a.length)) },",
|
||||
" (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))",
|
||||
" return Array.from({ length: Math.max(...array.map(a => a.length)) }, (_, i) =>",
|
||||
" fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])",
|
||||
" );",
|
||||
"};"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user