Skip to content

Instantly share code, notes, and snippets.

View romario333's full-sized avatar

Roman Masek romario333

  • Prague, Czech Republic
View GitHub Profile
/**
* Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
*
* This can be used with JS designed for browsers to improve reuse of code and
* allow the use of existing libraries.
*
* Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs.
*
* @author Dan DeFelippi <dan@driverdan.com>
* @contributor David Ellis <d.f.ellis@ieee.org>
let OriginalPromise = Promise;
var unfulfilledPromises = new Set();
function TrackedPromise(fn) {
function resolve(value) {
unfulfilledPromises.delete(promise);
return trackedResolve(value);
}
function reject(err) {