![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | dist/ | a year ago | - | |
![]() | LICENSE | a year ago | 1.1K | |
![]() | README.md | a year ago | 1.3K | 595aea1 more query options + view options [كارل مبارك] |
![]() | package.json | a year ago | 1.3K | afd0ccc remove unused [كارل مبارك] |
Extend Babel AST for magic-string.
# npm
npm i magic-string-ast
# jsr
npx jsr add -D @sxzz/magic-string-ast
import { MagicStringAST } from 'magic-string-ast'
const offset = 0
const node = {
// AST node from @babel/parser
start: 6,
end: 7,
// ...
}
const s = new MagicStringAST('const a = 1')
s.sliceNode(node, { offset }) // 'a'
s.removeNode(node)
s.moveNode(node, 0)
s.overwriteNode(node, 'foo')
For more APIs, see docs and magic-string.