-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web-vis): extract wasm vector APIs into a wrapper with listener
- Loading branch information
1 parent
b75076a
commit ae9abb9
Showing
3 changed files
with
52 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as wasm from "web-vis"; | ||
|
||
export class WasmDecorator { | ||
constructor(listener) { | ||
this.listener = listener; | ||
} | ||
|
||
pushVec() { | ||
const vecId = wasm.len(); | ||
|
||
wasm.push_vec(); | ||
this.listener(); | ||
|
||
return vecId; | ||
} | ||
|
||
setVecSize(id, size) { | ||
wasm.set_vec_size(id, size); | ||
this.listener(); | ||
} | ||
|
||
splitOffVec(id, index) { | ||
const other = wasm.split_off_vec(id, index); | ||
this.listener(); | ||
|
||
return other; | ||
} | ||
|
||
concatenatAll() { | ||
wasm.concatenat_all(); | ||
this.listener(); | ||
} | ||
|
||
getVecSize(id) { | ||
return wasm.get_vec_size(id); | ||
} | ||
|
||
get(id) { | ||
return wasm.get(id); | ||
} | ||
|
||
len() { | ||
return wasm.len(); | ||
} | ||
} |