verb-nurbs
Version:
A library for creating and manipulating NURBS surfaces and curves in many languages
1,841 lines (1,814 loc) • 287 kB
JavaScript
import 'web-worker';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var verbHaxe = {};
(function (exports) {
// Generated by Haxe 4.3.4
(function (global, undefined$1) {
if (global.setImmediate) {
return;
}
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var setImmediate;
function addFromSetImmediateArguments(args) {
tasksByHandle[nextHandle] = partiallyApplied.apply(undefined$1, args);
return nextHandle++;
}
// This function accepts the same arguments as setImmediate, but
// returns a function that requires no arguments.
function partiallyApplied(handler) {
var args = [].slice.call(arguments, 1);
return function() {
if (typeof handler === "function") {
handler.apply(undefined$1, args);
} else {
(new Function("" + handler))();
}
};
}
function runIfPresent(handle) {
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
// So if we're currently running a task, we'll need to delay this invocation.
if (currentlyRunningATask) {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// "too much recursion" error.
setTimeout(partiallyApplied(runIfPresent, handle), 0);
} else {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
task();
} finally {
clearImmediate(handle);
currentlyRunningATask = false;
}
}
}
}
function clearImmediate(handle) {
delete tasksByHandle[handle];
}
function installNextTickImplementation() {
setImmediate = function() {
var handle = addFromSetImmediateArguments(arguments);
process.nextTick(partiallyApplied(runIfPresent, handle));
return handle;
};
}
function canUsePostMessage() {
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
if (global.postMessage && !global.importScripts) {
var postMessageIsAsynchronous = true;
var oldOnMessage = global.onmessage;
global.onmessage = function() {
postMessageIsAsynchronous = false;
};
global.postMessage("", "*");
global.onmessage = oldOnMessage;
return postMessageIsAsynchronous;
}
}
function installPostMessageImplementation() {
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
var messagePrefix = "setImmediate$" + Math.random() + "$";
var onGlobalMessage = function(event) {
if (event.source === global &&
typeof event.data === "string" &&
event.data.indexOf(messagePrefix) === 0) {
runIfPresent(+event.data.slice(messagePrefix.length));
}
};
if (global.addEventListener) {
global.addEventListener("message", onGlobalMessage, false);
} else {
global.attachEvent("onmessage", onGlobalMessage);
}
setImmediate = function() {
var handle = addFromSetImmediateArguments(arguments);
global.postMessage(messagePrefix + handle, "*");
return handle;
};
}
function installMessageChannelImplementation() {
var channel = new MessageChannel();
channel.port1.onmessage = function(event) {
var handle = event.data;
runIfPresent(handle);
};
setImmediate = function() {
var handle = addFromSetImmediateArguments(arguments);
channel.port2.postMessage(handle);
return handle;
};
}
function installReadyStateChangeImplementation() {
var html = doc.documentElement;
setImmediate = function() {
var handle = addFromSetImmediateArguments(arguments);
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
var script = doc.createElement("script");
script.onreadystatechange = function () {
runIfPresent(handle);
script.onreadystatechange = null;
html.removeChild(script);
script = null;
};
html.appendChild(script);
return handle;
};
}
function installSetTimeoutImplementation() {
setImmediate = function() {
var handle = addFromSetImmediateArguments(arguments);
setTimeout(partiallyApplied(runIfPresent, handle), 0);
return handle;
};
}
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
// Don't get fooled by e.g. browserify environments.
if ({}.toString.call(global.process) === "[object process]") {
// For Node.js before 0.9
installNextTickImplementation();
} else if (canUsePostMessage()) {
// For non-IE10 modern browsers
installPostMessageImplementation();
} else if (global.MessageChannel) {
// For web workers, where supported
installMessageChannelImplementation();
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
// For IE 6–8
installReadyStateChangeImplementation();
} else {
// For older browsers
installSetTimeoutImplementation();
}
attachTo.setImmediate = setImmediate;
attachTo.clearImmediate = clearImmediate;
}(new Function("return this")()));
(function ($hx_exports, $global) { $hx_exports["promhx"] = $hx_exports["promhx"] || {};
$hx_exports["core"] = $hx_exports["core"] || {};
$hx_exports["eval"] = $hx_exports["eval"] || {};
$hx_exports["exe"] = $hx_exports["exe"] || {};
$hx_exports["geom"] = $hx_exports["geom"] || {};
var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
function $extend(from, fields) {
var proto = Object.create(from);
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
var HxOverrides = function() { };
$hxClasses["HxOverrides"] = HxOverrides;
HxOverrides.__name__ = "HxOverrides";
HxOverrides.strDate = function(s) {
switch(s.length) {
case 8:
var k = s.split(":");
var d = new Date();
d["setTime"](0);
d["setUTCHours"](k[0]);
d["setUTCMinutes"](k[1]);
d["setUTCSeconds"](k[2]);
return d;
case 10:
var k = s.split("-");
return new Date(k[0],k[1] - 1,k[2],0,0,0);
case 19:
var k = s.split(" ");
var y = k[0].split("-");
var t = k[1].split(":");
return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]);
default:
throw haxe_Exception.thrown("Invalid date format : " + s);
}
};
HxOverrides.cca = function(s,index) {
var x = s.charCodeAt(index);
if(x != x) {
return undefined;
}
return x;
};
HxOverrides.substr = function(s,pos,len) {
if(len == null) {
len = s.length;
} else if(len < 0) {
if(pos == 0) {
len = s.length + len;
} else {
return "";
}
}
return s.substr(pos,len);
};
HxOverrides.now = function() {
return Date.now();
};
var Lambda = function() { };
$hxClasses["Lambda"] = Lambda;
Lambda.__name__ = "Lambda";
Lambda.fold = function(it,f,first) {
var x = $getIterator(it);
while(x.hasNext()) {
var x1 = x.next();
first = f(x1,first);
}
return first;
};
Math.__name__ = "Math";
var Reflect = function() { };
$hxClasses["Reflect"] = Reflect;
Reflect.__name__ = "Reflect";
Reflect.field = function(o,field) {
try {
return o[field];
} catch( _g ) {
return null;
}
};
Reflect.fields = function(o) {
var a = [];
if(o != null) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
for( var f in o ) {
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
a.push(f);
}
}
}
return a;
};
Reflect.isFunction = function(f) {
if(typeof(f) == "function") {
return !(f.__name__ || f.__ename__);
} else {
return false;
}
};
Reflect.deleteField = function(o,field) {
if(!Object.prototype.hasOwnProperty.call(o,field)) {
return false;
}
delete(o[field]);
return true;
};
var Std = function() { };
$hxClasses["Std"] = Std;
Std.__name__ = "Std";
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
var StringBuf = function() {
this.b = "";
};
$hxClasses["StringBuf"] = StringBuf;
StringBuf.__name__ = "StringBuf";
StringBuf.prototype = {
__class__: StringBuf
};
var ValueType = $hxEnums["ValueType"] = { __ename__:"ValueType",__constructs__:null
,TNull: {_hx_name:"TNull",_hx_index:0,__enum__:"ValueType",toString:$estr}
,TInt: {_hx_name:"TInt",_hx_index:1,__enum__:"ValueType",toString:$estr}
,TFloat: {_hx_name:"TFloat",_hx_index:2,__enum__:"ValueType",toString:$estr}
,TBool: {_hx_name:"TBool",_hx_index:3,__enum__:"ValueType",toString:$estr}
,TObject: {_hx_name:"TObject",_hx_index:4,__enum__:"ValueType",toString:$estr}
,TFunction: {_hx_name:"TFunction",_hx_index:5,__enum__:"ValueType",toString:$estr}
,TClass: ($_=function(c) { return {_hx_index:6,c:c,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TClass",$_.__params__ = ["c"],$_)
,TEnum: ($_=function(e) { return {_hx_index:7,e:e,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TEnum",$_.__params__ = ["e"],$_)
,TUnknown: {_hx_name:"TUnknown",_hx_index:8,__enum__:"ValueType",toString:$estr}
};
ValueType.__constructs__ = [ValueType.TNull,ValueType.TInt,ValueType.TFloat,ValueType.TBool,ValueType.TObject,ValueType.TFunction,ValueType.TClass,ValueType.TEnum,ValueType.TUnknown];
var Type = function() { };
$hxClasses["Type"] = Type;
Type.__name__ = "Type";
Type.createEnum = function(e,constr,params) {
var f = Reflect.field(e,constr);
if(f == null) {
throw haxe_Exception.thrown("No such constructor " + constr);
}
if(Reflect.isFunction(f)) {
if(params == null) {
throw haxe_Exception.thrown("Constructor " + constr + " need parameters");
}
return f.apply(e,params);
}
if(params != null && params.length != 0) {
throw haxe_Exception.thrown("Constructor " + constr + " does not need parameters");
}
return f;
};
Type.typeof = function(v) {
switch(typeof(v)) {
case "boolean":
return ValueType.TBool;
case "function":
if(v.__name__ || v.__ename__) {
return ValueType.TObject;
}
return ValueType.TFunction;
case "number":
if(Math.ceil(v) == v % 2147483648.0) {
return ValueType.TInt;
}
return ValueType.TFloat;
case "object":
if(v == null) {
return ValueType.TNull;
}
var e = v.__enum__;
if(e != null) {
return ValueType.TEnum($hxEnums[e]);
}
var c = js_Boot.getClass(v);
if(c != null) {
return ValueType.TClass(c);
}
return ValueType.TObject;
case "string":
return ValueType.TClass(String);
case "undefined":
return ValueType.TNull;
default:
return ValueType.TUnknown;
}
};
Type.enumParameters = function(e) {
var enm = $hxEnums[e.__enum__];
var params = enm.__constructs__[e._hx_index].__params__;
if(params != null) {
var _g = [];
var _g1 = 0;
while(_g1 < params.length) {
var p = params[_g1];
++_g1;
_g.push(e[p]);
}
return _g;
} else {
return [];
}
};
var haxe_IMap = function() { };
$hxClasses["haxe.IMap"] = haxe_IMap;
haxe_IMap.__name__ = "haxe.IMap";
haxe_IMap.__isInterface__ = true;
var haxe_Exception = function(message,previous,native) {
Error.call(this,message);
this.message = message;
this.__previousException = previous;
this.__nativeException = native != null ? native : this;
};
$hxClasses["haxe.Exception"] = haxe_Exception;
haxe_Exception.__name__ = "haxe.Exception";
haxe_Exception.caught = function(value) {
if(((value) instanceof haxe_Exception)) {
return value;
} else if(((value) instanceof Error)) {
return new haxe_Exception(value.message,null,value);
} else {
return new haxe_ValueException(value,null,value);
}
};
haxe_Exception.thrown = function(value) {
if(((value) instanceof haxe_Exception)) {
return value.get_native();
} else if(((value) instanceof Error)) {
return value;
} else {
var e = new haxe_ValueException(value);
return e;
}
};
haxe_Exception.__super__ = Error;
haxe_Exception.prototype = $extend(Error.prototype,{
unwrap: function() {
return this.__nativeException;
}
,get_native: function() {
return this.__nativeException;
}
,__class__: haxe_Exception
});
var haxe_Serializer = function() {
this.buf = new StringBuf();
this.cache = [];
this.useCache = haxe_Serializer.USE_CACHE;
this.useEnumIndex = haxe_Serializer.USE_ENUM_INDEX;
this.shash = new haxe_ds_StringMap();
this.scount = 0;
};
$hxClasses["haxe.Serializer"] = haxe_Serializer;
haxe_Serializer.__name__ = "haxe.Serializer";
haxe_Serializer.prototype = {
toString: function() {
return this.buf.b;
}
,serializeString: function(s) {
var x = this.shash.h[s];
if(x != null) {
this.buf.b += "R";
this.buf.b += x == null ? "null" : "" + x;
return;
}
this.shash.h[s] = this.scount++;
this.buf.b += "y";
s = encodeURIComponent(s);
this.buf.b += Std.string(s.length);
this.buf.b += ":";
this.buf.b += s == null ? "null" : "" + s;
}
,serializeRef: function(v) {
var vt = typeof(v);
var _g = 0;
var _g1 = this.cache.length;
while(_g < _g1) {
var i = _g++;
var ci = this.cache[i];
if(typeof(ci) == vt && ci == v) {
this.buf.b += "r";
this.buf.b += i == null ? "null" : "" + i;
return true;
}
}
this.cache.push(v);
return false;
}
,serializeFields: function(v) {
var _g = 0;
var _g1 = Reflect.fields(v);
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
this.serializeString(f);
this.serialize(Reflect.field(v,f));
}
this.buf.b += "g";
}
,serialize: function(v) {
var _g = Type.typeof(v);
switch(_g._hx_index) {
case 0:
this.buf.b += "n";
break;
case 1:
var v1 = v;
if(v1 == 0) {
this.buf.b += "z";
return;
}
this.buf.b += "i";
this.buf.b += v1 == null ? "null" : "" + v1;
break;
case 2:
var v1 = v;
if(isNaN(v1)) {
this.buf.b += "k";
} else if(!isFinite(v1)) {
this.buf.b += v1 < 0 ? "m" : "p";
} else {
this.buf.b += "d";
this.buf.b += v1 == null ? "null" : "" + v1;
}
break;
case 3:
this.buf.b += v ? "t" : "f";
break;
case 4:
if(js_Boot.__instanceof(v,Class)) {
var className = v.__name__;
this.buf.b += "A";
this.serializeString(className);
} else if(js_Boot.__instanceof(v,Enum)) {
this.buf.b += "B";
this.serializeString(v.__ename__);
} else {
if(this.useCache && this.serializeRef(v)) {
return;
}
this.buf.b += "o";
this.serializeFields(v);
}
break;
case 5:
throw haxe_Exception.thrown("Cannot serialize function");
case 6:
var c = _g.c;
if(c == String) {
this.serializeString(v);
return;
}
if(this.useCache && this.serializeRef(v)) {
return;
}
switch(c) {
case Array:
var ucount = 0;
this.buf.b += "a";
var l = v["length"];
var _g1 = 0;
var _g2 = l;
while(_g1 < _g2) {
var i = _g1++;
if(v[i] == null) {
++ucount;
} else {
if(ucount > 0) {
if(ucount == 1) {
this.buf.b += "n";
} else {
this.buf.b += "u";
this.buf.b += ucount == null ? "null" : "" + ucount;
}
ucount = 0;
}
this.serialize(v[i]);
}
}
if(ucount > 0) {
if(ucount == 1) {
this.buf.b += "n";
} else {
this.buf.b += "u";
this.buf.b += ucount == null ? "null" : "" + ucount;
}
}
this.buf.b += "h";
break;
case Date:
var d = v;
this.buf.b += "v";
this.buf.b += Std.string(d.getTime());
break;
case haxe_ds_IntMap:
this.buf.b += "q";
var v1 = v;
var k = v1.keys();
while(k.hasNext()) {
var k1 = k.next();
this.buf.b += ":";
this.buf.b += k1 == null ? "null" : "" + k1;
this.serialize(v1.h[k1]);
}
this.buf.b += "h";
break;
case haxe_ds_List:
this.buf.b += "l";
var v1 = v;
var _g_head = v1.h;
while(_g_head != null) {
var val = _g_head.item;
_g_head = _g_head.next;
var i = val;
this.serialize(i);
}
this.buf.b += "h";
break;
case haxe_ds_ObjectMap:
this.buf.b += "M";
var v1 = v;
var k = v1.keys();
while(k.hasNext()) {
var k1 = k.next();
var id = Reflect.field(k1,"__id__");
Reflect.deleteField(k1,"__id__");
this.serialize(k1);
k1["__id__"] = id;
this.serialize(v1.h[k1.__id__]);
}
this.buf.b += "h";
break;
case haxe_ds_StringMap:
this.buf.b += "b";
var v1 = v;
var h = v1.h;
var _g_keys = Object.keys(h);
var _g_length = _g_keys.length;
var _g_current = 0;
while(_g_current < _g_length) {
var k = _g_keys[_g_current++];
this.serializeString(k);
this.serialize(v1.h[k]);
}
this.buf.b += "h";
break;
case haxe_io_Bytes:
var v1 = v;
this.buf.b += "s";
this.buf.b += Std.string(Math.ceil(v1.length * 8 / 6));
this.buf.b += ":";
var i = 0;
var max = v1.length - 2;
var b64 = haxe_Serializer.BASE64_CODES;
if(b64 == null) {
b64 = new Array(haxe_Serializer.BASE64.length);
var _g1 = 0;
var _g2 = haxe_Serializer.BASE64.length;
while(_g1 < _g2) {
var i1 = _g1++;
b64[i1] = HxOverrides.cca(haxe_Serializer.BASE64,i1);
}
haxe_Serializer.BASE64_CODES = b64;
}
while(i < max) {
var b1 = v1.b[i++];
var b2 = v1.b[i++];
var b3 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[(b1 << 4 | b2 >> 4) & 63]);
this.buf.b += String.fromCodePoint(b64[(b2 << 2 | b3 >> 6) & 63]);
this.buf.b += String.fromCodePoint(b64[b3 & 63]);
}
if(i == max) {
var b1 = v1.b[i++];
var b2 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[(b1 << 4 | b2 >> 4) & 63]);
this.buf.b += String.fromCodePoint(b64[b2 << 2 & 63]);
} else if(i == max + 1) {
var b1 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[b1 << 4 & 63]);
}
break;
default:
if(this.useCache) {
this.cache.pop();
}
if(v.hxSerialize != null) {
this.buf.b += "C";
this.serializeString(c.__name__);
if(this.useCache) {
this.cache.push(v);
}
v.hxSerialize(this);
this.buf.b += "g";
} else {
this.buf.b += "c";
this.serializeString(c.__name__);
if(this.useCache) {
this.cache.push(v);
}
this.serializeFields(v);
}
}
break;
case 7:
var e = _g.e;
if(this.useCache) {
if(this.serializeRef(v)) {
return;
}
this.cache.pop();
}
this.buf.b += Std.string(this.useEnumIndex ? "j" : "w");
this.serializeString(e.__ename__);
if(this.useEnumIndex) {
this.buf.b += ":";
this.buf.b += Std.string(v._hx_index);
} else {
var e = v;
this.serializeString($hxEnums[e.__enum__].__constructs__[e._hx_index]._hx_name);
}
this.buf.b += ":";
var params = Type.enumParameters(v);
this.buf.b += Std.string(params.length);
var _g = 0;
while(_g < params.length) {
var p = params[_g];
++_g;
this.serialize(p);
}
if(this.useCache) {
this.cache.push(v);
}
break;
default:
throw haxe_Exception.thrown("Cannot serialize " + Std.string(v));
}
}
,__class__: haxe_Serializer
};
var haxe__$Unserializer_DefaultResolver = function() {
};
$hxClasses["haxe._Unserializer.DefaultResolver"] = haxe__$Unserializer_DefaultResolver;
haxe__$Unserializer_DefaultResolver.__name__ = "haxe._Unserializer.DefaultResolver";
haxe__$Unserializer_DefaultResolver.prototype = {
resolveClass: function(name) {
return $hxClasses[name];
}
,resolveEnum: function(name) {
return $hxEnums[name];
}
,__class__: haxe__$Unserializer_DefaultResolver
};
var haxe_Unserializer = function(buf) {
this.buf = buf;
this.length = this.buf.length;
this.pos = 0;
this.scache = [];
this.cache = [];
var r = haxe_Unserializer.DEFAULT_RESOLVER;
if(r == null) {
r = new haxe__$Unserializer_DefaultResolver();
haxe_Unserializer.DEFAULT_RESOLVER = r;
}
this.resolver = r;
};
$hxClasses["haxe.Unserializer"] = haxe_Unserializer;
haxe_Unserializer.__name__ = "haxe.Unserializer";
haxe_Unserializer.initCodes = function() {
var codes = [];
var _g = 0;
var _g1 = haxe_Unserializer.BASE64.length;
while(_g < _g1) {
var i = _g++;
codes[haxe_Unserializer.BASE64.charCodeAt(i)] = i;
}
return codes;
};
haxe_Unserializer.prototype = {
readDigits: function() {
var k = 0;
var s = false;
var fpos = this.pos;
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c != c) {
break;
}
if(c == 45) {
if(this.pos != fpos) {
break;
}
s = true;
this.pos++;
continue;
}
if(c < 48 || c > 57) {
break;
}
k = k * 10 + (c - 48);
this.pos++;
}
if(s) {
k *= -1;
}
return k;
}
,readFloat: function() {
var p1 = this.pos;
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c != c) {
break;
}
if(c >= 43 && c < 58 || c == 101 || c == 69) {
this.pos++;
} else {
break;
}
}
return parseFloat(HxOverrides.substr(this.buf,p1,this.pos - p1));
}
,unserializeObject: function(o) {
while(true) {
if(this.pos >= this.length) {
throw haxe_Exception.thrown("Invalid object");
}
if(this.buf.charCodeAt(this.pos) == 103) {
break;
}
var k = this.unserialize();
if(typeof(k) != "string") {
throw haxe_Exception.thrown("Invalid object key");
}
var v = this.unserialize();
o[k] = v;
}
this.pos++;
}
,unserializeEnum: function(edecl,tag) {
if(this.buf.charCodeAt(this.pos++) != 58) {
throw haxe_Exception.thrown("Invalid enum format");
}
var nargs = this.readDigits();
if(nargs == 0) {
return Type.createEnum(edecl,tag);
}
var args = [];
while(nargs-- > 0) args.push(this.unserialize());
return Type.createEnum(edecl,tag,args);
}
,unserialize: function() {
switch(this.buf.charCodeAt(this.pos++)) {
case 65:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
return cl;
case 66:
var name = this.unserialize();
var e = this.resolver.resolveEnum(name);
if(e == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
return e;
case 67:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
var o = Object.create(cl.prototype);
this.cache.push(o);
o.hxUnserialize(this);
if(this.buf.charCodeAt(this.pos++) != 103) {
throw haxe_Exception.thrown("Invalid custom data");
}
return o;
case 77:
var h = new haxe_ds_ObjectMap();
this.cache.push(h);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) {
var s = this.unserialize();
h.set(s,this.unserialize());
}
this.pos++;
return h;
case 82:
var n = this.readDigits();
if(n < 0 || n >= this.scache.length) {
throw haxe_Exception.thrown("Invalid string reference");
}
return this.scache[n];
case 97:
var buf = this.buf;
var a = [];
this.cache.push(a);
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c == 104) {
this.pos++;
break;
}
if(c == 117) {
this.pos++;
var n = this.readDigits();
a[a.length + n - 1] = null;
} else {
a.push(this.unserialize());
}
}
return a;
case 98:
var h = new haxe_ds_StringMap();
this.cache.push(h);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) {
var s = this.unserialize();
var value = this.unserialize();
h.h[s] = value;
}
this.pos++;
return h;
case 99:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
var o = Object.create(cl.prototype);
this.cache.push(o);
this.unserializeObject(o);
return o;
case 100:
return this.readFloat();
case 102:
return false;
case 105:
return this.readDigits();
case 106:
var name = this.unserialize();
var edecl = this.resolver.resolveEnum(name);
if(edecl == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
this.pos++;
var index = this.readDigits();
var _this = edecl.__constructs__;
var result = new Array(_this.length);
var _g = 0;
var _g1 = _this.length;
while(_g < _g1) {
var i = _g++;
result[i] = _this[i]._hx_name;
}
var tag = result[index];
if(tag == null) {
throw haxe_Exception.thrown("Unknown enum index " + name + "@" + index);
}
var e = this.unserializeEnum(edecl,tag);
this.cache.push(e);
return e;
case 107:
return NaN;
case 108:
var l = new haxe_ds_List();
this.cache.push(l);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) l.add(this.unserialize());
this.pos++;
return l;
case 109:
return -Infinity;
case 110:
return null;
case 111:
var o = { };
this.cache.push(o);
this.unserializeObject(o);
return o;
case 112:
return Infinity;
case 113:
var h = new haxe_ds_IntMap();
this.cache.push(h);
var buf = this.buf;
var c = this.buf.charCodeAt(this.pos++);
while(c == 58) {
var i = this.readDigits();
var value = this.unserialize();
h.h[i] = value;
c = this.buf.charCodeAt(this.pos++);
}
if(c != 104) {
throw haxe_Exception.thrown("Invalid IntMap format");
}
return h;
case 114:
var n = this.readDigits();
if(n < 0 || n >= this.cache.length) {
throw haxe_Exception.thrown("Invalid reference");
}
return this.cache[n];
case 115:
var len = this.readDigits();
var buf = this.buf;
if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len) {
throw haxe_Exception.thrown("Invalid bytes length");
}
var codes = haxe_Unserializer.CODES;
if(codes == null) {
codes = haxe_Unserializer.initCodes();
haxe_Unserializer.CODES = codes;
}
var i = this.pos;
var rest = len & 3;
var size = (len >> 2) * 3 + (rest >= 2 ? rest - 1 : 0);
var max = i + (len - rest);
var bytes = new haxe_io_Bytes(new ArrayBuffer(size));
var bpos = 0;
while(i < max) {
var c1 = codes[buf.charCodeAt(i++)];
var c2 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c1 << 2 | c2 >> 4;
var c3 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c2 << 4 | c3 >> 2;
var c4 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c3 << 6 | c4;
}
if(rest >= 2) {
var c1 = codes[buf.charCodeAt(i++)];
var c2 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c1 << 2 | c2 >> 4;
if(rest == 3) {
var c3 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c2 << 4 | c3 >> 2;
}
}
this.pos += len;
this.cache.push(bytes);
return bytes;
case 116:
return true;
case 118:
var d;
if(this.buf.charCodeAt(this.pos) >= 48 && this.buf.charCodeAt(this.pos) <= 57 && this.buf.charCodeAt(this.pos + 1) >= 48 && this.buf.charCodeAt(this.pos + 1) <= 57 && this.buf.charCodeAt(this.pos + 2) >= 48 && this.buf.charCodeAt(this.pos + 2) <= 57 && this.buf.charCodeAt(this.pos + 3) >= 48 && this.buf.charCodeAt(this.pos + 3) <= 57 && this.buf.charCodeAt(this.pos + 4) == 45) {
d = HxOverrides.strDate(HxOverrides.substr(this.buf,this.pos,19));
this.pos += 19;
} else {
d = new Date(this.readFloat());
}
this.cache.push(d);
return d;
case 119:
var name = this.unserialize();
var edecl = this.resolver.resolveEnum(name);
if(edecl == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
var e = this.unserializeEnum(edecl,this.unserialize());
this.cache.push(e);
return e;
case 120:
throw haxe_Exception.thrown(this.unserialize());
case 121:
var len = this.readDigits();
if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len) {
throw haxe_Exception.thrown("Invalid string length");
}
var s = HxOverrides.substr(this.buf,this.pos,len);
this.pos += len;
s = decodeURIComponent(s.split("+").join(" "));
this.scache.push(s);
return s;
case 122:
return 0;
}
this.pos--;
throw haxe_Exception.thrown("Invalid char " + this.buf.charAt(this.pos) + " at position " + this.pos);
}
,__class__: haxe_Unserializer
};
var haxe_ValueException = function(value,previous,native) {
haxe_Exception.call(this,String(value),previous,native);
this.value = value;
};
$hxClasses["haxe.ValueException"] = haxe_ValueException;
haxe_ValueException.__name__ = "haxe.ValueException";
haxe_ValueException.__super__ = haxe_Exception;
haxe_ValueException.prototype = $extend(haxe_Exception.prototype,{
unwrap: function() {
return this.value;
}
,__class__: haxe_ValueException
});
var haxe_ds_IntMap = function() {
this.h = { };
};
$hxClasses["haxe.ds.IntMap"] = haxe_ds_IntMap;
haxe_ds_IntMap.__name__ = "haxe.ds.IntMap";
haxe_ds_IntMap.__interfaces__ = [haxe_IMap];
haxe_ds_IntMap.prototype = {
remove: function(key) {
if(!this.h.hasOwnProperty(key)) {
return false;
}
delete(this.h[key]);
return true;
}
,keys: function() {
var a = [];
for( var key in this.h ) if(this.h.hasOwnProperty(key)) a.push(+key);
return new haxe_iterators_ArrayIterator(a);
}
,__class__: haxe_ds_IntMap
};
var haxe_ds_List = function() {
this.length = 0;
};
$hxClasses["haxe.ds.List"] = haxe_ds_List;
haxe_ds_List.__name__ = "haxe.ds.List";
haxe_ds_List.prototype = {
add: function(item) {
var x = new haxe_ds__$List_ListNode(item,null);
if(this.h == null) {
this.h = x;
} else {
this.q.next = x;
}
this.q = x;
this.length++;
}
,pop: function() {
if(this.h == null) {
return null;
}
var x = this.h.item;
this.h = this.h.next;
if(this.h == null) {
this.q = null;
}
this.length--;
return x;
}
,isEmpty: function() {
return this.h == null;
}
,__class__: haxe_ds_List
};
var haxe_ds__$List_ListNode = function(item,next) {
this.item = item;
this.next = next;
};
$hxClasses["haxe.ds._List.ListNode"] = haxe_ds__$List_ListNode;
haxe_ds__$List_ListNode.__name__ = "haxe.ds._List.ListNode";
haxe_ds__$List_ListNode.prototype = {
__class__: haxe_ds__$List_ListNode
};
var haxe_ds_ObjectMap = function() {
this.h = { __keys__ : { }};
};
$hxClasses["haxe.ds.ObjectMap"] = haxe_ds_ObjectMap;
haxe_ds_ObjectMap.__name__ = "haxe.ds.ObjectMap";
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap];
haxe_ds_ObjectMap.prototype = {
set: function(key,value) {
var id = key.__id__;
if(id == null) {
id = (key.__id__ = $global.$haxeUID++);
}
this.h[id] = value;
this.h.__keys__[id] = key;
}
,keys: function() {
var a = [];
for( var key in this.h.__keys__ ) {
if(this.h.hasOwnProperty(key)) {
a.push(this.h.__keys__[key]);
}
}
return new haxe_iterators_ArrayIterator(a);
}
,__class__: haxe_ds_ObjectMap
};
var haxe_ds_Option = $hxEnums["haxe.ds.Option"] = { __ename__:"haxe.ds.Option",__constructs__:null
,Some: ($_=function(v) { return {_hx_index:0,v:v,__enum__:"haxe.ds.Option",toString:$estr}; },$_._hx_name="Some",$_.__params__ = ["v"],$_)
,None: {_hx_name:"None",_hx_index:1,__enum__:"haxe.ds.Option",toString:$estr}
};
haxe_ds_Option.__constructs__ = [haxe_ds_Option.Some,haxe_ds_Option.None];
var haxe_ds_StringMap = function() {
this.h = Object.create(null);
};
$hxClasses["haxe.ds.StringMap"] = haxe_ds_StringMap;
haxe_ds_StringMap.__name__ = "haxe.ds.StringMap";
haxe_ds_StringMap.__interfaces__ = [haxe_IMap];
haxe_ds_StringMap.prototype = {
__class__: haxe_ds_StringMap
};
var haxe_io_Bytes = function(data) {
this.length = data.byteLength;
this.b = new Uint8Array(data);
this.b.bufferValue = data;
data.hxBytes = this;
data.bytes = this.b;
};
$hxClasses["haxe.io.Bytes"] = haxe_io_Bytes;
haxe_io_Bytes.__name__ = "haxe.io.Bytes";
haxe_io_Bytes.prototype = {
__class__: haxe_io_Bytes
};
var haxe_iterators_ArrayIterator = function(array) {
this.current = 0;
this.array = array;
};
$hxClasses["haxe.iterators.ArrayIterator"] = haxe_iterators_ArrayIterator;
haxe_iterators_ArrayIterator.__name__ = "haxe.iterators.ArrayIterator";
haxe_iterators_ArrayIterator.prototype = {
hasNext: function() {
return this.current < this.array.length;
}
,next: function() {
return this.array[this.current++];
}
,__class__: haxe_iterators_ArrayIterator
};
var js_Boot = function() { };
$hxClasses["js.Boot"] = js_Boot;
js_Boot.__name__ = "js.Boot";
js_Boot.getClass = function(o) {
if(o == null) {
return null;
} else if(((o) instanceof Array)) {
return Array;
} else {
var cl = o.__class__;
if(cl != null) {
return cl;
}
var name = js_Boot.__nativeClassName(o);
if(name != null) {
return js_Boot.__resolveNativeClass(name);
}
return null;
}
};
js_Boot.__string_rec = function(o,s) {
if(o == null) {
return "null";
}
if(s.length >= 5) {
return "<...>";
}
var t = typeof(o);
if(t == "function" && (o.__name__ || o.__ename__)) {
t = "object";
}
switch(t) {
case "function":
return "<function>";
case "object":
if(o.__enum__) {
var e = $hxEnums[o.__enum__];
var con = e.__constructs__[o._hx_index];
var n = con._hx_name;
if(con.__params__) {
s = s + "\t";
return n + "(" + ((function($this) {
var $r;
var _g = [];
{
var _g1 = 0;
var _g2 = con.__params__;
while(true) {
if(!(_g1 < _g2.length)) {
break;
}
var p = _g2[_g1];
_g1 = _g1 + 1;
_g.push(js_Boot.__string_rec(o[p],s));
}
}
$r = _g;
return $r;
}())).join(",") + ")";
} else {
return n;
}
}
if(((o) instanceof Array)) {
var str = "[";
s += "\t";
var _g = 0;
var _g1 = o.length;
while(_g < _g1) {
var i = _g++;
str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
}
str += "]";
return str;
}
var tostr;
try {
tostr = o.toString;
} catch( _g ) {
return "???";
}
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
var s2 = o.toString();
if(s2 != "[object Object]") {
return s2;
}
}
var str = "{\n";
s += "\t";
var hasp = o.hasOwnProperty != null;
var k = null;
for( k in o ) {
if(hasp && !o.hasOwnProperty(k)) {
continue;
}
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
continue;
}
if(str.length != 2) {
str += ", \n";
}
str += s + k + " : " + js_Boot.__string_rec(o[k],s);
}
s = s.substring(1);
str += "\n" + s + "}";
return str;
case "string":
return o;
default:
return String(o);
}
};
js_Boot.__interfLoop = function(cc,cl) {
if(cc == null) {
return false;
}
if(cc == cl) {
return true;
}
var intf = cc.__interfaces__;
if(intf != null) {
var _g = 0;
var _g1 = intf.length;
while(_g < _g1) {
var i = _g++;
var i1 = intf[i];
if(i1 == cl || js_Boot.__interfLoop(i1,cl)) {
return true;
}
}
}
return js_Boot.__interfLoop(cc.__super__,cl);
};
js_Boot.__instanceof = function(o,cl) {
if(cl == null) {
return false;
}
switch(cl) {
case Array:
return ((o) instanceof Array);
case Bool:
return typeof(o) == "boolean";
case Dynamic:
return o != null;
case Float:
return typeof(o) == "number";
case Int:
if(typeof(o) == "number") {
return ((o | 0) === o);
} else {
return false;
}
case String:
return typeof(o) == "string";
default:
if(o != null) {
if(typeof(cl) == "function") {
if(js_Boot.__downcastCheck(o,cl)) {
return true;
}
} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
if(((o) instanceof cl)) {
return true;
}
}
} else {
return false;
}
if(cl == Class ? o.__name__ != null : false) {
return true;
}
if(cl == Enum ? o.__ename__ != null : false) {
return true;
}
return o.__enum__ != null ? $hxEnums[o.__enum__] == cl : false;
}
};
js_Boot.__downcastCheck = function(o,cl) {
if(!((o) instanceof cl)) {
if(cl.__isInterface__) {
return js_Boot.__interfLoop(js_Boot.getClass(o),cl);
} else {
return false;
}
} else {
return true;
}
};
js_Boot.__nativeClassName = function(o) {
var name = js_Boot.__toStr.call(o).slice(8,-1);
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
return null;
}
return name;
};
js_Boot.__isNativeObj = function(o) {
return js_Boot.__nativeClassName(o) != null;
};
js_Boot.__resolveNativeClass = function(name) {
return $global[name];
};
var promhx_base_AsyncBase = function(d) {
this._resolved = false;
this._pending = false;
this._errorPending = false;
this._fulfilled = false;
this._update = [];
this._error = [];
this._errored = false;
if(d != null) {
var next = this;
var f = function(x) {
return x;
};
d._update.push({ async : next, linkf : function(x) {
next.handleResolve(f(x));
}});
promhx_base_AsyncBase.immediateLinkUpdate(d,next,f);
}
};
$hxClasses["promhx.base.AsyncBase"] = promhx_base_AsyncBase;
promhx_base_AsyncBase.__name__ = "promhx.base.AsyncBase";
promhx_base_AsyncBase.link = function(current,next,f) {
current._update.push({ async : next, linkf : function(x) {
next.handleResolve(f(x));
}});
promhx_base_AsyncBase.immediateLinkUpdate(current,next,f);
};
promhx_base_AsyncBase.immediateLinkUpdate = function(current,next,f) {
if(current._errored && !current._errorPending && current._error.length <= 0) {
next.handleError(current._errorVal);
}
if(current._resolved && !current._pending) {
try {
next.handleResolve(f(current._val));
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
next.handleError(e);
}
}
};
promhx_base_AsyncBase.linkAll = function(all,next) {
var cthen = function(arr,current,v) {
if(arr.length == 0 || promhx_base_AsyncBase.allFulfilled(arr)) {
var _g = [];
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
_g.push(a1 == current ? v : a1._val);
}
var vals = _g;
next.handleResolve(vals);
}
};
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
var a2 = a1._update;
var next1 = next;
var _g = [cthen];
var _g1 = [];
var a21 = $getIterator(all);
while(a21.hasNext()) {
var a22 = a21.next();
if(a22 != a1) {
_g1.push(a22);
}
}
a2.push({ async : next1, linkf : (function(_g,current,arr) {
return function(v) {
_g[0](arr[0],current[0],v);
};
})(_g,[a1],[_g1])});
}
if(promhx_base_AsyncBase.allFulfilled(all)) {
var next1 = next;
var _g1 = [];
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
_g1.push(a1._val);
}
next1.handleResolve(_g1);
}
};
promhx_base_AsyncBase.pipeLink = function(current,ret,f) {
var linked = false;
var linkf = function(x) {
if(!linked) {
linked = true;
var pipe_ret = f(x);
pipe_ret._update.push({ async : ret, linkf : $bind(ret,ret.handleResolve)});
promhx_base_AsyncBase.immediateLinkUpdate(pipe_ret,ret,function(x) {
return x;
});
}
};
current._update.push({ async : ret, linkf : linkf});
if(current._resolved && !current._pending) {
try {
linkf(current._val);
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
ret.handleError(e);
}
}
};
promhx_base_AsyncBase.allResolved = function(as) {
var a = $getIterator(as);
while(a.hasNext()) {
var a1 = a.next();
if(!a1._resolved) {
return false;
}
}
return true;
};
promhx_base_AsyncBase.allFulfilled = function(as) {
var a = $getIterator(as);
while(a.hasNext()) {
var a1 = a.next();
if(!a1._fulfilled) {
return false;
}
}
return true;
};
promhx_base_AsyncBase.prototype = {
catchError: function(f) {
this._error.push(f);
return this;
}
,errorThen: function(f) {
this._errorMap = f;
return this;
}
,isResolved: function() {
return this._resolved;
}
,isErrored: function() {
return this._errored;
}
,isErrorHandled: function() {
return this._error.length > 0;
}
,isErrorPending: function() {
return this._errorPending;
}
,isFulfilled: function() {
return this._fulfilled;
}
,isPending: function() {
return this._pending;
}
,handleResolve: function(val) {
this._resolve(val);
}
,_resolve: function(val) {
var _gthis = this;
if(this._pending) {
var _g = this;
var val1 = val;
var tmp = function() {
_g._resolve(val1);
};
promhx_base_EventLoop.queue.add(tmp);
promhx_base_EventLoop.continueOnNextLoop();
} else {
this._resolved = true;
this._pending = true;
promhx_base_EventLoop.queue.add(function() {
_gthis._val = val;
var _g = 0;
var _g1 = _gthis._update;
while(_g < _g1.length) {
var up = _g1[_g];
++_g;
try {
up.linkf(val);
} catch( _g2 ) {
var e = haxe_Exception.caught(_g2).unwrap();
up.async.handleError(e);
}
}
_gthis._fulfilled = true;
_gthis._pending = false;
});
promhx_base_EventLoop.continueOnNextLoop();
}
}
,handleError: function(error) {
this._handleError(error);
}
,_handleError: function(error) {
var _gthis = this;
var update_errors = function(e) {
if(_gthis._error.length > 0) {
var _g = 0;
var _g1 = _gthis._error;
while(_g < _g1.length) {
var ef = _g1[_g];
++_g;
ef(e);
}
} else if(_gthis._update.length > 0) {
var _g = 0;
var _g1 = _gthis._update;
while(_g < _g1.length) {
var up = _g1[_g];
++_g;
up.async.handleError(e);
}
} else {
throw haxe_Exception.thrown(e);
}
_gthis._errorPending = false;
};
if(!this._errorPending) {
this._errorPending = true;
this._errored = true;
this._errorVal = error;
promhx_base_EventLoop.queue.add(function() {
if(_gthis._errorMap != null) {
try {
_gthis._resolve(_gthis._errorMap(error));
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
update_errors(e);
}
} else {
update_errors(error);
}
});
promhx_base_EventLoop.continueOnNextLoop();
}
}
,then: function(f) {
var ret = new promhx_base_AsyncBase(null);
var next = ret;
var f1 = f;
this._update.push({ async : next, linkf : function(x) {
next.handleResolve(f1(x));
}});
promhx_base_AsyncBase.immediateLinkUpdate(this,next,f1);
return ret;
}
,unlink: function(to) {
var _gthis = this;
promhx_base_EventLoop.queue.add(function() {
var _g = [];
var _g1 = 0;
var _g2 = _gthis._update;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.async != to) {
_g.push(v);
}
}
_gthis._update = _g;
});
promhx_base_EventLoop.continueOnNextLoop();
}
,isLinked: function(to) {
var updated = false;
var _g = 0;
var _g1 = this._update;
while(_g < _g1.length) {
var u = _g1[_g];
++_g;
if(u.async == to) {
return true;
}
}
return updated;
}
,__class__: promhx_base_AsyncBase
};
var promhx_Deferred = $hx_exports["promhx"]["Deferred"] = function() {
promhx_base_AsyncBase.call(this);
};
$hxClasses["promhx.Deferred"] = promhx_Deferred;
promhx_Deferred.__name__ = "promhx.Deferred";
promhx_Deferred.__super__ = promhx_base_AsyncBase;
promhx_Deferred.prototype = $extend(promhx_base_AsyncBase.prototype,{
resolve: function(val) {
this.handleResolve(val);
}
,throwError: function(e) {
this.handleError(e);
}
,promise: function() {
return new promhx_Promise(this);
}
,stream: function() {
return new promhx_Stream(this);
}
,publicStream: function() {
return new promhx_PublicStream(this);
}
,__class__: promhx_Deferred
});
var promhx_Promise = $hx_exports["promhx"]["Promise"] = function(d) {
promhx_base_AsyncBase.call(this,d);
this._rejected = false;
};
$hxClasses["promhx.Promise"] = promhx_Promise;
promhx_Promise.__name__ = "promhx.Promise";
promhx_Promise.whenAll = function(itb) {
var ret = new promhx_Promise(null);
var all = itb;
var next = ret;
var cthen = function(arr,current,v) {
if(arr.length == 0 || promhx_base_AsyncBase.allFulfilled(arr)) {
var _g = [];
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
_g.push(a1 == current ? v : a1._val);
}
var vals = _g;
next.handleResolve(vals);
}
};
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
var a2 = a1._update;
var next1 = next;
var _g = [cthen];
var _g1 = [];
var a21 = $getIterator(all);
while(a21.hasNext()) {
var a22 = a21.next();
if(a22 != a1) {
_g1.push(a22);
}
}
a2.push({ async : next1, linkf : (function(current,arr,_g) {
return function(v) {
_g[0](arr[0],current[0],v);
};
})([a1],[_g1],_g)});
}
if(promhx_base_AsyncBase.allFulfilled(all)) {
var next1 = next;
var _g1 = [];
var a = $getIterator(all);
while(a.hasNext()) {
var a1 = a.next();
_g1.push(a1._val);
}
next1.handleResolve(_g1);
}
return ret;
};
promhx_Promise.promise = function(_val) {
var ret = new promhx_Promise();
ret.handleResolve(_val);
return ret;
};
promhx_Promise.__super__ = promhx_base_AsyncBase;
promhx_Promise.prototype = $extend(promhx_base_AsyncBase.prototype,{
isRejected: function() {
return this._rejected;
}
,reject: function(e) {
this._rejected = true;
this.handleError(e);
}
,handleResolve: function(val) {
if(this._resolved) {
var msg = "Promise has already been resolved";
throw haxe_Exception.thrown(promhx_error_PromiseError.AlreadyResolved(msg));
}
this._resolve(val);
}
,then: function(f) {
var ret = new promhx_Promise(null);
var next = ret;
var f1 = f;
this._update.push({ async : next, linkf : function(x) {
next.handleResolve(f1(x));
}});
promhx_base_AsyncBase.immediateLinkUpdate(this,next,f1);
return ret;
}
,unlink: function(to) {
var _gthis = this;
promhx_base_EventLoop.queue.add(function() {
if(!_gthis._fulfilled) {
var msg = "Downstream Promise is not fullfilled";
_gthis.handleError(promhx_error_PromiseError.DownstreamNotFullfilled(msg));
} else {
var _g = [];
var _g1 = 0;
var _g2 = _gthis._update;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.async != to) {
_g.push(v);
}
}
_gthis._update = _g;
}
});
promhx_base_EventLoop.continueOnNextLoop();
}
,handleError: function(error) {
this._rejected = true;
this._handleError(error);
}
,pipe: function(f) {
var ret = new promhx_Promise(null);
var ret1 = ret;
var f1 = f;
var linked = false;
var linkf = function(x) {
if(!linked) {
linked = true;
var pipe_ret = f1(x);
pipe_ret._update.push({ async : ret1, linkf : $bind(ret1,ret1.handleResolve)});
promhx_base_AsyncBase.immediateLinkUpdate(pipe_ret,ret