orgize/wasm
2023-11-13 16:33:04 +08:00
..
src chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00
.gitignore feat: initial wasm support 2021-11-08 16:17:11 +08:00
build.rs chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00
Cargo.toml chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00
index.html chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00
package.json chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00
README.md chore: prepare for v0.10.0-alpha.1 2023-11-13 16:33:04 +08:00

orgize

npm

Install

npm install orgize
yarn add orgize

Browser

import init, { Org } from "orgize";

init().then(() => {
  const org = new Org("* Hello, /world/!");
  const html = org.html();
  console.log(html);
  org.free();
});

Node.js

import { Org, initSync } from "orgize";
import { readFile } from "node:fs/promises";

// you can also use import.meta.resolve, but it's currently behind
// an experimental flag --experimental-import-meta-resolve
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

readFile(require.resolve("orgize/wasm")).then((bytes) => {
  initSync(bytes);

  const org = new Org("* Hello, /world/!");
  const html = org.html();
  console.log(html);
  org.free();
});

Notes

  1. You must initialize the WebAssembly module (using either init or initSync function) before using the Org class;

  2. Don't forgot to call org.free() to release the memory that allocated by Rust;

  3. This npm package is primarily aim to demonstrate and power the online demo, so it doesn't provide any customization or settings.

    If you need to, please build your own npm package by wasm-pack. (or napi if you're only targeting node.js users)

License

MIT