diff --git a/snippet-template.md b/snippet-template.md index d87a82f49..c2e266cd9 100644 --- a/snippet-template.md +++ b/snippet-template.md @@ -1,6 +1,6 @@ --- title: functionName -tags: utility,intermediate +tags: array,intermediate --- Explain briefly what the snippet does. diff --git a/snippets/CSVToArray.md b/snippets/CSVToArray.md index dc448de3d..6294834af 100644 --- a/snippets/CSVToArray.md +++ b/snippets/CSVToArray.md @@ -1,6 +1,6 @@ --- title: CSVToArray -tags: string,array,utility,intermediate +tags: string,array,intermediate --- Converts a comma-separated values (CSV) string to a 2D array. @@ -22,4 +22,4 @@ const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => CSVToArray('a,b\nc,d'); // [['a','b'],['c','d']]; CSVToArray('a;b\nc;d', ';'); // [['a','b'],['c','d']]; CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']]; -``` \ No newline at end of file +``` diff --git a/snippets/RGBToHex.md b/snippets/RGBToHex.md index 4d9ea9391..8ffb2f652 100644 --- a/snippets/RGBToHex.md +++ b/snippets/RGBToHex.md @@ -1,6 +1,6 @@ --- title: RGBToHex -tags: utility,intermediate +tags: string,math,intermediate --- Converts the values of RGB components to a color code. @@ -13,4 +13,4 @@ const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6 ```js RGBToHex(255, 165, 1); // 'ffa501' -``` \ No newline at end of file +``` diff --git a/snippets/URLJoin.md b/snippets/URLJoin.md index a9256f8cf..c66b9607b 100644 --- a/snippets/URLJoin.md +++ b/snippets/URLJoin.md @@ -1,6 +1,6 @@ --- title: URLJoin -tags: string,utility,regexp,advanced +tags: string,regexp,advanced --- Joins all given URL segments together, then normalizes the resulting URL. @@ -21,4 +21,4 @@ const URLJoin = (...args) => ```js URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'); // 'http://www.google.com/a/b/cd?foo=123&bar=foo' -``` \ No newline at end of file +``` diff --git a/snippets/UUIDGeneratorBrowser.md b/snippets/UUIDGeneratorBrowser.md index 4d11897ef..418e5c760 100644 --- a/snippets/UUIDGeneratorBrowser.md +++ b/snippets/UUIDGeneratorBrowser.md @@ -1,6 +1,6 @@ --- title: UUIDGeneratorBrowser -tags: browser,utility,random,intermediate +tags: browser,random,intermediate --- Generates a UUID in a browser. @@ -16,4 +16,4 @@ const UUIDGeneratorBrowser = () => ```js UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d' -``` \ No newline at end of file +``` diff --git a/snippets/UUIDGeneratorNode.md b/snippets/UUIDGeneratorNode.md index 4d4a0d085..61651151c 100644 --- a/snippets/UUIDGeneratorNode.md +++ b/snippets/UUIDGeneratorNode.md @@ -1,6 +1,6 @@ --- title: UUIDGeneratorNode -tags: node,utility,random,intermediate +tags: node,random,intermediate --- Generates a UUID in Node.JS. @@ -17,4 +17,4 @@ const UUIDGeneratorNode = () => ```js UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' -``` \ No newline at end of file +``` diff --git a/snippets/arrayToCSV.md b/snippets/arrayToCSV.md index f78ffdbc4..6137994a2 100644 --- a/snippets/arrayToCSV.md +++ b/snippets/arrayToCSV.md @@ -1,6 +1,6 @@ --- title: arrayToCSV -tags: array,string,utility,intermediate +tags: array,string,intermediate --- Converts a 2D array to a comma-separated values (CSV) string. @@ -20,4 +20,4 @@ const arrayToCSV = (arr, delimiter = ',') => arrayToCSV([['a', 'b'], ['c', 'd']]); // '"a","b"\n"c","d"' arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '"a";"b"\n"c";"d"' arrayToCSV([['a', '"b" great'], ['c', 3.1415]]); // '"a","""b"" great"\n"c",3.1415' -``` \ No newline at end of file +``` diff --git a/snippets/atob.md b/snippets/atob.md index 222c052a2..f18769bf7 100644 --- a/snippets/atob.md +++ b/snippets/atob.md @@ -1,6 +1,6 @@ --- title: atob -tags: node,string,utility,beginner +tags: node,string,beginner --- Decodes a string of data which has been encoded using base-64 encoding. @@ -13,4 +13,4 @@ const atob = str => Buffer.from(str, 'base64').toString('binary'); ```js atob('Zm9vYmFy'); // 'foobar' -``` \ No newline at end of file +``` diff --git a/snippets/btoa.md b/snippets/btoa.md index 6cbe32f46..ced08825a 100644 --- a/snippets/btoa.md +++ b/snippets/btoa.md @@ -1,6 +1,6 @@ --- title: btoa -tags: node,string,utility,beginner +tags: node,string,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. @@ -13,4 +13,4 @@ const btoa = str => Buffer.from(str, 'binary').toString('base64'); ```js btoa('foobar'); // 'Zm9vYmFy' -``` \ No newline at end of file +``` diff --git a/snippets/castArray.md b/snippets/castArray.md index e8c498058..39cc4cb6a 100644 --- a/snippets/castArray.md +++ b/snippets/castArray.md @@ -1,6 +1,6 @@ --- title: castArray -tags: utility,array,type,beginner +tags: type,array,beginner --- Casts the provided value as an array if it's not one. @@ -14,4 +14,4 @@ const castArray = val => (Array.isArray(val) ? val : [val]); ```js castArray('foo'); // ['foo'] castArray([1]); // [1] -``` \ No newline at end of file +``` diff --git a/snippets/checkProp.md b/snippets/checkProp.md index ae8320e59..e1bbaa740 100644 --- a/snippets/checkProp.md +++ b/snippets/checkProp.md @@ -1,6 +1,6 @@ --- title: checkProp -tags: function,object,utility,beginner +tags: function,object,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. diff --git a/snippets/cloneRegExp.md b/snippets/cloneRegExp.md index 5c072c4e4..6a4b86628 100644 --- a/snippets/cloneRegExp.md +++ b/snippets/cloneRegExp.md @@ -1,6 +1,6 @@ --- title: cloneRegExp -tags: utility,regexp,intermediate +tags: type,string,regexp,intermediate --- Clones a regular expression. @@ -14,4 +14,4 @@ const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); ```js const regExp = /lorem ipsum/gi; const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi -``` \ No newline at end of file +``` diff --git a/snippets/coalesce.md b/snippets/coalesce.md index f57a7ac8b..1841329e9 100644 --- a/snippets/coalesce.md +++ b/snippets/coalesce.md @@ -1,6 +1,6 @@ --- title: coalesce -tags: utility,beginner +tags: type,beginner --- Returns the first defined, non-null argument. diff --git a/snippets/coalesceFactory.md b/snippets/coalesceFactory.md index 16ef17c90..639b951af 100644 --- a/snippets/coalesceFactory.md +++ b/snippets/coalesceFactory.md @@ -1,6 +1,6 @@ --- title: coalesceFactory -tags: utility,intermediate +tags: type,intermediate --- Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function. @@ -14,4 +14,4 @@ const coalesceFactory = valid => (...args) => args.find(valid); ```js const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_)); customCoalesce(undefined, null, NaN, '', 'Waldo'); // "Waldo" -``` \ No newline at end of file +``` diff --git a/snippets/colorize.md b/snippets/colorize.md index 9f67fa468..e5ac93930 100644 --- a/snippets/colorize.md +++ b/snippets/colorize.md @@ -1,6 +1,6 @@ --- title: colorize -tags: node,utility,string,intermediate +tags: node,string,intermediate --- Add special characters to text to print in color in the console (combined with `console.log()`). @@ -33,4 +33,4 @@ const colorize = (...args) => ({ console.log(colorize('foo').red); // 'foo' (red letters) console.log(colorize('foo', 'bar').bgBlue); // 'foo bar' (blue background) console.log(colorize(colorize('foo').yellow, colorize('foo').green).bgWhite); // 'foo bar' (first word in yellow letters, second word in green letters, white background for both) -``` \ No newline at end of file +``` diff --git a/snippets/createElement.md b/snippets/createElement.md index 4f5c31242..3f7ec3e21 100644 --- a/snippets/createElement.md +++ b/snippets/createElement.md @@ -1,13 +1,13 @@ --- title: createElement -tags: browser,utility,beginner +tags: browser,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. Use `document.createElement()` to create a new element. -Set its `innerHTML` to the string supplied as the argument. +Set its `innerHTML` to the string supplied as the argument. Use `ParentNode.firstElementChild` to return the element version of the string. ```js @@ -25,4 +25,4 @@ const el = createElement( ` ); console.log(el.className); // 'container' -``` \ No newline at end of file +``` diff --git a/snippets/extendHex.md b/snippets/extendHex.md index 4fc24af82..c63c72459 100644 --- a/snippets/extendHex.md +++ b/snippets/extendHex.md @@ -1,6 +1,6 @@ --- title: extendHex -tags: utility,string,intermediate +tags: string,intermediate --- Extends a 3-digit color code to a 6-digit color code. @@ -21,4 +21,4 @@ const extendHex = shortHex => ```js extendHex('#03f'); // '#0033ff' extendHex('05a'); // '#0055aa' -``` \ No newline at end of file +``` diff --git a/snippets/formatDuration.md b/snippets/formatDuration.md index 48b3e5df8..9bc7ef63a 100644 --- a/snippets/formatDuration.md +++ b/snippets/formatDuration.md @@ -1,6 +1,6 @@ --- title: formatDuration -tags: date,math,string,utility,intermediate +tags: date,math,string,intermediate --- Returns the human readable format of the given number of milliseconds. @@ -30,4 +30,4 @@ const formatDuration = ms => { ```js formatDuration(1001); // '1 second, 1 millisecond' formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds' -``` \ No newline at end of file +``` diff --git a/snippets/functionName.md b/snippets/functionName.md index 0811b550b..97aeaf931 100644 --- a/snippets/functionName.md +++ b/snippets/functionName.md @@ -1,6 +1,6 @@ --- title: functionName -tags: function,utility,beginner +tags: function,beginner --- Logs the name of a function. @@ -13,4 +13,4 @@ const functionName = fn => (console.debug(fn.name), fn); ```js functionName(Math.max); // max (logged in debug channel of console) -``` \ No newline at end of file +``` diff --git a/snippets/getURLParameters.md b/snippets/getURLParameters.md index 287abebb8..28a7b50e5 100644 --- a/snippets/getURLParameters.md +++ b/snippets/getURLParameters.md @@ -1,6 +1,6 @@ --- title: getURLParameters -tags: utility,browser,string,url,intermediate +tags: browser,string,url,intermediate --- Returns an object containing the parameters of the current URL. @@ -19,4 +19,4 @@ const getURLParameters = url => ```js getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam', surname: 'Smith'} getURLParameters('google.com'); // {} -``` \ No newline at end of file +``` diff --git a/snippets/hashBrowser.md b/snippets/hashBrowser.md index 91c7741dc..e50cf2b36 100644 --- a/snippets/hashBrowser.md +++ b/snippets/hashBrowser.md @@ -1,6 +1,6 @@ --- title: hashBrowser -tags: browser,utility,advanced,promise,advanced +tags: browser,advanced,promise,advanced --- Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise. @@ -20,4 +20,4 @@ const hashBrowser = val => ```js hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' -``` \ No newline at end of file +``` diff --git a/snippets/hashNode.md b/snippets/hashNode.md index b29ba3814..5ce49528a 100644 --- a/snippets/hashNode.md +++ b/snippets/hashNode.md @@ -1,6 +1,6 @@ --- title: hashNode -tags: node,utility,promise,intermediate +tags: node,promise,intermediate --- Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise. @@ -26,4 +26,4 @@ const hashNode = val => ```js hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' -``` \ No newline at end of file +``` diff --git a/snippets/hexToRGB.md b/snippets/hexToRGB.md index 0638ea9c9..9d2ae035b 100644 --- a/snippets/hexToRGB.md +++ b/snippets/hexToRGB.md @@ -1,6 +1,6 @@ --- title: hexToRGB -tags: utility,string,math,advanced +tags: string,math,advanced --- Converts a color code to a `rgb()` or `rgba()` string if alpha value is provided. @@ -33,4 +33,4 @@ const hexToRGB = hex => { hexToRGB('#27ae60ff'); // 'rgba(39, 174, 96, 255)' hexToRGB('27ae60'); // 'rgb(39, 174, 96)' hexToRGB('#fff'); // 'rgb(255, 255, 255)' -``` \ No newline at end of file +``` diff --git a/snippets/httpDelete.md b/snippets/httpDelete.md index 7fafa8093..1365c26be 100644 --- a/snippets/httpDelete.md +++ b/snippets/httpDelete.md @@ -1,6 +1,6 @@ --- title: httpDelete -tags: utility,url,browser,intermediate +tags: browser,url,intermediate --- Makes a `DELETE` request to the passed URL. diff --git a/snippets/httpGet.md b/snippets/httpGet.md index 00feccc64..26670c286 100644 --- a/snippets/httpGet.md +++ b/snippets/httpGet.md @@ -1,6 +1,6 @@ --- title: httpGet -tags: utility,url,browser,intermediate +tags: browser,url,intermediate --- Makes a `GET` request to the passed URL. @@ -32,4 +32,4 @@ Logs: { "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" } */ -``` \ No newline at end of file +``` diff --git a/snippets/httpPost.md b/snippets/httpPost.md index 1522a3c41..b6160eae5 100644 --- a/snippets/httpPost.md +++ b/snippets/httpPost.md @@ -1,6 +1,6 @@ --- title: httpPost -tags: utility,url,browser,intermediate +tags: browser,url,intermediate --- Makes a `POST` request to the passed URL. @@ -52,4 +52,4 @@ Logs: { "id": 101 } */ -``` \ No newline at end of file +``` diff --git a/snippets/httpPut.md b/snippets/httpPut.md index ea785ccff..9ac16fd44 100644 --- a/snippets/httpPut.md +++ b/snippets/httpPut.md @@ -1,6 +1,6 @@ --- title: httpPut -tags: utility,url,browser,intermediate +tags: browser,url,intermediate --- Makes a `PUT` request to the passed URL. diff --git a/snippets/indentString.md b/snippets/indentString.md index 06380c995..36ca10c9a 100644 --- a/snippets/indentString.md +++ b/snippets/indentString.md @@ -1,6 +1,6 @@ --- title: indentString -tags: string,utility,beginner +tags: string,beginner --- Indents each line in the provided string. @@ -15,4 +15,4 @@ const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.rep ```js indentString('Lorem\nIpsum', 2); // ' Lorem\n Ipsum' indentString('Lorem\nIpsum', 2, '_'); // '__Lorem\n__Ipsum' -``` \ No newline at end of file +``` diff --git a/snippets/isAbsoluteURL.md b/snippets/isAbsoluteURL.md index 127aaf18f..19b412ad8 100644 --- a/snippets/isAbsoluteURL.md +++ b/snippets/isAbsoluteURL.md @@ -1,6 +1,6 @@ --- title: isAbsoluteURL -tags: string,utility,browser,url,intermediate +tags: string,browser,url,intermediate --- Returns `true` if the given string is an absolute URL, `false` otherwise. @@ -15,4 +15,4 @@ const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); isAbsoluteURL('https://google.com'); // true isAbsoluteURL('ftp://www.myserver.net'); // true isAbsoluteURL('/foo/bar'); // false -``` \ No newline at end of file +``` diff --git a/snippets/isAfterDate.md b/snippets/isAfterDate.md index 75d1ce350..7e1247c95 100644 --- a/snippets/isAfterDate.md +++ b/snippets/isAfterDate.md @@ -1,6 +1,6 @@ --- title: isAfterDate -tags: date,utility,beginner +tags: date,beginner --- Check if a date is after another date. @@ -13,4 +13,4 @@ const isAfterDate = (dateA, dateB) => dateA > dateB; ```js isAfterDate(new Date(2010, 10, 21), new Date(2010, 10, 20)); // true -``` \ No newline at end of file +``` diff --git a/snippets/isBeforeDate.md b/snippets/isBeforeDate.md index b2ebd41c6..d71702112 100644 --- a/snippets/isBeforeDate.md +++ b/snippets/isBeforeDate.md @@ -1,6 +1,6 @@ --- title: isBeforeDate -tags: date,utility,beginner +tags: date,beginner --- Check if a date is before another date. @@ -13,4 +13,4 @@ const isBeforeDate = (dateA, dateB) => dateA < dateB; ```js isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21)); // true -``` \ No newline at end of file +``` diff --git a/snippets/isBrowser.md b/snippets/isBrowser.md index 0226ea600..ba9906992 100644 --- a/snippets/isBrowser.md +++ b/snippets/isBrowser.md @@ -1,6 +1,6 @@ --- title: isBrowser -tags: utility,browser,intermediate +tags: browser,intermediate --- Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node) without throwing errors. @@ -16,4 +16,4 @@ const isBrowser = () => ![typeof window, typeof document].includes('undefined'); ```js isBrowser(); // true (browser) isBrowser(); // false (Node) -``` \ No newline at end of file +``` diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md index 7be7b4a7d..893688c4f 100644 --- a/snippets/isLowerCase.md +++ b/snippets/isLowerCase.md @@ -1,6 +1,6 @@ --- title: isLowerCase -tags: string,utility,beginner +tags: string,beginner --- Checks if a string is lower case. @@ -15,4 +15,4 @@ const isLowerCase = str => str === str.toLowerCase(); isLowerCase('abc'); // true isLowerCase('a3@$'); // true isLowerCase('Ab4'); // false -``` \ No newline at end of file +``` diff --git a/snippets/isNegativeZero.md b/snippets/isNegativeZero.md index 065c1a01d..564242173 100644 --- a/snippets/isNegativeZero.md +++ b/snippets/isNegativeZero.md @@ -1,6 +1,6 @@ --- title: isNegativeZero -tags: math,utility,beginner +tags: math,beginner --- Checks if the given value is equal to negative zero (`-0`). @@ -14,4 +14,4 @@ const isNegativeZero = val => val === 0 && 1 / val === -Infinity; ```js isNegativeZero(-0); // true isNegativeZero(0); // false -``` \ No newline at end of file +``` diff --git a/snippets/isSameDate.md b/snippets/isSameDate.md index 8447317c2..953aab1eb 100644 --- a/snippets/isSameDate.md +++ b/snippets/isSameDate.md @@ -1,6 +1,6 @@ --- title: isSameDate -tags: date,utility,beginner +tags: date,beginner --- Check if a date is the same as another date. @@ -13,4 +13,4 @@ const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString() ```js isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true -``` \ No newline at end of file +``` diff --git a/snippets/isUpperCase.md b/snippets/isUpperCase.md index cbcd0868a..f047c7692 100644 --- a/snippets/isUpperCase.md +++ b/snippets/isUpperCase.md @@ -1,6 +1,6 @@ --- title: isUpperCase -tags: string,utility,beginner +tags: string,beginner --- Checks if a string is upper case. diff --git a/snippets/longestItem.md b/snippets/longestItem.md index 918865ee4..b5b7e46da 100644 --- a/snippets/longestItem.md +++ b/snippets/longestItem.md @@ -1,6 +1,6 @@ --- title: longestItem -tags: array,string,utility,intermediate +tags: array,string,intermediate --- Takes any number of iterable objects or objects with a `length` property and returns the longest one. @@ -19,4 +19,4 @@ longestItem(...['a', 'ab', 'abc']); // 'abc' longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd' longestItem([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]); // [1, 2, 3, 4, 5] longestItem([1, 2, 3], 'foobar'); // 'foobar' -``` \ No newline at end of file +``` diff --git a/snippets/luhnCheck.md b/snippets/luhnCheck.md index 797a204ba..292f37825 100644 --- a/snippets/luhnCheck.md +++ b/snippets/luhnCheck.md @@ -1,6 +1,6 @@ --- title: luhnCheck -tags: math,utility,advanced +tags: math,advanced --- Implementation of the [Luhn Algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc. @@ -27,4 +27,4 @@ const luhnCheck = num => { luhnCheck('4485275742308327'); // true luhnCheck(6011329933655299); // false luhnCheck(123456789); // false -``` \ No newline at end of file +``` diff --git a/snippets/mapString.md b/snippets/mapString.md index 8140a5b28..8809e1c62 100644 --- a/snippets/mapString.md +++ b/snippets/mapString.md @@ -1,6 +1,6 @@ --- title: mapString -tags: string,array,function,utility,beginner +tags: string,array,function,beginner --- Creates a new string with the results of calling a provided function on every character in the calling string. @@ -19,4 +19,4 @@ const mapString = (str, fn) => ```js mapString('lorem ipsum', c => c.toUpperCase()); // 'LOREM IPSUM' -``` \ No newline at end of file +``` diff --git a/snippets/mask.md b/snippets/mask.md index dbf04ef7a..a43ed77dc 100644 --- a/snippets/mask.md +++ b/snippets/mask.md @@ -1,6 +1,6 @@ --- title: mask -tags: string,utility,intermediate +tags: string,intermediate --- Replaces all but the last `num` of characters with the specified mask character. diff --git a/snippets/mostPerformant.md b/snippets/mostPerformant.md index a61be4063..091c55844 100644 --- a/snippets/mostPerformant.md +++ b/snippets/mostPerformant.md @@ -1,6 +1,6 @@ --- title: mostPerformant -tags: utility,function +tags: function,intermediate --- Returns the index of the function in an array of functions which executed the fastest. @@ -31,4 +31,4 @@ mostPerformant([ [1, '2', 3, 4, 5, 6, 7, 8, 9, 10].every(el => typeof el === 'number'); } ]); // 1 -``` \ No newline at end of file +``` diff --git a/snippets/nthArg.md b/snippets/nthArg.md index 53b25c3da..52cbddd39 100644 --- a/snippets/nthArg.md +++ b/snippets/nthArg.md @@ -1,6 +1,6 @@ --- title: nthArg -tags: utility,function,beginner +tags: function,beginner --- Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned. @@ -17,4 +17,4 @@ third(1, 2, 3); // 3 third(1, 2); // undefined const last = nthArg(-1); last(1, 2, 3, 4, 5); // 5 -``` \ No newline at end of file +``` diff --git a/snippets/objectToQueryString.md b/snippets/objectToQueryString.md index bb5da7fc5..40cc9776c 100644 --- a/snippets/objectToQueryString.md +++ b/snippets/objectToQueryString.md @@ -1,6 +1,6 @@ --- title: objectToQueryString -tags: utility,object,function,intermediate +tags: object,function,intermediate --- Returns a query string generated from the key-value pairs of the given object. diff --git a/snippets/parseCookie.md b/snippets/parseCookie.md index cbbe24bc5..26c0f63cd 100644 --- a/snippets/parseCookie.md +++ b/snippets/parseCookie.md @@ -1,6 +1,6 @@ --- title: parseCookie -tags: utility,string,intermediate +tags: browser,string,intermediate --- Parse an HTTP Cookie header string and return an object of all cookie name-value pairs. @@ -22,4 +22,4 @@ const parseCookie = str => ```js parseCookie('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2' } -``` \ No newline at end of file +``` diff --git a/snippets/prefix.md b/snippets/prefix.md index 0c1b9c216..61fbb92e7 100644 --- a/snippets/prefix.md +++ b/snippets/prefix.md @@ -1,6 +1,6 @@ --- title: prefix -tags: browser,utility,intermediate +tags: browser,intermediate --- Returns the prefixed version (if necessary) of a CSS property that the browser supports. @@ -21,4 +21,4 @@ const prefix = prop => { ```js prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitAppearance', 'mozAppearance', 'msAppearance' or 'oAppearance' -``` \ No newline at end of file +``` diff --git a/snippets/prettyBytes.md b/snippets/prettyBytes.md index aef44f8ea..287a43ef5 100644 --- a/snippets/prettyBytes.md +++ b/snippets/prettyBytes.md @@ -1,6 +1,6 @@ --- title: prettyBytes -tags: utility,string,math,advanced +tags: string,math,advanced --- Converts a number in bytes to a human-readable string. @@ -25,4 +25,4 @@ const prettyBytes = (num, precision = 3, addSpace = true) => { prettyBytes(1000); // "1 KB" prettyBytes(-27145424323.5821, 5); // "-27.145 GB" prettyBytes(123456789, 3, false); // "123MB" -``` \ No newline at end of file +``` diff --git a/snippets/randomHexColorCode.md b/snippets/randomHexColorCode.md index 4fe7818ba..b54ef1c2b 100644 --- a/snippets/randomHexColorCode.md +++ b/snippets/randomHexColorCode.md @@ -1,11 +1,12 @@ --- title: randomHexColorCode -tags: utility,random,beginner +tags: math,random,beginner --- Generates a random hexadecimal color code. -Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use bit shifting and then convert it to an hexadecimal String using `toString(16)`. +Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. +Use bit shifting and then convert it to an hexadecimal String using `toString(16)`. ```js const randomHexColorCode = () => { @@ -16,4 +17,4 @@ const randomHexColorCode = () => { ```js randomHexColorCode(); // "#e34155" -``` \ No newline at end of file +``` diff --git a/snippets/randomIntArrayInRange.md b/snippets/randomIntArrayInRange.md index 075bece9d..a689aedd4 100644 --- a/snippets/randomIntArrayInRange.md +++ b/snippets/randomIntArrayInRange.md @@ -1,6 +1,6 @@ --- title: randomIntArrayInRange -tags: math,utility,random,intermediate +tags: math,random,intermediate --- Returns an array of n random integers in the specified range. @@ -14,4 +14,4 @@ const randomIntArrayInRange = (min, max, n = 1) => ```js randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ] -``` \ No newline at end of file +``` diff --git a/snippets/randomIntegerInRange.md b/snippets/randomIntegerInRange.md index 177c61983..6151717c4 100644 --- a/snippets/randomIntegerInRange.md +++ b/snippets/randomIntegerInRange.md @@ -1,6 +1,6 @@ --- title: randomIntegerInRange -tags: math,utility,random,beginner +tags: math,random,beginner --- Returns a random integer in the specified range. @@ -13,4 +13,4 @@ const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min ```js randomIntegerInRange(0, 5); // 2 -``` \ No newline at end of file +``` diff --git a/snippets/randomNumberInRange.md b/snippets/randomNumberInRange.md index ff6a5a1dd..ea0011159 100644 --- a/snippets/randomNumberInRange.md +++ b/snippets/randomNumberInRange.md @@ -1,6 +1,6 @@ --- title: randomNumberInRange -tags: math,utility,random,beginner +tags: math,random,beginner --- Returns a random number in the specified range. @@ -13,4 +13,4 @@ const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; ```js randomNumberInRange(2, 10); // 6.0211363285087005 -``` \ No newline at end of file +``` diff --git a/snippets/recordAnimationFrames.md b/snippets/recordAnimationFrames.md index 37975c298..531c1f9fe 100644 --- a/snippets/recordAnimationFrames.md +++ b/snippets/recordAnimationFrames.md @@ -1,13 +1,13 @@ --- title: recordAnimationFrames -tags: browser,utility,intermediate +tags: browser,intermediate --- Invokes the provided callback on each animation frame. -Use recursion. -Provided that `running` is `true`, continue invoking `window.requestAnimationFrame()` which invokes the provided callback. -Return an object with two methods `start` and `stop` to allow manual control of the recording. +Use recursion. +Provided that `running` is `true`, continue invoking `window.requestAnimationFrame()` which invokes the provided callback. +Return an object with two methods `start` and `stop` to allow manual control of the recording. Omit the second argument, `autoStart`, to implicitly call `start` when the function is invoked. ```js @@ -39,4 +39,4 @@ const recorder = recordAnimationFrames(cb); // logs 'Animation frame fired' on e recorder.stop(); // stops logging recorder.start(); // starts again const recorder2 = recordAnimationFrames(cb, false); // `start` needs to be explicitly called to begin recording frames -``` \ No newline at end of file +``` diff --git a/snippets/sdbm.md b/snippets/sdbm.md index fdd4d3090..c0fd3caa8 100644 --- a/snippets/sdbm.md +++ b/snippets/sdbm.md @@ -1,6 +1,6 @@ --- title: sdbm -tags: math,utility,intermediate +tags: math,intermediate --- Hashes the input string into a whole number. @@ -20,4 +20,4 @@ const sdbm = str => { ```js sdbm('name'); // -3521204949 -``` \ No newline at end of file +``` diff --git a/snippets/serializeCookie.md b/snippets/serializeCookie.md index b5dade2e7..3ee721d56 100644 --- a/snippets/serializeCookie.md +++ b/snippets/serializeCookie.md @@ -1,6 +1,6 @@ --- title: serializeCookie -tags: utility,string,intermediate +tags: browser,string,intermediate --- Serialize a cookie name-value pair into a Set-Cookie header string. @@ -13,4 +13,4 @@ const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIC ```js serializeCookie('foo', 'bar'); // 'foo=bar' -``` \ No newline at end of file +``` diff --git a/snippets/stripHTMLTags.md b/snippets/stripHTMLTags.md index 819159734..42bb17367 100644 --- a/snippets/stripHTMLTags.md +++ b/snippets/stripHTMLTags.md @@ -1,6 +1,6 @@ --- title: stripHTMLTags -tags: string,utility,regexp,beginner +tags: string,regexp,beginner --- Removes HTML/XML tags from string. @@ -13,4 +13,4 @@ const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); ```js stripHTMLTags('

