hello-world-wasm-pack-lib v1.0.0
"Hello world!" wasm-pack library
š¦ Greeter demo using wasm-pack to create an npm package
import { greet, Calculator } from "hello-world-wasm-pack-lib";
greet("Alan Turing");
//=> 'Hello Alan Turing!'
const calc = new Calculator();
calc.add(10);
console.log(calc.value);
//=> 10
calc.mult(20);
console.log(calc.value);
//=> 200Installation
You can install this package using your favorite npm package manager like npm, Yarn, pnpm, or Bun.
npm install hello-world-wasm-pack-libIf you're using Deno you can import it straight from npm:
import {} from "npm:hello-world-wasm-pack-lib";If you prefer to go buildless in the browser you can use an npm CDN like jsDelivr or esm.sh.
<script type="module">
  import {} from "https://esm.run/hello-world-wasm-pack-lib";
</script>Usage
You should be able to just import and use this JavaScript package like any other. The WASM magic is hidden behind a really nice wrapper layer.
import { greet, Calculator, get_report } from "hello-world-wasm-pack-lib";
greet("Alan Turing");
//=> 'Hello Alan Turing!'
const report = get_report();
console.log(report);
//=> Report {
//   dog_count: 5,
//   bouncy_castles: 3,
//   fun_percent: 76.8
// }š You can find complete API documentation on the docs website
Development
To build the JavaScript package just run ./just build. Then you can cd into
the pkg/ folder if you want and launch a REPL to try it out!
./just build
cd pkg
nodeIf you need to edit the pkg.patch file, you can do so via the below command.
It will create two folders: a/ and b/. Edit anything in the b/ folder and
a .patch will be generated against the a/ folder and saved to pkg.patch.
./just generate-patch
# Pauses while you make changes...