MCPcopy Create free account
hub / github.com/Effect-TS/effect / location

Function location

packages/tools/doctest/src/Transform.ts:72–84  ·  view source on GitHub ↗
(source: string, offset: number, file: string, line: number)

Source from the content-addressed store, hash-verified

70}
71
72const location = (source: string, offset: number, file: string, line: number): string => {
73 let localLine = 1
74 let column = 1
75 for (let index = 0; index < offset; index++) {
76 if (source.charCodeAt(index) === 10) {
77 localLine++
78 column = 1
79 } else {
80 column++
81 }
82 }
83 return `${file}:${line + localLine}:${column}`
84}
85
86const fail = (source: string, offset: number, file: string, line: number, message: string): never => {
87 throw new Error(`${location(source, offset, file, line)} ${message}`)

Callers 1

failFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected