I hereby claim:
- I am jacoscaz on github.
- I am jacoscaz (https://keybase.io/jacoscaz) on keybase.
- I have a public key whose fingerprint is F67A 98DE 5FCE DD0E 2EEA 76C8 0BF7 EC1D 98EF 8CAD
To claim this, I am signing this object:
// Script largely inspired by: | |
// - https://gist.github.com/silassare/cc3db860edeea07298cb03f64738c997 | |
// - https://github.com/dsblv/string-replace-async/blob/7a7b1c6c5db728c298ac12df05c4eaf7e0ec8805/index.js | |
const fs = require('fs'); | |
const path = require('path'); | |
const { resolve, dirname, relative, extname } = path; | |
const { readFile, writeFile, stat, opendir } = fs.promises; |
import require$$2$1 from "https://cdn.skypack.dev/-/rdf-data-factory@v1.1.0-ZTi0caLaeyyL4GjQhZzX/dist=es2019,mode=imports/optimized/rdf-data-factory.js"; | |
function defaultSetTimout() { | |
throw new Error("setTimeout has not been defined"); | |
} | |
function defaultClearTimeout() { | |
throw new Error("clearTimeout has not been defined"); | |
} | |
var cachedSetTimeout = defaultSetTimout; | |
var cachedClearTimeout = defaultClearTimeout; | |
var globalContext; |
const STATE = { | |
RELEASED: 'released', | |
ACQUIRED: 'acquired', | |
}; | |
class SequentialLock { | |
constructor() { | |
this.state = STATE.RELEASED; | |
this.queue = []; // TODO: use a linked list for better perf as Array.prototype.shift() is very expensive in V8 |
interface LinkedNode<V> { | |
value: V; | |
next: LinkedNode<V> | null; | |
} | |
export class LinkedListCursor<V> { | |
private _curr: LinkedNode<V>; | |
constructor(list: LinkedList<V>) { |
function whilst(condition, action) { | |
return P.resolve(condition()) | |
.then(function (proceed) { | |
if (!proceed) return null; | |
return P.resolve(action()) | |
.then(function () { | |
return whilst(condition, action); | |
}); | |
}); | |
}; |
I hereby claim:
To claim this, I am signing this object: