Travis build: 188 [cron]

This commit is contained in:
30secondsofcode
2018-08-03 19:51:50 +00:00
parent 65d5601630
commit c5c0375f2c
9 changed files with 1627 additions and 1705 deletions

File diff suppressed because one or more lines are too long

View File

@ -2249,7 +2249,7 @@
"fileName": "indexOfAll.md", "fileName": "indexOfAll.md",
"text": "Returns all indices of `val` in an array. If `val` never occurs, returns `[]`.\n\nUse `Array.reduce()` to loop over elements and store indices for matching elements.\nReturn the array of indices.", "text": "Returns all indices of `val` in an array. If `val` never occurs, returns `[]`.\n\nUse `Array.reduce()` to loop over elements and store indices for matching elements.\nReturn the array of indices.",
"codeBlocks": [ "codeBlocks": [
"const indexOfAll = (arr, val) => (arr, val) =>\n arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);", "const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);",
"indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3]\nindexOfAll([1, 2, 3], 4); // []" "indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3]\nindexOfAll([1, 2, 3], 4); // []"
], ],
"tags": [ "tags": [
@ -2258,7 +2258,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "785b13b5ab3ecdeab0c40e4b4103818daf5e1ef9c2213eb19f9a41d77bfd6734" "hash": "643cb7b5df16c9da268e21b65b4cf73bb572e7b93a5859d09bb3bc949665f65b"
} }
}, },
{ {

View File

@ -1,6 +1,6 @@
const httpDelete = (url, callback, err = console.error) => { const httpDelete = (url, callback, err = console.error) => {
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
request.open('DELETE', url, true); request.open("DELETE", url, true);
request.onload = () => callback(request); request.onload = () => callback(request);
request.onerror = () => err(request); request.onerror = () => err(request);
request.send(); request.send();

View File

@ -1,7 +1,7 @@
const httpPut = (url, data, callback, err = console.error) => { const httpPut = (url, data, callback, err = console.error) => {
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
request.open('PUT', url, true); request.open("PUT", url, true);
request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); request.setRequestHeader('Content-type','application/json; charset=utf-8');
request.onload = () => callback(request); request.onload = () => callback(request);
request.onerror = () => err(request); request.onerror = () => err(request);
request.send(data); request.send(data);

View File

@ -1,3 +1,2 @@
const indexOfAll = (arr, val) => (arr, val) => const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
module.exports = indexOfAll; module.exports = indexOfAll;

View File

@ -1,11 +1,5 @@
const isSimilar = (pattern, str) => const isSimilar = (pattern, str) =>
[...str].reduce( [...str].reduce(
(matchIndex, char) => (matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ) === pattern.length ? true : false;
? matchIndex + 1
: matchIndex,
0
) === pattern.length
? true
: false;
module.exports = isSimilar; module.exports = isSimilar;

View File

@ -1,22 +1,15 @@
const levenshteinDistance = (string1, string2) => { const levenshteinDistance = (string1, string2) => {
if (string1.length === 0) return string2.length; if(string1.length === 0) return string2.length;
if (string2.length === 0) return string1.length; if(string2.length === 0) return string1.length;
let matrix = Array(string2.length + 1) let matrix = Array(string2.length + 1).fill(0).map((x,i) => [i]);
.fill(0) matrix[0] = Array(string1.length + 1).fill(0).map((x,i) => i);
.map((x, i) => [i]); for(let i = 1; i <= string2.length; i++) {
matrix[0] = Array(string1.length + 1) for(let j = 1; j<=string1.length; j++) {
.fill(0) if(string2[i-1] === string1[j-1]) {
.map((x, i) => i); matrix[i][j] = matrix[i-1][j-1];
for (let i = 1; i <= string2.length; i++) { }
for (let j = 1; j <= string1.length; j++) { else{
if (string2[i - 1] === string1[j - 1]) { matrix[i][j] = Math.min(matrix[i-1][j-1]+1, matrix[i][j-1]+1, matrix[i-1][j]+1);
matrix[i][j] = matrix[i - 1][j - 1];
} else {
matrix[i][j] = Math.min(
matrix[i - 1][j - 1] + 1,
matrix[i][j - 1] + 1,
matrix[i - 1][j] + 1
);
} }
} }
} }

View File

@ -1,2 +1,2 @@
const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl); const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl);
module.exports = removeVowels; module.exports = removeVowels;

File diff suppressed because it is too large Load Diff