You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Isomorphic library to handle passing high-level data structures between Assembly
11
11
- Wraps around imported JavaScript functions, and exported AssemblyScript functions of the AssemblyScript Wasm Module. This allows high-level data types to be passed to AssemblyScript functions, without having to touch Wasm memory! 🤯
12
12
- The library works at runtime, so no generated code that you have to maintain and try to get to work in your environment. 🏃
13
13
- Maintains great performance (relative to generating the corresponding JavaScript code), by using [Speculative Execution](https://en.wikipedia.org/wiki/Speculative_execution), and caching types passed between functions. 🤔
14
-
- The library is [< 5KB (minified and gzip'd)](https://bundlephobia.com/result?p=as-bind@0.0.2) and tree-shakeable! 📦🌲
14
+
- The library is [< 5KB (minified and gzip'd)](https://bundlephobia.com/result?p=as-bind) and tree-shakeable! 📦🌲
15
15
- This library is currently the [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) in the Rust/Wasm ecosystem, for AssemblyScript. 😀
16
16
17
17
## Installation
@@ -26,11 +26,11 @@ You can install as-bind in your project by running the following:
26
26
27
27
Export everything from the asbind assemblyscript library:
28
28
29
-
```
29
+
```typescript
30
30
// This should be in your entry point file for your Assemblyscript project
31
31
32
32
// '../node_modules/as-bind/*' should be the relative path to this directory in your project
33
-
export * from '../node_modules/as-bind/lib/assembly/asbind.ts'
After this, let's export an example function we can try:
@@ -84,6 +84,14 @@ asyncTask();
84
84
85
85
## Motivation
86
86
87
+
This library was inspired by several chats I had with some awesome buddies of mine in the WebAssembly Communitty:
88
+
89
+
- Till Schneidereit and I had a chat about [WasmBoy](https://github.com/torch2424/wasmboy), and about how I had a really good experience writing the emulator, even though I had to do my own memory management. But they helped me realize, building something low level isn't that bad with manual memory management, but building something like a markdown parser would be very tedious since you have to manually write the string back and forth. Which then inspired this library, and it's [markdown parser demo](https://torch2424.github.io/as-bind/).
90
+
91
+
- While I was building [WasmByExample](https://wasmbyexample.dev/?programmingLanguage=assemblyscript) I wanted to start building the "High Level Data Structures" section. I then realized how much work it would be to maintain code for passing data between WebAssembly Linear memory would be for each data type, and how much work it would be to created each individual example. Then, my buddy [Ashley Williams](https://twitter.com/ag_dubs) helped me realize, if your docs are becoming too complex, it may be a good idea to write a tool. That way you have less docs to write, and users will have an easier time using your stuff!
92
+
93
+
Thus, this library was made to help AssemblyScript/JavaScript users build awesome things! 😄🎉
94
+
87
95
## Supported Data Types
88
96
89
97
**TL;DR:** Currently Numbers, Strings, and Typed Arrays are supported. Returning a high-level data type from an imported JavaScript function, and passing AssemblyScript Classes will be coming later.
as-bind only supports AssemblyScript modules compiled with the `--runtime full` (default), and `--runtime stub` flags. These should be the only supported modes, because these runtime variants specify that you would like types / objects to be created externally as well as internally. Other runtime variants would mean that you DO NOT want anything externally created for your wasm module.
103
111
104
-
Only supports the `--runtime full`, and `--runtime stub` flag. And should, because anything else would mean that you DO NOT want to create objects externally to your wasm module. Simply need to wrap the docs from: https://docs.assemblyscript.org/details/runtime and we should be good to go!
112
+
Please see the [AssemblyScript Docs on runtime variants](https://docs.assemblyscript.org/details/runtime) for more information.
0 commit comments