{ } qjs-modules

location

Source: quickjs-location.c — module export: Location

Represents a position in a source text: line, column, character/byte offset and file name. Used by the lexer and other parsers.

Constructor

new Location([line, column, charOffset, file])   // length 1

Properties (read/write, enumerable)

PropertyDescription
line1-based line number.
column1-based column number.
charOffsetOffset in characters from the start.
byteOffsetOffset in bytes from the start.
fileSource file name.

Methods

MethodArgsDescription
equal(other)1Compares this location with another for equality.
clone()0Returns a copy of the location.
toString()0Renders as file:line:column.
[Symbol.toPrimitive]()0Primitive coercion (string form).

Static functions

FunctionArgsDescription
count(input)1Counts lines/columns by scanning a string, producing a Location.