Merge branch 'master' into update-memoize
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
setup_git() {
|
setup_git() {
|
||||||
git config --global user.email "travis@travis-ci.org"
|
git config --global user.email "30secondsofcode@gmail.com"
|
||||||
git config --global user.name "Travis CI"
|
git config --global user.name "30secondsofcode"
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_website_files() {
|
commit_website_files() {
|
||||||
|
|||||||
313
README.md
313
README.md
@ -5,7 +5,7 @@
|
|||||||
[](https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE) [](https://gitter.im/30-seconds-of-code/Lobby) [](http://makeapullrequest.com) [](https://travis-ci.org/Chalarangelo/30-seconds-of-code) [](https://insight.io/github.com/Chalarangelo/30-seconds-of-code/tree/master/?source=0) [](https://github.com/Flet/semistandard) [](https://www.producthunt.com/posts/30-seconds-of-code)
|
[](https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE) [](https://gitter.im/30-seconds-of-code/Lobby) [](http://makeapullrequest.com) [](https://travis-ci.org/Chalarangelo/30-seconds-of-code) [](https://insight.io/github.com/Chalarangelo/30-seconds-of-code/tree/master/?source=0) [](https://github.com/Flet/semistandard) [](https://www.producthunt.com/posts/30-seconds-of-code)
|
||||||
|
|
||||||
|
|
||||||
> Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.
|
> Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.
|
||||||
|
|
||||||
|
|
||||||
- Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
- Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
||||||
@ -13,7 +13,58 @@
|
|||||||
- Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility.
|
- Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility.
|
||||||
- You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in [this repo](https://github.com/Rob-Rychs/30-seconds-of-code-texteditorsnippets).
|
- You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in [this repo](https://github.com/Rob-Rychs/30-seconds-of-code-texteditorsnippets).
|
||||||
- You can import these snippets into Alfred 3, using [this file](https://github.com/lslvxy/30-seconds-of-code-alfredsnippets).
|
- You can import these snippets into Alfred 3, using [this file](https://github.com/lslvxy/30-seconds-of-code-alfredsnippets).
|
||||||
- You can find a package with all the snippets on [npm](https://www.npmjs.com/package/30-seconds-of-code). Bear in mind that most of these snippets are not production-ready.
|
|
||||||
|
#### Package
|
||||||
|
|
||||||
|
⚠️ **WARNING:** Snippets are not production ready.
|
||||||
|
|
||||||
|
You can find a package with all the snippets on [npm](https://www.npmjs.com/package/30-seconds-of-code).
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install 30-seconds-of-code
|
||||||
|
```
|
||||||
|
|
||||||
|
CDN links
|
||||||
|
- [ES2017 Full (UMD)](https://unpkg.com/30-seconds-of-code)
|
||||||
|
- [ES5 Minified (UMD)](https://unpkg.com/30-seconds-of-code/dist/_30s.es5.min.js)
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
**Browser**
|
||||||
|
|
||||||
|
> IMPORTANT: replace the `src` with the full version link and desired target spec (such as ES5 minified)):
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://unpkg.com/30-seconds-of-code"></script>
|
||||||
|
<script>
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Node**
|
||||||
|
|
||||||
|
```js
|
||||||
|
// CommonJS
|
||||||
|
const _30s = require('30-seconds-of-code');
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
|
||||||
|
// ES Modules
|
||||||
|
import _30s from '30-seconds-of-code';
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
```
|
||||||
|
|
||||||
|
To import snippets directly:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// CommonJS
|
||||||
|
const { average } = require('30-seconds-of-code');
|
||||||
|
average(1, 2, 3);
|
||||||
|
|
||||||
|
// ES Modules
|
||||||
|
import { average } from '30-seconds-of-code';
|
||||||
|
average(1, 2, 3);
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@ -60,6 +111,8 @@
|
|||||||
* [`join`](#join)
|
* [`join`](#join)
|
||||||
* [`last`](#last)
|
* [`last`](#last)
|
||||||
* [`mapObject`](#mapobject)
|
* [`mapObject`](#mapobject)
|
||||||
|
* [`maxN`](#maxn)
|
||||||
|
* [`minN`](#minn)
|
||||||
* [`nthElement`](#nthelement)
|
* [`nthElement`](#nthelement)
|
||||||
* [`pick`](#pick)
|
* [`pick`](#pick)
|
||||||
* [`pull`](#pull)
|
* [`pull`](#pull)
|
||||||
@ -162,11 +215,14 @@
|
|||||||
* [`distance`](#distance)
|
* [`distance`](#distance)
|
||||||
* [`elo`](#elo)
|
* [`elo`](#elo)
|
||||||
* [`factorial`](#factorial)
|
* [`factorial`](#factorial)
|
||||||
|
* [`factors`](#factors)
|
||||||
* [`fibonacci`](#fibonacci)
|
* [`fibonacci`](#fibonacci)
|
||||||
* [`fibonacciCountUntilNum`](#fibonaccicountuntilnum)
|
* [`fibonacciCountUntilNum`](#fibonaccicountuntilnum)
|
||||||
* [`fibonacciUntilNum`](#fibonacciuntilnum)
|
* [`fibonacciUntilNum`](#fibonacciuntilnum)
|
||||||
* [`gcd`](#gcd)
|
* [`gcd`](#gcd)
|
||||||
|
* [`geometricProgression`](#geometricprogression)
|
||||||
* [`hammingDistance`](#hammingdistance)
|
* [`hammingDistance`](#hammingdistance)
|
||||||
|
* [`howManyTimes`](#howmanytimes)
|
||||||
* [`inRange`](#inrange)
|
* [`inRange`](#inrange)
|
||||||
* [`isArmstrongNumber`](#isarmstrongnumber)
|
* [`isArmstrongNumber`](#isarmstrongnumber)
|
||||||
* [`isDivisible`](#isdivisible)
|
* [`isDivisible`](#isdivisible)
|
||||||
@ -237,6 +293,7 @@
|
|||||||
* [`isAbsoluteURL`](#isabsoluteurl)
|
* [`isAbsoluteURL`](#isabsoluteurl)
|
||||||
* [`mask`](#mask)
|
* [`mask`](#mask)
|
||||||
* [`palindrome`](#palindrome)
|
* [`palindrome`](#palindrome)
|
||||||
|
* [`pluralize`](#pluralize)
|
||||||
* [`repeatString`](#repeatstring)
|
* [`repeatString`](#repeatstring)
|
||||||
* [`reverseString`](#reversestring)
|
* [`reverseString`](#reversestring)
|
||||||
* [`sortCharactersInString`](#sortcharactersinstring)
|
* [`sortCharactersInString`](#sortcharactersinstring)
|
||||||
@ -290,7 +347,8 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>View contents</summary>
|
<summary>View contents</summary>
|
||||||
|
|
||||||
* [`geometricProgression`](#geometricprogression)
|
* [`maxN`](#maxn)
|
||||||
|
* [`minN`](#minn)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@ -1054,6 +1112,57 @@ squareIt([1, 2, 3]); // { 1: 1, 2: 4, 3: 9 }
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### maxN
|
||||||
|
|
||||||
|
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in descending order).
|
||||||
|
|
||||||
|
Use `Array.sort()` combined with the spread operator (`...`) to create a shallow clone of the array and sort it in descending order.
|
||||||
|
Use `Array.slice()` to get the specified number of elements.
|
||||||
|
Omit the second argument, `n`, to get a one-element array.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
maxN([1, 2, 3]); // [3]
|
||||||
|
maxN([1, 2, 3], 2); // [3,2]
|
||||||
|
maxN([1, 2, 3], 4); // [3,2,1]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### minN
|
||||||
|
|
||||||
|
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in ascending order).
|
||||||
|
|
||||||
|
Use `Array.sort()` combined with the spread operator (`...`) to create a shallow clone of the array and sort it in ascending order.
|
||||||
|
Use `Array.slice()` to get the specified number of elements.
|
||||||
|
Omit the second argument, `n`, to get a one-element array.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
|
```
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
minN([1, 2, 3]); // [1]
|
||||||
|
minN([1, 2, 3], 2); // [1,2]
|
||||||
|
minN([1, 2, 3], 4); // [1,2,3]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### nthElement
|
### nthElement
|
||||||
|
|
||||||
Returns the nth element of an array.
|
Returns the nth element of an array.
|
||||||
@ -2763,6 +2872,57 @@ factorial(6); // 720
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### factors
|
||||||
|
|
||||||
|
Returns the array of factors of the given `num`.
|
||||||
|
If the second argument is set to `true` returns only the prime factors of `num`.
|
||||||
|
If `num` is `1` or `0` returns an empty array.
|
||||||
|
If `num` is less than `0` returns all the factors of `-int` together with their additive inverses.
|
||||||
|
|
||||||
|
Use `Array.from()`, `Array.map()` and `Array.filter()` to find all the factors of `num`.
|
||||||
|
If given `num` is negative, use `Array.reduce()` to add the additive inverses to the array.
|
||||||
|
Return all results if `primes` is `false`, else determine and return only the prime factors using `isPrime` and `Array.filter()`.
|
||||||
|
Omit the second argument, `primes`, to return prime and non-prime factors by default.
|
||||||
|
|
||||||
|
**Note**:- _Negative numbers are not considered prime._
|
||||||
|
|
||||||
|
```js
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
factors(12); // [2,3,4,6,12]
|
||||||
|
factors(12, true); // [2,3]
|
||||||
|
factors(-12); // [2, -2, 3, -3, 4, -4, 6, -6, 12, -12]
|
||||||
|
factors(-12, true); // [2,3]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### fibonacci
|
### fibonacci
|
||||||
|
|
||||||
Generates an array, containing the Fibonacci sequence, up until the nth term.
|
Generates an array, containing the Fibonacci sequence, up until the nth term.
|
||||||
@ -2871,6 +3031,37 @@ gcd(8, 36); // 4
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### geometricProgression
|
||||||
|
|
||||||
|
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.
|
||||||
|
Returns an error if `step` equals `1`.
|
||||||
|
|
||||||
|
Use `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the desired length, `Array.map()` to fill with the desired values in a range.
|
||||||
|
Omit the second argument, `start`, to use a default value of `1`.
|
||||||
|
Omit the third argument, `step`, to use a default value of `2`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const geometricProgression = (end, start = 1, step = 2) =>
|
||||||
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
|
(v, i) => start * step ** i
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||||
|
geometricProgression(256, 3); //[3, 6, 12, 24, 48, 96, 192]
|
||||||
|
geometricProgression(256, 1, 4); //[1, 4, 16, 64, 256]
|
||||||
|
geometricProgression(256, 2, 1); //Gives error
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### hammingDistance
|
### hammingDistance
|
||||||
|
|
||||||
Calculates the Hamming distance between two values.
|
Calculates the Hamming distance between two values.
|
||||||
@ -2894,6 +3085,47 @@ hammingDistance(2, 3); // 1
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### howManyTimes
|
||||||
|
|
||||||
|
Returns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer.
|
||||||
|
Works for both negative and positive integers.
|
||||||
|
|
||||||
|
If `divisor` is `-1` or `1` return `Infinity`.
|
||||||
|
If `divisor` is `-0` or `0` return `0`.
|
||||||
|
Otherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer.
|
||||||
|
Return the number of times the loop was executed, `i`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
howManyTimes(100, 2); //2
|
||||||
|
howManyTimes(100, -2); //2
|
||||||
|
howManyTimes(100, 2.5); //2
|
||||||
|
howManyTimes(100, 3); //0
|
||||||
|
howManyTimes(100, 0); //0
|
||||||
|
howManyTimes(100, 1); //Infinity
|
||||||
|
howManyTimes(100, -1); //Infinity
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### inRange
|
### inRange
|
||||||
|
|
||||||
Checks if the given number falls within the given range.
|
Checks if the given number falls within the given range.
|
||||||
@ -4146,6 +4378,38 @@ palindrome('taco cat'); // true
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
# pluralize
|
||||||
|
|
||||||
|
If `num` is greater than `1` returns the plural form of the given string, else return the singular form.
|
||||||
|
|
||||||
|
Check if `num` is greater than `0`. Throw an appropriate `Error` if not, return the appropriate string otherwise.
|
||||||
|
Omit the third argument, `items`, to use a default plural form same as `item` suffixed with a single `'s'`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const pluralize = (num, item, items = item + 's') =>
|
||||||
|
num <= 0
|
||||||
|
? (() => {
|
||||||
|
throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
|
||||||
|
})()
|
||||||
|
: num === 1 ? item : items;
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
pluralize(1, 'apple', 'apples'); // 'apple'
|
||||||
|
pluralize(3, 'apple', 'apples'); // 'apples'
|
||||||
|
pluralize(2, 'apple'); // 'apples'
|
||||||
|
pluralize(0, 'apple', 'apples'); // Gives error
|
||||||
|
pluralize(-3, 'apple', 'apples'); // Gives error
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### repeatString
|
### repeatString
|
||||||
|
|
||||||
Repeats a string n times using `String.repeat()`
|
Repeats a string n times using `String.repeat()`
|
||||||
@ -5145,30 +5409,41 @@ yesNo('Foo', true); // true
|
|||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
---
|
|
||||||
## _Uncategorized_
|
|
||||||
|
|
||||||
### geometricProgression
|
### maxN
|
||||||
|
|
||||||
Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.
|
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in descending order).
|
||||||
Returns an error if `step` equals `1`.
|
|
||||||
|
|
||||||
Use `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the desired length, `Array.map()` to fill with the desired values in a range.
|
Sort's the array's shallow copy in descending order and returns the first n elements
|
||||||
Omit the second argument, `start`, to use a default value of `1`.
|
|
||||||
Omit the third argument, `step`, to use a default value of `2`.
|
|
||||||
|
|
||||||
|
Skip the second argument to get a single element(in the form of a array)
|
||||||
```js
|
```js
|
||||||
const geometricProgression = (end, start = 1, step = 2) =>
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
|
||||||
(v, i) => start * step ** i
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
|
maxN([1, 2, 3]); // [3]
|
||||||
geometricProgression(256, 3); //[3, 6, 12, 24, 48, 96, 192]
|
maxN([1, 2, 3], 2); // [3,2]
|
||||||
geometricProgression(256, 1, 4); //[1, 4, 16, 64, 256]
|
maxN([1, 2, 3], 4); // [3,2,1]
|
||||||
geometricProgression(256, 2, 1); //Gives error
|
```
|
||||||
|
|
||||||
|
<br>[⬆ back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### minN
|
||||||
|
|
||||||
|
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in ascending order).
|
||||||
|
|
||||||
|
Sort's the array's shallow copy in ascending order and returns the first n elements
|
||||||
|
|
||||||
|
Skip the second argument to get a single element(in the form of a array)
|
||||||
|
```js
|
||||||
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
|
```
|
||||||
|
```js
|
||||||
|
minN([1, 2, 3]); // [1]
|
||||||
|
minN([1, 2, 3], 2); // [1,2]
|
||||||
|
minN([1, 2, 3], 4); // [1,2,3]
|
||||||
```
|
```
|
||||||
|
|
||||||
<br>[⬆ back to top](#table-of-contents)
|
<br>[⬆ back to top](#table-of-contents)
|
||||||
|
|||||||
187
dist/_30s.es5.js
vendored
187
dist/_30s.es5.js
vendored
@ -4,6 +4,33 @@
|
|||||||
(global._30s = factory());
|
(global._30s = factory());
|
||||||
}(this, (function () { 'use strict';
|
}(this, (function () { 'use strict';
|
||||||
|
|
||||||
|
var JSONToDate = function JSONToDate(arr) {
|
||||||
|
var dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
|
||||||
|
};
|
||||||
|
|
||||||
|
var fs = typeof require !== "undefined" && require('fs');
|
||||||
|
var JSONToFile = function JSONToFile(obj, filename) {
|
||||||
|
return fs.writeFile(filename + ".json", JSON.stringify(obj, null, 2));
|
||||||
|
};
|
||||||
|
|
||||||
|
var RGBToHex = function RGBToHex(r, g, b) {
|
||||||
|
return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
|
};
|
||||||
|
|
||||||
|
var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() {
|
||||||
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
|
||||||
|
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var crypto$1 = typeof require !== "undefined" && require('crypto');
|
||||||
|
var UUIDGeneratorNode = function UUIDGeneratorNode() {
|
||||||
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
|
||||||
|
return (c ^ crypto$1.randomBytes(1)[0] & 15 >> c / 4).toString(16);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var anagrams = function anagrams(str) {
|
var anagrams = function anagrams(str) {
|
||||||
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
||||||
return str.split('').reduce(function (acc, letter, i) {
|
return str.split('').reduce(function (acc, letter, i) {
|
||||||
@ -324,6 +351,30 @@ var factorial = function factorial(n) {
|
|||||||
}() : n <= 1 ? 1 : n * factorial(n - 1);
|
}() : n <= 1 ? 1 : n * factorial(n - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var factors = function factors(num) {
|
||||||
|
var primes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||||
|
|
||||||
|
var isPrime = function isPrime(num) {
|
||||||
|
var boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) {
|
||||||
|
if (num % i === 0) return false;
|
||||||
|
}return num >= 2;
|
||||||
|
};
|
||||||
|
var isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
var array = Array.from({ length: num - 1 }).map(function (val, i) {
|
||||||
|
return num % (i + 2) === 0 ? i + 2 : false;
|
||||||
|
}).filter(function (val) {
|
||||||
|
return val;
|
||||||
|
});
|
||||||
|
if (isNeg) array = array.reduce(function (acc, val) {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
|
||||||
var fibonacci = function fibonacci(n) {
|
var fibonacci = function fibonacci(n) {
|
||||||
return Array.from({ length: n }).reduce(function (acc, val, i) {
|
return Array.from({ length: n }).reduce(function (acc, val, i) {
|
||||||
return acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i);
|
return acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i);
|
||||||
@ -395,6 +446,14 @@ var gcd = function gcd() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var geometricProgression = function geometricProgression(end) {
|
||||||
|
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||||
|
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
||||||
|
return Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(function (v, i) {
|
||||||
|
return start * Math.pow(step, i);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var getDaysDiffBetweenDates = function getDaysDiffBetweenDates(dateInitial, dateFinal) {
|
var getDaysDiffBetweenDates = function getDaysDiffBetweenDates(dateInitial, dateFinal) {
|
||||||
return (dateFinal - dateInitial) / (1000 * 3600 * 24);
|
return (dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||||
};
|
};
|
||||||
@ -474,10 +533,28 @@ var hide = function hide() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var howManyTimes = function howManyTimes(num, divisor) {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
var i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
|
||||||
var httpsRedirect = function httpsRedirect() {
|
var httpsRedirect = function httpsRedirect() {
|
||||||
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var inRange = function inRange(n, start) {
|
||||||
|
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
||||||
|
|
||||||
|
if (end && start > end) end = [start, start = end][0];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
|
|
||||||
var initial = function initial(arr) {
|
var initial = function initial(arr) {
|
||||||
return arr.slice(0, -1);
|
return arr.slice(0, -1);
|
||||||
};
|
};
|
||||||
@ -491,8 +568,9 @@ var initialize2DArray = function initialize2DArray(w, h) {
|
|||||||
|
|
||||||
var initializeArrayWithRange = function initializeArrayWithRange(end) {
|
var initializeArrayWithRange = function initializeArrayWithRange(end) {
|
||||||
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||||
return Array.from({ length: end + 1 - start }).map(function (v, i) {
|
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
||||||
return i + start;
|
return Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(function (v, i) {
|
||||||
|
return i * step + start;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -501,13 +579,6 @@ var initializeArrayWithValues = function initializeArrayWithValues(n) {
|
|||||||
return Array(n).fill(value);
|
return Array(n).fill(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
var inRange = function inRange(n, start) {
|
|
||||||
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
||||||
|
|
||||||
if (end && start > end) end = [start, start = end][0];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
|
|
||||||
var intersection = function intersection(a, b) {
|
var intersection = function intersection(a, b) {
|
||||||
var s = new Set(b);
|
var s = new Set(b);
|
||||||
return a.filter(function (x) {
|
return a.filter(function (x) {
|
||||||
@ -658,16 +729,6 @@ var join = function join(arr) {
|
|||||||
}, '');
|
}, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
var JSONToDate = function JSONToDate(arr) {
|
|
||||||
var dt = new Date(parseInt(arr.toString().substr(6)));
|
|
||||||
return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
|
|
||||||
};
|
|
||||||
|
|
||||||
var fs = typeof require !== "undefined" && require('fs');
|
|
||||||
var JSONToFile = function JSONToFile(obj, filename) {
|
|
||||||
return fs.writeFile(filename + ".json", JSON.stringify(obj, null, 2));
|
|
||||||
};
|
|
||||||
|
|
||||||
var last = function last(arr) {
|
var last = function last(arr) {
|
||||||
return arr[arr.length - 1];
|
return arr[arr.length - 1];
|
||||||
};
|
};
|
||||||
@ -709,10 +770,11 @@ var mask = function mask(cc) {
|
|||||||
|
|
||||||
function _toConsumableArray$6(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
function _toConsumableArray$6(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||||
|
|
||||||
var max = function max() {
|
var maxN = function maxN(arr) {
|
||||||
var _ref;
|
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||||
|
return [].concat(_toConsumableArray$6(arr)).sort(function (a, b) {
|
||||||
return Math.max.apply(Math, _toConsumableArray$6((_ref = []).concat.apply(_ref, arguments)));
|
return b - a;
|
||||||
|
}).slice(0, n);
|
||||||
};
|
};
|
||||||
|
|
||||||
function _toConsumableArray$7(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
function _toConsumableArray$7(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||||
@ -734,10 +796,11 @@ var memoize = function memoize(fn) {
|
|||||||
|
|
||||||
function _toConsumableArray$8(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
function _toConsumableArray$8(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||||
|
|
||||||
var min = function min(arr) {
|
var minN = function minN(arr) {
|
||||||
var _ref;
|
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||||
|
return [].concat(_toConsumableArray$8(arr)).sort(function (a, b) {
|
||||||
return Math.min.apply(Math, _toConsumableArray$8((_ref = []).concat.apply(_ref, _toConsumableArray$8(arr))));
|
return a - b;
|
||||||
|
}).slice(0, n);
|
||||||
};
|
};
|
||||||
|
|
||||||
var negate = function negate(func) {
|
var negate = function negate(func) {
|
||||||
@ -763,20 +826,6 @@ var objectToPairs = function objectToPairs(obj) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var once = function once(fn) {
|
|
||||||
var called = false;
|
|
||||||
return function () {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
|
|
||||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
||||||
args[_key] = arguments[_key];
|
|
||||||
}
|
|
||||||
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var onUserInputChange = function onUserInputChange(callback) {
|
var onUserInputChange = function onUserInputChange(callback) {
|
||||||
var type = 'mouse',
|
var type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -791,6 +840,20 @@ var onUserInputChange = function onUserInputChange(callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var once = function once(fn) {
|
||||||
|
var called = false;
|
||||||
|
return function () {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
|
||||||
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||||
|
args[_key] = arguments[_key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var _slicedToArray$2 = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
var _slicedToArray$2 = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
||||||
|
|
||||||
function _toConsumableArray$9(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
function _toConsumableArray$9(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||||
@ -840,6 +903,13 @@ var pipeFunctions = function pipeFunctions() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var pluralize = function pluralize(num, item) {
|
||||||
|
var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : item + 's';
|
||||||
|
return num <= 0 ? function () {
|
||||||
|
throw new Error('\'num\' should be >= 1. Value povided was ' + num + '.');
|
||||||
|
}() : num === 1 ? item : items;
|
||||||
|
};
|
||||||
|
|
||||||
var powerset = function powerset(arr) {
|
var powerset = function powerset(arr) {
|
||||||
return arr.reduce(function (a, v) {
|
return arr.reduce(function (a, v) {
|
||||||
return a.concat(a.map(function (r) {
|
return a.concat(a.map(function (r) {
|
||||||
@ -999,10 +1069,6 @@ var reverseString = function reverseString(str) {
|
|||||||
return str.split('').reverse().join('');
|
return str.split('').reverse().join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
var RGBToHex = function RGBToHex(r, g, b) {
|
|
||||||
return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
};
|
|
||||||
|
|
||||||
var round = function round(n) {
|
var round = function round(n) {
|
||||||
var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||||
return Number(Math.round(n + "e" + decimals) + "e-" + decimals);
|
return Number(Math.round(n + "e" + decimals) + "e-" + decimals);
|
||||||
@ -1279,20 +1345,12 @@ var toEnglishDate = function toEnglishDate(time) {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
var toggleClass = function toggleClass(el, className) {
|
|
||||||
return el.classList.toggle(className);
|
|
||||||
};
|
|
||||||
|
|
||||||
var toKebabCase = function toKebabCase(str) {
|
var toKebabCase = function toKebabCase(str) {
|
||||||
return str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function (x) {
|
return str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function (x) {
|
||||||
return x.toLowerCase();
|
return x.toLowerCase();
|
||||||
}).join('-');
|
}).join('-');
|
||||||
};
|
};
|
||||||
|
|
||||||
var tomorrow = function tomorrow() {
|
|
||||||
return new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
var toOrdinalSuffix = function toOrdinalSuffix(num) {
|
var toOrdinalSuffix = function toOrdinalSuffix(num) {
|
||||||
var int = parseInt(num),
|
var int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -1308,6 +1366,14 @@ var toSnakeCase = function toSnakeCase(str) {
|
|||||||
}).join('_');
|
}).join('_');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var toggleClass = function toggleClass(el, className) {
|
||||||
|
return el.classList.toggle(className);
|
||||||
|
};
|
||||||
|
|
||||||
|
var tomorrow = function tomorrow() {
|
||||||
|
return new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
||||||
|
};
|
||||||
|
|
||||||
var truncateString = function truncateString(str, num) {
|
var truncateString = function truncateString(str, num) {
|
||||||
return str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
return str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
||||||
};
|
};
|
||||||
@ -1340,19 +1406,6 @@ var untildify = function untildify(str) {
|
|||||||
return str.replace(/^~($|\/|\\)/, (typeof require !== "undefined" && require('os').homedir()) + "$1");
|
return str.replace(/^~($|\/|\\)/, (typeof require !== "undefined" && require('os').homedir()) + "$1");
|
||||||
};
|
};
|
||||||
|
|
||||||
var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() {
|
|
||||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
|
|
||||||
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var crypto$1 = typeof require !== "undefined" && require('crypto');
|
|
||||||
var UUIDGeneratorNode = function UUIDGeneratorNode() {
|
|
||||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
|
|
||||||
return (c ^ crypto$1.randomBytes(1)[0] & 15 >> c / 4).toString(16);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
@ -1401,7 +1454,7 @@ var zipObject = function zipObject(props, values) {
|
|||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
var imports = { anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collatz: collatz, collectInto: collectInto, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countOccurrences: countOccurrences, countVowels: countVowels, currentURL: currentURL, curry: curry, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, distinctValuesOfArray: distinctValuesOfArray, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, fibonacciCountUntilNum: fibonacciCountUntilNum, fibonacciUntilNum: fibonacciUntilNum, filterNonUnique: filterNonUnique, flatten: flatten, flattenDepth: flattenDepth, flip: flip, fromCamelCase: fromCamelCase, functionName: functionName, gcd: gcd, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, head: head, hexToRGB: hexToRGB, hide: hide, httpsRedirect: httpsRedirect, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithValues: initializeArrayWithValues, inRange: inRange, intersection: intersection, invertKeyValues: invertKeyValues, isAbsoluteURL: isAbsoluteURL, isArmstrongNumber: isArmstrongNumber, isArray: isArray, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isNull: isNull, isNumber: isNumber, isPrime: isPrime, isPrimitive: isPrimitive, isPromiseLike: isPromiseLike, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isValidJSON: isValidJSON, join: join, JSONToDate: JSONToDate, JSONToFile: JSONToFile, last: last, lcm: lcm, lowercaseKeys: lowercaseKeys, mapObject: mapObject, mask: mask, max: max, median: median, memoize: memoize, min: min, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, once: once, onUserInputChange: onUserInputChange, orderBy: orderBy, palindrome: palindrome, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, quickSort: quickSort, randomHexColorCode: randomHexColorCode, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, repeatString: repeatString, reverseString: reverseString, RGBToHex: RGBToHex, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, solveRPN: solveRPN, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, speechSynthesis: speechSynthesis, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toEnglishDate: toEnglishDate, toggleClass: toggleClass, toKebabCase: toKebabCase, tomorrow: tomorrow, toOrdinalSuffix: toOrdinalSuffix, toSnakeCase: toSnakeCase, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, untildify: untildify, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject };
|
var imports = { JSONToDate: JSONToDate, JSONToFile: JSONToFile, RGBToHex: RGBToHex, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collatz: collatz, collectInto: collectInto, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countOccurrences: countOccurrences, countVowels: countVowels, currentURL: currentURL, curry: curry, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, distinctValuesOfArray: distinctValuesOfArray, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, factors: factors, fibonacci: fibonacci, fibonacciCountUntilNum: fibonacciCountUntilNum, fibonacciUntilNum: fibonacciUntilNum, filterNonUnique: filterNonUnique, flatten: flatten, flattenDepth: flattenDepth, flip: flip, fromCamelCase: fromCamelCase, functionName: functionName, 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, howManyTimes: howManyTimes, httpsRedirect: httpsRedirect, inRange: inRange, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, invertKeyValues: invertKeyValues, isAbsoluteURL: isAbsoluteURL, isArmstrongNumber: isArmstrongNumber, isArray: isArray, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isNull: isNull, isNumber: isNumber, isPrime: isPrime, isPrimitive: isPrimitive, isPromiseLike: isPromiseLike, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, lowercaseKeys: lowercaseKeys, mapObject: mapObject, mask: mask, maxN: maxN, median: median, memoize: memoize, minN: minN, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, palindrome: palindrome, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, quickSort: quickSort, randomHexColorCode: randomHexColorCode, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, repeatString: repeatString, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, solveRPN: solveRPN, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, speechSynthesis: speechSynthesis, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toEnglishDate: toEnglishDate, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, untildify: untildify, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject };
|
||||||
|
|
||||||
return imports;
|
return imports;
|
||||||
|
|
||||||
|
|||||||
2
dist/_30s.es5.min.js
vendored
2
dist/_30s.es5.min.js
vendored
File diff suppressed because one or more lines are too long
133
dist/_30s.esm.js
vendored
133
dist/_30s.esm.js
vendored
@ -1,3 +1,25 @@
|
|||||||
|
const JSONToDate = arr => {
|
||||||
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const fs = typeof require !== "undefined" && require('fs');
|
||||||
|
const JSONToFile = (obj, filename) =>
|
||||||
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
|
|
||||||
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
|
|
||||||
|
const UUIDGeneratorBrowser = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
|
||||||
|
const crypto$1 = typeof require !== "undefined" && require('crypto');
|
||||||
|
const UUIDGeneratorNode = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto$1.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
|
||||||
const anagrams = str => {
|
const anagrams = str => {
|
||||||
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
||||||
return str
|
return str
|
||||||
@ -171,6 +193,26 @@ const factorial = n =>
|
|||||||
})()
|
})()
|
||||||
: n <= 1 ? 1 : n * factorial(n - 1);
|
: n <= 1 ? 1 : n * factorial(n - 1);
|
||||||
|
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
|
||||||
const fibonacci = n =>
|
const fibonacci = n =>
|
||||||
Array.from({ length: n }).reduce(
|
Array.from({ length: n }).reduce(
|
||||||
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||||
@ -213,6 +255,11 @@ const gcd = (...arr) => {
|
|||||||
return data.reduce((a, b) => helperGcd(a, b));
|
return data.reduce((a, b) => helperGcd(a, b));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const geometricProgression = (end, start = 1, step = 2) =>
|
||||||
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
|
(v, i) => start * step ** i
|
||||||
|
);
|
||||||
|
|
||||||
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
||||||
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||||
|
|
||||||
@ -268,10 +315,26 @@ const hexToRGB = hex => {
|
|||||||
|
|
||||||
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
||||||
|
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
|
||||||
const httpsRedirect = () => {
|
const httpsRedirect = () => {
|
||||||
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const inRange = (n, start, end = null) => {
|
||||||
|
if (end && start > end) end = [start, (start = end)][0];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
|
|
||||||
const initial = arr => arr.slice(0, -1);
|
const initial = arr => arr.slice(0, -1);
|
||||||
|
|
||||||
const initialize2DArray = (w, h, val = null) =>
|
const initialize2DArray = (w, h, val = null) =>
|
||||||
@ -279,16 +342,11 @@ const initialize2DArray = (w, h, val = null) =>
|
|||||||
.fill()
|
.fill()
|
||||||
.map(() => Array(w).fill(val));
|
.map(() => Array(w).fill(val));
|
||||||
|
|
||||||
const initializeArrayWithRange = (end, start = 0) =>
|
const initializeArrayWithRange = (end, start = 0, step = 1) =>
|
||||||
Array.from({ length: end + 1 - start }).map((v, i) => i + start);
|
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start);
|
||||||
|
|
||||||
const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);
|
const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);
|
||||||
|
|
||||||
const inRange = (n, start, end = null) => {
|
|
||||||
if (end && start > end) end = [start, (start = end)][0];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
|
|
||||||
const intersection = (a, b) => {
|
const intersection = (a, b) => {
|
||||||
const s = new Set(b);
|
const s = new Set(b);
|
||||||
return a.filter(x => s.has(x));
|
return a.filter(x => s.has(x));
|
||||||
@ -373,15 +431,6 @@ const join = (arr, separator = ',', end = separator) =>
|
|||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
const JSONToDate = arr => {
|
|
||||||
const dt = new Date(parseInt(arr.toString().substr(6)));
|
|
||||||
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const fs = typeof require !== "undefined" && require('fs');
|
|
||||||
const JSONToFile = (obj, filename) =>
|
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
|
||||||
|
|
||||||
const last = arr => arr[arr.length - 1];
|
const last = arr => arr[arr.length - 1];
|
||||||
|
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
@ -403,7 +452,7 @@ const mapObject = (arr, fn) =>
|
|||||||
const mask = (cc, num = 4, mask = '*') =>
|
const mask = (cc, num = 4, mask = '*') =>
|
||||||
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
||||||
|
|
||||||
const max = (...arr) => Math.max(...[].concat(...arr));
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
|
|
||||||
const median = arr => {
|
const median = arr => {
|
||||||
const mid = Math.floor(arr.length / 2),
|
const mid = Math.floor(arr.length / 2),
|
||||||
@ -416,7 +465,7 @@ const memoize = fn => {
|
|||||||
return value => cache[value] || (cache[value] = fn(value));
|
return value => cache[value] || (cache[value] = fn(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
const min = arr => Math.min(...[].concat(...arr));
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
|
|
||||||
const negate = func => (...args) => !func(...args);
|
const negate = func => (...args) => !func(...args);
|
||||||
|
|
||||||
@ -426,15 +475,6 @@ 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 objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||||
|
|
||||||
const once = fn => {
|
|
||||||
let called = false;
|
|
||||||
return function(...args) {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const onUserInputChange = callback => {
|
const onUserInputChange = callback => {
|
||||||
let type = 'mouse',
|
let type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -450,6 +490,15 @@ const onUserInputChange = callback => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const once = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function(...args) {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const orderBy = (arr, props, orders) =>
|
const orderBy = (arr, props, orders) =>
|
||||||
[...arr].sort((a, b) =>
|
[...arr].sort((a, b) =>
|
||||||
props.reduce((acc, prop, i) => {
|
props.reduce((acc, prop, i) => {
|
||||||
@ -480,6 +529,13 @@ const pick = (obj, arr) =>
|
|||||||
|
|
||||||
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
||||||
|
|
||||||
|
const pluralize = (num, item, items = item + 's') =>
|
||||||
|
num <= 0
|
||||||
|
? (() => {
|
||||||
|
throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
|
||||||
|
})()
|
||||||
|
: num === 1 ? item : items;
|
||||||
|
|
||||||
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
||||||
|
|
||||||
const prettyBytes = (num, precision = 3, addSpace = true) => {
|
const prettyBytes = (num, precision = 3, addSpace = true) => {
|
||||||
@ -583,8 +639,6 @@ const reverseString = str =>
|
|||||||
.reverse()
|
.reverse()
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
|
|
||||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||||
|
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
@ -773,8 +827,6 @@ const toEnglishDate = time => {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
|
||||||
|
|
||||||
const toKebabCase = str =>
|
const toKebabCase = str =>
|
||||||
str &&
|
str &&
|
||||||
str
|
str
|
||||||
@ -782,8 +834,6 @@ const toKebabCase = str =>
|
|||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('-');
|
.join('-');
|
||||||
|
|
||||||
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
|
||||||
|
|
||||||
const toOrdinalSuffix = num => {
|
const toOrdinalSuffix = num => {
|
||||||
const int = parseInt(num),
|
const int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -802,6 +852,10 @@ const toSnakeCase = str =>
|
|||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('_');
|
.join('_');
|
||||||
|
|
||||||
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
|
|
||||||
|
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
||||||
|
|
||||||
const truncateString = (str, num) =>
|
const truncateString = (str, num) =>
|
||||||
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
||||||
|
|
||||||
@ -824,17 +878,6 @@ const union = (a, b) => Array.from(new Set([...a, ...b]));
|
|||||||
|
|
||||||
const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`);
|
const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`);
|
||||||
|
|
||||||
const UUIDGeneratorBrowser = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
|
|
||||||
const crypto$1 = typeof require !== "undefined" && require('crypto');
|
|
||||||
const UUIDGeneratorNode = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto$1.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
|
|
||||||
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||||
|
|
||||||
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
|
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
|
||||||
@ -854,6 +897,6 @@ const zip = (...arrays) => {
|
|||||||
const zipObject = (props, values) =>
|
const zipObject = (props, values) =>
|
||||||
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
||||||
|
|
||||||
var imports = {anagrams,arrayToHtmlList,average,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collatz,collectInto,compact,compose,copyToClipboard,countOccurrences,countVowels,currentURL,curry,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,fibonacciCountUntilNum,fibonacciUntilNum,filterNonUnique,flatten,flattenDepth,flip,fromCamelCase,functionName,gcd,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpsRedirect,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,inRange,intersection,invertKeyValues,isAbsoluteURL,isArmstrongNumber,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isNull,isNumber,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isValidJSON,join,JSONToDate,JSONToFile,last,lcm,lowercaseKeys,mapObject,mask,max,median,memoize,min,negate,nthElement,objectFromPairs,objectToPairs,once,onUserInputChange,orderBy,palindrome,percentile,pick,pipeFunctions,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,quickSort,randomHexColorCode,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,repeatString,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,setStyle,shallowClone,show,shuffle,similarity,size,sleep,solveRPN,sortCharactersInString,sortedIndex,speechSynthesis,splitLines,spreadOver,standardDeviation,sum,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toEnglishDate,toggleClass,toKebabCase,tomorrow,toOrdinalSuffix,toSnakeCase,truncateString,truthCheckCollection,unescapeHTML,union,untildify,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,without,words,yesNo,zip,zipObject,}
|
var imports = {JSONToDate,JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collatz,collectInto,compact,compose,copyToClipboard,countOccurrences,countVowels,currentURL,curry,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,factors,fibonacci,fibonacciCountUntilNum,fibonacciUntilNum,filterNonUnique,flatten,flattenDepth,flip,fromCamelCase,functionName,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,howManyTimes,httpsRedirect,inRange,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArmstrongNumber,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isNull,isNumber,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isValidJSON,join,last,lcm,lowercaseKeys,mapObject,mask,maxN,median,memoize,minN,negate,nthElement,objectFromPairs,objectToPairs,onUserInputChange,once,orderBy,palindrome,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,quickSort,randomHexColorCode,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,repeatString,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,setStyle,shallowClone,show,shuffle,similarity,size,sleep,solveRPN,sortCharactersInString,sortedIndex,speechSynthesis,splitLines,spreadOver,standardDeviation,sum,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toEnglishDate,toKebabCase,toOrdinalSuffix,toSnakeCase,toggleClass,tomorrow,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
|
||||||
|
|
||||||
export default imports;
|
export default imports;
|
||||||
|
|||||||
133
dist/_30s.js
vendored
133
dist/_30s.js
vendored
@ -4,6 +4,28 @@
|
|||||||
(global._30s = factory());
|
(global._30s = factory());
|
||||||
}(this, (function () { 'use strict';
|
}(this, (function () { 'use strict';
|
||||||
|
|
||||||
|
const JSONToDate = arr => {
|
||||||
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const fs = typeof require !== "undefined" && require('fs');
|
||||||
|
const JSONToFile = (obj, filename) =>
|
||||||
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
|
|
||||||
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
|
|
||||||
|
const UUIDGeneratorBrowser = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
|
||||||
|
const crypto$1 = typeof require !== "undefined" && require('crypto');
|
||||||
|
const UUIDGeneratorNode = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto$1.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
|
||||||
const anagrams = str => {
|
const anagrams = str => {
|
||||||
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
||||||
return str
|
return str
|
||||||
@ -177,6 +199,26 @@ const factorial = n =>
|
|||||||
})()
|
})()
|
||||||
: n <= 1 ? 1 : n * factorial(n - 1);
|
: n <= 1 ? 1 : n * factorial(n - 1);
|
||||||
|
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
|
||||||
const fibonacci = n =>
|
const fibonacci = n =>
|
||||||
Array.from({ length: n }).reduce(
|
Array.from({ length: n }).reduce(
|
||||||
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||||
@ -219,6 +261,11 @@ const gcd = (...arr) => {
|
|||||||
return data.reduce((a, b) => helperGcd(a, b));
|
return data.reduce((a, b) => helperGcd(a, b));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const geometricProgression = (end, start = 1, step = 2) =>
|
||||||
|
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
||||||
|
(v, i) => start * step ** i
|
||||||
|
);
|
||||||
|
|
||||||
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
||||||
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
(dateFinal - dateInitial) / (1000 * 3600 * 24);
|
||||||
|
|
||||||
@ -274,10 +321,26 @@ const hexToRGB = hex => {
|
|||||||
|
|
||||||
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
||||||
|
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
|
||||||
const httpsRedirect = () => {
|
const httpsRedirect = () => {
|
||||||
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const inRange = (n, start, end = null) => {
|
||||||
|
if (end && start > end) end = [start, (start = end)][0];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
|
|
||||||
const initial = arr => arr.slice(0, -1);
|
const initial = arr => arr.slice(0, -1);
|
||||||
|
|
||||||
const initialize2DArray = (w, h, val = null) =>
|
const initialize2DArray = (w, h, val = null) =>
|
||||||
@ -285,16 +348,11 @@ const initialize2DArray = (w, h, val = null) =>
|
|||||||
.fill()
|
.fill()
|
||||||
.map(() => Array(w).fill(val));
|
.map(() => Array(w).fill(val));
|
||||||
|
|
||||||
const initializeArrayWithRange = (end, start = 0) =>
|
const initializeArrayWithRange = (end, start = 0, step = 1) =>
|
||||||
Array.from({ length: end + 1 - start }).map((v, i) => i + start);
|
Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start);
|
||||||
|
|
||||||
const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);
|
const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);
|
||||||
|
|
||||||
const inRange = (n, start, end = null) => {
|
|
||||||
if (end && start > end) end = [start, (start = end)][0];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
|
|
||||||
const intersection = (a, b) => {
|
const intersection = (a, b) => {
|
||||||
const s = new Set(b);
|
const s = new Set(b);
|
||||||
return a.filter(x => s.has(x));
|
return a.filter(x => s.has(x));
|
||||||
@ -379,15 +437,6 @@ const join = (arr, separator = ',', end = separator) =>
|
|||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
const JSONToDate = arr => {
|
|
||||||
const dt = new Date(parseInt(arr.toString().substr(6)));
|
|
||||||
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const fs = typeof require !== "undefined" && require('fs');
|
|
||||||
const JSONToFile = (obj, filename) =>
|
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
|
||||||
|
|
||||||
const last = arr => arr[arr.length - 1];
|
const last = arr => arr[arr.length - 1];
|
||||||
|
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
@ -409,7 +458,7 @@ const mapObject = (arr, fn) =>
|
|||||||
const mask = (cc, num = 4, mask = '*') =>
|
const mask = (cc, num = 4, mask = '*') =>
|
||||||
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num);
|
||||||
|
|
||||||
const max = (...arr) => Math.max(...[].concat(...arr));
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
|
|
||||||
const median = arr => {
|
const median = arr => {
|
||||||
const mid = Math.floor(arr.length / 2),
|
const mid = Math.floor(arr.length / 2),
|
||||||
@ -422,7 +471,7 @@ const memoize = fn => {
|
|||||||
return value => cache[value] || (cache[value] = fn(value));
|
return value => cache[value] || (cache[value] = fn(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
const min = arr => Math.min(...[].concat(...arr));
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
|
|
||||||
const negate = func => (...args) => !func(...args);
|
const negate = func => (...args) => !func(...args);
|
||||||
|
|
||||||
@ -432,15 +481,6 @@ 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 objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||||
|
|
||||||
const once = fn => {
|
|
||||||
let called = false;
|
|
||||||
return function(...args) {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const onUserInputChange = callback => {
|
const onUserInputChange = callback => {
|
||||||
let type = 'mouse',
|
let type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -456,6 +496,15 @@ const onUserInputChange = callback => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const once = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function(...args) {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const orderBy = (arr, props, orders) =>
|
const orderBy = (arr, props, orders) =>
|
||||||
[...arr].sort((a, b) =>
|
[...arr].sort((a, b) =>
|
||||||
props.reduce((acc, prop, i) => {
|
props.reduce((acc, prop, i) => {
|
||||||
@ -486,6 +535,13 @@ const pick = (obj, arr) =>
|
|||||||
|
|
||||||
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
||||||
|
|
||||||
|
const pluralize = (num, item, items = item + 's') =>
|
||||||
|
num <= 0
|
||||||
|
? (() => {
|
||||||
|
throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
|
||||||
|
})()
|
||||||
|
: num === 1 ? item : items;
|
||||||
|
|
||||||
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
||||||
|
|
||||||
const prettyBytes = (num, precision = 3, addSpace = true) => {
|
const prettyBytes = (num, precision = 3, addSpace = true) => {
|
||||||
@ -589,8 +645,6 @@ const reverseString = str =>
|
|||||||
.reverse()
|
.reverse()
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
|
|
||||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||||
|
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
@ -779,8 +833,6 @@ const toEnglishDate = time => {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
|
||||||
|
|
||||||
const toKebabCase = str =>
|
const toKebabCase = str =>
|
||||||
str &&
|
str &&
|
||||||
str
|
str
|
||||||
@ -788,8 +840,6 @@ const toKebabCase = str =>
|
|||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('-');
|
.join('-');
|
||||||
|
|
||||||
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
|
||||||
|
|
||||||
const toOrdinalSuffix = num => {
|
const toOrdinalSuffix = num => {
|
||||||
const int = parseInt(num),
|
const int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -808,6 +858,10 @@ const toSnakeCase = str =>
|
|||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('_');
|
.join('_');
|
||||||
|
|
||||||
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
|
|
||||||
|
const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
|
||||||
|
|
||||||
const truncateString = (str, num) =>
|
const truncateString = (str, num) =>
|
||||||
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
||||||
|
|
||||||
@ -830,17 +884,6 @@ const union = (a, b) => Array.from(new Set([...a, ...b]));
|
|||||||
|
|
||||||
const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`);
|
const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`);
|
||||||
|
|
||||||
const UUIDGeneratorBrowser = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
|
|
||||||
const crypto$1 = typeof require !== "undefined" && require('crypto');
|
|
||||||
const UUIDGeneratorNode = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto$1.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
|
|
||||||
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||||
|
|
||||||
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
|
const without = (arr, ...args) => arr.filter(v => !args.includes(v));
|
||||||
@ -860,7 +903,7 @@ const zip = (...arrays) => {
|
|||||||
const zipObject = (props, values) =>
|
const zipObject = (props, values) =>
|
||||||
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {});
|
||||||
|
|
||||||
var imports = {anagrams,arrayToHtmlList,average,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collatz,collectInto,compact,compose,copyToClipboard,countOccurrences,countVowels,currentURL,curry,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,fibonacciCountUntilNum,fibonacciUntilNum,filterNonUnique,flatten,flattenDepth,flip,fromCamelCase,functionName,gcd,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpsRedirect,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,inRange,intersection,invertKeyValues,isAbsoluteURL,isArmstrongNumber,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isNull,isNumber,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isValidJSON,join,JSONToDate,JSONToFile,last,lcm,lowercaseKeys,mapObject,mask,max,median,memoize,min,negate,nthElement,objectFromPairs,objectToPairs,once,onUserInputChange,orderBy,palindrome,percentile,pick,pipeFunctions,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,quickSort,randomHexColorCode,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,repeatString,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,setStyle,shallowClone,show,shuffle,similarity,size,sleep,solveRPN,sortCharactersInString,sortedIndex,speechSynthesis,splitLines,spreadOver,standardDeviation,sum,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toEnglishDate,toggleClass,toKebabCase,tomorrow,toOrdinalSuffix,toSnakeCase,truncateString,truthCheckCollection,unescapeHTML,union,untildify,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,without,words,yesNo,zip,zipObject,}
|
var imports = {JSONToDate,JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collatz,collectInto,compact,compose,copyToClipboard,countOccurrences,countVowels,currentURL,curry,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,factors,fibonacci,fibonacciCountUntilNum,fibonacciUntilNum,filterNonUnique,flatten,flattenDepth,flip,fromCamelCase,functionName,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,howManyTimes,httpsRedirect,inRange,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArmstrongNumber,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isNull,isNumber,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isValidJSON,join,last,lcm,lowercaseKeys,mapObject,mask,maxN,median,memoize,minN,negate,nthElement,objectFromPairs,objectToPairs,onUserInputChange,once,orderBy,palindrome,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,quickSort,randomHexColorCode,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,repeatString,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,setStyle,shallowClone,show,shuffle,similarity,size,sleep,solveRPN,sortCharactersInString,sortedIndex,speechSynthesis,splitLines,spreadOver,standardDeviation,sum,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toEnglishDate,toKebabCase,toOrdinalSuffix,toSnakeCase,toggleClass,tomorrow,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,}
|
||||||
|
|
||||||
return imports;
|
return imports;
|
||||||
|
|
||||||
|
|||||||
4
dist/_30s.min.js
vendored
4
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
94
package-lock.json
generated
94
package-lock.json
generated
@ -1421,6 +1421,12 @@
|
|||||||
"esutils": "2.0.2"
|
"esutils": "2.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"duplexer": {
|
||||||
|
"version": "0.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
||||||
|
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"ecc-jsbn": {
|
"ecc-jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
||||||
@ -3092,6 +3098,12 @@
|
|||||||
"error-ex": "1.3.1"
|
"error-ex": "1.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"parse-ms": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"path-exists": {
|
"path-exists": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
|
||||||
@ -3190,6 +3202,12 @@
|
|||||||
"find-up": "1.1.2"
|
"find-up": "1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plur": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/plur/-/plur-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-24XGgU9eXlo7Se/CjWBP7GKXUVY=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"pluralize": {
|
"pluralize": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz",
|
||||||
@ -3235,6 +3253,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
|
||||||
"integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw="
|
"integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw="
|
||||||
},
|
},
|
||||||
|
"re-emitter": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/re-emitter/-/re-emitter-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-+p4xn/3u6zWycpbvDz03TawvUqc=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"read-pkg": {
|
"read-pkg": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
|
||||||
@ -3387,6 +3411,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
|
||||||
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
|
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
|
||||||
},
|
},
|
||||||
|
"repeat-string": {
|
||||||
|
"version": "1.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
|
||||||
|
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"repeating": {
|
"repeating": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz",
|
||||||
@ -3655,6 +3685,15 @@
|
|||||||
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz",
|
||||||
"integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc="
|
"integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc="
|
||||||
},
|
},
|
||||||
|
"split": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"through": "2.3.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sprintf-js": {
|
"sprintf-js": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||||
@ -3831,6 +3870,55 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tap-out": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tap-out/-/tap-out-1.4.2.tgz",
|
||||||
|
"integrity": "sha1-yQfsG/lAURHQiCY+kvVgi4jLs3o=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"re-emitter": "1.1.3",
|
||||||
|
"readable-stream": "2.3.3",
|
||||||
|
"split": "1.0.1",
|
||||||
|
"trim": "0.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tap-spec": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tap-spec/-/tap-spec-4.1.1.tgz",
|
||||||
|
"integrity": "sha1-4unyb1IIIysfViKIyXYk1YqI8Fo=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "1.1.3",
|
||||||
|
"duplexer": "0.1.1",
|
||||||
|
"figures": "1.7.0",
|
||||||
|
"lodash": "3.10.1",
|
||||||
|
"pretty-ms": "2.1.0",
|
||||||
|
"repeat-string": "1.6.1",
|
||||||
|
"tap-out": "1.4.2",
|
||||||
|
"through2": "2.0.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"chalk": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "2.2.1",
|
||||||
|
"escape-string-regexp": "1.0.5",
|
||||||
|
"has-ansi": "2.0.0",
|
||||||
|
"strip-ansi": "3.0.1",
|
||||||
|
"supports-color": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lodash": {
|
||||||
|
"version": "3.10.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
|
||||||
|
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"tape": {
|
"tape": {
|
||||||
"version": "4.8.0",
|
"version": "4.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/tape/-/tape-4.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/tape/-/tape-4.8.0.tgz",
|
||||||
@ -3894,6 +3982,12 @@
|
|||||||
"punycode": "1.4.1"
|
"punycode": "1.4.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"trim": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz",
|
||||||
|
"integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"trim-newlines": {
|
"trim-newlines": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
"rollup-plugin-babel": "^3.0.3",
|
"rollup-plugin-babel": "^3.0.3",
|
||||||
"rollup-plugin-babel-minify": "^3.1.2",
|
"rollup-plugin-babel-minify": "^3.1.2",
|
||||||
"semistandard": "^11.0.0",
|
"semistandard": "^11.0.0",
|
||||||
"tape": "^4.8.0"
|
"tape": "^4.8.0",
|
||||||
|
"tap-spec": "^4.1.1"
|
||||||
},
|
},
|
||||||
"name": "30-seconds-of-code",
|
"name": "30-seconds-of-code",
|
||||||
"description": "A collection of useful JavaScript snippets.",
|
"description": "A collection of useful JavaScript snippets.",
|
||||||
@ -24,7 +25,8 @@
|
|||||||
"tagger": "node ./scripts/tag.js",
|
"tagger": "node ./scripts/tag.js",
|
||||||
"webber": "node ./scripts/web.js",
|
"webber": "node ./scripts/web.js",
|
||||||
"tdd": "node ./scripts/tdd.js",
|
"tdd": "node ./scripts/tdd.js",
|
||||||
"module": "node ./scripts/module.js"
|
"module": "node ./scripts/module.js",
|
||||||
|
"test": "tape test/**/*.test.js | tap-spec"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@ -1,50 +1,84 @@
|
|||||||
const fs = require('fs-extra');
|
/*
|
||||||
|
This is the tdd script that creates & updates your TDD environment .
|
||||||
|
Run using `npm run tagger`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load modules
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
// Load helper functions (these are from existing snippets in 30 seconds of code!)
|
||||||
|
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
||||||
|
if(isTravisCI() && process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && process.env['TRAVIS_EVENT_TYPE'] !== 'api') {
|
||||||
|
console.log(`${chalk.green('NOBUILD')} Testing terminated, not a cron job or a custom build!`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
// Declare paths
|
||||||
const SNIPPETS_PATH = './snippets';
|
const SNIPPETS_PATH = './snippets';
|
||||||
const TEST_PATH = './test';
|
const TEST_PATH = './test';
|
||||||
|
|
||||||
|
// Array of snippet names
|
||||||
const snippetFiles = fs.readdirSync(SNIPPETS_PATH, 'utf8').map(fileName => fileName.slice(0, -3));
|
const snippetFiles = fs.readdirSync(SNIPPETS_PATH, 'utf8').map(fileName => fileName.slice(0, -3));
|
||||||
|
|
||||||
fs.removeSync(TEST_PATH);
|
// Current Snippet that depend on node_modules
|
||||||
|
const errSnippets = ['JSONToFile', 'readFileLines', 'UUIDGeneratorNode'];
|
||||||
|
|
||||||
snippetFiles
|
snippetFiles
|
||||||
|
.filter(fileName => !errSnippets.includes(fileName))
|
||||||
.map(fileName => {
|
.map(fileName => {
|
||||||
|
// Check if fileName for snippet exist in test/ dir, if doesnt create
|
||||||
fs.ensureDirSync(`${TEST_PATH}/${fileName}`);
|
fs.ensureDirSync(`${TEST_PATH}/${fileName}`);
|
||||||
|
|
||||||
|
// return fileName for later use
|
||||||
return fileName;
|
return fileName;
|
||||||
})
|
})
|
||||||
.map(fileName => {
|
.map(fileName => {
|
||||||
|
// Grab snippetData
|
||||||
const fileData = fs.readFileSync(`${SNIPPETS_PATH}/${fileName}.md`, 'utf8');
|
const fileData = fs.readFileSync(`${SNIPPETS_PATH}/${fileName}.md`, 'utf8');
|
||||||
|
// Grab snippet Code blocks
|
||||||
const fileCode = fileData.slice(fileData.indexOf('```js'), fileData.lastIndexOf('```') + 3);
|
const fileCode = fileData.slice(fileData.indexOf('```js'), fileData.lastIndexOf('```') + 3);
|
||||||
|
// Split code based on code markers
|
||||||
const blockMarkers = fileCode
|
const blockMarkers = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
|
||||||
.filter(x => !(x === '//CLEAR//'));
|
.filter(x => !(x === '//CLEAR//'));
|
||||||
|
// Grab snippet function based on code markers
|
||||||
const fileFunction = fileCode
|
const fileFunction = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(line => line.trim())
|
.map(line => line.trim())
|
||||||
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
|
||||||
|
// Grab snippet example based on code markers
|
||||||
const fileExample = fileCode
|
const fileExample = fileCode
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(line => line.trim())
|
.map(line => line.trim())
|
||||||
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
|
||||||
|
|
||||||
const exportFile = `module.exports = ${fileFunction.join('\n').slice(17)}`;
|
// Export template for snippetName.js which takes into account snippet name.length when generating snippetName.js file
|
||||||
|
const exportFile = `module.exports = ${fileFunction.join('\n').slice(9 + fileName.length)}`;
|
||||||
|
|
||||||
|
// Export template for snippetName.test.js which generates a example test & other information
|
||||||
const exportTest = [
|
const exportTest = [
|
||||||
`const test = require('tape');`,
|
`const test = require('tape');`,
|
||||||
`const ${fileName} = require('./${fileName}.js');`,
|
`const ${fileName} = require('./${fileName}.js');`,
|
||||||
`test('Testing ${fileName}', (t) => {`,
|
`\ntest('Testing ${fileName}', (t) => {`,
|
||||||
`//For more information on all the methods supported by tape\n//Please go to https://github.com/substack/tape`,
|
`\t//For more information on all the methods supported by tape\n\t//Please go to https://github.com/substack/tape`,
|
||||||
`//t.deepEqual(${fileName}(args..), 'Expected');`,
|
`\tt.true(typeof ${fileName} === 'function', '${fileName} is a Function');`,
|
||||||
`//t.equal(${fileName}(args..), 'Expected');`,
|
`\t//t.deepEqual(${fileName}(args..), 'Expected');`,
|
||||||
`//t.false(${fileName}(args..), 'Expected');`,
|
`\t//t.equal(${fileName}(args..), 'Expected');`,
|
||||||
`//t.true(${fileName}(args..), 'Expected');`,
|
`\t//t.false(${fileName}(args..), 'Expected');`,
|
||||||
`//t.throws(${fileName}(args..), 'Expected');`,
|
`\t//t.throws(${fileName}(args..), 'Expected');`,
|
||||||
`t.end();`,
|
`\tt.end();`,
|
||||||
`});`
|
`});`
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
|
// Write/Update exportFile which is snippetName.js in respective dir
|
||||||
fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.js`, exportFile);
|
fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.js`, exportFile);
|
||||||
fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.test.js`, exportTest);
|
|
||||||
|
|
||||||
|
if ( !fs.existsSync(`${TEST_PATH}/${fileName}/${fileName}.test.js`) ) {
|
||||||
|
// if snippetName.test.js doesn't exist inrespective dir exportTest
|
||||||
|
fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.test.js`, exportTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return fileName for later use
|
||||||
return fileName;
|
return fileName;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
42
snippets/factors.md
Normal file
42
snippets/factors.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
### factors
|
||||||
|
|
||||||
|
Returns the array of factors of the given `num`.
|
||||||
|
If the second argument is set to `true` returns only the prime factors of `num`.
|
||||||
|
If `num` is `1` or `0` returns an empty array.
|
||||||
|
If `num` is less than `0` returns all the factors of `-int` together with their additive inverses.
|
||||||
|
|
||||||
|
Use `Array.from()`, `Array.map()` and `Array.filter()` to find all the factors of `num`.
|
||||||
|
If given `num` is negative, use `Array.reduce()` to add the additive inverses to the array.
|
||||||
|
Return all results if `primes` is `false`, else determine and return only the prime factors using `isPrime` and `Array.filter()`.
|
||||||
|
Omit the second argument, `primes`, to return prime and non-prime factors by default.
|
||||||
|
|
||||||
|
**Note**:- _Negative numbers are not considered prime._
|
||||||
|
|
||||||
|
```js
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
factors(12); // [2,3,4,6,12]
|
||||||
|
factors(12, true); // [2,3]
|
||||||
|
factors(-12); // [2, -2, 3, -3, 4, -4, 6, -6, 12, -12]
|
||||||
|
factors(-12, true); // [2,3]
|
||||||
|
```
|
||||||
32
snippets/howManyTimes.md
Normal file
32
snippets/howManyTimes.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
### howManyTimes
|
||||||
|
|
||||||
|
Returns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer.
|
||||||
|
Works for both negative and positive integers.
|
||||||
|
|
||||||
|
If `divisor` is `-1` or `1` return `Infinity`.
|
||||||
|
If `divisor` is `-0` or `0` return `0`.
|
||||||
|
Otherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer.
|
||||||
|
Return the number of times the loop was executed, `i`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
howManyTimes(100, 2); //2
|
||||||
|
howManyTimes(100, -2); //2
|
||||||
|
howManyTimes(100, 2.5); //2
|
||||||
|
howManyTimes(100, 3); //0
|
||||||
|
howManyTimes(100, 0); //0
|
||||||
|
howManyTimes(100, 1); //Infinity
|
||||||
|
howManyTimes(100, -1); //Infinity
|
||||||
|
```
|
||||||
@ -1,10 +1,11 @@
|
|||||||
### maxN
|
### maxN
|
||||||
|
|
||||||
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in descending order).
|
Returns the `n` maximum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in descending order).
|
||||||
|
|
||||||
Sort's the array's shallow copy in descending order and returns the first n elements
|
Use `Array.sort()` combined with the spread operator (`...`) to create a shallow clone of the array and sort it in descending order.
|
||||||
|
Use `Array.slice()` to get the specified number of elements.
|
||||||
|
Omit the second argument, `n`, to get a one-element array.
|
||||||
|
|
||||||
Skip the second argument to get a single element(in the form of a array)
|
|
||||||
```js
|
```js
|
||||||
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
||||||
```
|
```
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
### minN
|
### minN
|
||||||
|
|
||||||
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length than return the original array(sorted in ascending order).
|
Returns the `n` minimum elements from the provided array. If `n` is greater than or equal to the provided array's length, then return the original array(sorted in ascending order).
|
||||||
|
|
||||||
Sort's the array's shallow copy in ascending order and returns the first n elements
|
Use `Array.sort()` combined with the spread operator (`...`) to create a shallow clone of the array and sort it in ascending order.
|
||||||
|
Use `Array.slice()` to get the specified number of elements.
|
||||||
|
Omit the second argument, `n`, to get a one-element array.
|
||||||
|
|
||||||
Skip the second argument to get a single element(in the form of a array)
|
|
||||||
```js
|
```js
|
||||||
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
||||||
```
|
```
|
||||||
|
|||||||
23
snippets/pluralize.md
Normal file
23
snippets/pluralize.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# pluralize
|
||||||
|
|
||||||
|
If `num` is greater than `1` returns the plural form of the given string, else return the singular form.
|
||||||
|
|
||||||
|
Check if `num` is greater than `0`. Throw an appropriate `Error` if not, return the appropriate string otherwise.
|
||||||
|
Omit the third argument, `items`, to use a default plural form same as `item` suffixed with a single `'s'`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const pluralize = (num, item, items = item + 's') =>
|
||||||
|
num <= 0
|
||||||
|
? (() => {
|
||||||
|
throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
|
||||||
|
})()
|
||||||
|
: num === 1 ? item : items;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
pluralize(1, 'apple', 'apples'); // 'apple'
|
||||||
|
pluralize(3, 'apple', 'apples'); // 'apples'
|
||||||
|
pluralize(2, 'apple'); // 'apples'
|
||||||
|
pluralize(0, 'apple', 'apples'); // Gives error
|
||||||
|
pluralize(-3, 'apple', 'apples'); // Gives error
|
||||||
|
```
|
||||||
@ -5,7 +5,7 @@
|
|||||||
[](https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE) [](https://gitter.im/30-seconds-of-code/Lobby) [](http://makeapullrequest.com) [](https://travis-ci.org/Chalarangelo/30-seconds-of-code) [](https://insight.io/github.com/Chalarangelo/30-seconds-of-code/tree/master/?source=0) [](https://github.com/Flet/semistandard) [](https://www.producthunt.com/posts/30-seconds-of-code)
|
[](https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE) [](https://gitter.im/30-seconds-of-code/Lobby) [](http://makeapullrequest.com) [](https://travis-ci.org/Chalarangelo/30-seconds-of-code) [](https://insight.io/github.com/Chalarangelo/30-seconds-of-code/tree/master/?source=0) [](https://github.com/Flet/semistandard) [](https://www.producthunt.com/posts/30-seconds-of-code)
|
||||||
|
|
||||||
|
|
||||||
> Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.
|
> Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.
|
||||||
|
|
||||||
|
|
||||||
- Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
- Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
||||||
@ -13,6 +13,57 @@
|
|||||||
- Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility.
|
- Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility.
|
||||||
- You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in [this repo](https://github.com/Rob-Rychs/30-seconds-of-code-texteditorsnippets).
|
- You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in [this repo](https://github.com/Rob-Rychs/30-seconds-of-code-texteditorsnippets).
|
||||||
- You can import these snippets into Alfred 3, using [this file](https://github.com/lslvxy/30-seconds-of-code-alfredsnippets).
|
- You can import these snippets into Alfred 3, using [this file](https://github.com/lslvxy/30-seconds-of-code-alfredsnippets).
|
||||||
- You can find a package with all the snippets on [npm](https://www.npmjs.com/package/30-seconds-of-code). Bear in mind that most of these snippets are not production-ready.
|
|
||||||
|
#### Package
|
||||||
|
|
||||||
|
⚠️ **WARNING:** Snippets are not production ready.
|
||||||
|
|
||||||
|
You can find a package with all the snippets on [npm](https://www.npmjs.com/package/30-seconds-of-code).
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install 30-seconds-of-code
|
||||||
|
```
|
||||||
|
|
||||||
|
CDN links
|
||||||
|
- [ES2017 Full (UMD)](https://unpkg.com/30-seconds-of-code)
|
||||||
|
- [ES5 Minified (UMD)](https://unpkg.com/30-seconds-of-code/dist/_30s.es5.min.js)
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
**Browser**
|
||||||
|
|
||||||
|
> IMPORTANT: replace the `src` with the full version link and desired target spec (such as ES5 minified)):
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://unpkg.com/30-seconds-of-code"></script>
|
||||||
|
<script>
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Node**
|
||||||
|
|
||||||
|
```js
|
||||||
|
// CommonJS
|
||||||
|
const _30s = require('30-seconds-of-code');
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
|
||||||
|
// ES Modules
|
||||||
|
import _30s from '30-seconds-of-code';
|
||||||
|
_30s.average(1, 2, 3);
|
||||||
|
```
|
||||||
|
|
||||||
|
To import snippets directly:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// CommonJS
|
||||||
|
const { average } = require('30-seconds-of-code');
|
||||||
|
average(1, 2, 3);
|
||||||
|
|
||||||
|
// ES Modules
|
||||||
|
import { average } from '30-seconds-of-code';
|
||||||
|
average(1, 2, 3);
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|||||||
@ -39,6 +39,7 @@ escapeRegExp:string
|
|||||||
everyNth:array
|
everyNth:array
|
||||||
extendHex:utility
|
extendHex:utility
|
||||||
factorial:math
|
factorial:math
|
||||||
|
factors:math
|
||||||
fibonacci:math
|
fibonacci:math
|
||||||
fibonacciCountUntilNum:math
|
fibonacciCountUntilNum:math
|
||||||
fibonacciUntilNum:math
|
fibonacciUntilNum:math
|
||||||
@ -49,7 +50,7 @@ flip:adapter
|
|||||||
fromCamelCase:string
|
fromCamelCase:string
|
||||||
functionName:function
|
functionName:function
|
||||||
gcd:math
|
gcd:math
|
||||||
geometricProgression:uncategorized
|
geometricProgression:math
|
||||||
getDaysDiffBetweenDates:date
|
getDaysDiffBetweenDates:date
|
||||||
getScrollPosition:browser
|
getScrollPosition:browser
|
||||||
getStyle:browser
|
getStyle:browser
|
||||||
@ -62,6 +63,7 @@ hasFlags:node
|
|||||||
head:array
|
head:array
|
||||||
hexToRGB:utility
|
hexToRGB:utility
|
||||||
hide:browser
|
hide:browser
|
||||||
|
howManyTimes:math
|
||||||
httpsRedirect:browser
|
httpsRedirect:browser
|
||||||
initial:array
|
initial:array
|
||||||
initialize2DArray:array
|
initialize2DArray:array
|
||||||
@ -96,10 +98,10 @@ lcm:math
|
|||||||
lowercaseKeys:object
|
lowercaseKeys:object
|
||||||
mapObject:array
|
mapObject:array
|
||||||
mask:string
|
mask:string
|
||||||
maxN:math
|
maxN:array
|
||||||
median:math
|
median:math
|
||||||
memoize:function
|
memoize:function
|
||||||
minN:math
|
minN:array
|
||||||
negate:logic
|
negate:logic
|
||||||
nthElement:array
|
nthElement:array
|
||||||
objectFromPairs:object
|
objectFromPairs:object
|
||||||
@ -111,6 +113,7 @@ palindrome:string
|
|||||||
percentile:math
|
percentile:math
|
||||||
pick:array
|
pick:array
|
||||||
pipeFunctions:adapter
|
pipeFunctions:adapter
|
||||||
|
pluralize:string
|
||||||
powerset:math
|
powerset:math
|
||||||
prettyBytes:utility
|
prettyBytes:utility
|
||||||
primes:math
|
primes:math
|
||||||
|
|||||||
81
yarn.lock
81
yarn.lock
@ -1093,6 +1093,10 @@ doctrine@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
|
|
||||||
|
duplexer@^0.1.1:
|
||||||
|
version "0.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
|
||||||
|
|
||||||
ecc-jsbn@~0.1.1:
|
ecc-jsbn@~0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
|
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
|
||||||
@ -1379,7 +1383,7 @@ fast-levenshtein@~2.0.4:
|
|||||||
version "2.0.6"
|
version "2.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||||
|
|
||||||
figures@^1.3.5:
|
figures@^1.3.5, figures@^1.4.0:
|
||||||
version "1.7.0"
|
version "1.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
|
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -1758,7 +1762,7 @@ is-date-object@^1.0.1:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
|
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
|
||||||
|
|
||||||
is-finite@^1.0.0:
|
is-finite@^1.0.0, is-finite@^1.0.1:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa"
|
resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -1995,6 +1999,10 @@ lodash.some@^4.6.0:
|
|||||||
version "4.6.0"
|
version "4.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
|
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
|
||||||
|
|
||||||
|
lodash@^3.6.0:
|
||||||
|
version "3.10.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
|
||||||
|
|
||||||
lodash@^4.0.0, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.4:
|
lodash@^4.0.0, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.4:
|
||||||
version "4.17.4"
|
version "4.17.4"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
||||||
@ -2272,6 +2280,10 @@ parse-json@^2.2.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
error-ex "^1.2.0"
|
error-ex "^1.2.0"
|
||||||
|
|
||||||
|
parse-ms@^1.0.0:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d"
|
||||||
|
|
||||||
path-exists@^2.0.0:
|
path-exists@^2.0.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
|
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
|
||||||
@ -2347,6 +2359,10 @@ pkg-up@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
find-up "^1.0.0"
|
find-up "^1.0.0"
|
||||||
|
|
||||||
|
plur@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/plur/-/plur-1.0.0.tgz#db85c6814f5e5e5a3b49efc28d604fec62975156"
|
||||||
|
|
||||||
pluralize@^1.2.1:
|
pluralize@^1.2.1:
|
||||||
version "1.2.1"
|
version "1.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45"
|
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45"
|
||||||
@ -2359,6 +2375,14 @@ prettier@^1.9.2:
|
|||||||
version "1.9.2"
|
version "1.9.2"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.2.tgz#96bc2132f7a32338e6078aeb29727178c6335827"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.2.tgz#96bc2132f7a32338e6078aeb29727178c6335827"
|
||||||
|
|
||||||
|
pretty-ms@^2.1.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-2.1.0.tgz#4257c256df3fb0b451d6affaab021884126981dc"
|
||||||
|
dependencies:
|
||||||
|
is-finite "^1.0.1"
|
||||||
|
parse-ms "^1.0.0"
|
||||||
|
plur "^1.0.0"
|
||||||
|
|
||||||
private@^0.1.6, private@^0.1.7:
|
private@^0.1.6, private@^0.1.7:
|
||||||
version "0.1.8"
|
version "0.1.8"
|
||||||
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
||||||
@ -2387,6 +2411,10 @@ qs@~6.5.1:
|
|||||||
version "6.5.1"
|
version "6.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
|
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
|
||||||
|
|
||||||
|
re-emitter@^1.0.0:
|
||||||
|
version "1.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/re-emitter/-/re-emitter-1.1.3.tgz#fa9e319ffdeeeb35b27296ef0f3d374dac2f52a7"
|
||||||
|
|
||||||
read-pkg-up@^1.0.1:
|
read-pkg-up@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"
|
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"
|
||||||
@ -2402,7 +2430,7 @@ read-pkg@^1.0.0:
|
|||||||
normalize-package-data "^2.3.2"
|
normalize-package-data "^2.3.2"
|
||||||
path-type "^1.0.0"
|
path-type "^1.0.0"
|
||||||
|
|
||||||
readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.2.2:
|
readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2:
|
||||||
version "2.3.3"
|
version "2.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2473,6 +2501,10 @@ relateurl@0.2.x:
|
|||||||
version "0.2.7"
|
version "0.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
|
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
|
||||||
|
|
||||||
|
repeat-string@^1.5.2:
|
||||||
|
version "1.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
|
||||||
|
|
||||||
repeating@^2.0.0:
|
repeating@^2.0.0:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda"
|
resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda"
|
||||||
@ -2733,6 +2765,12 @@ spdx-license-ids@^1.0.2:
|
|||||||
version "1.2.2"
|
version "1.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57"
|
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57"
|
||||||
|
|
||||||
|
split@^1.0.0:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9"
|
||||||
|
dependencies:
|
||||||
|
through "2"
|
||||||
|
|
||||||
sprintf-js@~1.0.2:
|
sprintf-js@~1.0.2:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
||||||
@ -2852,6 +2890,28 @@ table@^3.7.8:
|
|||||||
slice-ansi "0.0.4"
|
slice-ansi "0.0.4"
|
||||||
string-width "^2.0.0"
|
string-width "^2.0.0"
|
||||||
|
|
||||||
|
tap-out@^1.4.1:
|
||||||
|
version "1.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/tap-out/-/tap-out-1.4.2.tgz#c907ec1bf9405111d088263e92f5608b88cbb37a"
|
||||||
|
dependencies:
|
||||||
|
re-emitter "^1.0.0"
|
||||||
|
readable-stream "^2.0.0"
|
||||||
|
split "^1.0.0"
|
||||||
|
trim "0.0.1"
|
||||||
|
|
||||||
|
tap-spec@^4.1.1:
|
||||||
|
version "4.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/tap-spec/-/tap-spec-4.1.1.tgz#e2e9f26f5208232b1f562288c97624d58a88f05a"
|
||||||
|
dependencies:
|
||||||
|
chalk "^1.0.0"
|
||||||
|
duplexer "^0.1.1"
|
||||||
|
figures "^1.4.0"
|
||||||
|
lodash "^3.6.0"
|
||||||
|
pretty-ms "^2.1.0"
|
||||||
|
repeat-string "^1.5.2"
|
||||||
|
tap-out "^1.4.1"
|
||||||
|
through2 "^2.0.0"
|
||||||
|
|
||||||
tape@^4.8.0:
|
tape@^4.8.0:
|
||||||
version "4.8.0"
|
version "4.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/tape/-/tape-4.8.0.tgz#f6a9fec41cc50a1de50fa33603ab580991f6068e"
|
resolved "https://registry.yarnpkg.com/tape/-/tape-4.8.0.tgz#f6a9fec41cc50a1de50fa33603ab580991f6068e"
|
||||||
@ -2882,7 +2942,14 @@ text-table@~0.2.0:
|
|||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
|
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
|
||||||
|
|
||||||
through@^2.3.6, through@~2.3.4, through@~2.3.8:
|
through2@^2.0.0:
|
||||||
|
version "2.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
|
||||||
|
dependencies:
|
||||||
|
readable-stream "^2.1.5"
|
||||||
|
xtend "~4.0.1"
|
||||||
|
|
||||||
|
through@2, through@^2.3.6, through@~2.3.4, through@~2.3.8:
|
||||||
version "2.3.8"
|
version "2.3.8"
|
||||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||||
|
|
||||||
@ -2904,6 +2971,10 @@ trim-right@^1.0.1:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
|
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
|
||||||
|
|
||||||
|
trim@0.0.1:
|
||||||
|
version "0.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd"
|
||||||
|
|
||||||
"true-case-path@^1.0.2":
|
"true-case-path@^1.0.2":
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-1.0.2.tgz#7ec91130924766c7f573be3020c34f8fdfd00d62"
|
resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-1.0.2.tgz#7ec91130924766c7f573be3020c34f8fdfd00d62"
|
||||||
@ -3027,7 +3098,7 @@ xml-char-classes@^1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/xml-char-classes/-/xml-char-classes-1.0.0.tgz#64657848a20ffc5df583a42ad8a277b4512bbc4d"
|
resolved "https://registry.yarnpkg.com/xml-char-classes/-/xml-char-classes-1.0.0.tgz#64657848a20ffc5df583a42ad8a277b4512bbc4d"
|
||||||
|
|
||||||
xtend@^4.0.0, xtend@^4.0.1:
|
xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
|
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user