Travis build: 1021 [cron]

This commit is contained in:
30secondsofcode
2019-02-25 15:09:51 +00:00
parent ffc7d2aeb8
commit e1d6a8f9af
7 changed files with 136 additions and 61 deletions

24
dist/_30s.es5.js vendored
View File

@ -2534,14 +2534,25 @@
var validateNumber = function validateNumber(n) { var validateNumber = function validateNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
}; };
var vectorDistance = function vectorDistance() {
for (var _len53 = arguments.length, coords = new Array(_len53), _key53 = 0; _key53 < _len53; _key53++) {
coords[_key53] = arguments[_key53];
}
var pointLength = Math.trunc(coords.length / 2);
var sum = coords.slice(0, pointLength).reduce(function (acc, val, i) {
return acc + Math.pow(val - coords[pointLength + i], 2);
}, 0);
return Math.sqrt(sum);
};
var when = function when(pred, whenTrue) { var when = function when(pred, whenTrue) {
return function (x) { return function (x) {
return pred(x) ? whenTrue(x) : x; return pred(x) ? whenTrue(x) : x;
}; };
}; };
var without = function without(arr) { var without = function without(arr) {
for (var _len53 = arguments.length, args = new Array(_len53 > 1 ? _len53 - 1 : 0), _key53 = 1; _key53 < _len53; _key53++) { for (var _len54 = arguments.length, args = new Array(_len54 > 1 ? _len54 - 1 : 0), _key54 = 1; _key54 < _len54; _key54++) {
args[_key53 - 1] = arguments[_key53]; args[_key54 - 1] = arguments[_key54];
} }
return arr.filter(function (v) { return arr.filter(function (v) {
@ -2564,8 +2575,8 @@
return /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; return /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;
}; };
var zip = function zip() { var zip = function zip() {
for (var _len54 = arguments.length, arrays = new Array(_len54), _key54 = 0; _key54 < _len54; _key54++) { for (var _len55 = arguments.length, arrays = new Array(_len55), _key55 = 0; _key55 < _len55; _key55++) {
arrays[_key54] = arguments[_key54]; arrays[_key55] = arguments[_key55];
} }
var maxLength = Math.max.apply(Math, _toConsumableArray(arrays.map(function (x) { var maxLength = Math.max.apply(Math, _toConsumableArray(arrays.map(function (x) {
@ -2587,8 +2598,8 @@
}, {}); }, {});
}; };
var zipWith = function zipWith() { var zipWith = function zipWith() {
for (var _len55 = arguments.length, array = new Array(_len55), _key55 = 0; _key55 < _len55; _key55++) { for (var _len56 = arguments.length, array = new Array(_len56), _key56 = 0; _key56 < _len56; _key56++) {
array[_key55] = arguments[_key55]; array[_key56] = arguments[_key56];
} }
var fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; var fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;
@ -2939,6 +2950,7 @@
exports.unzip = unzip; exports.unzip = unzip;
exports.unzipWith = unzipWith; exports.unzipWith = unzipWith;
exports.validateNumber = validateNumber; exports.validateNumber = validateNumber;
exports.vectorDistance = vectorDistance;
exports.when = when; exports.when = when;
exports.without = without; exports.without = without;
exports.words = words; exports.words = words;

File diff suppressed because one or more lines are too long

9
dist/_30s.esm.js vendored
View File

@ -1321,6 +1321,13 @@ const unzipWith = (arr, fn) =>
) )
.map(val => fn(...val)); .map(val => fn(...val));
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
const vectorDistance = (...coords) => {
let pointLength = Math.trunc(coords.length / 2);
let sum = coords
.slice(0, pointLength)
.reduce((acc, val, i) => acc + Math.pow(val - coords[pointLength + i], 2), 0);
return Math.sqrt(sum);
};
const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
const without = (arr, ...args) => arr.filter(v => !args.includes(v)); const without = (arr, ...args) => arr.filter(v => !args.includes(v));
const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
@ -1343,4 +1350,4 @@ const zipWith = (...array) => {
); );
}; };
export { CSVToArray, CSVToJSON, JSONToFile, JSONtoCSV, RGBToHex, URLJoin, UUIDGeneratorBrowser, UUIDGeneratorNode, 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, chunk, clampNumber, cloneRegExp, coalesce, coalesceFactory, collectInto, colorize, compact, compactWhitespace, compose, composeRight, converge, copyToClipboard, countBy, countOccurrences, counter, createDirIfNotExists, createElement, createEventHub, currentURL, curry, dayOfYear, debounce, decapitalize, deepClone, deepFlatten, deepFreeze, 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, forOwn, forOwnRight, formatDuration, fromCamelCase, functionName, functions, gcd, geometricProgression, get, getColonTimeFromDate, getDaysDiffBetweenDates, getImages, getMeridiemSuffixOfInteger, getScrollPosition, getStyle, getType, getURLParameters, groupBy, hammingDistance, hasClass, hasFlags, hashBrowser, hashNode, head, hexToRGB, hide, httpGet, httpPost, httpsRedirect, hz, inRange, indentString, indexOfAll, initial, initialize2DArray, initializeArrayWithRange, initializeArrayWithRangeRight, initializeArrayWithValues, initializeNDArray, 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, isPlainObject, isPrime, isPrimitive, isPromiseLike, isReadableStream, isSameDate, isSorted, isStream, isString, isSymbol, isTravisCI, isUndefined, isUpperCase, isValidJSON, isWritableStream, join, 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, onUserInputChange, once, 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, reduceSuccessive, reduceWhich, reducedFilter, reject, remove, removeNonASCII, renameKeys, reverseString, round, runAsync, runPromisesInSeries, sample, sampleSize, scrollToTop, sdbm, serializeCookie, 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, timeTaken, times, toCamelCase, toCurrency, toDecimalMark, toHash, toKebabCase, toOrdinalSuffix, toSafeInteger, toSnakeCase, toTitleCase, toggleClass, tomorrow, transform, triggerEvent, truncateString, truthCheckCollection, unary, uncurry, unescapeHTML, unflattenObject, unfold, union, unionBy, unionWith, uniqueElements, uniqueElementsBy, uniqueElementsByRight, uniqueSymmetricDifference, untildify, unzip, unzipWith, validateNumber, when, without, words, xProd, yesNo, zip, zipObject, zipWith }; export { CSVToArray, CSVToJSON, JSONToFile, JSONtoCSV, RGBToHex, URLJoin, UUIDGeneratorBrowser, UUIDGeneratorNode, 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, chunk, clampNumber, cloneRegExp, coalesce, coalesceFactory, collectInto, colorize, compact, compactWhitespace, compose, composeRight, converge, copyToClipboard, countBy, countOccurrences, counter, createDirIfNotExists, createElement, createEventHub, currentURL, curry, dayOfYear, debounce, decapitalize, deepClone, deepFlatten, deepFreeze, 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, forOwn, forOwnRight, formatDuration, fromCamelCase, functionName, functions, gcd, geometricProgression, get, getColonTimeFromDate, getDaysDiffBetweenDates, getImages, getMeridiemSuffixOfInteger, getScrollPosition, getStyle, getType, getURLParameters, groupBy, hammingDistance, hasClass, hasFlags, hashBrowser, hashNode, head, hexToRGB, hide, httpGet, httpPost, httpsRedirect, hz, inRange, indentString, indexOfAll, initial, initialize2DArray, initializeArrayWithRange, initializeArrayWithRangeRight, initializeArrayWithValues, initializeNDArray, 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, isPlainObject, isPrime, isPrimitive, isPromiseLike, isReadableStream, isSameDate, isSorted, isStream, isString, isSymbol, isTravisCI, isUndefined, isUpperCase, isValidJSON, isWritableStream, join, 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, onUserInputChange, once, 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, reduceSuccessive, reduceWhich, reducedFilter, reject, remove, removeNonASCII, renameKeys, reverseString, round, runAsync, runPromisesInSeries, sample, sampleSize, scrollToTop, sdbm, serializeCookie, 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, timeTaken, times, toCamelCase, toCurrency, toDecimalMark, toHash, toKebabCase, toOrdinalSuffix, toSafeInteger, toSnakeCase, toTitleCase, toggleClass, tomorrow, transform, triggerEvent, truncateString, truthCheckCollection, unary, uncurry, unescapeHTML, unflattenObject, unfold, union, unionBy, unionWith, uniqueElements, uniqueElementsBy, uniqueElementsByRight, uniqueSymmetricDifference, untildify, unzip, unzipWith, validateNumber, vectorDistance, when, without, words, xProd, yesNo, zip, zipObject, zipWith };

8
dist/_30s.js vendored
View File

@ -1327,6 +1327,13 @@
) )
.map(val => fn(...val)); .map(val => fn(...val));
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
const vectorDistance = (...coords) => {
let pointLength = Math.trunc(coords.length / 2);
let sum = coords
.slice(0, pointLength)
.reduce((acc, val, i) => acc + Math.pow(val - coords[pointLength + i], 2), 0);
return Math.sqrt(sum);
};
const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
const without = (arr, ...args) => arr.filter(v => !args.includes(v)); const without = (arr, ...args) => arr.filter(v => !args.includes(v));
const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
@ -1683,6 +1690,7 @@
exports.unzip = unzip; exports.unzip = unzip;
exports.unzipWith = unzipWith; exports.unzipWith = unzipWith;
exports.validateNumber = validateNumber; exports.validateNumber = validateNumber;
exports.vectorDistance = vectorDistance;
exports.when = when; exports.when = when;
exports.without = without; exports.without = without;
exports.words = words; exports.words = words;

View File

@ -811,7 +811,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a" "hash": "e66191a28aba485589b3b06933c13d999962af982b5b7b1b136c10f4d09abd8d"
} }
}, },
{ {
@ -941,7 +941,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62" "hash": "828a6f2f3b94cc537ef0ee30c5ebda28fff688fea65030e47d5721831bdb48ce"
} }
}, },
{ {
@ -1162,7 +1162,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "319e1a8fb41490965ee6e28db3e139e65c4ea5b7f43e332bc7216cd790e5d409" "hash": "383ed61e69b8f63ae42d0746a1995057f4f65b4af6ca7778d8f1771144802acd"
} }
}, },
{ {
@ -2688,7 +2688,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "41e67e7f95334dcb734cf92acea7e1398540a18c2358d85cde5ff82e6149a44f" "hash": "493eaac4ff025739014196f024923baf63e6eba5317c7b364166f3e7087f5bf1"
} }
}, },
{ {
@ -3391,7 +3391,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051" "hash": "0b04f5fe668888db0dc360535cd999669258019f0682eb6e4ad3a1164e408d13"
} }
}, },
{ {
@ -3763,7 +3763,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea" "hash": "536833a64ce0c000b82327ed1bb9bcb82e35b237f75aefcca0e0d2def4e9cb63"
} }
}, },
{ {
@ -4951,6 +4951,20 @@
"hash": "8fb993b0cf78fa83a170aca132bf5eb13430e2cef5ae06f85b9763f286bb792c" "hash": "8fb993b0cf78fa83a170aca132bf5eb13430e2cef5ae06f85b9763f286bb792c"
} }
}, },
{
"id": "vectorDistance",
"type": "snippetListing",
"attributes": {
"tags": [
"math",
"beginner"
],
"archived": false
},
"meta": {
"hash": "03d98fe59bf128d50085af5f2948009b08f53f53f72f2bff7421c34f70287b63"
}
},
{ {
"id": "when", "id": "when",
"type": "snippetListing", "type": "snippetListing",

View File

@ -1196,7 +1196,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a" "hash": "e66191a28aba485589b3b06933c13d999962af982b5b7b1b136c10f4d09abd8d"
} }
}, },
{ {
@ -1389,7 +1389,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62" "hash": "828a6f2f3b94cc537ef0ee30c5ebda28fff688fea65030e47d5721831bdb48ce"
} }
}, },
{ {
@ -1715,7 +1715,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "319e1a8fb41490965ee6e28db3e139e65c4ea5b7f43e332bc7216cd790e5d409" "hash": "383ed61e69b8f63ae42d0746a1995057f4f65b4af6ca7778d8f1771144802acd"
} }
}, },
{ {
@ -3962,7 +3962,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "41e67e7f95334dcb734cf92acea7e1398540a18c2358d85cde5ff82e6149a44f" "hash": "493eaac4ff025739014196f024923baf63e6eba5317c7b364166f3e7087f5bf1"
} }
}, },
{ {
@ -4994,7 +4994,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051" "hash": "0b04f5fe668888db0dc360535cd999669258019f0682eb6e4ad3a1164e408d13"
} }
}, },
{ {
@ -5541,7 +5541,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea" "hash": "536833a64ce0c000b82327ed1bb9bcb82e35b237f75aefcca0e0d2def4e9cb63"
} }
}, },
{ {
@ -7289,6 +7289,27 @@
"hash": "8fb993b0cf78fa83a170aca132bf5eb13430e2cef5ae06f85b9763f286bb792c" "hash": "8fb993b0cf78fa83a170aca132bf5eb13430e2cef5ae06f85b9763f286bb792c"
} }
}, },
{
"id": "vectorDistance",
"type": "snippet",
"attributes": {
"fileName": "vectorDistance.md",
"text": "Returns the distance between two vectors.\n\nUse `Array.prototype.reduce()`, `Math.pow()` and `Math.sqrt()` to calculate the Euclidean distance between two vectors.",
"codeBlocks": {
"es6": "const vectorDistance = (...coords) => {\n let pointLength = Math.trunc(coords.length / 2);\n let sum = coords\n .slice(0, pointLength)\n .reduce((acc, val, i) => acc + Math.pow(val - coords[pointLength + i], 2), 0);\n return Math.sqrt(sum);\n};",
"es5": "var vectorDistance = function vectorDistance() {\n for (var _len = arguments.length, coords = new Array(_len), _key = 0; _key < _len; _key++) {\n coords[_key] = arguments[_key];\n }\n\n var pointLength = Math.trunc(coords.length / 2);\n var sum = coords.slice(0, pointLength).reduce(function (acc, val, i) {\n return acc + Math.pow(val - coords[pointLength + i], 2);\n }, 0);\n return Math.sqrt(sum);\n};",
"example": "vectorDistance(10, 0, 5, 20, 0, 10); // 11.180339887498949"
},
"tags": [
"math",
"beginner"
]
},
"meta": {
"archived": false,
"hash": "03d98fe59bf128d50085af5f2948009b08f53f53f72f2bff7421c34f70287b63"
}
},
{ {
"id": "when", "id": "when",
"type": "snippet", "type": "snippet",

View File

@ -3328,6 +3328,19 @@
], ],
"description": "Returns `true` if the given value is a number, `false` otherwise.\n\nUse `!isNaN()` in combination with `parseFloat()` to check if the argument is a number.\nUse `isFinite()` to check if the number is finite.\nUse `Number()` to check if the coercion holds" "description": "Returns `true` if the given value is a number, `false` otherwise.\n\nUse `!isNaN()` in combination with `parseFloat()` to check if the argument is a number.\nUse `isFinite()` to check if the number is finite.\nUse `Number()` to check if the coercion holds"
}, },
"vectorDistance": {
"prefix": "30s_vectorDistance",
"body": [
"const vectorDistance = (...coords) => {",
" let pointLength = Math.trunc(coords.length / 2);",
" let sum = coords",
" .slice(0, pointLength)",
" .reduce((acc, val, i) => acc + Math.pow(val - coords[pointLength + i], 2), 0);",
" return Math.sqrt(sum);",
"};"
],
"description": "Returns the distance between two vectors.\n\nUse `Array.prototype.reduce()`, `Math.pow()` and `Math.sqrt()` to calculate the Euclidean distance between two vectors"
},
"when": { "when": {
"prefix": "30s_when", "prefix": "30s_when",
"body": [ "body": [