@svizzle/utils/string-array

Methods

(static) makeLines(string) → {array}

Source:
Since:
  • 0.1.0

Return rows in a string

Example
> makeRows('A,B\n1,2\n3,4\n')
['A,B', '1,2', '3,4']
Parameters:
Name Type Description
string string
Returns:
Type
array

(static) makeRows(string) → {array}

Source:
Since:
  • 0.1.0

Return rows in a string excluding the first line (the header). Useful for CSVs.

Example
> makeRows('A,B\n1,2\n3,4\n')
['1,2', '3,4']
Parameters:
Name Type Description
string string
Returns:
Type
array

(static) ndjsonToArray(ndjsonString) → {array}

Source:
Since:
  • 0.1.0

Return an array from a ndjson string

Example
> ndjsonToArray('{'a':1}\n{'b':2}\n\n')
[{a: 1}, {b: 2}]
Parameters:
Name Type Description
ndjsonString string
Returns:
Type
array

(static) splitByDot(string) → {array}

Source:
Since:
  • 0.1.0
See:

Return an array by splitting by '.'

Example
> splitByDot('a.b.c')
['a', 'b', 'c']
Parameters:
Name Type Description
string string
Returns:
Type
array

(static) splitByEOL(string) → {array}

Source:
Since:
  • 0.1.0
See:

Return an array by splitting by '\n'

Example
> splitByDot('a\nb\nc')
['a', 'b', 'c']
Parameters:
Name Type Description
string string
Returns:
Type
array

(static) splitBySemiColon(string) → {array}

Source:
Since:
  • 0.1.0
See:

Return an array by splitting by ';'

Example
> splitBySemiColon('A;B;C')
['A', 'B', 'C']
Parameters:
Name Type Description
string string
Returns:
Type
array