Skip to content

Commit

Permalink
Travis build: 1076 [cron]
Browse files Browse the repository at this point in the history
  • Loading branch information
30secondsofcode committed Mar 19, 2019
1 parent 089495f commit b4333dc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 65 deletions.
4 changes: 2 additions & 2 deletions dist/_30s.es5.js
Expand Up @@ -187,7 +187,7 @@
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
return arr.map(function (v) {
return v.map(function (x) {
return "\"".concat(x, "\"");
return isNaN(x) ? "\"".concat(x.replace(/"/g, '""'), "\"") : x;
}).join(delimiter);
}).join('\n');
};
Expand Down Expand Up @@ -1219,7 +1219,7 @@
return val === null;
};
var isNumber = function isNumber(val) {
return typeof val === 'number';
return typeof val === 'number' && val === val;
};
var isObject = function isObject(obj) {
return obj === Object(obj);
Expand Down
2 changes: 1 addition & 1 deletion dist/_30s.es5.min.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions dist/_30s.esm.js
Expand Up @@ -51,7 +51,9 @@ const allEqual = arr => arr.every(val => val === arr[0]);
const any = (arr, fn = Boolean) => arr.some(fn);
const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
const arrayToCSV = (arr, delimiter = ',') =>
arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n');
arr
.map(v => v.map(x => (isNaN(x) ? `"${x.replace(/"/g, '""')}"` : x)).join(delimiter))
.join('\n');
const arrayToHtmlList = (arr, listID) =>
(el => (
(el = document.querySelector('#' + listID)),
Expand Down Expand Up @@ -238,11 +240,11 @@ const deepMapKeys = (obj, f) =>
? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => {
const val = obj[current];
acc[f(current)] =
const val = obj[current];
acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc;
}, {})
return acc;
}, {})
: obj;
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
Expand All @@ -265,9 +267,9 @@ const dig = (obj, target) =>
target in obj
? obj[target]
: Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
const digitize = n => [...`${n}`].map(i => parseInt(i));
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
const drop = (arr, n = 1) => arr.slice(n);
Expand Down Expand Up @@ -598,7 +600,7 @@ const isLowerCase = str => str === str.toLowerCase();
const isNegativeZero = val => val === 0 && 1 / val === -Infinity;
const isNil = val => val === undefined || val === null;
const isNull = val => val === null;
const isNumber = val => typeof val === 'number';
const isNumber = val => typeof val === 'number' && val === val;
const isObject = obj => obj === Object(obj);
const isObjectLike = val => val !== null && typeof val === 'object';
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
Expand Down Expand Up @@ -986,9 +988,9 @@ const reject = (pred, array) => array.filter((...args) => !pred(...args));
const remove = (arr, func) =>
Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
: [];
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
const renameKeys = (keysMap, obj) =>
Expand Down
26 changes: 14 additions & 12 deletions dist/_30s.js
Expand Up @@ -57,7 +57,9 @@
const any = (arr, fn = Boolean) => arr.some(fn);
const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
const arrayToCSV = (arr, delimiter = ',') =>
arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n');
arr
.map(v => v.map(x => (isNaN(x) ? `"${x.replace(/"/g, '""')}"` : x)).join(delimiter))
.join('\n');
const arrayToHtmlList = (arr, listID) =>
(el => (
(el = document.querySelector('#' + listID)),
Expand Down Expand Up @@ -244,11 +246,11 @@
? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => {
const val = obj[current];
acc[f(current)] =
const val = obj[current];
acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc;
}, {})
return acc;
}, {})
: obj;
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
Expand All @@ -271,9 +273,9 @@
target in obj
? obj[target]
: Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
const digitize = n => [...`${n}`].map(i => parseInt(i));
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
const drop = (arr, n = 1) => arr.slice(n);
Expand Down Expand Up @@ -604,7 +606,7 @@
const isNegativeZero = val => val === 0 && 1 / val === -Infinity;
const isNil = val => val === undefined || val === null;
const isNull = val => val === null;
const isNumber = val => typeof val === 'number';
const isNumber = val => typeof val === 'number' && val === val;
const isObject = obj => obj === Object(obj);
const isObjectLike = val => val !== null && typeof val === 'object';
const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
Expand Down Expand Up @@ -992,9 +994,9 @@
const remove = (arr, func) =>
Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
: [];
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
const renameKeys = (keysMap, obj) =>
Expand Down
14 changes: 7 additions & 7 deletions snippet_data/snippetList.json
Expand Up @@ -72,7 +72,7 @@
"archived": false
},
"meta": {
"hash": "3508f9a15d8a0b0541d12373b8ea697773434fbfd946bb63fc4f0246e4f193ea"
"hash": "f31b6cd3ca1c861f0ffb8c05e164f29b674167a5b33cf0d4014febae4021afd1"
}
},
{
Expand Down Expand Up @@ -386,7 +386,7 @@
"archived": false
},
"meta": {
"hash": "2051a5037b3830e219c84dae16f72f42a8a8aee5e8f96bd98f506ea7c4f3bb42"
"hash": "2167243163f5217a7f81843fd6bf150a9994cc943a714a16f8992f428d99d805"
}
},
{
Expand Down Expand Up @@ -827,7 +827,7 @@
"archived": false
},
"meta": {
"hash": "e66191a28aba485589b3b06933c13d999962af982b5b7b1b136c10f4d09abd8d"
"hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a"
}
},
{
Expand Down Expand Up @@ -957,7 +957,7 @@
"archived": false
},
"meta": {
"hash": "828a6f2f3b94cc537ef0ee30c5ebda28fff688fea65030e47d5721831bdb48ce"
"hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62"
}
},
{
Expand Down Expand Up @@ -2302,7 +2302,7 @@
"archived": false
},
"meta": {
"hash": "446ed50e100f18a606c8443be196992b74b235ed98646632463fdc3d01f9eb04"
"hash": "3da255d35590d5e0c38cc86dc9bcd3d26cb7350b8880d4490649a3152e3fc945"
}
},
{
Expand Down Expand Up @@ -3407,7 +3407,7 @@
"archived": false
},
"meta": {
"hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051"
"hash": "4815876fd6dbb17ad34c0d8918e7a72d837104f9beee7dc51b0fa73057b9e83e"
}
},
{
Expand Down Expand Up @@ -3779,7 +3779,7 @@
"archived": false
},
"meta": {
"hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea"
"hash": "ec9cb9384817f84cf0bacd62a23b69b2304fa2cf0352b16d3950b21d48c04f11"
}
},
{
Expand Down
36 changes: 18 additions & 18 deletions snippet_data/snippets.json
Expand Up @@ -94,9 +94,9 @@
"fileName": "arrayToCSV.md",
"text": "Converts a 2D array to a comma-separated values (CSV) string.\n\nUse `Array.prototype.map()` and `Array.prototype.join(delimiter)` to combine individual 1D arrays (rows) into strings.\nUse `Array.prototype.join('\\n')` to combine all rows into a CSV string, separating each row with a newline.\nOmit the second argument, `delimiter`, to use a default delimiter of `,`.",
"codeBlocks": {
"es6": "const arrayToCSV = (arr, delimiter = ',') =>\n arr.map(v => v.map(x => `\"${x}\"`).join(delimiter)).join('\\n');",
"es5": "var arrayToCSV = function arrayToCSV(arr) {\n var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';\n return arr.map(function (v) {\n return v.map(function (x) {\n return \"\\\"\".concat(x, \"\\\"\");\n }).join(delimiter);\n }).join('\\n');\n};",
"example": "arrayToCSV([['a', 'b'], ['c', 'd']]); // '\"a\",\"b\"\\n\"c\",\"d\"'\narrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '\"a\";\"b\"\\n\"c\";\"d\"'"
"es6": "const arrayToCSV = (arr, delimiter = ',') =>\n arr\n .map(v => v.map(x => (isNaN(x) ? `\"${x.replace(/\"/g, '\"\"')}\"` : x)).join(delimiter))\n .join('\\n');",
"es5": "var arrayToCSV = function arrayToCSV(arr) {\n var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';\n return arr.map(function (v) {\n return v.map(function (x) {\n return isNaN(x) ? \"\\\"\".concat(x.replace(/\"/g, '\"\"'), \"\\\"\") : x;\n }).join(delimiter);\n }).join('\\n');\n};",
"example": "arrayToCSV([['a', 'b'], ['c', 'd']]); // '\"a\",\"b\"\\n\"c\",\"d\"'\narrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '\"a\";\"b\"\\n\"c\";\"d\"'\narrayToCSV([['a', '\"b\" great'], ['c', 3.1415]]); // '\"a\",\"\"\"b\"\" great\"\\n\"c\",3.1415'"
},
"tags": [
"array",
Expand All @@ -107,7 +107,7 @@
},
"meta": {
"archived": false,
"hash": "3508f9a15d8a0b0541d12373b8ea697773434fbfd946bb63fc4f0246e4f193ea"
"hash": "f31b6cd3ca1c861f0ffb8c05e164f29b674167a5b33cf0d4014febae4021afd1"
}
},
{
Expand Down Expand Up @@ -568,7 +568,7 @@
},
"meta": {
"archived": false,
"hash": "2051a5037b3830e219c84dae16f72f42a8a8aee5e8f96bd98f506ea7c4f3bb42"
"hash": "2167243163f5217a7f81843fd6bf150a9994cc943a714a16f8992f428d99d805"
}
},
{
Expand Down Expand Up @@ -1207,7 +1207,7 @@
"fileName": "deepMapKeys.md",
"text": "Deep maps an object keys.\n\nCreates an object with the same values as the provided object and keys generated by running the provided function for each key.\n\nUse `Object.keys(obj)` to iterate over the object's keys. \nUse `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.",
"codeBlocks": {
"es6": "const deepMapKeys = (obj, f) =>\n Array.isArray(obj)\n ? obj.map(val => deepMapKeys(val, f))\n : typeof obj === 'object'\n ? Object.keys(obj).reduce((acc, current) => {\n const val = obj[current];\n acc[f(current)] =\n val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);\n return acc;\n }, {})\n : obj;",
"es6": "const deepMapKeys = (obj, f) =>\n Array.isArray(obj)\n ? obj.map(val => deepMapKeys(val, f))\n : typeof obj === 'object'\n ? Object.keys(obj).reduce((acc, current) => {\n const val = obj[current];\n acc[f(current)] =\n val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);\n return acc;\n }, {})\n : obj;",
"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 deepMapKeys = function deepMapKeys(obj, f) {\n return Array.isArray(obj) ? obj.map(function (val) {\n return deepMapKeys(val, f);\n }) : _typeof(obj) === 'object' ? Object.keys(obj).reduce(function (acc, current) {\n var val = obj[current];\n acc[f(current)] = val !== null && _typeof(val) === 'object' ? deepMapKeys(val, f) : acc[f(current)] = val;\n return acc;\n }, {}) : obj;\n};",
"example": "const obj = {\n foo: '1',\n nested: {\n child: {\n withArray: [\n {\n grandChild: ['hello']\n }\n ]\n }\n }\n};\nconst upperKeysObj = deepMapKeys(obj, key => key.toUpperCase());\n/*\n{\n \"FOO\":\"1\",\n \"NESTED\":{\n \"CHILD\":{\n \"WITHARRAY\":[\n {\n \"GRANDCHILD\":[ 'hello' ]\n }\n ]\n }\n }\n}\n*/"
},
Expand All @@ -1219,7 +1219,7 @@
},
"meta": {
"archived": false,
"hash": "e66191a28aba485589b3b06933c13d999962af982b5b7b1b136c10f4d09abd8d"
"hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a"
}
},
{
Expand Down Expand Up @@ -1400,7 +1400,7 @@
"fileName": "dig.md",
"text": "Returns the target value in a nested JSON object, based on the given key.\n\nUse the `in` operator to check if `target` exists in `obj`.\nIf 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.",
"codeBlocks": {
"es6": "const dig = (obj, target) =>\n target in obj\n ? obj[target]\n : Object.values(obj).reduce((acc, val) => {\n if (acc !== undefined) return acc;\n if (typeof val === 'object') return dig(val, target);\n }, undefined);",
"es6": "const dig = (obj, target) =>\n target in obj\n ? obj[target]\n : Object.values(obj).reduce((acc, val) => {\n if (acc !== undefined) return acc;\n if (typeof val === 'object') return dig(val, target);\n }, undefined);",
"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 dig = function dig(obj, target) {\n return target in obj ? obj[target] : Object.values(obj).reduce(function (acc, val) {\n if (acc !== undefined) return acc;\n if (_typeof(val) === 'object') return dig(val, target);\n }, undefined);\n};",
"example": "const data = {\n level1: {\n level2: {\n level3: 'some data'\n }\n }\n};\ndig(data, 'level3'); // 'some data'\ndig(data, 'level4'); // undefined"
},
Expand All @@ -1412,7 +1412,7 @@
},
"meta": {
"archived": false,
"hash": "828a6f2f3b94cc537ef0ee30c5ebda28fff688fea65030e47d5721831bdb48ce"
"hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62"
}
},
{
Expand Down Expand Up @@ -3380,11 +3380,11 @@
"type": "snippet",
"attributes": {
"fileName": "isNumber.md",
"text": "Checks if the given argument is a number.\n\nUse `typeof` to check if a value is classified as a number primitive.",
"text": "Checks if the given argument is a number.\n\nUse `typeof` to check if a value is classified as a number primitive. \nTo safeguard against `NaN`, check if `val === val` (as `NaN` has a `typeof` equal to `number` and is the only value not equal to itself).",
"codeBlocks": {
"es6": "const isNumber = val => typeof val === 'number';",
"es5": "var isNumber = function isNumber(val) {\n return typeof val === 'number';\n};",
"example": "isNumber('1'); // false\nisNumber(1); // true"
"es6": "const isNumber = val => typeof val === 'number' && val === val;",
"es5": "var isNumber = function isNumber(val) {\n return typeof val === 'number' && val === val;\n};",
"example": "isNumber(1); // true\nisNumber('1'); // false\nisNumber(NaN); // false"
},
"tags": [
"type",
Expand All @@ -3394,7 +3394,7 @@
},
"meta": {
"archived": false,
"hash": "446ed50e100f18a606c8443be196992b74b235ed98646632463fdc3d01f9eb04"
"hash": "3da255d35590d5e0c38cc86dc9bcd3d26cb7350b8880d4490649a3152e3fc945"
}
},
{
Expand Down Expand Up @@ -5006,7 +5006,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": [
"adapter",
Expand All @@ -5017,7 +5017,7 @@
},
"meta": {
"archived": false,
"hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051"
"hash": "4815876fd6dbb17ad34c0d8918e7a72d837104f9beee7dc51b0fa73057b9e83e"
}
},
{
Expand Down Expand Up @@ -5553,7 +5553,7 @@
"fileName": "remove.md",
"text": "Removes elements from an array 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`).",
"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]"
},
Expand All @@ -5564,7 +5564,7 @@
},
"meta": {
"archived": false,
"hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea"
"hash": "ec9cb9384817f84cf0bacd62a23b69b2304fa2cf0352b16d3950b21d48c04f11"
}
},
{
Expand Down

0 comments on commit b4333dc

Please sign in to comment.