Travis build: 27 [custom]

This commit is contained in:
30secondsofcode
2018-06-27 17:46:34 +00:00
parent 11c393f296
commit 6c8888fcc6
16 changed files with 1628 additions and 3559 deletions

View File

@ -107,6 +107,7 @@ average(1, 2, 3);
* [`all`](#all)
* [`any`](#any)
* [`arrayToCSV`](#arraytocsv)
* [`bifurcate`](#bifurcate)
* [`bifurcateBy`](#bifurcateby)
* [`chunk`](#chunk)
@ -849,6 +850,31 @@ any([0, 0, 1, 0]); // true
<br>[⬆ Back to top](#table-of-contents)
### arrayToCSV
Converts a 2D array to a comma-separated values (CSV) string.
Use `Array.map()` and `String.join(delimiter)` to combine individual 1D arrays (rows) into strings.
Use `String.join('\n')` to combine all rows into a CSV string, separating each row with a newline.
Omit the second argument, `delimiter` to use a default delimiter of `,`.
```js
const arrayToCSV = (arr, delimiter = ',') => arr.map(v => v.join(delimiter)).join('\n');
```
<details>
<summary>Examples</summary>
```js
arrayToCSV([['a', 'b'], ['c', 'd']]); // 'a,b\nc,d'
arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // 'a;b\nc;d'
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### bifurcate
Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.