Skip to content

Commit 05891d7

Browse files
committed
Started Work on the README, got a bit done
1 parent 3d4f120 commit 05891d7

File tree

1 file changed

+65
-5
lines changed

1 file changed

+65
-5
lines changed

README.md

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,65 @@ You can install as-bind in your project by running the following:
1212

1313
## Quick Start
1414

15-
**In your Assemblyscript**
15+
**1. In your Assemblyscript**
1616

17-
1. Export everything from the asbind assemblyscript library:
17+
Export everything from the asbind assemblyscript library:
1818

1919
```
2020
// This should be in your entry point file for your Assemblyscript project
2121
22+
// '../node_modules/as-bind/*' should be the relative path to this directory in your project
23+
export * from '../node_modules/as-bind/lib/assembly/asbind.ts'
24+
```
25+
26+
After this, let's export an example function we can try:
27+
28+
```
29+
export function myExportedFunctionThatTakesAString(value: string): string {
30+
return 'AsBind: ' + value;
31+
}
32+
```
33+
34+
**2. In your Javascript**
35+
36+
In the browser using ESM Syntax:
2237

2338
```
39+
import {AsBind} from 'as-bind';
2440
25-
# Compatibility notes
41+
const wasm = fetch('./path-to-my-wasm.wasm');
42+
43+
const asyncTask = async () => {
44+
const asBindInstance = await AsBind.instantiate(wasm);
45+
46+
// You can now use your wasm / asbind instance!
47+
const response = asBindInstance.exports.myExportedFunctionThatTakesAString('Hello World!');
48+
console.log(response); // AsBind: Hello World!
49+
}
50+
asyncTask();
51+
```
52+
53+
Or we can also use Node:
54+
55+
```
56+
const AsBind = require('as-bind');
57+
const fs = require('fs');
58+
59+
const wasm = fs.readFileSync('./path-to-my-wasm.wasm');
60+
61+
const asyncTask = async () => {
62+
const asBindInstance = await AsBind.instantiate(wasm);
63+
64+
// You can now use your wasm / asbind instance!
65+
const response = asBindInstance.exports.myExportedFunctionThatTakesAString('Hello World!');
66+
console.log(response); // AsBind: Hello World!
67+
}
68+
asyncTask();
69+
```
70+
71+
## Supported Data Types
72+
73+
TODO
2674

2775
Supported types (params and returns on exported functions FROM Assemblyscript):
2876

@@ -32,10 +80,22 @@ Supported types (params on import object functions. RETURNS NOT SUPPORTED):
3280

3381
Strings, TypedArrays
3482

35-
# API Planning Notes
83+
## Supported AssemblyScript Runtime Modes
3684

37-
Maybe not asbind? Yes, as bind it matches up with what wasm bndgen says
85+
TODO
3886

3987
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.
4088

4189
Simply need to wrap the docs from: https://docs.assemblyscript.org/details/runtime and we should be good to go!
90+
91+
## Performance
92+
93+
TODO
94+
95+
## Reference API
96+
97+
TODO
98+
99+
Be sure to mention speculative execution
100+
101+
## License

0 commit comments

Comments
 (0)