Merge branch 'master' into urlJoin

This commit is contained in:
Angelos Chalaris
2018-01-16 18:48:59 +02:00
committed by GitHub
25 changed files with 821 additions and 1550 deletions

283
README.md
View File

@ -112,6 +112,7 @@ average(1, 2, 3);
* [`initial`](#initial)
* [`initialize2DArray`](#initialize2darray)
* [`initializeArrayWithRange`](#initializearraywithrange)
* [`initializeArrayWithRangeRight`](#initializearraywithrangeright)
* [`initializeArrayWithValues`](#initializearraywithvalues)
* [`intersection`](#intersection)
* [`isSorted`](#issorted)
@ -163,6 +164,7 @@ average(1, 2, 3);
* [`hasClass`](#hasclass)
* [`hide`](#hide)
* [`httpsRedirect`](#httpsredirect)
* [`observeMutations`](#observemutations-)
* [`off`](#off)
* [`on`](#on)
* [`onUserInputChange`](#onuserinputchange-)
@ -323,17 +325,26 @@ average(1, 2, 3);
* [`getType`](#gettype)
* [`isArray`](#isarray)
* [`isArrayBuffer`](#isarraybuffer)
* [`isArrayLike`](#isarraylike)
* [`isBoolean`](#isboolean)
* [`isFunction`](#isfunction)
* [`isMap`](#ismap)
* [`isNil`](#isnil)
* [`isNull`](#isnull)
* [`isNumber`](#isnumber)
* [`isObject`](#isobject)
* [`isPrimitive`](#isprimitive)
* [`isPromiseLike`](#ispromiselike)
* [`isRegExp`](#isregexp)
* [`isSet`](#isset)
* [`isString`](#isstring)
* [`isSymbol`](#issymbol)
* [`isTypedArray`](#istypedarray)
* [`isUndefined`](#isundefined)
* [`isValidJSON`](#isvalidjson)
* [`isWeakMap`](#isweakmap)
* [`isWeakSet`](#isweakset)
</details>
@ -1016,7 +1027,7 @@ initialize2DArray(2, 2, 0); // [[0,0], [0,0]]
### initializeArrayWithRange
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with there common difference `step`.
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.
Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
You can omit `start` to use a default value of `0`.
@ -1041,6 +1052,35 @@ initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8]
<br>[⬆ Back to top](#table-of-contents)
### initializeArrayWithRangeRight
Initializes an array containing the numbers in the specified range (in reverse) where `start` and `end` are inclusive with their common difference `step`.
Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
You can omit `start` to use a default value of `0`.
You can omit `step` to use a default value of `1`.
```js
const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(
(v, i, arr) => (arr.length - i - 1) * step + start
);
```
<details>
<summary>Examples</summary>
```js
initializeArrayWithRangeRight(5); // [5,4,3,2,1,0]
initializeArrayWithRangeRight(7, 3); // [7,6,5,4,3]
initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0]
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### initializeArrayWithValues
Initializes and fills an array with the specified values.
@ -2228,6 +2268,48 @@ httpsRedirect(); // If you are on http://mydomain.com, you are redirected to htt
<br>[⬆ Back to top](#table-of-contents)
### observeMutations ![advanced](/advanced.svg)
Returns a new MutationObserver and runs the provided callback for each mutation on the specified element.
Use a [`MutationObserver`](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to observe mutations on the given element.
Use `Array.forEach()` to run the callback for each mutation that is observed.
Omit the third argument, `options`, to use the default [options](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver#MutationObserverInit) (all `true`).
```js
const observeMutations = (element, callback, options) => {
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
observer.observe(
element,
Object.assign(
{
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
},
options
)
);
return observer;
};
```
<details>
<summary>Examples</summary>
```js
const obs = observeMutations(document, console.log); // Logs all mutations that happen on the page
obs.disconnect(); // Disconnects the observer and stops logging mutations on the page
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### off
Removes an event listener from an element.
@ -5107,6 +5189,28 @@ isArray([1]); // true
<br>[⬆ Back to top](#table-of-contents)
### isArrayBuffer
Checks if value is classified as a ArrayBuffer object.
Use the `instanceof`operator to check if the provided value is a `ArrayBuffer` object.
```js
const isArrayBuffer = val => val instanceof ArrayBuffer;
```
<details>
<summary>Examples</summary>
```js
isArrayBuffer(new ArrayBuffer()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isArrayLike
Checks if the provided argument is array-like (i.e. is iterable).
@ -5183,6 +5287,51 @@ isFunction(x => x); // true
<br>[⬆ Back to top](#table-of-contents)
### isMap
Checks if value is classified as a Map object.
Use the `instanceof`operator to check if the provided value is a `Map` object.
```js
const isMap = val => val instanceof Map;
```
<details>
<summary>Examples</summary>
```js
isMap(new Map()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isNil
Returns `true` if the specified value is `null` or `undefined`, `false` otherwise.
Use the strict equality operator to check if the value and of `val` are equal to `null` or `undefined`.
```js
const isNil = val => val === undefined || val === null;
```
<details>
<summary>Examples</summary>
```js
isNil(null); // true
isNil(undefined); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isNull
Returns `true` if the specified value is `null`, `false` otherwise.
@ -5316,6 +5465,50 @@ isPromiseLike({}); // false
<br>[⬆ Back to top](#table-of-contents)
### isRegExp
Checks if value is classified as a RegExp object.
Use the `instanceof`operator to check if the provided value is a `RegExp` object.
```js
const isRegExp = val => val instanceof RegExp;
```
<details>
<summary>Examples</summary>
```js
isRegExp(/./g); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isSet
Checks if value is classified as a Set object.
Use the `instanceof`operator to check if the provided value is a `Set` object.
```js
const isSet = val => val instanceof Set;
```
<details>
<summary>Examples</summary>
```js
isSet(new Set()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isString
Checks if the given argument is a string.
@ -5360,6 +5553,50 @@ isSymbol(Symbol('x')); // true
<br>[⬆ Back to top](#table-of-contents)
### isTypedArray
Checks if value is classified as a TypedArray object.
Use the `instanceof`operator to check if the provided value is a `TypedArray` object.
```js
const isTypedArray = val => val instanceof TypedArray;
```
<details>
<summary>Examples</summary>
```js
isTypedArray(new TypedArray()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isUndefined
Returns `true` if the specified value is `undefined`, `false` otherwise.
Use the strict equality operator to check if the value and of `val` are equal to `undefined`.
```js
const isUndefined = val => val === undefined;
```
<details>
<summary>Examples</summary>
```js
isUndefined(undefined); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isValidJSON
Checks if the provided argument is a valid JSON.
@ -5390,6 +5627,50 @@ isValidJSON(null); // true
<br>[⬆ Back to top](#table-of-contents)
### isWeakMap
Checks if value is classified as a WeakMap object.
Use the `instanceof`operator to check if the provided value is a `WeakMap` object.
```js
const isWeakMap = val => val instanceof WeakMap;
```
<details>
<summary>Examples</summary>
```js
isWeakMap(new WeakMap()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### isWeakSet
Checks if value is classified as a WeakSet object.
Use the `instanceof`operator to check if the provided value is a `WeakSet` object.
```js
const isWeakSet = val => val instanceof WeakSet;
```
<details>
<summary>Examples</summary>
```js
isWeakSet(new WeakSet()); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
---
## 🔧 Utility

19
dist/_30s.es5.js vendored
View File

@ -1023,6 +1023,23 @@ var objectToPairs = function objectToPairs(obj) {
});
};
var observeMutations = function observeMutations(element, callback, options) {
var observer = new MutationObserver(function (mutations) {
return mutations.forEach(function (m) {
return callback(m);
});
});
observer.observe(element, Object.assign({
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
}, options));
return observer;
};
var off = function off(el, evt, fn) {
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return el.removeEventListener(evt, fn, opts);
@ -1656,7 +1673,7 @@ var zipObject = function zipObject(props, values) {
}, {});
};
var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, averageBy: averageBy, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, decapitalize: decapitalize, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, distinctValuesOfArray: distinctValuesOfArray, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findLast: findLast, flatten: flatten, flip: flip, forEachRight: forEachRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, invertKeyValues: invertKeyValues, isAbsoluteURL: isAbsoluteURL, isArray: isArray, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isLowerCase: isLowerCase, isNull: isNull, isNumber: isNumber, isObject: isObject, isPrime: isPrime, isPrimitive: isPrimitive, isPromiseLike: isPromiseLike, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isUpperCase: isUpperCase, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, longestItem: longestItem, lowercaseKeys: lowercaseKeys, luhnCheck: luhnCheck, mapKeys: mapKeys, mapObject: mapObject, mapValues: mapValues, mask: mask, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, off: off, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, palindrome: palindrome, parseCookie: parseCookie, partition: partition, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, untildify: untildify, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject };
var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, averageBy: averageBy, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, decapitalize: decapitalize, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, distinctValuesOfArray: distinctValuesOfArray, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findLast: findLast, flatten: flatten, flip: flip, forEachRight: forEachRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, invertKeyValues: invertKeyValues, isAbsoluteURL: isAbsoluteURL, isArray: isArray, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isLowerCase: isLowerCase, isNull: isNull, isNumber: isNumber, isObject: isObject, isPrime: isPrime, isPrimitive: isPrimitive, isPromiseLike: isPromiseLike, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isUpperCase: isUpperCase, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, longestItem: longestItem, lowercaseKeys: lowercaseKeys, luhnCheck: luhnCheck, mapKeys: mapKeys, mapObject: mapObject, mapValues: mapValues, mask: mask, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, observeMutations: observeMutations, off: off, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, palindrome: palindrome, parseCookie: parseCookie, partition: partition, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, untildify: untildify, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject };
return imports;

File diff suppressed because one or more lines are too long

21
dist/_30s.esm.js vendored
View File

@ -589,6 +589,25 @@ const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
const observeMutations = (element, callback, options) => {
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
observer.observe(
element,
Object.assign(
{
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
},
options
)
);
return observer;
};
const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts);
const on = (el, evt, fn, opts = {}) => {
@ -982,6 +1001,6 @@ const zip = (...arrays) => {
const zipObject = (props, values) =>
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
export default imports;

21
dist/_30s.js vendored
View File

@ -595,6 +595,25 @@ const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
const observeMutations = (element, callback, options) => {
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
observer.observe(
element,
Object.assign(
{
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
},
options
)
);
return observer;
};
const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts);
const on = (el, evt, fn, opts = {}) => {
@ -988,7 +1007,7 @@ const zip = (...arrays) => {
const zipObject = (props, values) =>
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
return imports;

2
dist/_30s.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ if(isTravisCI() && (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['
.readdirSync(SNIPPETS_ARCHIVE_PATH)
.sort((a, b) => a.toLowerCase() - b.toLowerCase());
// Store the data read from each snippet in the appropriate object
for (const name of snippetFilenames) {
for (const name of snippetFilenames.filter(s => s !== 'README.md')) {
snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8');
}
} catch (err) {
@ -45,7 +45,7 @@ These snippets, while useful and interesting, didn\'t quite make it into the rep
`
for(const snippet of Object.entries(snippets))
output += `* [\`${snippet[0]}\`](#${snippet[0].toLowerCase()})\n`;
output += `* [\`${snippet[0].slice(0,-3)}\`](#${snippet[0].toLowerCase().slice(0,-3)})\n`;
output += '\n---\n';
for(const snippet of Object.entries(snippets)){
let data = snippet[1];

View File

@ -1,6 +1,6 @@
### initializeArrayWithRange
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with there common difference `step`.
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.
Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
You can omit `start` to use a default value of `0`.

View File

@ -0,0 +1,20 @@
### initializeArrayWithRangeRight
Initializes an array containing the numbers in the specified range (in reverse) where `start` and `end` are inclusive with their common difference `step`.
Use `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.map()` to fill with the desired values in a range.
You can omit `start` to use a default value of `0`.
You can omit `step` to use a default value of `1`.
```js
const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(
(v, i, arr) => (arr.length - i - 1) * step + start
);
```
```js
initializeArrayWithRangeRight(5); // [5,4,3,2,1,0]
initializeArrayWithRangeRight(7, 3); // [7,6,5,4,3]
initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0]
```

13
snippets/isArrayBuffer.md Normal file
View File

@ -0,0 +1,13 @@
### isArrayBuffer
Checks if value is classified as a ArrayBuffer object.
Use the `instanceof`operator to check if the provided value is a `ArrayBuffer` object.
```js
const isArrayBuffer = val => val instanceof ArrayBuffer;
```
```js
isArrayBuffer(new ArrayBuffer()); // true
```

13
snippets/isMap.md Normal file
View File

@ -0,0 +1,13 @@
### isMap
Checks if value is classified as a Map object.
Use the `instanceof`operator to check if the provided value is a `Map` object.
```js
const isMap = val => val instanceof Map;
```
```js
isMap(new Map()); // true
```

14
snippets/isNil.md Normal file
View File

@ -0,0 +1,14 @@
### isNil
Returns `true` if the specified value is `null` or `undefined`, `false` otherwise.
Use the strict equality operator to check if the value and of `val` are equal to `null` or `undefined`.
```js
const isNil = val => val === undefined || val === null;
```
```js
isNil(null); // true
isNil(undefined); // true
```

13
snippets/isRegExp.md Normal file
View File

@ -0,0 +1,13 @@
### isRegExp
Checks if value is classified as a RegExp object.
Use the `instanceof`operator to check if the provided value is a `RegExp` object.
```js
const isRegExp = val => val instanceof RegExp;
```
```js
isRegExp(/./g); // true
```

13
snippets/isSet.md Normal file
View File

@ -0,0 +1,13 @@
### isSet
Checks if value is classified as a Set object.
Use the `instanceof`operator to check if the provided value is a `Set` object.
```js
const isSet = val => val instanceof Set;
```
```js
isSet(new Set()); // true
```

13
snippets/isTypedArray.md Normal file
View File

@ -0,0 +1,13 @@
### isTypedArray
Checks if value is classified as a TypedArray object.
Use the `instanceof`operator to check if the provided value is a `TypedArray` object.
```js
const isTypedArray = val => val instanceof TypedArray;
```
```js
isTypedArray(new TypedArray()); // true
```

13
snippets/isUndefined.md Normal file
View File

@ -0,0 +1,13 @@
### isUndefined
Returns `true` if the specified value is `undefined`, `false` otherwise.
Use the strict equality operator to check if the value and of `val` are equal to `undefined`.
```js
const isUndefined = val => val === undefined;
```
```js
isUndefined(undefined); // true
```

13
snippets/isWeakMap.md Normal file
View File

@ -0,0 +1,13 @@
### isWeakMap
Checks if value is classified as a WeakMap object.
Use the `instanceof`operator to check if the provided value is a `WeakMap` object.
```js
const isWeakMap = val => val instanceof WeakMap;
```
```js
isWeakMap(new WeakMap()); // true
```

13
snippets/isWeakSet.md Normal file
View File

@ -0,0 +1,13 @@
### isWeakSet
Checks if value is classified as a WeakSet object.
Use the `instanceof`operator to check if the provided value is a `WeakSet` object.
```js
const isWeakSet = val => val instanceof WeakSet;
```
```js
isWeakSet(new WeakSet()); // true
```

View File

@ -0,0 +1,33 @@
### observeMutations
Returns a new MutationObserver and runs the provided callback for each mutation on the specified element.
Use a [`MutationObserver`](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to observe mutations on the given element.
Use `Array.forEach()` to run the callback for each mutation that is observed.
Omit the third argument, `options`, to use the default [options](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver#MutationObserverInit) (all `true`).
```js
const observeMutations = (element, callback, options) => {
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
observer.observe(
element,
Object.assign(
{
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
},
options
)
);
return observer;
};
```
```js
const obs = observeMutations(document, console.log); // Logs all mutations that happen on the page
obs.disconnect(); // Disconnects the observer and stops logging mutations on the page
```

File diff suppressed because it is too large Load Diff

View File

@ -75,30 +75,40 @@ indexOfAll:array
initial:array
initialize2DArray:array
initializeArrayWithRange:array,math
initializeArrayWithRangeRight:array,math
initializeArrayWithValues:array,math
inRange:math
intersection:array,math
invertKeyValues:object
isAbsoluteURL:string,utility,browser,url
isArray:type,array
isArrayBuffer:type
isArrayLike:type,array
isBoolean:type
isDivisible:math
isEven:math
isFunction:type,function
isLowerCase:string,utility
isMap:type
isNil:type
isNull:type
isNumber:type,math
isObject:type,object
isPrime:math
isPrimitive:type,function,array,string
isPromiseLike:type,function,promise
isRegExp:type,regexp
isSet:type
isSorted:array
isString:type,string
isSymbol:type
isTravisCI:node
isTypedArray:type
isUndefined:type
isUpperCase:string,utility
isValidJSON:type,json
isWeakMap:type
isWeakSet:type
join:array
JSONToFile:node,json
last:array
@ -121,6 +131,7 @@ negate:function
nthElement:array
objectFromPairs:object,array
objectToPairs:object,array
observeMutations:browser,event,advanced
off:browser,event
on:browser,event
once:function

View File

@ -0,0 +1,18 @@
module.exports = observeMutations = (element, callback, options) => {
const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
observer.observe(
element,
Object.assign(
{
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
subtree: true
},
options
)
);
return observer;
};

View File

@ -0,0 +1,13 @@
const test = require('tape');
const observeMutations = require('./observeMutations.js');
test('Testing observeMutations', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof observeMutations === 'function', 'observeMutations is a Function');
//t.deepEqual(observeMutations(args..), 'Expected');
//t.equal(observeMutations(args..), 'Expected');
//t.false(observeMutations(args..), 'Expected');
//t.throws(observeMutations(args..), 'Expected');
t.end();
});

View File

@ -721,6 +721,10 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time)
√ objectToPairs is a Function
√ Creates an array of key-value pair arrays from an object.
Testing observeMutations
✔ observeMutations is a Function
Testing off
√ off is a Function
@ -1153,3 +1157,4 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time)
duration: 345ms