-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat(examples): AssemblyScript implementation of median algorithm #4
base: main
Are you sure you want to change the base?
Conversation
The `alloc` function has been removed as it should be provided by the host environment. Several clarifying comments have been made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include a write-up of how this interfaces with the allocator, to actually get buffers into and out of the AssemblyScript code?
Can this branch also update the Rust host do an example call, to pass the data in and out?
examples/as-median/assembly/index.ts
Outdated
} | ||
|
||
let median = calc_median(len, sample); | ||
let out = '{ median: ${median} }'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be using JSONEncoder
, like here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will make a to-do for that in the PR description
We now properly use the JSONEncoder from `assemblyscript-json`. The output buffer (and its length) is now returned as a mutable pointer.
Note that an `ArrayBuffer` must have an i32 as its length, by definition.
TODO
JSONEncoder
class for encoding JSON. Currently, this is done manually via raw strings.Build instructions
assembly
subdirectory of the Node project directory i.e.examples/as-median
. Change to this directory before proceedingnpm
, builds the AssemblyScript (AS) project.Additional information