cadence-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Cadence Parser

The Cadence parser compiled to WebAssembly and bundled as an NPM package, so it can be used in tools written in JavaScript.

Usage

Broswer

import { CadenceParser } from "@onflow/cadence-parser"

const parser = await CadenceParser.create("cadence-parser.wasm")

const ast = parser.parse(`
  pub contract HelloWorld {
    pub fun hello() {
      log("Hello, world!")
    }
  }
`)

Node.js

const { CadenceParser } = require("@onflow/cadence-parser");
const fs = require("fs");
const path = require("path");

(async () => {
  const parser = await CadenceParser.create(
    await fs.promises.readFile(
      path.join(
        __dirname,
        "./node_modules/@onflow/cadence-parser/dist/cadence-parser.wasm"
      )
    )
  );

  const ast = parser.parse(`
  pub contract HelloWorld {
    pub fun hello() {
      log("Hello, world!")
    }
  }
`);
})();

Readme

Keywords

none

Package Sidebar

Install

npm i cadence-parser

Weekly Downloads

0

Version

1.0.1

License

Apache-2.0

Unpacked Size

4.72 MB

Total Files

13

Last publish

Collaborators

  • purepeace