magic-string-ast
TypeScript icon, indicating that this package has built-in type declarations

0.6.1 • Public • Published

magic-string-ast npm JSR

Unit Test

magic-string with Babel AST shortcut.

Install

# npm
npm i magic-string-ast

# jsr
npx jsr add -D @sxzz/magic-string-ast

Usage

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.

Sponsors

License

MIT License © 2023-PRESENT 三咲智子

/magic-string-ast/

    Package Sidebar

    Install

    npm i magic-string-ast

    Weekly Downloads

    449,285

    Version

    0.6.1

    License

    MIT

    Unpacked Size

    13.4 kB

    Total Files

    7

    Last publish

    Collaborators

    • sxzz