Skip to content

Instantly share code, notes, and snippets.

View vbkmr's full-sized avatar

vb vbkmr

View GitHub Profile
@vbkmr
vbkmr / fido-notes.md
Last active August 1, 2022 09:07
FIDO
fetch('factorial.wasm')
//getting WASM Module from response
.then(response => response.arrayBuffer())
//instantiating WASM instance from WASM Module
.then(bytes => WebAssembly.instantiate(bytes))
//using exported factorial fn from WASM Instance
.then(results => {
console.log(results.instance.exports.factorial(12))
})
int factorial(int n)
{
if(n > 1)
return n * factorial(n - 1);
else
return 1;
}
int squareMe (int n) {
return n * n;
}
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "squareMe" (func $squareMe))
(func $squareMe (; 0 ;) (param $0 i32) (result i32)
(i32.mul
(get_local $0)
(get_local $0)
)
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "factorial" (func $factorial))
(func $factorial (; 0 ;) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(set_local $2
(i32.const 1)
import { r as registerInstance, h } from './core-957b5e39.js';
const FancyAFButton = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.clickedCount = 0;
}
handleClick() {
this.clickedCount += 1;
}
import { Component, Prop, h, Listen, State } from "@stencil/core";
@Component({
tag: "fancy-af-button",
styleUrl: "fancy-af-button.css",
shadow: true
})
export class FancyAFButton {
@State() clickedCount: number = 0;
customElements.define( // registering our custom-element to CustomElementRegistry
"fancy-af-button",
class extends HTMLElement { // defining our custom-element
constructor() {
// always call super() first in the constructor.
super();
// reading custom-element's template
const template = document.getElementById("fancy-af-button-template");
const templateContent = template.content;