Skip to content

Instantly share code, notes, and snippets.

jfparadis / Compartment.js
Last active Jan 24, 2020
XS Compartment shim
View Compartment.js
trace(`Compartment imported\n`);
const XSCompartment = globalThis.Compartment;
trace(' ' + Object.keys('\n');
// Mappin utility function.
// Create the child XS map from the parent XS map.
function createXSMap(modules) {
// Need to at least allow new compartments to be created.
const result = { Compartment: };
rossberg / Wasm Reference Types
Last active Feb 19, 2018
Basic reference types for Wasm
View Wasm Reference Types
# Reference Types for WebAssembly
## Introduction
Use cases:
* Easier and more efficient interop with host
* Manipulation of tables inside Wasm
* Tyoed function pointers
* Setting the stage for other proposals like exception handling
isiahmeadows /
Last active May 1, 2017
A powerful non-linear control flow proposal unifying both Promise and Observable operations for highly expressive control flow and parallelism, inspired by non-Von Neumann models

Edit: The proposal now lives here, and this below is generally out of date.

Non-linear Control Flow

Asynchrony is hard. Modeling it is not super intuitive in most languages, JavaScript being no exception for the longest time. But we have been making progress:

  1. Callbacks give us the base concept, thanks to lambda calculus.
isiahmeadows / async-angular.js
Last active May 2, 2018
Proposed parallel async primitives, compared to callbacks + jQuery and RxJS + promises, using samples adapted from previous examples I found and used (I forget my sources...)
View async-angular.js
// Non-blocking async iterators + Angular 1
function searchWikipedia(term) {
return $http({
url: "",
method: "jsonp",
params: {
action: "opensearch",
search: encodeURI(term),
format: "json"
domenic /
Created Feb 10, 2017
Redirecting GitHub pages after a repository move

Redirecting GitHub Pages after a repository move

The problem

You have a repository, call it alice/repo. You would like to transfer it to the user bob, so it will become bob/repo.

However, you make heavy use of the GitHub Pages feature, so that people are often accessing GitHub will helpfully redirect all of your repository stuff hosted on after the move, but will not redirect the GitHub Pages hosted on

The solution

erights / microses-to-microses-for-persistence
Last active Jan 13, 2017
View microses-to-microses-for-persistence
const makeAddr = (x => (y => x + y));
const wm = makeWeakMap();
const makeAddr = (x => {
const fn = (y => x + y);
wm.set(fn, {get x() { return x; });
return fn;

Updated (Aug 2nd, 2016)

API Refinements:

  • The default global scope when creating a new realm has no extra capabilities, it is confusing, we can remove it.
  • The realm object is the real power object, and users can decide to share it or not via endowments.
  • In a realm, you can create as many global scopes as you want via realmObj.createNewGlobalScope().
  • No more proxy-like API at the realm level, if you want to proxy a global, that should be used when creating a new global scope.

The API proposal:

domenic / pipelining.txt
Last active Dec 26, 2015
Potential promise pipelining with subclassing
View pipelining.txt
var p0 = Promise.cast(null);
var p1 = p0.then(() => remotePromise);
var p2 = p1.invoke("foo");
line 2 calls remotePromise's .then method, like so:
remotePromise.then(v => { set p1's [[Value]] to v }, r => { set p1's [[Reason]] to r })
it ALSO stores remotePromise in [[Following]]
Once remotePromise settles, i.e. once one of the two above callbacks gets called,
[[Following]] gets cleared.
View gist:6399102
// This module uses AP2 as its starting point:
var hasOwn =;
function mixin(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
return a;