# visitor-as

> A generic visitor framework for AssemblyScript

Latest version **0.11.4** (published 2022-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install visitor-as
pnpm add visitor-as
yarn add visitor-as
bun add visitor-as
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.4 |
| Published | 2022-12-12 |
| First published | 2020-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 453.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Willem Wyndham |
| Maintainers | jtenner, sirwillem |

## Links

- npm: https://www.npmjs.com/package/visitor-as
- Repository: https://github.com/as-pect/visitor-as
- Homepage: https://github.com/as-pect/visitor-as#readme
- Issues: https://github.com/as-pect/visitor-as/issues
- npm.io page: https://npm.io/package/visitor-as

## Dependencies (2)

- [ts-mixer](https://npm.io/package/ts-mixer.md) ^6.0.2
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0

## Recent versions

- 0.11.4 (latest) — 2022-12-12
- 0.7.1-0 (next) — 2022-01-27
- 0.11.3 — 2022-11-15
- 0.11.2 — 2022-11-14
- 0.11.1 — 2022-11-14
- 0.11.0 — 2022-11-14
- 0.10.2 — 2022-08-27
- 0.10.1 — 2022-08-27
- 0.10.0 — 2022-08-19
- 0.8.0 — 2022-01-27
- 0.7.0-2 — 2021-07-13
- 0.7.0-1 — 2021-07-09
- 0.7.0-0 — 2021-07-09
- 0.6.0 — 2021-05-24
- 0.5.1-0 — 2021-05-13
- … 11 more at https://npm.io/package/visitor-as/versions

## README

# Visitor utilities for AssemblyScript Compiler transformers

## Example

### List Fields

The transformer:

```ts
import {
  ClassDeclaration,
  FieldDeclaration,
  MethodDeclaration,
} from "../../as";
import { ClassDecorator, registerDecorator } from "../decorator";
import { getName } from "../utils";

class ListMembers extends ClassDecorator {
  visitFieldDeclaration(node: FieldDeclaration): void {
    if (!node.name) console.log(getName(node) + "\n");
    const name = getName(node);
    const _type = getName(node.type!);
    this.stdout.write(name + ": " + _type + "\n");
  }

  visitMethodDeclaration(node: MethodDeclaration): void {
    const name = getName(node);
    if (name == "constructor") {
      return;
    }
    const sig = getName(node.signature);
    this.stdout.write(name + ": " + sig + "\n");
  }

  visitClassDeclaration(node: ClassDeclaration): void {
    this.visit(node.members);
  }

  get name(): string {
    return "list";
  }
}

export = registerDecorator(new ListMembers());
```

assembly/foo.ts:
```ts
@list
class Foo {
  a: u8;
  b: bool;
  i: i32;
}
```

And then compile with `--transform` flag:

```
asc assembly/foo.ts --transform ./dist/examples/list --noEmit
```

Which prints the following to the console:

```
a: u8
b: bool
i: i32
```

---
_Source: https://npm.io/package/visitor-as · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
