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 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 |
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
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; |
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
/** | |
* Turns: { | |
* keyOne: promiseOne, | |
* keyTwo: promiseTwo | |
* } into { | |
* keyOne: resolutionOne, | |
* keyTwo: resolutionTwo | |
* } | |
* | |
* (To avoid messing around with unclear array indices when calling different |
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
function ResourceBuilder(){ | |
this._dependencyPromises = []; | |
} | |
ResourceBuilder.prototype._load = function () { | |
// specific to the resource... | |
}; | |
ResourceBuilder.prototype.addDependency = function(dep){ | |
this._dependencyPromises.add(dep); |
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
// 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 |
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
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. |
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
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; |
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
class Purse { | |
private balance; | |
constructor(balance = 0) { | |
this.@checkNum(amount); | |
this.@balance = balance; | |
} | |
getBalance() { return this.@balance; } |