lorem ipsum

'); // 'lorem ipsum' -``` \ No newline at end of file +``` diff --git a/snippets/timeTaken.md b/snippets/timeTaken.md index 71011d46e..2c8be2631 100644 --- a/snippets/timeTaken.md +++ b/snippets/timeTaken.md @@ -1,6 +1,6 @@ --- title: timeTaken -tags: utility,beginner +tags: function,beginner --- Measures the time taken by a function to execute. @@ -18,4 +18,4 @@ const timeTaken = callback => { ```js timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms -``` \ No newline at end of file +``` diff --git a/snippets/toCurrency.md b/snippets/toCurrency.md index a89bca3d8..ba0a5a113 100644 --- a/snippets/toCurrency.md +++ b/snippets/toCurrency.md @@ -1,6 +1,6 @@ --- title: toCurrency -tags: utility,intermediate +tags: math,string,intermediate --- Take a number and return specified currency formatting. @@ -18,4 +18,4 @@ toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79 | currency: US Dollar | toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish -``` \ No newline at end of file +``` diff --git a/snippets/toDecimalMark.md b/snippets/toDecimalMark.md index b2ab2210b..5edbc41e5 100644 --- a/snippets/toDecimalMark.md +++ b/snippets/toDecimalMark.md @@ -1,6 +1,6 @@ --- title: toDecimalMark -tags: utility,math,beginner +tags: math,beginner --- Converts a number to a decimal mark formatted string. diff --git a/snippets/toOrdinalSuffix.md b/snippets/toOrdinalSuffix.md index 28025b5de..ef9484ff1 100644 --- a/snippets/toOrdinalSuffix.md +++ b/snippets/toOrdinalSuffix.md @@ -1,6 +1,6 @@ --- title: toOrdinalSuffix -tags: utility,math,intermediate +tags: math,intermediate --- Adds an ordinal suffix to a number. @@ -24,4 +24,4 @@ const toOrdinalSuffix = num => { ```js toOrdinalSuffix('123'); // "123rd" -``` \ No newline at end of file +``` diff --git a/snippets/validateNumber.md b/snippets/validateNumber.md index ba0047d44..031cc01e8 100644 --- a/snippets/validateNumber.md +++ b/snippets/validateNumber.md @@ -1,6 +1,6 @@ --- title: validateNumber -tags: utility,math,intermediate +tags: math,intermediate --- Returns `true` if the given value is a number, `false` otherwise. @@ -15,4 +15,4 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == ```js validateNumber('10'); // true -``` \ No newline at end of file +``` diff --git a/snippets/yesNo.md b/snippets/yesNo.md index 0be6776ed..4d1b2958b 100644 --- a/snippets/yesNo.md +++ b/snippets/yesNo.md @@ -1,6 +1,6 @@ --- title: yesNo -tags: utility,regexp,intermediate +tags: string,regexp,intermediate --- Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`. @@ -18,4 +18,4 @@ yesNo('Y'); // true yesNo('yes'); // true yesNo('No'); // false yesNo('Foo', true); // true -``` \ No newline at end of file +```