Skip to content

Instantly share code, notes, and snippets.

View gskachkov's full-sized avatar

Oleksander Skachkov gskachkov

  • Itera Consulting
  • Ukraine, Kiev
View GitHub Profile
@gskachkov
gskachkov / change_first_symbol.wat
Created January 12, 2018 07:40
Change value in first symbol
(module
(import "imp" "log" (func $log (param i32 i32)))
(memory (import "imp" "mem") 1)
(func $writeHi
(i32.store8
(i32.const 0)
(i32.const 72)
)
i32.const 0
i32.const 5
var importObject = {
imports: {
imported_func: function(arg) {
console.log(arg);
}
}
};
fetch('simple.wasm').then(response =>
response.arrayBuffer()
class A {
x = 0;
constructor() {}
}
class B extends A {
y = 10;
constructor() {
let t = _ => super(); t();
}
this.model.set({ attr: "foo" });
this.model.attributes.attr = "foo";
this.model.attr = "foo";
$scope.prop = "foo";
setTimeout(function () {
$scope.prop = "foo";
const onChange = value => console.log(value);
const proxy = new Proxy({}, {
set: function (target, propertyName, newValue) {
const oldName = Reflect.get(target, propertyName);
onChange({ propertyName, oldName, newValue });
return Reflect.set(target, propertyName, newValue);
},
deleteProperty: function (target, propertyName) {
onChange({ propertyName, oldValue: Reflect.get(target, propertyName) });
const obj = { id: "foo", name: "boo" };
const proxy = new Proxy(obj, {
get: function (target, prop) {
console.log(`Access to property: ${prop}`);
return Reflect.get(target, prop);
}
});
proxy.id; // Access to property: id
const obj = {};
const proxy = new Proxy(obj, {
set: function (target, prop, value) {
if (prop === "id" && value === undefined)
throw new Error("'undefined' is not allowed.");
Reflect.set(target, prop, value);
return true;
}
});
function getter () {}
const target = { id: "foo" };
const proxy = new Proxy(target, {
get: getter
});
console.log(proxy.id);
var proxy = new Proxy({}, {
ownKeys: function () {
return [ null ];
}
});
Object.keys(proxy); // TypeError: null is not a valid property name
const { proxy, revoke } = Proxy.revocable({ id: "foo"}, {
get: function(target, property) {
console.log(`get:${property}:${target[property]}`);
return target[property];
}
});
proxy.id; // get:id:foo
revoke();
proxy.id; // TypeError: Cannot perform 'get' on a proxy that has been revoked