Skip to content

Instantly share code, notes, and snippets.

View jurassix's full-sized avatar
🐢
hello world

Clint Ayres jurassix

🐢
hello world
View GitHub Profile
@jurassix
jurassix / abortable.js
Last active April 21, 2016 14:38
Abort your promises!
const abortable = (func) => (...args) => {
let aborted = false;
const abort = () => { aborted = true; };
const promise = new Promise((resolve, reject) => {
const resolveIfNotAborted = resolution => {
if (aborted) {
reject(Error('promise aborted'));
}