MCPcopy Create free account
hub / github.com/CashScript/cashscript / offset

Method offset

packages/cashc/src/ast/Location.ts:41–46  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

39 constructor(public line: number, public column: number) {}
40
41 offset(code: string): number {
42 const lines = code.split('\n');
43 const newLines = this.line - 1;
44 const lineOffset = lines.slice(0, newLines).reduce((acc, curr) => acc + curr.length, 0);
45 return lineOffset + newLines + this.column;
46 }
47
48 toString(): string {
49 return `Line ${this.line}, Column ${this.column}`;

Callers 1

textMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected