/    Sign up×
Community /Pin to ProfileBookmark

fetch() js: parameter ??

I have been work on getting up to speed with WebAssembly. One tutorial shows the use of the ‘js:’ in a fetch call

> WebAssembly.instantiateStreaming(fetch(“memory.wasm”), {
> js: {mem: memory}})

I have not found any mention of the js: parameter in any of the programming references I have found. Could someone point me a fairly complete reference.

Thanks
W.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 06.2023 — Till now I never heard of WebAssembly but looked into the docs on MDN:

https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiateStreaming
>importObject Optional

An object containing the values to be imported into the newly-created Instance, such as functions or WebAssembly.Memory objects.


Note that the object containing `js</C> in your example is not a parameter for <C>fetch</C> but for <C>WebAssembly.instantiateStreaming`.

Presumed I understand this section in the docs correctly, the parameter importObject is **custom**, i. e. any WebAssembly application can define the structure of this parameter and it will vary among applications.

BTW: Seems to be interesting stuff.
Copy linkTweet thisAlerts:
@Programming_PadawanauthorJan 06.2023 — Thanks for the reply.

WebAssembly is fairly new. It is still in its MVP (Minimum Viable Product) stage, so I should be prepared for some major changes. I think we will seeing more of WebAssembly in the future.

I have successfully compiled a C source hashing algorithm for hashing passwords inside the browser. I does a right smart job of it.

I will investigate it being instantiateStreaming parameter. I figured if it was in the fetch block that it had to be a fetch parameter. JavaScript is still an odd creature to me, but we're becoming better acquainted with time.

Thanks

W.
Copy linkTweet thisAlerts:
@Programming_PadawanauthorJan 06.2023 — >js: {mem: memory}

is from the JavaScript's WebAssembly.instantiateStreaming class and makes reference to the

> (import "js" "mem" (memory 1))

in the compiled .wasm file to import memory from JavaScript. If you were to write WebAssembly Text (WAT) source file this is a statement that you might use in your code.
×

Success!

Help @Programming_Padawan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...