Snippet format update
To match the starter (for the migration)
This commit is contained in:
24
migrator.js
Normal file
24
migrator.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const snippets = require('./snippet_data/snippets.json');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
snippets.data.forEach(snippet => {
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(
|
||||||
|
snippet.meta.archived ? './snippets_archive' : './snippets',
|
||||||
|
`${snippet.attributes.fileName}`),
|
||||||
|
`---
|
||||||
|
title: ${snippet.id}
|
||||||
|
tags: ${snippet.attributes.tags.join(',')}
|
||||||
|
---
|
||||||
|
|
||||||
|
${snippet.attributes.text}
|
||||||
|
|
||||||
|
\`\`\`js
|
||||||
|
${snippet.attributes.codeBlocks.es6}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
\`\`\`js
|
||||||
|
${snippet.attributes.codeBlocks.example}
|
||||||
|
\`\`\``);
|
||||||
|
});
|
||||||
45
package-lock.json
generated
45
package-lock.json
generated
@ -3488,7 +3488,7 @@
|
|||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minipass": "2.2.4"
|
"minipass": "^2.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fs.realpath": {
|
"fs.realpath": {
|
||||||
@ -3606,17 +3606,16 @@
|
|||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "3.0.2"
|
"yallist": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minizlib": {
|
"minizlib": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minipass": "2.2.4"
|
"minipass": "^2.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
@ -3651,16 +3650,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"detect-libc": "1.0.3",
|
"detect-libc": "^1.0.2",
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"needle": "2.2.0",
|
"needle": "^2.2.0",
|
||||||
"nopt": "4.0.1",
|
"nopt": "^4.0.1",
|
||||||
"npm-packlist": "1.1.10",
|
"npm-packlist": "^1.1.6",
|
||||||
"npmlog": "4.1.2",
|
"npmlog": "^4.0.2",
|
||||||
"rc": "1.2.7",
|
"rc": "^1.1.7",
|
||||||
"rimraf": "2.6.2",
|
"rimraf": "^2.6.1",
|
||||||
"semver": "5.5.0",
|
"semver": "^5.3.0",
|
||||||
"tar": "4.4.1"
|
"tar": "^4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nopt": {
|
"nopt": {
|
||||||
@ -3802,8 +3801,7 @@
|
|||||||
},
|
},
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
@ -3893,8 +3891,7 @@
|
|||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -6049,11 +6046,11 @@
|
|||||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-styles": "2.2.1",
|
"ansi-styles": "^2.2.1",
|
||||||
"escape-string-regexp": "1.0.5",
|
"escape-string-regexp": "^1.0.2",
|
||||||
"has-ansi": "2.0.0",
|
"has-ansi": "^2.0.0",
|
||||||
"strip-ansi": "3.0.1",
|
"strip-ansi": "^3.0.0",
|
||||||
"supports-color": "2.0.0"
|
"supports-color": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
|
|||||||
@ -10,13 +10,11 @@
|
|||||||
"glossary:keymaker": "node ./scripts/glossary/keyword.js",
|
"glossary:keymaker": "node ./scripts/glossary/keyword.js",
|
||||||
"builder": "node ./scripts/build.js",
|
"builder": "node ./scripts/build.js",
|
||||||
"linter": "node ./scripts/lint.js",
|
"linter": "node ./scripts/lint.js",
|
||||||
"tagger": "node ./scripts/tag.js",
|
|
||||||
"webber": "node ./scripts/web.js",
|
"webber": "node ./scripts/web.js",
|
||||||
"tester": "node ./scripts/tdd.js",
|
"tester": "node ./scripts/tdd.js",
|
||||||
"extractor": "node ./scripts/extract.js",
|
"extractor": "node ./scripts/extract.js",
|
||||||
"vscoder": "node ./scripts/vscodegen.js",
|
"vscoder": "node ./scripts/vscodegen.js",
|
||||||
"packager": "node ./scripts/module.js",
|
"packager": "node ./scripts/module.js",
|
||||||
"localizer": "node ./scripts/localize.js",
|
|
||||||
"test": "jest --verbose --coverage"
|
"test": "jest --verbose --coverage"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
This is the tagger script that updates the tag_databse file and logs stats for snippet tags.
|
|
||||||
Run using `npm run tagger`.
|
|
||||||
*/
|
|
||||||
// Load modules
|
|
||||||
const fs = require('fs-extra'),
|
|
||||||
{ black, blue, green, yellow, red, bgWhite } = require('kleur');
|
|
||||||
const util = require('./util');
|
|
||||||
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
|
||||||
console.log(`${green('NOBUILD')} Tagging terminated, parent commit is a Travis build!`);
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
// Set variables for paths
|
|
||||||
const snippetsPath = './snippets';
|
|
||||||
// Set variables for script
|
|
||||||
let snippets = {},
|
|
||||||
output = '',
|
|
||||||
tagDbData = {},
|
|
||||||
missingTags = 0,
|
|
||||||
tagDbStats = {};
|
|
||||||
// Start the timer of the script
|
|
||||||
console.time('Tagger');
|
|
||||||
// Synchronously read all snippets and sort them as necessary (case-insensitive)
|
|
||||||
snippets = util.readSnippets(snippetsPath);
|
|
||||||
// Load tag data from the database
|
|
||||||
tagDbData = util.readTags();
|
|
||||||
tagDbStats = Object.entries(tagDbData).reduce((acc, val) => {
|
|
||||||
val[1].forEach(v => (acc.hasOwnProperty(v) ? acc[v]++ : (acc[v] = 1)));
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
// Update the listing of snippets in tag_database and log the statistics, along with missing scripts
|
|
||||||
try {
|
|
||||||
for (let snippet of Object.entries(snippets)) {
|
|
||||||
if (
|
|
||||||
tagDbData.hasOwnProperty(snippet[0].slice(0, -3)) &&
|
|
||||||
tagDbData[snippet[0].slice(0, -3)].join(',').trim()
|
|
||||||
) {
|
|
||||||
output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)]
|
|
||||||
.join(',')
|
|
||||||
.trim()}\n`;
|
|
||||||
} else {
|
|
||||||
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
|
|
||||||
missingTags++;
|
|
||||||
console.log(`${yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Write to tag_database
|
|
||||||
fs.writeFileSync('tag_database', output);
|
|
||||||
} catch (err) {
|
|
||||||
// Handle errors (hopefully not!)
|
|
||||||
console.log(`${red('ERROR!')} During tag_database generation: ${err}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
// Log statistics for the tag_database file
|
|
||||||
console.log(`\n${bgWhite(black('=== TAG STATS ==='))}`);
|
|
||||||
for (let tagData of Object.entries(tagDbStats)
|
|
||||||
.filter(v => v[0] !== 'undefined')
|
|
||||||
.sort((a, b) => a[0].localeCompare(b[0])))
|
|
||||||
console.log(`${green(tagData[0])}: ${tagData[1]} snippets`);
|
|
||||||
console.log(
|
|
||||||
`${blue("New untagged snippets (will be tagged as 'uncategorized'):")} ${missingTags}\n`
|
|
||||||
);
|
|
||||||
// Log a success message
|
|
||||||
console.log(`${green('SUCCESS!')} tag_database file updated!`);
|
|
||||||
// Log the time taken
|
|
||||||
console.timeEnd('Tagger');
|
|
||||||
@ -1,4 +1,7 @@
|
|||||||
### CSVToArray
|
---
|
||||||
|
title: CSVToArray
|
||||||
|
tags: string,array,utility,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Converts a comma-separated values (CSV) string to a 2D array.
|
Converts a comma-separated values (CSV) string to a 2D array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### CSVToJSON
|
---
|
||||||
|
title: CSVToJSON
|
||||||
|
tags: string,array,object,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Converts a comma-separated values (CSV) string to a 2D array of objects.
|
Converts a comma-separated values (CSV) string to a 2D array of objects.
|
||||||
The first row of the string is used as the title row.
|
The first row of the string is used as the title row.
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### JSONToFile
|
---
|
||||||
|
title: JSONToFile
|
||||||
|
tags: node,json,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Writes a JSON object to a file.
|
Writes a JSON object to a file.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### JSONtoCSV
|
---
|
||||||
|
title: JSONtoCSV
|
||||||
|
tags: array,string,object,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Converts an array of objects to a comma-separated values (CSV) string that contains only the `columns` specified.
|
Converts an array of objects to a comma-separated values (CSV) string that contains only the `columns` specified.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### RGBToHex
|
---
|
||||||
|
title: RGBToHex
|
||||||
|
tags: utility,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Converts the values of RGB components to a color code.
|
Converts the values of RGB components to a color code.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### URLJoin
|
---
|
||||||
|
title: URLJoin
|
||||||
|
tags: string,utility,regexp,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Joins all given URL segments together, then normalizes the resulting URL.
|
Joins all given URL segments together, then normalizes the resulting URL.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### UUIDGeneratorBrowser
|
---
|
||||||
|
title: UUIDGeneratorBrowser
|
||||||
|
tags: browser,utility,random,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Generates a UUID in a browser.
|
Generates a UUID in a browser.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### UUIDGeneratorNode
|
---
|
||||||
|
title: UUIDGeneratorNode
|
||||||
|
tags: node,utility,random,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Generates a UUID in Node.JS.
|
Generates a UUID in Node.JS.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### all
|
---
|
||||||
|
title: all
|
||||||
|
tags: array,function,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.
|
Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### allEqual
|
---
|
||||||
|
title: allEqual
|
||||||
|
tags: array,function,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Check if all elements in an array are equal.
|
Check if all elements in an array are equal.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### any
|
---
|
||||||
|
title: any
|
||||||
|
tags: array,function,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.
|
Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### approximatelyEqual
|
---
|
||||||
|
title: approximatelyEqual
|
||||||
|
tags: math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Checks if two numbers are approximately equal to each other.
|
Checks if two numbers are approximately equal to each other.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### arrayToCSV
|
---
|
||||||
|
title: arrayToCSV
|
||||||
|
tags: array,string,utility,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Converts a 2D array to a comma-separated values (CSV) string.
|
Converts a 2D array to a comma-separated values (CSV) string.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### arrayToHtmlList
|
---
|
||||||
|
title: arrayToHtmlList
|
||||||
|
tags: browser,array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Converts the given array elements into `<li>` tags and appends them to the list of the given id.
|
Converts the given array elements into `<li>` tags and appends them to the list of the given id.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### ary
|
---
|
||||||
|
title: ary
|
||||||
|
tags: adapter,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Creates a function that accepts up to `n` arguments, ignoring any additional arguments.
|
Creates a function that accepts up to `n` arguments, ignoring any additional arguments.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### atob
|
---
|
||||||
|
title: atob
|
||||||
|
tags: node,string,utility,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Decodes a string of data which has been encoded using base-64 encoding.
|
Decodes a string of data which has been encoded using base-64 encoding.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### attempt
|
---
|
||||||
|
title: attempt
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
|
Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### average
|
---
|
||||||
|
title: average
|
||||||
|
tags: math,array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the average of two or more numbers.
|
Returns the average of two or more numbers.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### averageBy
|
---
|
||||||
|
title: averageBy
|
||||||
|
tags: math,array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the average of an array, after mapping each element to a value using the provided function.
|
Returns the average of an array, after mapping each element to a value using the provided function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bifurcate
|
---
|
||||||
|
title: bifurcate
|
||||||
|
tags: array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.
|
Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bifurcateBy
|
---
|
||||||
|
title: bifurcateBy
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.
|
Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bind
|
---
|
||||||
|
title: bind
|
||||||
|
tags: function,object,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.
|
Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bindAll
|
---
|
||||||
|
title: bindAll
|
||||||
|
tags: object,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Binds methods of an object to the object itself, overwriting the existing method.
|
Binds methods of an object to the object itself, overwriting the existing method.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bindKey
|
---
|
||||||
|
title: bindKey
|
||||||
|
tags: function,object,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.
|
Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### binomialCoefficient
|
---
|
||||||
|
title: binomialCoefficient
|
||||||
|
tags: math,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Evaluates the binomial coefficient of two integers `n` and `k`.
|
Evaluates the binomial coefficient of two integers `n` and `k`.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### bottomVisible
|
---
|
||||||
|
title: bottomVisible
|
||||||
|
tags: browser,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns `true` if the bottom of the page is visible, `false` otherwise.
|
Returns `true` if the bottom of the page is visible, `false` otherwise.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### btoa
|
---
|
||||||
|
title: btoa
|
||||||
|
tags: node,string,utility,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
|
Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### byteSize
|
---
|
||||||
|
title: byteSize
|
||||||
|
tags: string,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the length of a string in bytes.
|
Returns the length of a string in bytes.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### call
|
---
|
||||||
|
title: call
|
||||||
|
tags: adapter,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
|
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### capitalize
|
---
|
||||||
|
title: capitalize
|
||||||
|
tags: string,array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Capitalizes the first letter of a string.
|
Capitalizes the first letter of a string.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### capitalizeEveryWord
|
---
|
||||||
|
title: capitalizeEveryWord
|
||||||
|
tags: string,regexp,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Capitalizes the first letter of every word in a string.
|
Capitalizes the first letter of every word in a string.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### castArray
|
---
|
||||||
|
title: castArray
|
||||||
|
tags: utility,array,type,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Casts the provided value as an array if it's not one.
|
Casts the provided value as an array if it's not one.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### chainAsync
|
---
|
||||||
|
title: chainAsync
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Chains asynchronous functions.
|
Chains asynchronous functions.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### checkProp
|
---
|
||||||
|
title: checkProp
|
||||||
|
tags: function,object,utility,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Given a `predicate` function and a `prop` string, this curried function will then take an `object` to inspect by calling the property and passing it to the predicate.
|
Given a `predicate` function and a `prop` string, this curried function will then take an `object` to inspect by calling the property and passing it to the predicate.
|
||||||
|
|
||||||
@ -9,22 +12,6 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const lengthIs4 = checkProp(l => l === 4, 'length');
|
const lengthIs4 = checkProp(l => l === 4, 'length');
|
||||||
lengthIs4([]); // false
|
lengthIs4([]); // false
|
||||||
lengthIs4([1,2,3,4]); // true
|
lengthIs4([1,2,3,4]); // true
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### chunk
|
---
|
||||||
|
title: chunk
|
||||||
|
tags: array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Chunks an array into smaller arrays of a specified size.
|
Chunks an array into smaller arrays of a specified size.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### clampNumber
|
---
|
||||||
|
title: clampNumber
|
||||||
|
tags: math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.
|
Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### cloneRegExp
|
---
|
||||||
|
title: cloneRegExp
|
||||||
|
tags: utility,regexp,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Clones a regular expression.
|
Clones a regular expression.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### coalesce
|
---
|
||||||
|
title: coalesce
|
||||||
|
tags: utility,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the first non-null/undefined argument.
|
Returns the first non-null/undefined argument.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### coalesceFactory
|
---
|
||||||
|
title: coalesceFactory
|
||||||
|
tags: utility,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.
|
Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### collectInto
|
---
|
||||||
|
title: collectInto
|
||||||
|
tags: adapter,function,array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Changes a function that accepts an array into a variadic function.
|
Changes a function that accepts an array into a variadic function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### colorize
|
---
|
||||||
|
title: colorize
|
||||||
|
tags: node,utility,string,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Add special characters to text to print in color in the console (combined with `console.log()`).
|
Add special characters to text to print in color in the console (combined with `console.log()`).
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### compact
|
---
|
||||||
|
title: compact
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Removes falsy values from an array.
|
Removes falsy values from an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### compactWhitespace
|
---
|
||||||
|
title: compactWhitespace
|
||||||
|
tags: string,regexp,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns a string with whitespaces compacted.
|
Returns a string with whitespaces compacted.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### compose
|
---
|
||||||
|
title: compose
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Performs right-to-left function composition.
|
Performs right-to-left function composition.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### composeRight
|
---
|
||||||
|
title: composeRight
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Performs left-to-right function composition.
|
Performs left-to-right function composition.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### converge
|
---
|
||||||
|
title: converge
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.
|
Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### copyToClipboard
|
---
|
||||||
|
title: copyToClipboard
|
||||||
|
tags: browser,string,advanced
|
||||||
|
---
|
||||||
|
|
||||||
⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard).
|
⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard).
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### countBy
|
---
|
||||||
|
title: countBy
|
||||||
|
tags: array,object,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Groups the elements of an array based on the given function and returns the count of elements in each group.
|
Groups the elements of an array based on the given function and returns the count of elements in each group.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### countOccurrences
|
---
|
||||||
|
title: countOccurrences
|
||||||
|
tags: array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Counts the occurrences of a value in an array.
|
Counts the occurrences of a value in an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### counter
|
---
|
||||||
|
title: counter
|
||||||
|
tags: browser,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Creates a counter with the specified range, step and duration for the specified selector.
|
Creates a counter with the specified range, step and duration for the specified selector.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### createDirIfNotExists
|
---
|
||||||
|
title: createDirIfNotExists
|
||||||
|
tags: node,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Creates a directory, if it does not exist.
|
Creates a directory, if it does not exist.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### createElement
|
---
|
||||||
|
title: createElement
|
||||||
|
tags: browser,utility,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Creates an element from a string (without appending it to the document).
|
Creates an element from a string (without appending it to the document).
|
||||||
If the given string contains multiple elements, only the first one will be returned.
|
If the given string contains multiple elements, only the first one will be returned.
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### createEventHub
|
---
|
||||||
|
title: createEventHub
|
||||||
|
tags: browser,event,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Creates a pub/sub ([publish–subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)) event hub with `emit`, `on`, and `off` methods.
|
Creates a pub/sub ([publish–subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)) event hub with `emit`, `on`, and `off` methods.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### currentURL
|
---
|
||||||
|
title: currentURL
|
||||||
|
tags: browser,url,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the current URL.
|
Returns the current URL.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### curry
|
---
|
||||||
|
title: curry
|
||||||
|
tags: function,recursion,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Curries a function.
|
Curries a function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### dayOfYear
|
---
|
||||||
|
title: dayOfYear
|
||||||
|
tags: date,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Gets the day of the year from a `Date` object.
|
Gets the day of the year from a `Date` object.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### debounce
|
---
|
||||||
|
title: debounce
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.
|
Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### decapitalize
|
---
|
||||||
|
title: decapitalize
|
||||||
|
tags: string,array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Decapitalizes the first letter of a string.
|
Decapitalizes the first letter of a string.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### deepClone
|
---
|
||||||
|
title: deepClone
|
||||||
|
tags: object,recursion,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Creates a deep clone of an object.
|
Creates a deep clone of an object.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### deepFlatten
|
---
|
||||||
|
title: deepFlatten
|
||||||
|
tags: array,recursion,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Deep flattens an array.
|
Deep flattens an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### deepFreeze
|
---
|
||||||
|
title: deepFreeze
|
||||||
|
tags: object,recursion,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Deep freezes an object.
|
Deep freezes an object.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### deepGet
|
---
|
||||||
|
title: deepGet
|
||||||
|
tags: object,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the target value in a nested JSON object, based on the `keys` array.
|
Returns the target value in a nested JSON object, based on the `keys` array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### deepMapKeys
|
---
|
||||||
|
title: deepMapKeys
|
||||||
|
tags: object,recursion,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Deep maps an object keys.
|
Deep maps an object keys.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### defaults
|
---
|
||||||
|
title: defaults
|
||||||
|
tags: object,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Assigns default values for all properties in an object that are `undefined`.
|
Assigns default values for all properties in an object that are `undefined`.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### defer
|
---
|
||||||
|
title: defer
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Defers invoking a function until the current call stack has cleared.
|
Defers invoking a function until the current call stack has cleared.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### degreesToRads
|
---
|
||||||
|
title: degreesToRads
|
||||||
|
tags: math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Converts an angle from degrees to radians.
|
Converts an angle from degrees to radians.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### delay
|
---
|
||||||
|
title: delay
|
||||||
|
tags: function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Invokes the provided function after `wait` milliseconds.
|
Invokes the provided function after `wait` milliseconds.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### detectDeviceType
|
---
|
||||||
|
title: detectDeviceType
|
||||||
|
tags: browser,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Detects whether the website is being opened in a mobile device or a desktop/laptop.
|
Detects whether the website is being opened in a mobile device or a desktop/laptop.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### difference
|
---
|
||||||
|
title: difference
|
||||||
|
tags: array,math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the difference between two arrays.
|
Returns the difference between two arrays.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### differenceBy
|
---
|
||||||
|
title: differenceBy
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the difference between two arrays, after applying the provided function to each array element of both.
|
Returns the difference between two arrays, after applying the provided function to each array element of both.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### differenceWith
|
---
|
||||||
|
title: differenceWith
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Filters out all values from an array for which the comparator function does not return `true`.
|
Filters out all values from an array for which the comparator function does not return `true`.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### dig
|
---
|
||||||
|
title: dig
|
||||||
|
tags: object,recursion,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the target value in a nested JSON object, based on the given key.
|
Returns the target value in a nested JSON object, based on the given key.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### digitize
|
---
|
||||||
|
title: digitize
|
||||||
|
tags: math,array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Converts a number to an array of digits.
|
Converts a number to an array of digits.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### distance
|
---
|
||||||
|
title: distance
|
||||||
|
tags: math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the distance between two points.
|
Returns the distance between two points.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### drop
|
---
|
||||||
|
title: drop
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns a new array with `n` elements removed from the left.
|
Returns a new array with `n` elements removed from the left.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### dropRight
|
---
|
||||||
|
title: dropRight
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns a new array with `n` elements removed from the right.
|
Returns a new array with `n` elements removed from the right.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### dropRightWhile
|
---
|
||||||
|
title: dropRightWhile
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Removes elements from the end of an array until the passed function returns `true`. Returns the remaining elements in the array.
|
Removes elements from the end of an array until the passed function returns `true`. Returns the remaining elements in the array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### dropWhile
|
---
|
||||||
|
title: dropWhile
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Removes elements in an array until the passed function returns `true`. Returns the remaining elements in the array.
|
Removes elements in an array until the passed function returns `true`. Returns the remaining elements in the array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### elementContains
|
---
|
||||||
|
title: elementContains
|
||||||
|
tags: browser,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns `true` if the `parent` element contains the `child` element, `false` otherwise.
|
Returns `true` if the `parent` element contains the `child` element, `false` otherwise.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### elementIsVisibleInViewport
|
---
|
||||||
|
title: elementIsVisibleInViewport
|
||||||
|
tags: browser,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Returns `true` if the element specified is visible in the viewport, `false` otherwise.
|
Returns `true` if the element specified is visible in the viewport, `false` otherwise.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### elo
|
---
|
||||||
|
title: elo
|
||||||
|
tags: math,array,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Computes the new ratings between two or more opponents using the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system). It takes an array
|
Computes the new ratings between two or more opponents using the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system). It takes an array
|
||||||
of pre-ratings and returns an array containing post-ratings.
|
of pre-ratings and returns an array containing post-ratings.
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### equals
|
---
|
||||||
|
title: equals
|
||||||
|
tags: object,array,type,advanced
|
||||||
|
---
|
||||||
|
|
||||||
Performs a deep comparison between two values to determine if they are equivalent.
|
Performs a deep comparison between two values to determine if they are equivalent.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### escapeHTML
|
---
|
||||||
|
title: escapeHTML
|
||||||
|
tags: string,browser,regexp,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Escapes a string for use in HTML.
|
Escapes a string for use in HTML.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### escapeRegExp
|
---
|
||||||
|
title: escapeRegExp
|
||||||
|
tags: string,regexp,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Escapes a string to use in a regular expression.
|
Escapes a string to use in a regular expression.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### everyNth
|
---
|
||||||
|
title: everyNth
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns every nth element in an array.
|
Returns every nth element in an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### extendHex
|
---
|
||||||
|
title: extendHex
|
||||||
|
tags: utility,string,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Extends a 3-digit color code to a 6-digit color code.
|
Extends a 3-digit color code to a 6-digit color code.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### factorial
|
---
|
||||||
|
title: factorial
|
||||||
|
tags: math,recursion,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Calculates the factorial of a number.
|
Calculates the factorial of a number.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### fibonacci
|
---
|
||||||
|
title: fibonacci
|
||||||
|
tags: math,array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Generates an array, containing the Fibonacci sequence, up until the nth term.
|
Generates an array, containing the Fibonacci sequence, up until the nth term.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### filterFalsy
|
---
|
||||||
|
title: filterFalsy
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Filters out the falsy values in an array.
|
Filters out the falsy values in an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### filterNonUnique
|
---
|
||||||
|
title: filterNonUnique
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Filters out the non-unique values in an array.
|
Filters out the non-unique values in an array.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### filterNonUniqueBy
|
---
|
||||||
|
title: filterNonUniqueBy
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Filters out the non-unique values in an array, based on a provided comparator function.
|
Filters out the non-unique values in an array, based on a provided comparator function.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### findKey
|
---
|
||||||
|
title: findKey
|
||||||
|
tags: object,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the first key that satisfies the provided testing function. Otherwise `undefined` is returned.
|
Returns the first key that satisfies the provided testing function. Otherwise `undefined` is returned.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### findLast
|
---
|
||||||
|
title: findLast
|
||||||
|
tags: array,beginner
|
||||||
|
---
|
||||||
|
|
||||||
Returns the last element for which the provided function returns a truthy value.
|
Returns the last element for which the provided function returns a truthy value.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### findLastIndex
|
---
|
||||||
|
title: findLastIndex
|
||||||
|
tags: array,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the index of the last element for which the provided function returns a truthy value.
|
Returns the index of the last element for which the provided function returns a truthy value.
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### findLastKey
|
---
|
||||||
|
title: findLastKey
|
||||||
|
tags: object,function,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Returns the last key that satisfies the provided testing function.
|
Returns the last key that satisfies the provided testing function.
|
||||||
Otherwise `undefined` is returned.
|
Otherwise `undefined` is returned.
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
### flatten
|
---
|
||||||
|
title: flatten
|
||||||
|
tags: array,intermediate
|
||||||
|
---
|
||||||
|
|
||||||
Flattens an array up to the specified depth.
|
Flattens an array up to the specified depth.
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user