Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ jobs:
npm test
cd lib/loader
npm version "$VERSION" --no-git-tag-version
npm run build
npm test
cd ../rtrace
npm version "$VERSION" --no-git-tag-version
npm run build
npm test
cd ../..
fi
Expand Down
13 changes: 9 additions & 4 deletions lib/loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A tiny module loader that makes working with AssemblyScript modules as convenien
## Example

```ts
import loader from "@assemblyscript/loader"; // or require
import loader from "@assemblyscript/loader";
loader.instantiate(
// Binary to instantiate
fetch("optimized.wasm"), // or fs.readFileSync
Expand All @@ -33,12 +33,17 @@ npm install --save @assemblyscript/loader
On the web:

```html
<!-- ESM -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/index.js"></script>
<!-- UMD -->
<script src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/umd/index.js"></script>
```

The package is ESM-only. From CommonJS, load it with a dynamic import:

```js
const loader = (await import("@assemblyscript/loader")).default;
```

Node.js 20.19+ and 22.12+ also accept a plain `require` of an ES module.

## Usage

One task the loader does not perform is to implicitly translate between WebAssembly pointers and JavaScript objects, and that's where the mixed in utility comes into play. For example, if one has
Expand Down
9 changes: 9 additions & 0 deletions lib/loader/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,12 @@ export declare function demangle<T extends Record<string,unknown>>(
exports: Record<string,unknown>,
extendedExports?: Record<string,unknown>
): T;

declare const _default: {
instantiate: typeof instantiate,
instantiateSync: typeof instantiateSync,
instantiateStreaming: typeof instantiateStreaming,
demangle: typeof demangle
};

export default _default;
Loading
Loading