Skip to content

Commit abec9f4

Browse files
committed
READE code types
1 parent 2e33565 commit abec9f4

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,50 @@ export * from '../node_modules/as-bind/lib/assembly/asbind.ts'
3535

3636
After this, let's export an example function we can try:
3737

38-
```
38+
```typescript
3939
export function myExportedFunctionThatTakesAString(value: string): string {
40-
return 'AsBind: ' + value;
40+
return "AsBind: " + value;
4141
}
4242
```
4343

4444
**2. In your Javascript**
4545

4646
In the browser using ESM Syntax:
4747

48-
```
49-
import {AsBind} from 'as-bind';
48+
```javascript
49+
import { AsBind } from "as-bind";
5050

51-
const wasm = fetch('./path-to-my-wasm.wasm');
51+
const wasm = fetch("./path-to-my-wasm.wasm");
5252

5353
const asyncTask = async () => {
5454
const asBindInstance = await AsBind.instantiate(wasm);
5555

5656
// You can now use your wasm / asbind instance!
57-
const response = asBindInstance.exports.myExportedFunctionThatTakesAString('Hello World!');
57+
const response = asBindInstance.exports.myExportedFunctionThatTakesAString(
58+
"Hello World!"
59+
);
5860
console.log(response); // AsBind: Hello World!
59-
}
61+
};
6062
asyncTask();
6163
```
6264

6365
Or we can also use Node:
6466

65-
```
66-
const AsBind = require('as-bind');
67-
const fs = require('fs');
67+
```javascript
68+
const AsBind = require("as-bind");
69+
const fs = require("fs");
6870

69-
const wasm = fs.readFileSync('./path-to-my-wasm.wasm');
71+
const wasm = fs.readFileSync("./path-to-my-wasm.wasm");
7072

7173
const asyncTask = async () => {
7274
const asBindInstance = await AsBind.instantiate(wasm);
7375

7476
// You can now use your wasm / asbind instance!
75-
const response = asBindInstance.exports.myExportedFunctionThatTakesAString('Hello World!');
77+
const response = asBindInstance.exports.myExportedFunctionThatTakesAString(
78+
"Hello World!"
79+
);
7680
console.log(response); // AsBind: Hello World!
77-
}
81+
};
7882
asyncTask();
7983
```
8084

0 commit comments

Comments
 (0)