|
|
|
|
@ -1411,8 +1411,8 @@
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "77a01af8797ecbe71b9c9412d21c144c03a46a49dd3d0e7d869c3df38b39b2b4",
|
|
|
|
|
"firstSeen": "1516733326",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 86,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 87,
|
|
|
|
|
"authorCount": 9
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -1514,8 +1514,8 @@
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "6fa14364405f7b99aa49c2157bdc08c02b4ce2f288db29a4348a6983460933c7",
|
|
|
|
|
"firstSeen": "1544374334",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 98,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 99,
|
|
|
|
|
"authorCount": 4
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -1743,8 +1743,8 @@
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "bdc202436bee09f06a353d31841c6cfff33e8efead34c6c56ae1a1413284976d",
|
|
|
|
|
"firstSeen": "1531080384",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 123,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 124,
|
|
|
|
|
"authorCount": 5
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -1987,7 +1987,7 @@
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const equals = (a, b) => {\n if (a === b) return true;\n if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();\n if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b;\n if (a.prototype !== b.prototype) return false;\n let keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(k => equals(a[k], b[k]));\n};",
|
|
|
|
|
"es5": "function _typeof(obj) { \"@babel/helpers - typeof\"; 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 equals = function equals(a, b) {\n if (a === b) return true;\n if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();\n if (!a || !b || _typeof(a) !== 'object' && _typeof(b) !== 'object') return a === b;\n if (a.prototype !== b.prototype) return false;\n var keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(function (k) {\n return equals(a[k], b[k]);\n });\n};",
|
|
|
|
|
"example": "equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true"
|
|
|
|
|
"example": "equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true\nequals([1, 2, 3], { 0: 1, 1: 2, 2: 3 }); // true"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"object",
|
|
|
|
|
@ -1997,10 +1997,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "7738cec1d3804a4542cd80899d7f6d2890d8950aae5751a76e733b0ed270d802",
|
|
|
|
|
"hash": "ff5ed6bd1f89525d1481499cd24fcb5f1f4d5f5e268d42caef3b23076fd5fd91",
|
|
|
|
|
"firstSeen": "1516034051",
|
|
|
|
|
"lastUpdated": "1570640396",
|
|
|
|
|
"updateCount": 8,
|
|
|
|
|
"lastUpdated": "1587067279",
|
|
|
|
|
"updateCount": 9,
|
|
|
|
|
"authorCount": 6
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -2129,8 +2129,8 @@
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "6e9710c9117f500e74e65c0ee36b39fb80bd55537fa5ff9c4b1136b2667096f2",
|
|
|
|
|
"firstSeen": "1512650493",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 129,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 130,
|
|
|
|
|
"authorCount": 6
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -2818,8 +2818,8 @@
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "f9e6687cc28cd80e68f7a6776f893c7478aaa942710e0eb7144f105eba574a54",
|
|
|
|
|
"firstSeen": "1515856488",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 88,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 89,
|
|
|
|
|
"authorCount": 4
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -2880,11 +2880,11 @@
|
|
|
|
|
"type": "snippet",
|
|
|
|
|
"attributes": {
|
|
|
|
|
"fileName": "getType.md",
|
|
|
|
|
"text": "Returns the native type of a value.\n\nReturn `\"undefined\"` or `\"null\"` if the value is `undefined` or `null`.\nOtherwise, use `Object.prototype.constructor.name` to get the name of the constructor, `String.prototype.toLowerCase()` to return it in lowercase.\n\n",
|
|
|
|
|
"text": "Returns the native type of a value.\n\nReturn `'undefined'` or `'null'` if the value is `undefined` or `null`.\nOtherwise, use `Object.prototype.constructor.name` to get the name of the constructor.\n\n",
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const getType = v =>\n v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();",
|
|
|
|
|
"es5": "var getType = function getType(v) {\n return v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();\n};",
|
|
|
|
|
"example": "getType(new Set([1, 2, 3])); // 'set'"
|
|
|
|
|
"es6": "const getType = v => (v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name);",
|
|
|
|
|
"es5": "var getType = function getType(v) {\n return v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name;\n};",
|
|
|
|
|
"example": "getType(new Set([1, 2, 3])); // 'Set'"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"type",
|
|
|
|
|
@ -2892,10 +2892,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "87c0b3cc13caebf6bb46f0769fecc8b13140ea133bbf096136c740154c1d456f",
|
|
|
|
|
"hash": "0a1f42c4c267fe273f3452f80ed1fbdbe45bc47793f86077c5733146a7018e44",
|
|
|
|
|
"firstSeen": "1513526151",
|
|
|
|
|
"lastUpdated": "1583442386",
|
|
|
|
|
"updateCount": 11,
|
|
|
|
|
"lastUpdated": "1587067279",
|
|
|
|
|
"updateCount": 12,
|
|
|
|
|
"authorCount": 6
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -3922,7 +3922,7 @@
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function';",
|
|
|
|
|
"es5": "var isArrayLike = function isArrayLike(obj) {\n return obj != null && typeof obj[Symbol.iterator] === 'function';\n};",
|
|
|
|
|
"example": "isArrayLike(document.querySelectorAll('.className')); // true\nisArrayLike('abc'); // true\nisArrayLike(null); // false"
|
|
|
|
|
"example": "isArrayLike([1, 2, 3]); // true\nisArrayLike(document.querySelectorAll('.className')); // true\nisArrayLike('abc'); // true\nisArrayLike(null); // false"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"type",
|
|
|
|
|
@ -3931,10 +3931,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "0694b883486ca56109cb2c2ad8ed3477c0c4ee84d2fa81884409c40302a13fa7",
|
|
|
|
|
"hash": "e7668258c3cf902fa59107db45e7d73f7cf506a3a2074905b1eb79bb0f5c3d33",
|
|
|
|
|
"firstSeen": "1514724781",
|
|
|
|
|
"lastUpdated": "1565681352",
|
|
|
|
|
"updateCount": 18,
|
|
|
|
|
"lastUpdated": "1587067279",
|
|
|
|
|
"updateCount": 19,
|
|
|
|
|
"authorCount": 5
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -4282,7 +4282,7 @@
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const isNil = val => val === undefined || val === null;",
|
|
|
|
|
"es5": "var isNil = function isNil(val) {\n return val === undefined || val === null;\n};",
|
|
|
|
|
"example": "isNil(null); // true\nisNil(undefined); // true"
|
|
|
|
|
"example": "isNil(null); // true\nisNil(undefined); // true\nisNil(''); // false"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"type",
|
|
|
|
|
@ -4290,10 +4290,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "c09e927ebf399af3fa3bd3873b407f26130f86e6abb7871f88e1892baed899bf",
|
|
|
|
|
"hash": "f8d09a514807d27b893a37f2efc76fb01336ee118241e7df5a3913ef460850db",
|
|
|
|
|
"firstSeen": "1516114221",
|
|
|
|
|
"lastUpdated": "1583442386",
|
|
|
|
|
"updateCount": 4,
|
|
|
|
|
"lastUpdated": "1587067279",
|
|
|
|
|
"updateCount": 5,
|
|
|
|
|
"authorCount": 2
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -4512,7 +4512,7 @@
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const isPrimitive = val => Object(val) !== val;",
|
|
|
|
|
"es5": "var isPrimitive = function isPrimitive(val) {\n return Object(val) !== val;\n};",
|
|
|
|
|
"example": "isPrimitive(null); // true\nisPrimitive(50); // true\nisPrimitive('Hello!'); // true\nisPrimitive(false); // true\nisPrimitive(Symbol()); // true\nisPrimitive([]); // false"
|
|
|
|
|
"example": "isPrimitive(null); // true\nisPrimitive(undefined); // true\nisPrimitive(50); // true\nisPrimitive('Hello!'); // true\nisPrimitive(false); // true\nisPrimitive(Symbol()); // true\nisPrimitive([]); // false\nisPrimitive({}); // false"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"type",
|
|
|
|
|
@ -4523,10 +4523,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "2df9322464af125f8a33dad1f15a7df5ccd7d8f9322efe871dc026974971ac85",
|
|
|
|
|
"hash": "dc7d429725fc03d1b33fc1702fd881dfffce74fe4b8291225a54ec2214667822",
|
|
|
|
|
"firstSeen": "1514717293",
|
|
|
|
|
"lastUpdated": "1565681352",
|
|
|
|
|
"updateCount": 9,
|
|
|
|
|
"lastUpdated": "1587067279",
|
|
|
|
|
"updateCount": 10,
|
|
|
|
|
"authorCount": 6
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -4897,7 +4897,7 @@
|
|
|
|
|
"fileName": "join.md",
|
|
|
|
|
"text": "Joins all elements of an array into a string and returns this string.\nUses a separator and an end separator.\n\nUse `Array.prototype.reduce()` to combine elements into a string.\nOmit the second argument, `separator`, to use a default separator of `','`.\nOmit the third argument, `end`, to use the same value as `separator` by default.\n\n",
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const join = (arr, separator = ',', end = separator) =>\n arr.reduce(\n (acc, val, i) =>\n i === arr.length - 2\n ? acc + val + end\n : i === arr.length - 1\n ? acc + val\n : acc + val + separator,\n ''\n );",
|
|
|
|
|
"es6": "const join = (arr, separator = ',', end = separator) =>\n arr.reduce(\n (acc, val, i) =>\n i === arr.length - 2\n ? acc + val + end\n : i === arr.length - 1\n ? acc + val\n : acc + val + separator,\n ''\n );",
|
|
|
|
|
"es5": "var join = function join(arr) {\n var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';\n var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : separator;\n return arr.reduce(function (acc, val, i) {\n return i === arr.length - 2 ? acc + val + end : i === arr.length - 1 ? acc + val : acc + val + separator;\n }, '');\n};",
|
|
|
|
|
"example": "join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'); // \"pen,pineapple,apple&pen\"\njoin(['pen', 'pineapple', 'apple', 'pen'], ','); // \"pen,pineapple,apple,pen\"\njoin(['pen', 'pineapple', 'apple', 'pen']); // \"pen,pineapple,apple,pen\""
|
|
|
|
|
},
|
|
|
|
|
@ -4907,10 +4907,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "682a6b7cfeb58efe9ed7b6daf467c45397df0acecfc21cab59e5ffedd03503ba",
|
|
|
|
|
"hash": "3db3faac666ee61ab86c70766d2ab5d1293ffd818da87edb971bfff7a366364a",
|
|
|
|
|
"firstSeen": "1514801920",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 95,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 96,
|
|
|
|
|
"authorCount": 7
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -5856,7 +5856,7 @@
|
|
|
|
|
"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 `length` of `queryString` 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 = queryString.length === 0 ? '?' : '&';\n queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';\n return queryString;\n }, '')\n : '';\n};",
|
|
|
|
|
"es6": "const objectToQueryString = queryParameters => {\n return queryParameters\n ? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {\n const symbol = queryString.length === 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) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } 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 = queryString.length === 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'"
|
|
|
|
|
},
|
|
|
|
|
@ -5868,10 +5868,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "406723128cb71796de5503b04c137c89c9e9bd245164483c74b0229df50d2021",
|
|
|
|
|
"hash": "e8f820ce6da97eabde082ffb829c9fb700e85efc79bdebe883c67237269e3f52",
|
|
|
|
|
"firstSeen": "1570824965",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 62,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 63,
|
|
|
|
|
"authorCount": 4
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -6425,7 +6425,7 @@
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));",
|
|
|
|
|
"es5": "var pipeAsyncFunctions = function pipeAsyncFunctions() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n\n return function (arg) {\n return fns.reduce(function (p, f) {\n return p.then(f);\n }, Promise.resolve(arg));\n };\n};",
|
|
|
|
|
"example": "const sum = pipeAsyncFunctions(\n x => x + 1,\n x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),\n x => x + 3,\n async x => (await x) + 4\n);\n(async() => {\n console.log(await sum(5)); // 15 (after one second)\n})();"
|
|
|
|
|
"example": "const sum = pipeAsyncFunctions(\n x => x + 1,\n x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),\n x => x + 3,\n async x => (await x) + 4\n);\n(async () => {\n console.log(await sum(5)); // 15 (after one second)\n})();"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"function",
|
|
|
|
|
@ -6434,10 +6434,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "345bea897a67c1b851ef4110b3db692140064c418703a5d102e057b002808de3",
|
|
|
|
|
"hash": "a2b9ac4f1209c3791caa6f40f0d041acd75514e9ee8909f2e3833635f357c0bd",
|
|
|
|
|
"firstSeen": "1517069864",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 120,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 121,
|
|
|
|
|
"authorCount": 5
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -7068,7 +7068,7 @@
|
|
|
|
|
"fileName": "remove.md",
|
|
|
|
|
"text": "Mutates an array by removing elements for which the given function returns `false`.\n\nUse `Array.prototype.filter()` to find array elements that return truthy values and `Array.prototype.reduce()` to remove elements using `Array.prototype.splice()`.\nThe `func` is invoked with three arguments (`value, index, array`).\n\n",
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const remove = (arr, func) =>\n Array.isArray(arr)\n ? arr.filter(func).reduce((acc, val) => {\n arr.splice(arr.indexOf(val), 1);\n return acc.concat(val);\n }, [])\n : [];",
|
|
|
|
|
"es6": "const remove = (arr, func) =>\n Array.isArray(arr)\n ? arr.filter(func).reduce((acc, val) => {\n arr.splice(arr.indexOf(val), 1);\n return acc.concat(val);\n }, [])\n : [];",
|
|
|
|
|
"es5": "var remove = function remove(arr, func) {\n return Array.isArray(arr) ? arr.filter(func).reduce(function (acc, val) {\n arr.splice(arr.indexOf(val), 1);\n return acc.concat(val);\n }, []) : [];\n};",
|
|
|
|
|
"example": "remove([1, 2, 3, 4], n => n % 2 === 0); // [2, 4]"
|
|
|
|
|
},
|
|
|
|
|
@ -7078,10 +7078,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "0b549930f468d934adcb898f371ef590beff15bf2816d7e5c65264a567d68486",
|
|
|
|
|
"hash": "ffb9c0d1d09aeb989789286efb91cc237b89ce13f44ad9510a014f9ab150df71",
|
|
|
|
|
"firstSeen": "1513521691",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 117,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 118,
|
|
|
|
|
"authorCount": 6
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -7582,7 +7582,7 @@
|
|
|
|
|
"fileName": "size.md",
|
|
|
|
|
"text": "Gets the size of an array, object or string.\n\nGet type of `val` (`array`, `object` or `string`). \nUse `length` property for arrays.\nUse `length` or `size` value if available or number of keys for objects.\nUse `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `val` for strings.\nSplit strings into array of characters with `split('')` and return its length.\n\n",
|
|
|
|
|
"codeBlocks": {
|
|
|
|
|
"es6": "const size = val =>\n Array.isArray(val)\n ? val.length\n : val && typeof val === 'object'\n ? val.size || val.length || Object.keys(val).length\n : typeof val === 'string'\n ? new Blob([val]).size\n : 0;",
|
|
|
|
|
"es6": "const size = val =>\n Array.isArray(val)\n ? val.length\n : val && typeof val === 'object'\n ? val.size || val.length || Object.keys(val).length\n : typeof val === 'string'\n ? new Blob([val]).size\n : 0;",
|
|
|
|
|
"es5": "function _typeof(obj) { \"@babel/helpers - typeof\"; 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 size = function size(val) {\n return Array.isArray(val) ? val.length : val && _typeof(val) === 'object' ? val.size || val.length || Object.keys(val).length : typeof val === 'string' ? new Blob([val]).size : 0;\n};",
|
|
|
|
|
"example": "size([1, 2, 3, 4, 5]); // 5\nsize('size'); // 4\nsize({ one: 1, two: 2, three: 3 }); // 3"
|
|
|
|
|
},
|
|
|
|
|
@ -7594,10 +7594,10 @@
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"meta": {
|
|
|
|
|
"hash": "f77974f024d9c020fe8efe4ecc77686faf8ad690122f4c071fe5205df921e052",
|
|
|
|
|
"hash": "6dd4c6a51d2c80fa4768c95ae01c16a8359c4140bcad28c7fde0cecd72d7d3e2",
|
|
|
|
|
"firstSeen": "1514645161",
|
|
|
|
|
"lastUpdated": "1587043509",
|
|
|
|
|
"updateCount": 59,
|
|
|
|
|
"lastUpdated": "1587046062",
|
|
|
|
|
"updateCount": 60,
|
|
|
|
|
"authorCount": 5
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|