Skip to content

Instantly share code, notes, and snippets.

View grushetsky's full-sized avatar

Konstantin Grushetsky grushetsky

View GitHub Profile
@grushetsky
grushetsky / Infrastructure.js
Last active March 10, 2019 23:59 — forked from sebmarkbage/Infrastructure.js
Poor man's algebraic effects in JavaScript
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}