@hpcc-js/util
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -6,2 +6,14 @@ # Change Log | ||
## [2.2.1](https://github.com/hpcc-systems/Visualization/compare/@hpcc-js/util@2.2.0...@hpcc-js/util@2.2.1) (2019-01-29) | ||
### Bug Fixes | ||
* **marshaller:** Race condition ([2673d29](https://github.com/hpcc-systems/Visualization/commit/2673d29)), closes [#3106](https://github.com/hpcc-systems/Visualization/issues/3106) | ||
# [2.2.0](https://github.com/hpcc-systems/Visualization/compare/@hpcc-js/util@2.1.5...@hpcc-js/util@2.2.0) (2019-01-08) | ||
@@ -8,0 +20,0 @@ |
@@ -289,2 +289,31 @@ // Based on: https://tc39.github.io/ecma262/#sec-array.prototype.find | ||
} | ||
var AsyncOrderedQueue = /** @class */ (function () { | ||
function AsyncOrderedQueue() { | ||
this._q = []; | ||
} | ||
AsyncOrderedQueue.prototype.isTop = function (p) { | ||
return this._q[0] === p; | ||
}; | ||
AsyncOrderedQueue.prototype.push = function (p) { | ||
var _this = this; | ||
var retVal = p.then(function (response) { | ||
if (_this.isTop(retVal)) { | ||
_this._q.shift(); | ||
return response; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var intervalHandler = setInterval(function () { | ||
if (_this.isTop(retVal)) { | ||
clearInterval(intervalHandler); | ||
_this._q.shift(); | ||
resolve(response); | ||
} | ||
}, 20); | ||
}); | ||
}); | ||
this._q.push(retVal); | ||
return retVal; | ||
}; | ||
return AsyncOrderedQueue; | ||
}()); | ||
@@ -1578,3 +1607,3 @@ var Dictionary = /** @class */ (function () { | ||
export { find, compare, Cache, AsyncCache, debounce, promiseTimeout, Dictionary, DictionaryNoCase, espTime2Seconds, GraphItem, Subgraph, Vertex, Edge, Graph, hashSum, deepEquals, update, Level, Logging, logger, ScopedLogging, scopedLogger, degreesToRadians, radiansToDegrees, normalizeRadians, normalizeDegrees, normalize, inner, exists, deepMixin, deepMixinT, safeStringify, isArray$1 as isArray, classID2Meta, Observable, root, isBrowser, isNode, isTravis, XMLNode, SAXStackParser, xml2json, Stack, StateObject, trim, endsWith, join }; | ||
export { find, compare, Cache, AsyncCache, debounce, promiseTimeout, AsyncOrderedQueue, Dictionary, DictionaryNoCase, espTime2Seconds, GraphItem, Subgraph, Vertex, Edge, Graph, hashSum, deepEquals, update, Level, Logging, logger, ScopedLogging, scopedLogger, degreesToRadians, radiansToDegrees, normalizeRadians, normalizeDegrees, normalize, inner, exists, deepMixin, deepMixinT, safeStringify, isArray$1 as isArray, classID2Meta, Observable, root, isBrowser, isNode, isTravis, XMLNode, SAXStackParser, xml2json, Stack, StateObject, trim, endsWith, join }; | ||
//# sourceMappingURL=index.es6.js.map |
@@ -295,2 +295,31 @@ (function (global, factory) { | ||
} | ||
var AsyncOrderedQueue = /** @class */ (function () { | ||
function AsyncOrderedQueue() { | ||
this._q = []; | ||
} | ||
AsyncOrderedQueue.prototype.isTop = function (p) { | ||
return this._q[0] === p; | ||
}; | ||
AsyncOrderedQueue.prototype.push = function (p) { | ||
var _this = this; | ||
var retVal = p.then(function (response) { | ||
if (_this.isTop(retVal)) { | ||
_this._q.shift(); | ||
return response; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var intervalHandler = setInterval(function () { | ||
if (_this.isTop(retVal)) { | ||
clearInterval(intervalHandler); | ||
_this._q.shift(); | ||
resolve(response); | ||
} | ||
}, 20); | ||
}); | ||
}); | ||
this._q.push(retVal); | ||
return retVal; | ||
}; | ||
return AsyncOrderedQueue; | ||
}()); | ||
@@ -1589,2 +1618,3 @@ var Dictionary = /** @class */ (function () { | ||
exports.promiseTimeout = promiseTimeout; | ||
exports.AsyncOrderedQueue = AsyncOrderedQueue; | ||
exports.Dictionary = Dictionary; | ||
@@ -1591,0 +1621,0 @@ exports.DictionaryNoCase = DictionaryNoCase; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["@hpcc-js/util"]={})}(this,function(o){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(r,n){var o,i,s,t,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&e[0]?i.return:e[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,e[1])).done)return s;switch(i=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,i=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(r,a)}catch(t){e=[6,t],i=0}finally{o=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function c(t,e){if(0===e.length)return t;for(var r=0;r<e.length;++r){t=(t<<5)-t+e.charCodeAt(r),t|=0}return t<0?-2*t:t}function p(t,e,r,n){var o,i,s,a,u=c(c(c(t,r),(o=e,Object.prototype.toString.call(o))),typeof e);return null===e?c(u,"null"):void 0===e?c(u,"undefined"):"object"==typeof e?-1!==n.indexOf(e)?c(u,"[Circular]"+r):(n.push(e),i=u,a=n,"function"==typeof(s=e).hashSum?s.hashSum():Object.keys(s).sort().reduce(function(t,e){return p(t,s[e],e,a)},i)):c(u,e.toString())}function s(t){return function(t,e){for(;t.length<e;)t="0"+t;return t}(p(0,t,"",[]).toString(16),8)}var t=function(){function t(t){this._cache={},this._calcID=t}return t.hash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(r({},t))},t.prototype.has=function(t){return this._calcID(t)in this._cache},t.prototype.set=function(t){return this._cache[this._calcID(t)]=t},t.prototype.get=function(t,e){var r=this._cache[this._calcID(t)];return r||(e?this.set(e()):null)},t}(),a=function(){function t(t){this._cache={},this._calcID=t}return t.hash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(r({},t))},t.prototype.has=function(t){return this._calcID(t)in this._cache},t.prototype.set=function(t,e){return this._cache[this._calcID(t)]=e},t.prototype.get=function(t,e){var r=this._cache[this._calcID(t)];return r||(e?this.set(t,e()):Promise.resolve(null))},t}();var u=function(){function t(t){if(this.store={},t)for(var e in t)this.set(e,t[e])}return t.prototype.set=function(t,e){var r=this.store[t];return this.store[t]=e,r},t.prototype.get=function(t){return this.store[t]},t.prototype.has=function(t){return void 0!==this.store[t]},t.prototype.remove=function(t){delete this.store[t]},t.prototype.keys=function(){var t=[];for(var e in this.store)t.push(e);return t},t.prototype.values=function(){var t=[];for(var e in this.store)t.push(this.store[e]);return t},t}(),h=function(r){function t(t){return r.call(this,t)||this}return i(t,r),t.prototype.set=function(t,e){return r.prototype.set.call(this,t.toLowerCase(),e)},t.prototype.get=function(t){return r.prototype.get.call(this,t.toLowerCase())},t.prototype.has=function(t){return r.prototype.has.call(this,t.toLowerCase())},t.prototype.remove=function(t){return r.prototype.remove.call(this,t.toLowerCase())},t}(u);var f=function(t,e){this.props={},this._graph=t,this.parent=e},l=function(o){function e(t,e,r){var n=o.call(this,t,e)||this;return n.subgraphs=[],n.vertices=[],n.edges=[],e&&e._addSubgraph(n),n._=r,n}return i(e,o),e.prototype.remove=function(t){void 0===t&&(t=!0),this._graph.removeSubgraph(this,t)},e.prototype.createSubgraph=function(t){return this._graph.createSubgraph(this,t)},e.prototype._addSubgraph=function(t){if(0<=this.subgraphs.indexOf(t))throw new Error("Subgraph already exists");this.subgraphs.push(t)},e.prototype._removeSubgraph=function(t){var e=this.subgraphs.indexOf(t);if(e<0)throw new Error("Subgraph does not exist");this.subgraphs.splice(e,1)},e.prototype.removeAllSubgraphs=function(){for(var t=this.subgraphs.length-1;0<=t;--t)this._graph.removeSubgraph(this.subgraphs[t],!0)},e.prototype.createVertex=function(t){return this._graph.createVertex(this,t)},e.prototype._addVertex=function(t){if(0<=this.vertices.indexOf(t))throw new Error("Vertex already exists");this.vertices.push(t)},e.prototype._removeVertex=function(t){var e=this.vertices.indexOf(t);if(e<0)throw new Error("Vertex does not exist");this.vertices.splice(e,1)},e.prototype.removeAllVertices=function(){for(var t=this.vertices.length-1;0<=t;--t)this._graph.removeVertex(this.vertices[t],!0)},e.prototype.createEdge=function(t,e,r){return this._graph.createEdge(this,t,e,r)},e.prototype._addEdge=function(t){if(0<=this.edges.indexOf(t))throw new Error("Edge already exists");this.edges.push(t)},e.prototype._removeEdge=function(t){var e=this.edges.indexOf(t);if(e<0)throw new Error("Edge does not exist");this.edges.splice(e,1)},e.prototype._add=function(t){t instanceof e?this._addSubgraph(t):t instanceof d?this._addVertex(t):this._addEdge(t)},e}(f),d=function(o){function t(t,e,r){var n=o.call(this,t,e)||this;return n.inEdges=[],n.outEdges=[],e._addVertex(n),n._=r,n}return i(t,o),Object.defineProperty(t.prototype,"edges",{get:function(){return this.inEdges.concat(this.outEdges)},enumerable:!0,configurable:!0}),t.prototype.remove=function(t,e){return void 0===t&&(t=!0),this._graph.removeVertex(this,t,e)},t.prototype.addInEdge=function(t){this.inEdges.push(t)},t.prototype.removeInEdge=function(t){var e=this.inEdges.indexOf(t);if(e<0)throw new Error("In edge does not exist");this.inEdges.splice(e,1)},t.prototype.addOutEdge=function(t){this.outEdges.push(t)},t.prototype.removeOutEdge=function(t){var e=this.outEdges.indexOf(t);if(e<0)throw new Error("Out edge does not exist");this.outEdges.splice(e,1)},t}(f),v=function(s){function t(t,e,r,n,o){var i=s.call(this,t,e)||this;if(!r)throw new Error("Missing source vertex");if(!n)throw new Error("Missing target vertex");return e._addEdge(i),i.source=r,i.source.addOutEdge(i),i.target=n,i.target.addInEdge(i),i._=o,i}return i(t,s),t.prototype.remove=function(){this._graph.removeEdge(this)},t}(f),g=function(){function t(t,e){void 0===t&&(t=function(t){return""+t._}),this._allSubgraphs=[],this._allSubgraphsMap={},this._allVertices=[],this._allVerticesMap={},this._allEdges=[],this._allEdgesMap={},this.root=new l(this,null,e),this.idOf=t}return t.prototype.createSubgraph=function(t,e){var r=new l(this,t||this.root,e);return this._allSubgraphs.push(r),this._allSubgraphsMap[this.idOf(r)]=r},t.prototype.removeSubgraph=function(e,r){var n=this;void 0===r&&(r=!0);var t=this._allSubgraphs.indexOf(e);if(t<0)throw new Error("Subgraph does not exist");this._allSubgraphs.splice(t,1),delete this._allSubgraphsMap[this.idOf(e)],e.parent&&e.parent._removeSubgraph(e),e.edges.forEach(function(t){return r?n.removeEdge(t):e.parent._addEdge(t)}),e.vertices.forEach(function(t){return r?n.removeVertex(t,r):e.parent._addVertex(t)}),e.subgraphs.forEach(function(t){return r?n.removeSubgraph(t,r):e.parent._addSubgraph(t)})},Object.defineProperty(t.prototype,"subgraphs",{get:function(){return this._allSubgraphs},enumerable:!0,configurable:!0}),t.prototype.subgraph=function(t){return this._allSubgraphsMap[t]},t.prototype.createVertex=function(t,e){var r=new d(this,t,e);return this._allVertices.push(r),this._allVerticesMap[this.idOf(r)]=r},t.prototype.removeVertex=function(t,e,r){var n=this;void 0===e&&(e=!0);var o=this._allVertices.indexOf(t);if(o<0)throw new Error("Vertex does not exist");this._allVertices.splice(o,1),delete this._allVerticesMap[this.idOf(t)],t.parent&&t.parent._removeVertex(t),e||t.inEdges.forEach(function(e){t.outEdges.forEach(function(t){n.createEdge(n.root,e.source,t.target,r?r(e.source._,t.target._):void 0)})}),t.inEdges.forEach(function(t){return n.removeEdge(t)}),t.outEdges.forEach(function(t){return n.removeEdge(t)})},Object.defineProperty(t.prototype,"vertices",{get:function(){return this._allVertices},enumerable:!0,configurable:!0}),t.prototype.vertex=function(t){return this._allVerticesMap[t]},t.prototype.createEdge=function(t,e,r,n){var o=new v(this,t,e,r,n);return this._allEdges.push(o),this._allEdgesMap[this.idOf(o)]=o},t.prototype.removeEdge=function(t){var e=this._allEdges.indexOf(t);if(e<0)throw new Error("Edge does not exist");this._allEdges.splice(e,1),delete this._allEdgesMap[this.idOf(t)],t.parent&&t.parent._removeEdge(t),t.source.removeOutEdge(t),t.target.removeInEdge(t)},Object.defineProperty(t.prototype,"edges",{get:function(){return this._allEdges},enumerable:!0,configurable:!0}),t.prototype.edge=function(t){return this._allEdgesMap[t]},t.prototype._walk=function(t,e){for(var r=0,n=t.subgraphs;r<n.length;r++){var o=n[r];switch(e(o)){case"abort":return!0;case"stepover":break;default:if(this._walk(o,e))return!0}}for(var i=0,s=t.vertices;i<s.length;i++){if("abort"===e(s[i]))return!0}},t.prototype.walk=function(t){this._walk(this.root,t);for(var e=0,r=this._allEdges;e<r.length;e++){if("abort"===t(r[e]))return!0}},t.prototype.clone=function(){var n,o,t=new this.constructor(this.idOf,this.root._),i=(n=[],o=[],{put:function(t,e){var r=n.indexOf(t);-1===r?(n.push(t),o.push(e)):o[r]=e},get:function(t){return o[n.indexOf(t)]}});return i.put(this.root,t.root),this.walk(function(t){var e=i.get(t.parent);if(t instanceof l)i.put(t,e.createSubgraph(t._));else if(t instanceof d)i.put(t,e.createVertex(t._));else if(t instanceof v){var r=i.get(t.source),n=i.get(t.target);e.createEdge(r,n,t._)}}),t},t}();var y=Array.isArray,_=Object.keys,b=Object.prototype.hasOwnProperty;function m(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){var r,n=y(t),o=y(e),i=void 0,s=void 0;if(n&&o){if((r=t.length)!==e.length)return!1;for(i=r;0!=i--;)if(!m(t[i],e[i]))return!1;return!0}if(n!==o)return!1;var a=t instanceof Date,u=e instanceof Date;if(a!==u)return!1;if(a&&u)return t.getTime()===e.getTime();var c=t instanceof RegExp,p=e instanceof RegExp;if(c!==p)return!1;if(c&&p)return t.toString()===e.toString();var h=_(t);if((r=h.length)!==_(e).length)return!1;for(i=r;0!=i--;)if(!b.call(e,h[i]))return!1;for(i=r;0!=i--;)if(!m(t[s=h[i]],e[s]))return!1;return!0}return t!=t&&e!=e}var w,E=new Function("return this;")(),O="undefined"!=typeof window&&E===window,S="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,x=S&&null!=process.env&&null!=process.env.TRAVIS,k=function(){function t(){this.stack=[]}return t.prototype.push=function(t){return this.stack.push(t),t},t.prototype.pop=function(){return this.stack.pop()},t.prototype.top=function(){return this.stack.length?this.stack[this.stack.length-1]:void 0},t.prototype.depth=function(){return this.stack.length},t}();(w=o.Level||(o.Level={}))[w.debug=0]="debug",w[w.info=1]="info",w[w.notice=2]="notice",w[w.warning=3]="warning",w[w.error=4]="error",w[w.critical=5]="critical",w[w.alert=6]="alert",w[w.emergency=7]="emergency";var D={debug:"cyan",info:"green",notice:"grey",warning:"blue",error:"red",critical:"magenta",alert:"magenta",emergency:"magenta"},I=function(){function t(){}return t.prototype.write=function(t,e,r,n){S?console.log("["+t+"] "+o.Level[e].toUpperCase()+" "+r+": "+n):console.log("["+t+"] %c"+o.Level[e].toUpperCase()+"%c "+r+": "+n,"color:"+D[o.Level[e]],"")},t}(),L=function(){function t(){this._levelStack=new k,this._level=o.Level.info,this._filter="",this._writer=new I}return t.Instance=function(){return this._instance||(this._instance=new this)},t.prototype.stringify=function(t){var r=[];return JSON.stringify(t,function(t,e){if("object"==typeof e&&null!==e){if(-1!==r.indexOf(e))return;r.push(e)}return e},2)},t.prototype.writer=function(t){return void 0===t?this._writer:(this._writer=t,this)},t.prototype.log=function(t,e,r){t<this._level||this._filter&&this._filter!==e||("string"!=typeof r&&(r=this.stringify(r)),this._writer.write((new Date).toISOString(),t,e,r))},t.prototype.debug=function(t,e){this.log(o.Level.debug,t,e)},t.prototype.info=function(t,e){this.log(o.Level.info,t,e)},t.prototype.notice=function(t,e){this.log(o.Level.notice,t,e)},t.prototype.warning=function(t,e){this.log(o.Level.warning,t,e)},t.prototype.error=function(t,e){this.log(o.Level.error,t,e)},t.prototype.critical=function(t,e){this.log(o.Level.critical,t,e)},t.prototype.alert=function(t,e){this.log(o.Level.alert,t,e)},t.prototype.emergency=function(t,e){this.log(o.Level.emergency,t,e)},t.prototype.level=function(t){return void 0===t?this._level:(this._level=t,this)},t.prototype.pushLevel=function(t){return this._levelStack.push(this._level),this._level=t,this},t.prototype.popLevel=function(){return this._level=this._levelStack.pop(),this},t.prototype.filter=function(t){return void 0===t?this._filter:(this._filter=t,this)},t}(),M=L.Instance(),V=function(){function t(t){this._scopeID=t}return t.prototype.debug=function(t){M.debug(this._scopeID,t)},t.prototype.info=function(t){M.info(this._scopeID,t)},t.prototype.notice=function(t){M.notice(this._scopeID,t)},t.prototype.warning=function(t){M.warning(this._scopeID,t)},t.prototype.error=function(t){M.error(this._scopeID,t)},t.prototype.critical=function(t){M.critical(this._scopeID,t)},t.prototype.alert=function(t){M.alert(this._scopeID,t)},t.prototype.emergency=function(t){M.emergency(this._scopeID,t)},t.prototype.pushLevel=function(t){return M.pushLevel(t),this},t.prototype.popLevel=function(){return M.popLevel(),this},t}();function C(t,e,r){var n=r-e,o=t-e;return o-Math.floor(o/n)*n+e}function T(t,e){if(void 0!==t&&void 0!==e){for(var r=0,n=t.split(".");r<n.length;r++){var o=n[r];if(!e.hasOwnProperty(o))return;e=e[o]}return e}}function j(t,e){var r={};for(var n in e){var o=e[n];o instanceof Array||"object"==typeof o&&(o=N(t[n],o)),n in t&&(t[n]===o||n in r&&r[n]===o)||(t[n]=o)}return t}function N(t){void 0===t&&(t={});for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if("object"!=typeof t)throw new Error('Destination "'+t+'" must be an object.');for(var n=0,o=e;n<o.length;n++){j(t,o[n])}return t}var P=function(){function t(t,e,r){this.eventTarget=t,this.eventID=e,this.callback=r}return t.prototype.release=function(){this.eventTarget.removeObserver(this.eventID,this.callback)},t.prototype.unwatch=function(){this.release()},t}(),A=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._eventObservers={}}return t.prototype.addObserver=function(t,e){var r=this._eventObservers[t];return r||(r=[],this._eventObservers[t]=r),r.push(e),new P(this,t,e)},t.prototype.removeObserver=function(t,e){var r=this._eventObservers[t];if(r)for(var n=r.length-1;0<=n;--n)r[n]===e&&r.splice(n,1);return this},t.prototype.dispatchEvent=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var n=this._eventObservers[t];if(n)for(var o=0,i=n;o<i.length;o++){i[o].apply(void 0,e)}return this},t.prototype._hasObserver=function(t){var e=this._eventObservers[t];for(var r in e)if(e[r])return!0;return!1},t.prototype.hasObserver=function(t){if(void 0!==t)return this._hasObserver(t);for(var e in this._eventObservers)if(this._hasObserver(e))return!0;return!1},t}(),X=function(){function t(t){this.name="",this.$={},this._children=[],this.content="",this.name=t}return t.prototype.appendAttribute=function(t,e){this.$[t]=e},t.prototype.appendContent=function(t){this.content+=t},t.prototype.appendChild=function(t){this._children.push(t)},t.prototype.children=function(e){return void 0===e?this._children:this._children.filter(function(t){return t.name===e})},t}(),F=function(){function t(){this.stack=new k}return t.prototype.walkDoc=function(t){var e=this._startXMLNode(t);if(t.attributes)for(var r=0;r<t.attributes.length;++r){var n=t.attributes.item(r);this.attributes(n.nodeName,n.nodeValue)}if(this.startXMLNode(e),t.childNodes)for(r=0;r<t.childNodes.length;++r){var o=t.childNodes.item(r);o.nodeType===o.TEXT_NODE?this.characters(o.nodeValue):this.walkDoc(o)}this.endXMLNode(this.stack.pop())},t.prototype._startXMLNode=function(t){var e=new X(t.nodeName);return this.stack.depth()?this.stack.top().appendChild(e):this.root=e,this.stack.push(e)},t.prototype.parse=function(t){var e=(new DOMParser).parseFromString(t,"application/xml");this.startDocument(),this.walkDoc(e),this.endDocument()},t.prototype.startDocument=function(){},t.prototype.endDocument=function(){},t.prototype.startXMLNode=function(t){},t.prototype.endXMLNode=function(t){},t.prototype.attributes=function(t,e){this.stack.top().appendAttribute(t,e)},t.prototype.characters=function(t){this.stack.top().appendContent(t)},t}(),R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.startXMLNode=function(t){e.prototype.startXMLNode.call(this,t),t.name},t.prototype.endXMLNode=function(t){t.name,e.prototype.endXMLNode.call(this,t)},t}(F);var z=function(){function t(){this._espState={},this._espStateCache={},this._events=new A,this._monitorTickCount=0}return t.prototype.clear=function(t){this._espState={},this._espStateCache={},void 0!==t&&this.set(t),this._monitorTickCount=0},t.prototype.get=function(t,e){return void 0===t?this._espState:this.has(t)?this._espState[t]:e},t.prototype.set=function(t,e,r){return void 0===r&&(r=!1),"string"==typeof t?this.setSingle(t,e,r):this.setAll(t)},t.prototype.setSingle=function(t,e,r){var n=this._espStateCache[t],o=s(e);if(n===o)return null;this._espStateCache[t]=o;var i={id:t,oldValue:this._espState[t],newValue:this._espState[t]=e};return r||(this._events.dispatchEvent("propChanged",i),this._events.dispatchEvent("changed",[i])),i},t.prototype.setAll=function(t){var e=[];for(var r in t)if(t.hasOwnProperty(r)){var n=this.setSingle(r,t[r],!0);n&&e.push(n)}if(e.length){for(var o=0,i=e;o<i.length;o++){var s=i[o];this._events.dispatchEvent("propChanged",s)}this._events.dispatchEvent("changed",e)}return e},t.prototype.has=function(t){return void 0!==this._espState[t]},t.prototype.addObserver=function(t,e,r){if(this.isCallback(e)){if("changed"!==t)throw new Error("Invalid eventID: "+t);return this._events.addObserver(t,e)}if("propChanged"!==t)throw new Error("Invalid eventID: "+t);return this._events.addObserver(t,function(t){t.id===e&&r(t)})},t.prototype.on=function(t,e,r){if(this.isCallback(e))switch(t){case"changed":this._events.addObserver(t,e)}else switch(t){case"propChanged":this._events.addObserver(t,function(t){t.id===e&&r(t)})}return this},t.prototype.isCallback=function(t){return"function"==typeof t},t.prototype.hasEventListener=function(){return this._events.hasObserver()},t.prototype.refresh=function(t){return void 0===t&&(t=!1),i=this,u=function(){return e(this,function(t){switch(t.label){case 0:return[4,Promise.resolve()];case 1:return t.sent(),[2,this]}})},new((a=s=void 0)||(a=Promise))(function(t,e){function r(t){try{o(u.next(t))}catch(t){e(t)}}function n(t){try{o(u.throw(t))}catch(t){e(t)}}function o(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(r,n)}o((u=u.apply(i,s||[])).next())});var i,s,a,u},t.prototype._monitor=function(){var t=this;this._monitorHandle?this._monitorTickCount=0:this._monitorHandle=setTimeout(function(){(t.hasEventListener()?t.refresh(!0):Promise.resolve()).then(function(){t._monitor()}),delete t._monitorHandle},this._monitorTimeoutDuraction())},t.prototype._monitorTimeoutDuraction=function(){return++this._monitorTickCount,this._monitorTickCount<=1?0:3e4},t.prototype.watch=function(n,t){var o=this;if(void 0===t&&(t=!0),"function"!=typeof n)throw new Error("Invalid Callback");t&&setTimeout(function(){var t=o.get(),e=[];for(var r in t)t.hasOwnProperty(t)&&e.push({id:r,newValue:t[r],oldValue:void 0});n(e)},0);var e=this.addObserver("changed",n);return this._monitor(),e},t}();function G(t,e){if("string"!=typeof e)return t;if(0===e.length)return t;for(;0===t.indexOf(e);)t=t.substring(1);for(;H(t,e);)t=t.substring(0,t.length-1);return t}function H(t,e,r){var n=t.toString();("number"!=typeof r||!isFinite(r)||Math.floor(r)!==r||r>n.length)&&(r=n.length),r-=e.length;var o=n.lastIndexOf(e,r);return-1!==o&&o===r}o.find=function(t,e){if(null==t)throw new TypeError('"o" is null or not defined');var r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n=e,o=0;o<r;){var i=t[o];if(e.call(n,i,o,t))return i;o++}},o.compare=function(t,e){for(var r={unchanged:[],removed:[],added:e.slice(0)},n=0,o=t;n<o.length;n++){var i=o[n],s=r.added.indexOf(i);0<=s?(r.unchanged.push(i),r.added.splice(s,1)):r.removed.push(i)}return r},o.Cache=t,o.AsyncCache=a,o.debounce=function(n,o){var i={};return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=s(t);return i[r]||(i[r]={clockStart:Date.now(),promise:n.apply(void 0,t).then(function(t){return void 0===o?i[r]=null:setTimeout(function(){i[r]=null},Math.max(o-(Date.now()-i[r].clockStart),0)),t}).catch(function(t){throw i[r]=null,t})}),i[r].promise}},o.promiseTimeout=function(r,t){var n,e=new Promise(function(t,e){n=setTimeout(function(){clearTimeout(n),e("Timed out in "+r+"ms.")},r)});return Promise.race([t,e]).then(function(t){return clearTimeout(n),t}).catch(function(t){throw clearTimeout(n),t})},o.Dictionary=u,o.DictionaryNoCase=h,o.espTime2Seconds=function(t){if(!t)return 0;if(!isNaN(Number(t)))return Number(t);var e=t.indexOf("ns");if(-1!==e)return parseFloat(t.substr(0,e))/1e9;var r=t.indexOf("ms");if(-1!==r)return parseFloat(t.substr(0,r))/1e3;var n=t.indexOf("s");if(-1!==n&&-1===t.indexOf("days"))return parseFloat(t.substr(0,n));for(var o=t.split(" days "),i=1<o.length?parseFloat(o[0]):0,s=0,a=(1<o.length?o[1]:o[0]).split(":").reverse(),u=0;u<a.length;++u)s+=parseFloat(a[u])*Math.pow(60,u);return 24*i*60*60+s},o.GraphItem=f,o.Subgraph=l,o.Vertex=d,o.Edge=v,o.Graph=g,o.hashSum=s,o.deepEquals=m,o.update=function(t,e){return m(t,e)?t:e},o.Logging=L,o.logger=M,o.ScopedLogging=V,o.scopedLogger=function(t,e){return void 0===e&&(e=!1),e&&M.filter(t),new V(t)},o.degreesToRadians=function(t){return t*(Math.PI/180)},o.radiansToDegrees=function(t){return t*(180/Math.PI)},o.normalizeRadians=function(t,e,r){return void 0===e&&(e=-Math.PI),void 0===r&&(r=Math.PI),C(t,e,r)},o.normalizeDegrees=function(t,e,r){return void 0===e&&(e=-180),void 0===r&&(r=180),C(t,e,r)},o.normalize=C,o.inner=T,o.exists=function(t,e){return void 0!==T(t,e)},o.deepMixin=N,o.deepMixinT=function(t){void 0===t&&(t={});for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return N.apply(void 0,[t].concat(e))},o.safeStringify=function(t){var r=[];return JSON.stringify(t,function(t,e){if("object"==typeof e&&null!==e){if(-1!==r.indexOf(e))return;r.push(e)}return e})},o.isArray=function(t){return void 0!==Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},o.classID2Meta=function(t){var e=t.split("_"),r=e[1].split(".");return{module:"@hpcc-js/"+e[0],file:r[0],class:r[1]||r[0]}},o.Observable=A,o.root=E,o.isBrowser=O,o.isNode=S,o.isTravis=x,o.XMLNode=X,o.SAXStackParser=F,o.xml2json=function(t){var e=new R;return e.parse(t),e.root},o.Stack=k,o.StateObject=z,o.trim=G,o.endsWith=H,o.join=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(t.length&&t[0].length&&"/"===t[0].charAt(0)?"/":"")+t.map(function(t){return G(t,"/")}).join("/")},Object.defineProperty(o,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["@hpcc-js/util"]={})}(this,function(o){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(r,n){var o,i,s,t,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&e[0]?i.return:e[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,e[1])).done)return s;switch(i=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,i=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(r,a)}catch(t){e=[6,t],i=0}finally{o=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function c(t,e){if(0===e.length)return t;for(var r=0;r<e.length;++r){t=(t<<5)-t+e.charCodeAt(r),t|=0}return t<0?-2*t:t}function p(t,e,r,n){var o,i,s,a,u=c(c(c(t,r),(o=e,Object.prototype.toString.call(o))),typeof e);return null===e?c(u,"null"):void 0===e?c(u,"undefined"):"object"==typeof e?-1!==n.indexOf(e)?c(u,"[Circular]"+r):(n.push(e),i=u,a=n,"function"==typeof(s=e).hashSum?s.hashSum():Object.keys(s).sort().reduce(function(t,e){return p(t,s[e],e,a)},i)):c(u,e.toString())}function s(t){return function(t,e){for(;t.length<e;)t="0"+t;return t}(p(0,t,"",[]).toString(16),8)}var t=function(){function t(t){this._cache={},this._calcID=t}return t.hash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(r({},t))},t.prototype.has=function(t){return this._calcID(t)in this._cache},t.prototype.set=function(t){return this._cache[this._calcID(t)]=t},t.prototype.get=function(t,e){var r=this._cache[this._calcID(t)];return r||(e?this.set(e()):null)},t}(),a=function(){function t(t){this._cache={},this._calcID=t}return t.hash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(r({},t))},t.prototype.has=function(t){return this._calcID(t)in this._cache},t.prototype.set=function(t,e){return this._cache[this._calcID(t)]=e},t.prototype.get=function(t,e){var r=this._cache[this._calcID(t)];return r||(e?this.set(t,e()):Promise.resolve(null))},t}();var u=function(){function t(){this._q=[]}return t.prototype.isTop=function(t){return this._q[0]===t},t.prototype.push=function(t){var o=this,i=t.then(function(n){return o.isTop(i)?(o._q.shift(),n):new Promise(function(t,e){var r=setInterval(function(){o.isTop(i)&&(clearInterval(r),o._q.shift(),t(n))},20)})});return this._q.push(i),i},t}(),h=function(){function t(t){if(this.store={},t)for(var e in t)this.set(e,t[e])}return t.prototype.set=function(t,e){var r=this.store[t];return this.store[t]=e,r},t.prototype.get=function(t){return this.store[t]},t.prototype.has=function(t){return void 0!==this.store[t]},t.prototype.remove=function(t){delete this.store[t]},t.prototype.keys=function(){var t=[];for(var e in this.store)t.push(e);return t},t.prototype.values=function(){var t=[];for(var e in this.store)t.push(this.store[e]);return t},t}(),f=function(r){function t(t){return r.call(this,t)||this}return i(t,r),t.prototype.set=function(t,e){return r.prototype.set.call(this,t.toLowerCase(),e)},t.prototype.get=function(t){return r.prototype.get.call(this,t.toLowerCase())},t.prototype.has=function(t){return r.prototype.has.call(this,t.toLowerCase())},t.prototype.remove=function(t){return r.prototype.remove.call(this,t.toLowerCase())},t}(h);var l=function(t,e){this.props={},this._graph=t,this.parent=e},d=function(o){function e(t,e,r){var n=o.call(this,t,e)||this;return n.subgraphs=[],n.vertices=[],n.edges=[],e&&e._addSubgraph(n),n._=r,n}return i(e,o),e.prototype.remove=function(t){void 0===t&&(t=!0),this._graph.removeSubgraph(this,t)},e.prototype.createSubgraph=function(t){return this._graph.createSubgraph(this,t)},e.prototype._addSubgraph=function(t){if(0<=this.subgraphs.indexOf(t))throw new Error("Subgraph already exists");this.subgraphs.push(t)},e.prototype._removeSubgraph=function(t){var e=this.subgraphs.indexOf(t);if(e<0)throw new Error("Subgraph does not exist");this.subgraphs.splice(e,1)},e.prototype.removeAllSubgraphs=function(){for(var t=this.subgraphs.length-1;0<=t;--t)this._graph.removeSubgraph(this.subgraphs[t],!0)},e.prototype.createVertex=function(t){return this._graph.createVertex(this,t)},e.prototype._addVertex=function(t){if(0<=this.vertices.indexOf(t))throw new Error("Vertex already exists");this.vertices.push(t)},e.prototype._removeVertex=function(t){var e=this.vertices.indexOf(t);if(e<0)throw new Error("Vertex does not exist");this.vertices.splice(e,1)},e.prototype.removeAllVertices=function(){for(var t=this.vertices.length-1;0<=t;--t)this._graph.removeVertex(this.vertices[t],!0)},e.prototype.createEdge=function(t,e,r){return this._graph.createEdge(this,t,e,r)},e.prototype._addEdge=function(t){if(0<=this.edges.indexOf(t))throw new Error("Edge already exists");this.edges.push(t)},e.prototype._removeEdge=function(t){var e=this.edges.indexOf(t);if(e<0)throw new Error("Edge does not exist");this.edges.splice(e,1)},e.prototype._add=function(t){t instanceof e?this._addSubgraph(t):t instanceof v?this._addVertex(t):this._addEdge(t)},e}(l),v=function(o){function t(t,e,r){var n=o.call(this,t,e)||this;return n.inEdges=[],n.outEdges=[],e._addVertex(n),n._=r,n}return i(t,o),Object.defineProperty(t.prototype,"edges",{get:function(){return this.inEdges.concat(this.outEdges)},enumerable:!0,configurable:!0}),t.prototype.remove=function(t,e){return void 0===t&&(t=!0),this._graph.removeVertex(this,t,e)},t.prototype.addInEdge=function(t){this.inEdges.push(t)},t.prototype.removeInEdge=function(t){var e=this.inEdges.indexOf(t);if(e<0)throw new Error("In edge does not exist");this.inEdges.splice(e,1)},t.prototype.addOutEdge=function(t){this.outEdges.push(t)},t.prototype.removeOutEdge=function(t){var e=this.outEdges.indexOf(t);if(e<0)throw new Error("Out edge does not exist");this.outEdges.splice(e,1)},t}(l),g=function(s){function t(t,e,r,n,o){var i=s.call(this,t,e)||this;if(!r)throw new Error("Missing source vertex");if(!n)throw new Error("Missing target vertex");return e._addEdge(i),i.source=r,i.source.addOutEdge(i),i.target=n,i.target.addInEdge(i),i._=o,i}return i(t,s),t.prototype.remove=function(){this._graph.removeEdge(this)},t}(l),y=function(){function t(t,e){void 0===t&&(t=function(t){return""+t._}),this._allSubgraphs=[],this._allSubgraphsMap={},this._allVertices=[],this._allVerticesMap={},this._allEdges=[],this._allEdgesMap={},this.root=new d(this,null,e),this.idOf=t}return t.prototype.createSubgraph=function(t,e){var r=new d(this,t||this.root,e);return this._allSubgraphs.push(r),this._allSubgraphsMap[this.idOf(r)]=r},t.prototype.removeSubgraph=function(e,r){var n=this;void 0===r&&(r=!0);var t=this._allSubgraphs.indexOf(e);if(t<0)throw new Error("Subgraph does not exist");this._allSubgraphs.splice(t,1),delete this._allSubgraphsMap[this.idOf(e)],e.parent&&e.parent._removeSubgraph(e),e.edges.forEach(function(t){return r?n.removeEdge(t):e.parent._addEdge(t)}),e.vertices.forEach(function(t){return r?n.removeVertex(t,r):e.parent._addVertex(t)}),e.subgraphs.forEach(function(t){return r?n.removeSubgraph(t,r):e.parent._addSubgraph(t)})},Object.defineProperty(t.prototype,"subgraphs",{get:function(){return this._allSubgraphs},enumerable:!0,configurable:!0}),t.prototype.subgraph=function(t){return this._allSubgraphsMap[t]},t.prototype.createVertex=function(t,e){var r=new v(this,t,e);return this._allVertices.push(r),this._allVerticesMap[this.idOf(r)]=r},t.prototype.removeVertex=function(t,e,r){var n=this;void 0===e&&(e=!0);var o=this._allVertices.indexOf(t);if(o<0)throw new Error("Vertex does not exist");this._allVertices.splice(o,1),delete this._allVerticesMap[this.idOf(t)],t.parent&&t.parent._removeVertex(t),e||t.inEdges.forEach(function(e){t.outEdges.forEach(function(t){n.createEdge(n.root,e.source,t.target,r?r(e.source._,t.target._):void 0)})}),t.inEdges.forEach(function(t){return n.removeEdge(t)}),t.outEdges.forEach(function(t){return n.removeEdge(t)})},Object.defineProperty(t.prototype,"vertices",{get:function(){return this._allVertices},enumerable:!0,configurable:!0}),t.prototype.vertex=function(t){return this._allVerticesMap[t]},t.prototype.createEdge=function(t,e,r,n){var o=new g(this,t,e,r,n);return this._allEdges.push(o),this._allEdgesMap[this.idOf(o)]=o},t.prototype.removeEdge=function(t){var e=this._allEdges.indexOf(t);if(e<0)throw new Error("Edge does not exist");this._allEdges.splice(e,1),delete this._allEdgesMap[this.idOf(t)],t.parent&&t.parent._removeEdge(t),t.source.removeOutEdge(t),t.target.removeInEdge(t)},Object.defineProperty(t.prototype,"edges",{get:function(){return this._allEdges},enumerable:!0,configurable:!0}),t.prototype.edge=function(t){return this._allEdgesMap[t]},t.prototype._walk=function(t,e){for(var r=0,n=t.subgraphs;r<n.length;r++){var o=n[r];switch(e(o)){case"abort":return!0;case"stepover":break;default:if(this._walk(o,e))return!0}}for(var i=0,s=t.vertices;i<s.length;i++){if("abort"===e(s[i]))return!0}},t.prototype.walk=function(t){this._walk(this.root,t);for(var e=0,r=this._allEdges;e<r.length;e++){if("abort"===t(r[e]))return!0}},t.prototype.clone=function(){var n,o,t=new this.constructor(this.idOf,this.root._),i=(n=[],o=[],{put:function(t,e){var r=n.indexOf(t);-1===r?(n.push(t),o.push(e)):o[r]=e},get:function(t){return o[n.indexOf(t)]}});return i.put(this.root,t.root),this.walk(function(t){var e=i.get(t.parent);if(t instanceof d)i.put(t,e.createSubgraph(t._));else if(t instanceof v)i.put(t,e.createVertex(t._));else if(t instanceof g){var r=i.get(t.source),n=i.get(t.target);e.createEdge(r,n,t._)}}),t},t}();var _=Array.isArray,b=Object.keys,m=Object.prototype.hasOwnProperty;function w(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){var r,n=_(t),o=_(e),i=void 0,s=void 0;if(n&&o){if((r=t.length)!==e.length)return!1;for(i=r;0!=i--;)if(!w(t[i],e[i]))return!1;return!0}if(n!==o)return!1;var a=t instanceof Date,u=e instanceof Date;if(a!==u)return!1;if(a&&u)return t.getTime()===e.getTime();var c=t instanceof RegExp,p=e instanceof RegExp;if(c!==p)return!1;if(c&&p)return t.toString()===e.toString();var h=b(t);if((r=h.length)!==b(e).length)return!1;for(i=r;0!=i--;)if(!m.call(e,h[i]))return!1;for(i=r;0!=i--;)if(!w(t[s=h[i]],e[s]))return!1;return!0}return t!=t&&e!=e}var E,O=new Function("return this;")(),S="undefined"!=typeof window&&O===window,x="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,k=x&&null!=process.env&&null!=process.env.TRAVIS,D=function(){function t(){this.stack=[]}return t.prototype.push=function(t){return this.stack.push(t),t},t.prototype.pop=function(){return this.stack.pop()},t.prototype.top=function(){return this.stack.length?this.stack[this.stack.length-1]:void 0},t.prototype.depth=function(){return this.stack.length},t}();(E=o.Level||(o.Level={}))[E.debug=0]="debug",E[E.info=1]="info",E[E.notice=2]="notice",E[E.warning=3]="warning",E[E.error=4]="error",E[E.critical=5]="critical",E[E.alert=6]="alert",E[E.emergency=7]="emergency";var I={debug:"cyan",info:"green",notice:"grey",warning:"blue",error:"red",critical:"magenta",alert:"magenta",emergency:"magenta"},L=function(){function t(){}return t.prototype.write=function(t,e,r,n){x?console.log("["+t+"] "+o.Level[e].toUpperCase()+" "+r+": "+n):console.log("["+t+"] %c"+o.Level[e].toUpperCase()+"%c "+r+": "+n,"color:"+I[o.Level[e]],"")},t}(),M=function(){function t(){this._levelStack=new D,this._level=o.Level.info,this._filter="",this._writer=new L}return t.Instance=function(){return this._instance||(this._instance=new this)},t.prototype.stringify=function(t){var r=[];return JSON.stringify(t,function(t,e){if("object"==typeof e&&null!==e){if(-1!==r.indexOf(e))return;r.push(e)}return e},2)},t.prototype.writer=function(t){return void 0===t?this._writer:(this._writer=t,this)},t.prototype.log=function(t,e,r){t<this._level||this._filter&&this._filter!==e||("string"!=typeof r&&(r=this.stringify(r)),this._writer.write((new Date).toISOString(),t,e,r))},t.prototype.debug=function(t,e){this.log(o.Level.debug,t,e)},t.prototype.info=function(t,e){this.log(o.Level.info,t,e)},t.prototype.notice=function(t,e){this.log(o.Level.notice,t,e)},t.prototype.warning=function(t,e){this.log(o.Level.warning,t,e)},t.prototype.error=function(t,e){this.log(o.Level.error,t,e)},t.prototype.critical=function(t,e){this.log(o.Level.critical,t,e)},t.prototype.alert=function(t,e){this.log(o.Level.alert,t,e)},t.prototype.emergency=function(t,e){this.log(o.Level.emergency,t,e)},t.prototype.level=function(t){return void 0===t?this._level:(this._level=t,this)},t.prototype.pushLevel=function(t){return this._levelStack.push(this._level),this._level=t,this},t.prototype.popLevel=function(){return this._level=this._levelStack.pop(),this},t.prototype.filter=function(t){return void 0===t?this._filter:(this._filter=t,this)},t}(),T=M.Instance(),V=function(){function t(t){this._scopeID=t}return t.prototype.debug=function(t){T.debug(this._scopeID,t)},t.prototype.info=function(t){T.info(this._scopeID,t)},t.prototype.notice=function(t){T.notice(this._scopeID,t)},t.prototype.warning=function(t){T.warning(this._scopeID,t)},t.prototype.error=function(t){T.error(this._scopeID,t)},t.prototype.critical=function(t){T.critical(this._scopeID,t)},t.prototype.alert=function(t){T.alert(this._scopeID,t)},t.prototype.emergency=function(t){T.emergency(this._scopeID,t)},t.prototype.pushLevel=function(t){return T.pushLevel(t),this},t.prototype.popLevel=function(){return T.popLevel(),this},t}();function C(t,e,r){var n=r-e,o=t-e;return o-Math.floor(o/n)*n+e}function j(t,e){if(void 0!==t&&void 0!==e){for(var r=0,n=t.split(".");r<n.length;r++){var o=n[r];if(!e.hasOwnProperty(o))return;e=e[o]}return e}}function N(t,e){var r={};for(var n in e){var o=e[n];o instanceof Array||"object"==typeof o&&(o=P(t[n],o)),n in t&&(t[n]===o||n in r&&r[n]===o)||(t[n]=o)}return t}function P(t){void 0===t&&(t={});for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if("object"!=typeof t)throw new Error('Destination "'+t+'" must be an object.');for(var n=0,o=e;n<o.length;n++){N(t,o[n])}return t}var A=function(){function t(t,e,r){this.eventTarget=t,this.eventID=e,this.callback=r}return t.prototype.release=function(){this.eventTarget.removeObserver(this.eventID,this.callback)},t.prototype.unwatch=function(){this.release()},t}(),X=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._eventObservers={}}return t.prototype.addObserver=function(t,e){var r=this._eventObservers[t];return r||(r=[],this._eventObservers[t]=r),r.push(e),new A(this,t,e)},t.prototype.removeObserver=function(t,e){var r=this._eventObservers[t];if(r)for(var n=r.length-1;0<=n;--n)r[n]===e&&r.splice(n,1);return this},t.prototype.dispatchEvent=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var n=this._eventObservers[t];if(n)for(var o=0,i=n;o<i.length;o++){i[o].apply(void 0,e)}return this},t.prototype._hasObserver=function(t){var e=this._eventObservers[t];for(var r in e)if(e[r])return!0;return!1},t.prototype.hasObserver=function(t){if(void 0!==t)return this._hasObserver(t);for(var e in this._eventObservers)if(this._hasObserver(e))return!0;return!1},t}(),F=function(){function t(t){this.name="",this.$={},this._children=[],this.content="",this.name=t}return t.prototype.appendAttribute=function(t,e){this.$[t]=e},t.prototype.appendContent=function(t){this.content+=t},t.prototype.appendChild=function(t){this._children.push(t)},t.prototype.children=function(e){return void 0===e?this._children:this._children.filter(function(t){return t.name===e})},t}(),q=function(){function t(){this.stack=new D}return t.prototype.walkDoc=function(t){var e=this._startXMLNode(t);if(t.attributes)for(var r=0;r<t.attributes.length;++r){var n=t.attributes.item(r);this.attributes(n.nodeName,n.nodeValue)}if(this.startXMLNode(e),t.childNodes)for(r=0;r<t.childNodes.length;++r){var o=t.childNodes.item(r);o.nodeType===o.TEXT_NODE?this.characters(o.nodeValue):this.walkDoc(o)}this.endXMLNode(this.stack.pop())},t.prototype._startXMLNode=function(t){var e=new F(t.nodeName);return this.stack.depth()?this.stack.top().appendChild(e):this.root=e,this.stack.push(e)},t.prototype.parse=function(t){var e=(new DOMParser).parseFromString(t,"application/xml");this.startDocument(),this.walkDoc(e),this.endDocument()},t.prototype.startDocument=function(){},t.prototype.endDocument=function(){},t.prototype.startXMLNode=function(t){},t.prototype.endXMLNode=function(t){},t.prototype.attributes=function(t,e){this.stack.top().appendAttribute(t,e)},t.prototype.characters=function(t){this.stack.top().appendContent(t)},t}(),R=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.startXMLNode=function(t){e.prototype.startXMLNode.call(this,t),t.name},t.prototype.endXMLNode=function(t){t.name,e.prototype.endXMLNode.call(this,t)},t}(q);var z=function(){function t(){this._espState={},this._espStateCache={},this._events=new X,this._monitorTickCount=0}return t.prototype.clear=function(t){this._espState={},this._espStateCache={},void 0!==t&&this.set(t),this._monitorTickCount=0},t.prototype.get=function(t,e){return void 0===t?this._espState:this.has(t)?this._espState[t]:e},t.prototype.set=function(t,e,r){return void 0===r&&(r=!1),"string"==typeof t?this.setSingle(t,e,r):this.setAll(t)},t.prototype.setSingle=function(t,e,r){var n=this._espStateCache[t],o=s(e);if(n===o)return null;this._espStateCache[t]=o;var i={id:t,oldValue:this._espState[t],newValue:this._espState[t]=e};return r||(this._events.dispatchEvent("propChanged",i),this._events.dispatchEvent("changed",[i])),i},t.prototype.setAll=function(t){var e=[];for(var r in t)if(t.hasOwnProperty(r)){var n=this.setSingle(r,t[r],!0);n&&e.push(n)}if(e.length){for(var o=0,i=e;o<i.length;o++){var s=i[o];this._events.dispatchEvent("propChanged",s)}this._events.dispatchEvent("changed",e)}return e},t.prototype.has=function(t){return void 0!==this._espState[t]},t.prototype.addObserver=function(t,e,r){if(this.isCallback(e)){if("changed"!==t)throw new Error("Invalid eventID: "+t);return this._events.addObserver(t,e)}if("propChanged"!==t)throw new Error("Invalid eventID: "+t);return this._events.addObserver(t,function(t){t.id===e&&r(t)})},t.prototype.on=function(t,e,r){if(this.isCallback(e))switch(t){case"changed":this._events.addObserver(t,e)}else switch(t){case"propChanged":this._events.addObserver(t,function(t){t.id===e&&r(t)})}return this},t.prototype.isCallback=function(t){return"function"==typeof t},t.prototype.hasEventListener=function(){return this._events.hasObserver()},t.prototype.refresh=function(t){return void 0===t&&(t=!1),i=this,u=function(){return e(this,function(t){switch(t.label){case 0:return[4,Promise.resolve()];case 1:return t.sent(),[2,this]}})},new((a=s=void 0)||(a=Promise))(function(t,e){function r(t){try{o(u.next(t))}catch(t){e(t)}}function n(t){try{o(u.throw(t))}catch(t){e(t)}}function o(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(r,n)}o((u=u.apply(i,s||[])).next())});var i,s,a,u},t.prototype._monitor=function(){var t=this;this._monitorHandle?this._monitorTickCount=0:this._monitorHandle=setTimeout(function(){(t.hasEventListener()?t.refresh(!0):Promise.resolve()).then(function(){t._monitor()}),delete t._monitorHandle},this._monitorTimeoutDuraction())},t.prototype._monitorTimeoutDuraction=function(){return++this._monitorTickCount,this._monitorTickCount<=1?0:3e4},t.prototype.watch=function(n,t){var o=this;if(void 0===t&&(t=!0),"function"!=typeof n)throw new Error("Invalid Callback");t&&setTimeout(function(){var t=o.get(),e=[];for(var r in t)t.hasOwnProperty(t)&&e.push({id:r,newValue:t[r],oldValue:void 0});n(e)},0);var e=this.addObserver("changed",n);return this._monitor(),e},t}();function G(t,e){if("string"!=typeof e)return t;if(0===e.length)return t;for(;0===t.indexOf(e);)t=t.substring(1);for(;H(t,e);)t=t.substring(0,t.length-1);return t}function H(t,e,r){var n=t.toString();("number"!=typeof r||!isFinite(r)||Math.floor(r)!==r||r>n.length)&&(r=n.length),r-=e.length;var o=n.lastIndexOf(e,r);return-1!==o&&o===r}o.find=function(t,e){if(null==t)throw new TypeError('"o" is null or not defined');var r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n=e,o=0;o<r;){var i=t[o];if(e.call(n,i,o,t))return i;o++}},o.compare=function(t,e){for(var r={unchanged:[],removed:[],added:e.slice(0)},n=0,o=t;n<o.length;n++){var i=o[n],s=r.added.indexOf(i);0<=s?(r.unchanged.push(i),r.added.splice(s,1)):r.removed.push(i)}return r},o.Cache=t,o.AsyncCache=a,o.debounce=function(n,o){var i={};return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=s(t);return i[r]||(i[r]={clockStart:Date.now(),promise:n.apply(void 0,t).then(function(t){return void 0===o?i[r]=null:setTimeout(function(){i[r]=null},Math.max(o-(Date.now()-i[r].clockStart),0)),t}).catch(function(t){throw i[r]=null,t})}),i[r].promise}},o.promiseTimeout=function(r,t){var n,e=new Promise(function(t,e){n=setTimeout(function(){clearTimeout(n),e("Timed out in "+r+"ms.")},r)});return Promise.race([t,e]).then(function(t){return clearTimeout(n),t}).catch(function(t){throw clearTimeout(n),t})},o.AsyncOrderedQueue=u,o.Dictionary=h,o.DictionaryNoCase=f,o.espTime2Seconds=function(t){if(!t)return 0;if(!isNaN(Number(t)))return Number(t);var e=t.indexOf("ns");if(-1!==e)return parseFloat(t.substr(0,e))/1e9;var r=t.indexOf("ms");if(-1!==r)return parseFloat(t.substr(0,r))/1e3;var n=t.indexOf("s");if(-1!==n&&-1===t.indexOf("days"))return parseFloat(t.substr(0,n));for(var o=t.split(" days "),i=1<o.length?parseFloat(o[0]):0,s=0,a=(1<o.length?o[1]:o[0]).split(":").reverse(),u=0;u<a.length;++u)s+=parseFloat(a[u])*Math.pow(60,u);return 24*i*60*60+s},o.GraphItem=l,o.Subgraph=d,o.Vertex=v,o.Edge=g,o.Graph=y,o.hashSum=s,o.deepEquals=w,o.update=function(t,e){return w(t,e)?t:e},o.Logging=M,o.logger=T,o.ScopedLogging=V,o.scopedLogger=function(t,e){return void 0===e&&(e=!1),e&&T.filter(t),new V(t)},o.degreesToRadians=function(t){return t*(Math.PI/180)},o.radiansToDegrees=function(t){return t*(180/Math.PI)},o.normalizeRadians=function(t,e,r){return void 0===e&&(e=-Math.PI),void 0===r&&(r=Math.PI),C(t,e,r)},o.normalizeDegrees=function(t,e,r){return void 0===e&&(e=-180),void 0===r&&(r=180),C(t,e,r)},o.normalize=C,o.inner=j,o.exists=function(t,e){return void 0!==j(t,e)},o.deepMixin=P,o.deepMixinT=function(t){void 0===t&&(t={});for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return P.apply(void 0,[t].concat(e))},o.safeStringify=function(t){var r=[];return JSON.stringify(t,function(t,e){if("object"==typeof e&&null!==e){if(-1!==r.indexOf(e))return;r.push(e)}return e})},o.isArray=function(t){return void 0!==Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},o.classID2Meta=function(t){var e=t.split("_"),r=e[1].split(".");return{module:"@hpcc-js/"+e[0],file:r[0],class:r[1]||r[0]}},o.Observable=X,o.root=O,o.isBrowser=S,o.isNode=x,o.isTravis=k,o.XMLNode=F,o.SAXStackParser=q,o.xml2json=function(t){var e=new R;return e.parse(t),e.root},o.Stack=D,o.StateObject=z,o.trim=G,o.endsWith=H,o.join=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(t.length&&t[0].length&&"/"===t[0].charAt(0)?"/":"")+t.map(function(t){return G(t,"/")}).join("/")},Object.defineProperty(o,"__esModule",{value:!0})}); |
@@ -51,2 +51,32 @@ import { hashSum } from "./hashSum"; | ||
} | ||
var AsyncOrderedQueue = /** @class */ (function () { | ||
function AsyncOrderedQueue() { | ||
this._q = []; | ||
} | ||
AsyncOrderedQueue.prototype.isTop = function (p) { | ||
return this._q[0] === p; | ||
}; | ||
AsyncOrderedQueue.prototype.push = function (p) { | ||
var _this = this; | ||
var retVal = p.then(function (response) { | ||
if (_this.isTop(retVal)) { | ||
_this._q.shift(); | ||
return response; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var intervalHandler = setInterval(function () { | ||
if (_this.isTop(retVal)) { | ||
clearInterval(intervalHandler); | ||
_this._q.shift(); | ||
resolve(response); | ||
} | ||
}, 20); | ||
}); | ||
}); | ||
this._q.push(retVal); | ||
return retVal; | ||
}; | ||
return AsyncOrderedQueue; | ||
}()); | ||
export { AsyncOrderedQueue }; | ||
//# sourceMappingURL=debounce.js.map |
{ | ||
"name": "@hpcc-js/util", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "hpcc-js - Utilities", | ||
@@ -55,3 +55,3 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/hpcc-systems/Visualization", | ||
"gitHead": "344f25564999dfa148bfc649b3275ce50efd6a8b" | ||
"gitHead": "8827834e2329dcfae3b7cf960c3e263330fb1224" | ||
} |
@@ -7,1 +7,6 @@ export declare function debounce<R extends Promise<any>>(fn: () => R, timeout?: number): () => R; | ||
export declare function promiseTimeout<T>(ms: number, promise: Promise<T>): Promise<{} | T>; | ||
export declare class AsyncOrderedQueue { | ||
private _q; | ||
private isTop; | ||
push<T>(p: Promise<T>): Promise<T>; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
555425
5193