Skip to content

Instantly share code, notes, and snippets.

Domenic Denicola domenic

View GitHub Profile
@domenic
domenic / custom-element-super-swap.js
Last active Oct 23, 2015 — forked from esprehn/custom-element-super-swap.js
Custom element super swap algorithm
View custom-element-super-swap.js
/*
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
View gist:db44ae9dd73534d63e46
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;
View params.js
/**
* Turns: {
* keyOne: promiseOne,
* keyTwo: promiseTwo
* } into {
* keyOne: resolutionOne,
* keyTwo: resolutionTwo
* }
*
* (To avoid messing around with unclear array indices when calling different
View resource-builder.js
function ResourceBuilder(){
this._dependencyPromises = [];
}
ResourceBuilder.prototype._load = function () {
// specific to the resource...
};
ResourceBuilder.prototype.addDependency = function(dep){
this._dependencyPromises.add(dep);
View gist:9077224
// 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
View 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.
View gist:6143202
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;
View classes-with-private-members.js
class Purse {
private balance;
constructor(balance = 0) {
this.@checkNum(amount);
this.@balance = balance;
}
getBalance() { return this.@balance; }
You can’t perform that action at this time.