svelte-tree-walker Svelte Themes

Svelte Tree Walker

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

Top categories

Loading Svelte Themes