@mockpiler/code-frame
v0.2.0
Published
Code-frame generator used internally by MockpilerJS
Downloads
63
Readme
@mockpiler/code-frame
Code-frame generator used internally by MockpilerJS
Usage
import { scan } from '@mockpiler/lexer'
import { generateCodeFrame } from '@mockpiler/code-frame'
const input = `
[
(2) {
name
age
}
]
`
const tokens = scan(input)
const tokenIndex = tokens.findIndex(token => token.value === 'age')
console.log(generateCodeFrame(tokens, tokenIndex))
/**
* Output:
*
* 1|
* 2| [
* 3| (2) {
* 4| name
* > 5| age
* | ^^^
* 6| }
* 7| ]
* 8|
*/