Travis build: 1511
This commit is contained in:
38
README.md
38
README.md
@ -494,6 +494,7 @@ _30s.average(1, 2, 3);
|
||||
* [`isBrowser`](#isbrowser)
|
||||
* [`mostPerformant`](#mostperformant)
|
||||
* [`nthArg`](#ntharg)
|
||||
* [`objectToQueryString`](#objecttoquerystring)
|
||||
* [`parseCookie`](#parsecookie)
|
||||
* [`prettyBytes`](#prettybytes-)
|
||||
* [`randomHexColorCode`](#randomhexcolorcode)
|
||||
@ -7127,8 +7128,7 @@ Otherwise, use `Object.keys(obj)` in combination with `Array.prototype.includes(
|
||||
const hasKey = (obj, key) => {
|
||||
if (key.includes('.')) {
|
||||
let _key = key.split('.')[0];
|
||||
if (typeof obj[_key] === 'object')
|
||||
return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
if (typeof obj[_key] === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
}
|
||||
return Object.keys(obj).includes(key);
|
||||
};
|
||||
@ -7139,7 +7139,9 @@ const hasKey = (obj, key) => {
|
||||
|
||||
```js
|
||||
let obj = {
|
||||
a: 1, b: { c: 4 }, 'd.e': 5
|
||||
a: 1,
|
||||
b: { c: 4 },
|
||||
'd.e': 5
|
||||
};
|
||||
hasKey(obj, 'a'); // true
|
||||
hasKey(obj, 'b'); // true
|
||||
@ -9366,6 +9368,36 @@ last(1, 2, 3, 4, 5); // 5
|
||||
|
||||
<br>[⬆ Back to top](#contents)
|
||||
|
||||
### objectToQueryString
|
||||
|
||||
Returns a query string generated from the key-value pairs of the given object.
|
||||
|
||||
Use `Array.prototype.reduce()` on `Object.entries(queryParameters)` to create the query string.
|
||||
Determine the `symbol` to be either `?` or `&` based on the `index` and concatenate `val` to `queryString` only if it's a string.
|
||||
Return the `queryString` or an empty string when the `queryParameters` are falsy.
|
||||
|
||||
```js
|
||||
const objectToQueryString = queryParameters => {
|
||||
return queryParameters
|
||||
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {
|
||||
const symbol = index === 0 ? '?' : '&';
|
||||
queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';
|
||||
return queryString;
|
||||
}, '')
|
||||
: '';
|
||||
};
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
objectToQueryString({page: '1', size: '2kg', key: undefined}); // '?page=1&size=2kg'
|
||||
```
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#contents)
|
||||
|
||||
### parseCookie
|
||||
|
||||
Parse an HTTP Cookie header string and return an object of all cookie name-value pairs.
|
||||
|
||||
@ -412,7 +412,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "286cf039584d2a4ea54df6456bacb75e28f4fdc0891b61ee94f8ba8266918494"
|
||||
"hash": "34fedcb1752dc3907869f323b7fc519add6925d0868c0495ffc112b0d5706267"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -835,7 +835,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "5ab25ab96afd4f1f481fc318b5b290ba8c57a468ef6bca0ca200cfb7fcf3ba9f"
|
||||
"hash": "0a4684d6fc79bdbbac31df3af6c493ba7c881936ada5bc52824b4f26ca177459"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -898,7 +898,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "7a228b650ff668f697e524e0d27ebeff1bfa35e04333b6cd5e742ff63bfea25d"
|
||||
"hash": "a4e1e33c0688dbf1ca231d9d8ea315ffed93b7f83f5d8cbf0714f10fdfeda8cf"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1037,7 +1037,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "5f38360819f9225b887a94221bfee1a80f1bcc224a364440b3388f60491b03ba"
|
||||
"hash": "484bd222e636e8a8409c30ddb1fe6e3fe72ab7a43f2edf089b2758d5e9bee528"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1273,7 +1273,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "55b1ce0a892110d792a9487e40331774015525479faa2b8961f6c2ea6291c27b"
|
||||
"hash": "0eac852db7a7add352b0d36677b22718b342ed9dc12f11780cac87e3b8260a05"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1678,7 +1678,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "16c3b724b653dcb31f3e59f1664a59951abb15a93eb3697cade4d3ae0e63c532"
|
||||
"hash": "9e39c6a3a8ec5b51c5e16f69107fc9e90b2697b2cf2689850872071bb968723e"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1855,7 +1855,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "2d4e7ba65fd20501367a46132962fe282099ca6732fdd206204a540f643ce34f"
|
||||
"hash": "a34ac55719f935ad7a3a9a48291bb54cba6ee2c62713137b94f25ac065a78dbc"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -2836,7 +2836,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "362fddaa6244404741e84bca6fc442a101fdb642af53b299e8b9994d0d7162d8"
|
||||
"hash": "3db3faac666ee61ab86c70766d2ab5d1293ffd818da87edb971bfff7a366364a"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3383,6 +3383,23 @@
|
||||
"hash": "ed97cd30b8004ca41939fabebf535f9017868b261ded4c2081c3367fa0ab1847"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "objectToQueryString",
|
||||
"type": "snippetListing",
|
||||
"title": "objectToQueryString",
|
||||
"attributes": {
|
||||
"text": "Returns a query string generated from the key-value pairs of the given object.\n\nUse `Array.prototype.reduce()` on `Object.entries(queryParameters)` to create the query string.\nDetermine the `symbol` to be either `?` or `&` based on the `index` and concatenate `val` to `queryString` only if it's a string.\nReturn the `queryString` or an empty string when the `queryParameters` are falsy.\n\n",
|
||||
"tags": [
|
||||
"utility",
|
||||
"object",
|
||||
"function",
|
||||
"intermediate"
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "e87fc52b6d22804ebb9f4adb2acade44183b8db53d101839c6d5cb02aa32419b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "observeMutations",
|
||||
"type": "snippetListing",
|
||||
|
||||
@ -568,7 +568,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "286cf039584d2a4ea54df6456bacb75e28f4fdc0891b61ee94f8ba8266918494"
|
||||
"hash": "34fedcb1752dc3907869f323b7fc519add6925d0868c0495ffc112b0d5706267"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1153,7 +1153,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "5ab25ab96afd4f1f481fc318b5b290ba8c57a468ef6bca0ca200cfb7fcf3ba9f"
|
||||
"hash": "0a4684d6fc79bdbbac31df3af6c493ba7c881936ada5bc52824b4f26ca177459"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1240,7 +1240,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "7a228b650ff668f697e524e0d27ebeff1bfa35e04333b6cd5e742ff63bfea25d"
|
||||
"hash": "a4e1e33c0688dbf1ca231d9d8ea315ffed93b7f83f5d8cbf0714f10fdfeda8cf"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1433,7 +1433,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "5f38360819f9225b887a94221bfee1a80f1bcc224a364440b3388f60491b03ba"
|
||||
"hash": "484bd222e636e8a8409c30ddb1fe6e3fe72ab7a43f2edf089b2758d5e9bee528"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1759,7 +1759,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "55b1ce0a892110d792a9487e40331774015525479faa2b8961f6c2ea6291c27b"
|
||||
"hash": "0eac852db7a7add352b0d36677b22718b342ed9dc12f11780cac87e3b8260a05"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -2320,7 +2320,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "16c3b724b653dcb31f3e59f1664a59951abb15a93eb3697cade4d3ae0e63c532"
|
||||
"hash": "9e39c6a3a8ec5b51c5e16f69107fc9e90b2697b2cf2689850872071bb968723e"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -2552,9 +2552,9 @@
|
||||
"fileName": "hasKey.md",
|
||||
"text": "Returns `true` if the target value exists in a JSON object, `false` otherwise.\n\nCheck if the key contains `.`, use `String.prototype.split('.')[0]` to get the first part and store as `_key`.\nUse `typeof` to check if the contents of `obj[key]` are an `object` and, if so, call `hasKey` with that object and the remainder of the `key`.\nOtherwise, use `Object.keys(obj)` in combination with `Array.prototype.includes()` to check if the given `key` exists.\n\n",
|
||||
"codeBlocks": {
|
||||
"es6": "const hasKey = (obj, key) => {\n if (key.includes('.')) {\n let _key = key.split('.')[0];\n if (typeof obj[_key] === 'object')\n return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));\n }\n return Object.keys(obj).includes(key);\n};",
|
||||
"es6": "const hasKey = (obj, key) => {\n if (key.includes('.')) {\n let _key = key.split('.')[0];\n if (typeof obj[_key] === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));\n }\n return Object.keys(obj).includes(key);\n};",
|
||||
"es5": "function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar hasKey = function hasKey(obj, key) {\n if (key.includes('.')) {\n var _key = key.split('.')[0];\n if (_typeof(obj[_key]) === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));\n }\n\n return Object.keys(obj).includes(key);\n};",
|
||||
"example": "let obj = {\n a: 1, b: { c: 4 }, 'd.e': 5\n};\nhasKey(obj, 'a'); // true\nhasKey(obj, 'b'); // true\nhasKey(obj, 'b.c'); // true\nhasKey(obj, 'd.e'); // true\nhasKey(obj, 'd'); // false\nhasKey(obj, 'f'); // false"
|
||||
"example": "let obj = {\n a: 1,\n b: { c: 4 },\n 'd.e': 5\n};\nhasKey(obj, 'a'); // true\nhasKey(obj, 'b'); // true\nhasKey(obj, 'b.c'); // true\nhasKey(obj, 'd.e'); // true\nhasKey(obj, 'd'); // false\nhasKey(obj, 'f'); // false"
|
||||
},
|
||||
"tags": [
|
||||
"object",
|
||||
@ -2563,7 +2563,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "2d4e7ba65fd20501367a46132962fe282099ca6732fdd206204a540f643ce34f"
|
||||
"hash": "a34ac55719f935ad7a3a9a48291bb54cba6ee2c62713137b94f25ac065a78dbc"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3916,7 +3916,7 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "362fddaa6244404741e84bca6fc442a101fdb642af53b299e8b9994d0d7162d8"
|
||||
"hash": "3db3faac666ee61ab86c70766d2ab5d1293ffd818da87edb971bfff7a366364a"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -4667,6 +4667,29 @@
|
||||
"hash": "ed97cd30b8004ca41939fabebf535f9017868b261ded4c2081c3367fa0ab1847"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "objectToQueryString",
|
||||
"title": "objectToQueryString",
|
||||
"type": "snippet",
|
||||
"attributes": {
|
||||
"fileName": "objectToQueryString.md",
|
||||
"text": "Returns a query string generated from the key-value pairs of the given object.\n\nUse `Array.prototype.reduce()` on `Object.entries(queryParameters)` to create the query string.\nDetermine the `symbol` to be either `?` or `&` based on the `index` and concatenate `val` to `queryString` only if it's a string.\nReturn the `queryString` or an empty string when the `queryParameters` are falsy.\n\n",
|
||||
"codeBlocks": {
|
||||
"es6": "const objectToQueryString = queryParameters => {\n return queryParameters\n ? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {\n const symbol = index === 0 ? '?' : '&';\n queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';\n return queryString;\n }, '')\n : '';\n};",
|
||||
"es5": "function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nvar objectToQueryString = function objectToQueryString(queryParameters) {\n return queryParameters ? Object.entries(queryParameters).reduce(function (queryString, _ref, index) {\n var _ref2 = _slicedToArray(_ref, 2),\n key = _ref2[0],\n val = _ref2[1];\n\n var symbol = index === 0 ? '?' : '&';\n queryString += typeof val === 'string' ? \"\".concat(symbol).concat(key, \"=\").concat(val) : '';\n return queryString;\n }, '') : '';\n};",
|
||||
"example": "objectToQueryString({page: '1', size: '2kg', key: undefined}); // '?page=1&size=2kg'"
|
||||
},
|
||||
"tags": [
|
||||
"utility",
|
||||
"object",
|
||||
"function",
|
||||
"intermediate"
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "e87fc52b6d22804ebb9f4adb2acade44183b8db53d101839c6d5cb02aa32419b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "observeMutations",
|
||||
"title": "observeMutations",
|
||||
|
||||
@ -33,6 +33,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const lengthIs4 = checkProp(l => l === 4, 'length');
|
||||
|
||||
@ -11,7 +11,6 @@ Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of th
|
||||
Use `Object.keys()` and `Array.prototype.forEach()` to determine which key-value pairs need to be deep cloned.
|
||||
|
||||
```js
|
||||
|
||||
const deepClone = obj => {
|
||||
if (obj === null) return null;
|
||||
let clone = Object.assign({}, obj);
|
||||
|
||||
@ -10,7 +10,6 @@ Use `Object.keys(obj)` to iterate over the object's keys.
|
||||
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
|
||||
|
||||
```js
|
||||
|
||||
const deepMapKeys = (obj, f) =>
|
||||
Array.isArray(obj)
|
||||
? obj.map(val => deepMapKeys(val, f))
|
||||
|
||||
@ -9,7 +9,6 @@ Use the `in` operator to check if `target` exists in `obj`.
|
||||
If 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.
|
||||
|
||||
```js
|
||||
|
||||
const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
|
||||
@ -11,7 +11,6 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
|
||||
Throws an exception if `n` is a negative number.
|
||||
|
||||
```js
|
||||
|
||||
const factorial = n =>
|
||||
n < 0
|
||||
? (() => {
|
||||
|
||||
@ -8,7 +8,6 @@ Converts an integer to a suffixed string, adding `am` or `pm` based on its value
|
||||
Use the modulo operator (`%`) and conditional checks to transform an integer to a stringified 12-hour format with meridiem suffix.
|
||||
|
||||
```js
|
||||
|
||||
const getMeridiemSuffixOfInteger = num =>
|
||||
num === 0 || num === 24
|
||||
? 12 + 'am'
|
||||
|
||||
@ -10,21 +10,20 @@ Use `typeof` to check if the contents of `obj[key]` are an `object` and, if so,
|
||||
Otherwise, use `Object.keys(obj)` in combination with `Array.prototype.includes()` to check if the given `key` exists.
|
||||
|
||||
```js
|
||||
|
||||
const hasKey = (obj, key) => {
|
||||
if (key.includes('.')) {
|
||||
let _key = key.split('.')[0];
|
||||
if (typeof obj[_key] === 'object')
|
||||
return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
if (typeof obj[_key] === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
}
|
||||
return Object.keys(obj).includes(key);
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
let obj = {
|
||||
a: 1, b: { c: 4 }, 'd.e': 5
|
||||
a: 1,
|
||||
b: { c: 4 },
|
||||
'd.e': 5
|
||||
};
|
||||
hasKey(obj, 'a'); // true
|
||||
hasKey(obj, 'b'); // true
|
||||
|
||||
@ -11,7 +11,6 @@ Omit the second argument, `separator`, to use a default separator of `','`.
|
||||
Omit the third argument, `end`, to use the same value as `separator` by default.
|
||||
|
||||
```js
|
||||
|
||||
const join = (arr, separator = ',', end = separator) =>
|
||||
arr.reduce(
|
||||
(acc, val, i) =>
|
||||
|
||||
@ -10,11 +10,12 @@ Determine the `symbol` to be either `?` or `&` based on the `index` and concaten
|
||||
Return the `queryString` or an empty string when the `queryParameters` are falsy.
|
||||
|
||||
```js
|
||||
const objectToQueryString = (queryParameters) => {
|
||||
|
||||
const objectToQueryString = queryParameters => {
|
||||
return queryParameters
|
||||
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {
|
||||
const symbol = index === 0 ? '?' : '&';
|
||||
queryString += (typeof val === "string") ? `${symbol}${key}=${val}` : '';
|
||||
queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';
|
||||
return queryString;
|
||||
}, '')
|
||||
: '';
|
||||
@ -22,5 +23,6 @@ const objectToQueryString = (queryParameters) => {
|
||||
```
|
||||
|
||||
```js
|
||||
objectToQueryString({page: '1', size: "2kg", key: undefined}); // '?page=1&size=2kg'
|
||||
|
||||
objectToQueryString({page: '1', size: '2kg', key: undefined}); // '?page=1&size=2kg'
|
||||
```
|
||||
|
||||
14
test/_30s.js
14
test/_30s.js
@ -469,8 +469,7 @@ const hashNode = val =>
|
||||
const hasKey = (obj, key) => {
|
||||
if (key.includes('.')) {
|
||||
let _key = key.split('.')[0];
|
||||
if (typeof obj[_key] === 'object')
|
||||
return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
if (typeof obj[_key] === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));
|
||||
}
|
||||
return Object.keys(obj).includes(key);
|
||||
};
|
||||
@ -769,6 +768,15 @@ const nthArg = n => (...args) => args.slice(n)[0];
|
||||
const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0];
|
||||
const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {});
|
||||
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||
const objectToQueryString = queryParameters => {
|
||||
return queryParameters
|
||||
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {
|
||||
const symbol = index === 0 ? '?' : '&';
|
||||
queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';
|
||||
return queryString;
|
||||
}, '')
|
||||
: '';
|
||||
};
|
||||
const observeMutations = (element, callback, options) => {
|
||||
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
|
||||
observer.observe(
|
||||
@ -1553,4 +1561,4 @@ const speechSynthesis = message => {
|
||||
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||
|
||||
|
||||
module.exports = {all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,counter,countOccurrences,createDirIfNotExists,createElement,createEventHub,CSVToArray,CSVToJSON,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,formatDuration,formToObject,forOwn,forOwnRight,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,hasKey,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,inRange,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isOdd,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWeekday,isWeekend,isWritableStream,join,JSONtoCSV,JSONToFile,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,once,onUserInputChange,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reducedFilter,reduceSuccessive,reduceWhich,reject,remove,removeNonASCII,renameKeys,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,times,timeTaken,toCamelCase,toCurrency,toDecimalMark,toggleClass,toHash,toKebabCase,tomorrow,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,JSONToDate,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum}
|
||||
module.exports = {all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,counter,countOccurrences,createDirIfNotExists,createElement,createEventHub,CSVToArray,CSVToJSON,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,formatDuration,formToObject,forOwn,forOwnRight,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,hasKey,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,inRange,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isOdd,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWeekday,isWeekend,isWritableStream,join,JSONtoCSV,JSONToFile,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,objectToQueryString,observeMutations,off,offset,omit,omitBy,on,once,onUserInputChange,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reducedFilter,reduceSuccessive,reduceWhich,reject,remove,removeNonASCII,renameKeys,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,times,timeTaken,toCamelCase,toCurrency,toDecimalMark,toggleClass,toHash,toKebabCase,tomorrow,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,JSONToDate,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum}
|
||||
@ -1172,8 +1172,7 @@
|
||||
"const hasKey = (obj, key) => {",
|
||||
" if (key.includes('.')) {",
|
||||
" let _key = key.split('.')[0];",
|
||||
" if (typeof obj[_key] === 'object')",
|
||||
" return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));",
|
||||
" if (typeof obj[_key] === 'object') return hasKey(obj[_key], key.slice(key.indexOf('.') + 1));",
|
||||
" }",
|
||||
" return Object.keys(obj).includes(key);",
|
||||
"};"
|
||||
@ -2051,6 +2050,21 @@
|
||||
],
|
||||
"description": "Creates an array of key-value pair arrays from an object.\n\nUse `Object.keys()` and `Array.prototype.map()` to iterate over the object's keys and produce an array with key-value pairs.\n"
|
||||
},
|
||||
"objectToQueryString": {
|
||||
"prefix": "30s_objectToQueryString",
|
||||
"body": [
|
||||
"const objectToQueryString = queryParameters => {",
|
||||
" return queryParameters",
|
||||
" ? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {",
|
||||
" const symbol = index === 0 ? '?' : '&';",
|
||||
" queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';",
|
||||
" return queryString;",
|
||||
" }, '')",
|
||||
" : '';",
|
||||
"};"
|
||||
],
|
||||
"description": "Returns a query string generated from the key-value pairs of the given object.\n\nUse `Array.prototype.reduce()` on `Object.entries(queryParameters)` to create the query string.\nDetermine the `symbol` to be either `?` or `&` based on the `index` and concatenate `val` to `queryString` only if it's a string.\nReturn the `queryString` or an empty string when the `queryParameters` are falsy.\n"
|
||||
},
|
||||
"observeMutations": {
|
||||
"prefix": "30s_observeMutations",
|
||||
"body": [
|
||||
|
||||
Reference in New Issue
Block a user