{ "all": { "prefix": "30s_all", "body": [ "const all = (arr, fn = Boolean) => arr.every(fn);" ], "description": "Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.\n\nUse `Array.prototype.every()` to test if all elements in the collection return `true` based on `fn`.\nOmit the second argument, `fn`, to use `Boolean` as a default.\n" }, "allEqual": { "prefix": "30s_allEqual", "body": [ "const allEqual = arr => arr.every(val => val === arr[0]);" ], "description": "Check if all elements in an array are equal.\n\nUse `Array.prototype.every()` to check if all the elements of the array are the same as the first one.\nElements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.\n" }, "any": { "prefix": "30s_any", "body": [ "const any = (arr, fn = Boolean) => arr.some(fn);" ], "description": "Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.\n\nUse `Array.prototype.some()` to test if any elements in the collection return `true` based on `fn`.\nOmit the second argument, `fn`, to use `Boolean` as a default.\n" }, "approximatelyEqual": { "prefix": "30s_approximatelyEqual", "body": [ "const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;" ], "description": "Checks if two numbers are approximately equal to each other.\n\nUse `Math.abs()` to compare the absolute difference of the two values to `epsilon`.\nOmit the third parameter, `epsilon`, to use a default value of `0.001`.\n" }, "arrayToCSV": { "prefix": "30s_arrayToCSV", "body": [ "const arrayToCSV = (arr, delimiter = ',') =>", " arr", " .map(v => v.map(x => (isNaN(x) ? `\"${x.replace(/\"/g, '\"\"')}\"` : x)).join(delimiter))", " .join('\\n');" ], "description": "Converts a 2D array to a comma-separated values (CSV) string.\n\nUse `Array.prototype.map()` and `Array.prototype.join(delimiter)` to combine individual 1D arrays (rows) into strings.\nUse `Array.prototype.join('\\n')` to combine all rows into a CSV string, separating each row with a newline.\nOmit the second argument, `delimiter`, to use a default delimiter of `,`.\n" }, "arrayToHtmlList": { "prefix": "30s_arrayToHtmlList", "body": [ "const arrayToHtmlList = (arr, listID) =>", " (el => (", " (el = document.querySelector('#' + listID)),", " (el.innerHTML += arr.map(item => `