Code-frame generator used internally by MockpilerJS
npm install @mockpiler/code-framejs
import { scan } from '@mockpiler/lexer'
import { generateCodeFrame } from '@mockpiler/code-frame'
const input =
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|
*/
``