Skip to content

Instantly share code, notes, and snippets.

View domenic's full-sized avatar

Domenic Denicola domenic

View GitHub Profile
@domenic
domenic / custom-element-super-swap.js
Last active October 23, 2015 19:29 — forked from esprehn/custom-element-super-swap.js
Custom element super swap algorithm
/*
This is a rough approximation of what the algorithm woud do. In an
implementation you might make the JS Wrapper point to a different
C++ Element for the duration of the constructor, then make it
point back at the original C++ element, and move data between them.
This means that the C++ side remains consistent, if you querySelector
from the document you can still find your element where the constructor
is running, but if you look at the parentNode/firstChild or attributes
properties of the element they all appear empty. This means in the
interface PermissionStatus : EventTarget {
readonly attribute PermissionState status;
attribute EventHandler onchange;
};
interface Permissions {
readonly attribute GeolocationPermission geolocation;
readonly attribute MidiPermission midi;
readonly attribute NotificationsPermission notifications;
readonly attribute PushPermission push;
@domenic
domenic / params.js
Last active August 29, 2015 14:05 — forked from herzi/params.js
/**
* Turns: {
* keyOne: promiseOne,
* keyTwo: promiseTwo
* } into {
* keyOne: resolutionOne,
* keyTwo: resolutionTwo
* }
*
* (To avoid messing around with unclear array indices when calling different
function ResourceBuilder(){
this._dependencyPromises = [];
}
ResourceBuilder.prototype._load = function () {
// specific to the resource...
};
ResourceBuilder.prototype.addDependency = function(dep){
this._dependencyPromises.add(dep);
// Stream type: tcp
* fundamental unit: buffer given to us by the OS
* list representation: array of buffers
read() -> yields a Buffer containing whatever the OS gave us for that chunk
// Stream type: text lines (e.g. after splitting a text files into lines)
* fundamental unit: line (string)
* list representation: array
read() -> yields a string
@domenic
domenic / pipeline.js
Last active December 28, 2015 10:28 — forked from jorendorff/pipeline.js
load.metadata = {};
// Call the locate hook.
return loader.locate(name, {
name: load.name,
metadata: load.metadata
}).then(address => {
if (load.linkSets.size === 0)
return;
// This load still matters. Call the fetch hook.
@domenic
domenic / gist:6143202
Last active December 20, 2015 13:59 — forked from gkatsev/gist:6143193
function foo(id) {
return bar(id).then(function (obj) {
if (!obj) {
throw new Error('no obj');
}
return obj; // pass it through
}).then(
function (obj) {
console.log('we got here, and have an obj; passing it through');
return obj;
class Purse {
private balance;
constructor(balance = 0) {
this.@checkNum(amount);
this.@balance = balance;
}
getBalance() { return this.@balance; }