Idea: could we make the "default default export" the module instance object?
So for:
// a.js
export const x = 1;
export const y = 2;
This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.
A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
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 https://alice.github.io/repo/
. GitHub will helpfully redirect all of your repository stuff hosted on github.com after the move, but will not redirect the GitHub Pages hosted on github.io.
The first post-Return of the Jedi book series anyone should read is The Thrawn Trilogy: namely Heir to the Empire, Dark Force Rising, and The Last Command, all by Timothy Zahn. They are an excellent introduction to the "New Republic era" of the Star Wars Expanded Universe (EU), and notably they were the first books written in real-world time to explore this era.
But after that, what should you read?
First, be aware that the post-Return of the Jedi EU is broken up into three main eras:
// ES6 | |
class AngularPromise extends Promise { | |
constructor(executor) { | |
super((resolve, reject) => { | |
// before | |
return executor(resolve, reject); | |
}); | |
// after | |
} |
"use strict"; | |
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances. | |
// If one of those happens, we want to retry until it doesn't. | |
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a | |
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects; | |
// it has no synchronous behavior (e.g. throwing). | |
function dontGiveUp(f) { | |
return f().then( | |
undefined, // pass through success |
// Dynamic module loading using runtime-composed strings, decisions, etc. | |
for (const m of ["cool", "awesome", "fun", "whee"]) { | |
if (Math.random() > 0.5) { | |
importModule(`/js/${m}.js`).then( | |
module => console.log("Module instance object for " + m, module), | |
e => console.error(e) | |
); | |
} | |
} |
"use strict"; | |
const { URL } = require("."); | |
const inputs = [ | |
"https://\u0000y", | |
"https://x/\u0000y", | |
"https://x/?\u0000y", | |
"https://x/?#\u0000y" | |
]; |
(function () { | |
var $dropTarget = $("#drop-target"); | |
var slice = Function.prototype.call.bind(Array.prototype.slice); | |
$dropTarget.on({ | |
drop: function (event) { | |
slice(event.originalEvent.dataTransfer.files).forEach(putFile); | |
return false; |