-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve JS formatting and HTML content (#41)
A few things were annoying me about my recently-added JS builtin examples, which I've fixed in this PR: - The HTML content was left as my default template content "My template", which looked a bit unfinished/unprofessional. I've replaced those with a short description of what each example is doing. - The spacing in the JS was 4 spaces, and we tend to use 2 in MDN code. - I've updated the comments in the JavaScript files to be consistent with those used in the MDN page JavaScript snippets.
- Loading branch information
1 parent
01fcd00
commit 63af019
Showing
19 changed files
with
60 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
const importObject = { // Regular import | ||
m: { | ||
log: console.log | ||
} | ||
m: { | ||
log: console.log, | ||
} | ||
}; | ||
|
||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
WebAssembly.compileStreaming(fetch("log-concat.wasm"), compileOptions) | ||
.then(module => WebAssembly.instantiate(module, importObject)) | ||
.then(instance => instance.exports.main()); | ||
|
||
|
||
.then((module) => WebAssembly.instantiate(module, importObject)) | ||
.then((instance) => instance.exports.main()); |
Binary file not shown.
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 |
---|---|---|
@@ -1,18 +1,16 @@ | ||
const importObject = { // Regular import | ||
m: { | ||
log: console.log | ||
} | ||
m: { | ||
log: console.log, | ||
} | ||
}; | ||
|
||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
fetch("log-concat.wasm") | ||
.then(response => response.arrayBuffer()) | ||
.then(bytes => WebAssembly.compile(bytes, compileOptions)) | ||
.then(module => WebAssembly.instantiate(module, importObject)) | ||
.then(instance => instance.exports.main()); | ||
|
||
|
||
.then((response) => response.arrayBuffer()) | ||
.then((bytes) => WebAssembly.compile(bytes, compileOptions)) | ||
.then((module) => WebAssembly.instantiate(module, importObject)) | ||
.then((instance) => instance.exports.main()); |
Binary file not shown.
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
const importObject = { // Regular import | ||
m: { | ||
log: console.log | ||
} | ||
m: { | ||
log: console.log, | ||
} | ||
}; | ||
|
||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
WebAssembly.instantiateStreaming(fetch("log-concat.wasm"), importObject, compileOptions) | ||
.then(result => result.instance.exports.main()); | ||
|
||
|
||
.then((result) => result.instance.exports.main()); |
Binary file not shown.
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 |
---|---|---|
@@ -1,17 +1,15 @@ | ||
const importObject = { // Regular import | ||
m: { | ||
log: console.log | ||
} | ||
m: { | ||
log: console.log, | ||
} | ||
}; | ||
|
||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
fetch("log-concat.wasm") | ||
.then(response => response.arrayBuffer()) | ||
.then(bytes => WebAssembly.instantiate(bytes, importObject, compileOptions)) | ||
.then(result => result.instance.exports.main()); | ||
|
||
|
||
.then((response) => response.arrayBuffer()) | ||
.then((bytes) => WebAssembly.instantiate(bytes, importObject, compileOptions)) | ||
.then((result) => result.instance.exports.main()); |
Binary file not shown.
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
const importObject = { // Regular import | ||
m: { | ||
log: console.log | ||
} | ||
m: { | ||
log: console.log, | ||
} | ||
}; | ||
|
||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
fetch("log-concat.wasm") | ||
.then(response => response.arrayBuffer()) | ||
.then(bytes => { | ||
const module = new WebAssembly.Module(bytes, compileOptions); | ||
WebAssembly.instantiate(module, importObject) | ||
.then(instance => instance.exports.main()); | ||
}) | ||
.then((response) => response.arrayBuffer()) | ||
.then((bytes) => { | ||
const module = new WebAssembly.Module(bytes, compileOptions); | ||
WebAssembly.instantiate(module, importObject) | ||
.then((instance) => instance.exports.main()); | ||
}) |
Binary file not shown.
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
const compileOptions = { | ||
builtins: ["js-string"], // Opt-in to get magic imported functions | ||
importedStringConstants: "#" // Opt-in to get magic imported globals | ||
builtins: ["js-string"], // Enable JavaScript string builtins | ||
importedStringConstants: "string_constants", // Enable imported global string constants | ||
} | ||
|
||
fetch("log-concat.wasm") | ||
.then(response => response.arrayBuffer()) | ||
.then(bytes => WebAssembly.validate(bytes, compileOptions)) | ||
.then(result => console.log(`wasm module valid: ${result}`)); | ||
|
||
|
||
.then((response) => response.arrayBuffer()) | ||
.then((bytes) => WebAssembly.validate(bytes, compileOptions)) | ||
.then((result) => console.log(`wasm module valid: ${result}`)); |
Binary file not shown.