Travis build: 27 [custom]
This commit is contained in:
26
README.md
26
README.md
@ -107,6 +107,7 @@ average(1, 2, 3);
|
|||||||
|
|
||||||
* [`all`](#all)
|
* [`all`](#all)
|
||||||
* [`any`](#any)
|
* [`any`](#any)
|
||||||
|
* [`arrayToCSV`](#arraytocsv)
|
||||||
* [`bifurcate`](#bifurcate)
|
* [`bifurcate`](#bifurcate)
|
||||||
* [`bifurcateBy`](#bifurcateby)
|
* [`bifurcateBy`](#bifurcateby)
|
||||||
* [`chunk`](#chunk)
|
* [`chunk`](#chunk)
|
||||||
@ -849,6 +850,31 @@ any([0, 0, 1, 0]); // true
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<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
|
### 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.
|
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.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -59,6 +59,27 @@
|
|||||||
"hash": "4fa8b87ac30ec67afe40c80101a702986dd1e5cab3cd8b9653f1b7c8cbac7540"
|
"hash": "4fa8b87ac30ec67afe40c80101a702986dd1e5cab3cd8b9653f1b7c8cbac7540"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "arrayToCSV",
|
||||||
|
"type": "snippet",
|
||||||
|
"attributes": {
|
||||||
|
"fileName": "arrayToCSV.md",
|
||||||
|
"text": "Converts a 2D array to a comma-separated values (CSV) string.\n\nUse `Array.map()` and `String.join(delimiter)` to combine individual 1D arrays (rows) into strings.\nUse `String.join('\\n')` to combine all rows into a CSV string, separating each row with a newline.\nOmit the second argument, `delimiter` to use a default delimiter of `,`.",
|
||||||
|
"codeBlocks": [
|
||||||
|
"const arrayToCSV = (arr, delimiter = ',') => arr.map(v => v.join(delimiter)).join('\\n');",
|
||||||
|
"arrayToCSV([['a', 'b'], ['c', 'd']]); // 'a,b\\nc,d'\narrayToCSV([['a', 'b'], ['c', 'd']], ';'); // 'a;b\\nc;d'"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"array",
|
||||||
|
"string",
|
||||||
|
"utility"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"archived": false,
|
||||||
|
"hash": "a4b4c5a8bd490da8fa4c065beb88014541bf71e7ff6a875123f297ff06bacd12"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "arrayToHtmlList",
|
"id": "arrayToHtmlList",
|
||||||
"type": "snippet",
|
"type": "snippet",
|
||||||
|
|||||||
@ -11,6 +11,6 @@ const arrayToCSV = (arr, delimiter = ',') => arr.map(v => v.join(delimiter)).joi
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
arrayToCSV([['a','b'],['c','d']]); // 'a,b\nc,d'
|
arrayToCSV([['a', 'b'], ['c', 'd']]); // 'a,b\nc,d'
|
||||||
arrayToCSV([['a','b'],['c','d']], ';'); // 'a;b\nc;d'
|
arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // 'a;b\nc;d'
|
||||||
```
|
```
|
||||||
|
|||||||
5078
test/testlog
5078
test/testlog
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user