svelte-tree-walker
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Svelte Tree Walker

Creates a generatator that yields nodes as it traverses the AST.

Example

Simply take the output of the Svelte parser.

import { parse } from 'svelte/compiler';
import { walk } from 'svelte-tree-walker'l


const { html } = parse(/* A Svelte source file */);

for (const node of walk(tree)) {
  // Do something to the node.
}

Options

To filter by a certain type of Node, you can pass in a type as a second argument.

walk(tree, 'Text');

This will only yield elements with the type of "Text".

Developing

To install dependencies:

npm install

To test:

npm test

To build:

npm run build

Readme

Keywords

Package Sidebar

Install

npm i svelte-tree-walker

Weekly Downloads

10

Version

0.0.2

License

MIT

Unpacked Size

6.26 kB

Total Files

8

Last publish

Collaborators

  • stevekinney