Asset.prototype.lines

Return an AssetLineReader object that can be used to read the contents of the asset line-by-line.

It assumes the asset is UTF-8 encoded.

Syntax

lines()

Return value

An AssetLineReader object, which implements the Iterator interface and can be used in for-of loops.

Examples

Assuming the asset “myasset” contains lines “line 1” and "line 2":

let asset = Asset("myasset")
for (line of asset.lines()) {
  print(line)
}
line 1
line 2

You can also use the spread syntax to get an array of lines:

[...Asset("myasset").lines()]
[ "line 1", "line 2" ]

See also