diff --git a/README.md b/README.md index d0f12497..8d8903c2 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ ignored parts are [documented](https://arnaudbuchholz.github.io/gpf/doc/tutorial Metric name | average | total | SME | comment ------ | ----- | ----- | ----- | ----- Statements coverage|100%||90%|*0.32% ignored* -Branches coverage|100%||90%|*0.69% ignored* +Branches coverage|100%||90%|*0.68% ignored* Functions coverage|100%||90%|*0.6% ignored* -Maintainability|83.68||70| -Number of tests||1090||*pending: 0, duration: 1034ms* +Maintainability|83.64||70| +Number of tests||1109||*pending: 0, duration: 879ms* Number of sources||144|| -Lines of code|92|13339|| +Lines of code|93|13443|| ## Setup @@ -80,20 +80,21 @@ and the template from [ink-docstrap](https://www.npmjs.com/package/ink-docstrap) Date | Version | Label | Release | Debug | Flavors ------ | ------ | ----- | ----- | ----- | ----- -2019-03-12 | [0.2.9](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.9) | [ES6 Support](https://gpf-js.blogspot.com/p/release-notes-are-coming.html?version=0.2.9) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.9) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.9) | [node](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-node.js) / [require](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-require.js) +2019-10-30 | [1.0.0](https://github.com/ArnaudBuchholz/gpf-js/tree/v1.0.0) | [First productive version](https://gpf-js.blogspot.com/p/release-notes-are-coming.html?version=1.0.0) | [lib](https://arnaudbuchholz.github.io/gpf/1.0.0/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=1.0.0) | [lib](https://arnaudbuchholz.github.io/gpf/1.0.0/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=1.0.0) | [node](https://arnaudbuchholz.github.io/gpf/1.0.0/gpf-node.js) / [require](https://arnaudbuchholz.github.io/gpf/1.0.0/gpf-require.js) +2019-03-12 | [0.2.9](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.9) | [ES6 Support](https://gpf-js.blogspot.com/2019/03/release-029-es6-support.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.9) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.9) | [node](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-node.js) / [require](https://arnaudbuchholz.github.io/gpf/0.2.9/gpf-require.js) 2018-12-03 | [0.2.8](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.8) | [Serialization attributes](https://gpf-js.blogspot.com/2018/12/release-028.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.8/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.8) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.8/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.8) | [require](https://arnaudbuchholz.github.io/gpf/0.2.8/gpf-require.js) 2018-08-04 | [0.2.7](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.7) | [Quality and XML](https://gpf-js.blogspot.com/2018/08/release-027-quality-and-xml.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.7/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.7) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.7/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.7) | [require](https://arnaudbuchholz.github.io/gpf/0.2.7/gpf-require.js) 2018-05-03 | [0.2.6](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.6) | [gpf.require.js](https://gpf-js.blogspot.com/2018/05/release-026-gpfrequirejs.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.6/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.6) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.6/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.6) | [require](https://arnaudbuchholz.github.io/gpf/0.2.6/gpf-require.js) -2018-04-03 | [0.2.5](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.5) | [Flavors](https://gpf-js.blogspot.com/2018/04/release-025-flavors.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.5/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.5) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.5/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.5) | -2018-02-28 | [0.2.4](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.4) | [Attributes](https://gpf-js.blogspot.com/2018/03/release-024-attributes.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.4/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.4) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.4/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.4) | -2017-12-20 | [0.2.3](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.3) | [Streams and Pipes](https://gpf-js.blogspot.com/2017/12/release-023-streams-and-pipes.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.3/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.3) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.3/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.3) | -2017-11-01 | [0.2.2](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.2) | [gpf.require](https://gpf-js.blogspot.com/2017/11/release-022-gpfrequire.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.2/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.2) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.2/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.2) | -2017-06-06 | [0.2.1](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.1) | [Side project support](https://gpf-js.blogspot.com/2017/06/release-021-side-project-support.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.1/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.1) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.1/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.1) | -2017-04-29 | [0.1.9](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.9) | [Records files](https://gpf-js.blogspot.com/2017/04/release-019-records-files.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.9/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.9) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.9/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.9) | -2017-03-26 | [0.1.8](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.8) | [Interfaces](https://gpf-js.blogspot.com/2017/03/release-018.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.8/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.8) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.8/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.8) | -2017-03-02 | [0.1.7](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.7) | [Securing gpf.define](https://gpf-js.blogspot.com/2017/03/release-017.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.7/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.7) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.7/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.7) | -2017-02-05 | [0.1.6](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.6) | [gpf.define](https://gpf-js.blogspot.com/2017/02/release-016.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.6/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.6) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.6/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.6) | -2016-12-05 | [0.1.5](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.5) | [The new core](https://gpf-js.blogspot.com/2016/12/release-015.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.5/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.5) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.5/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.5) | +2018-04-03 | [0.2.5](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.5) | [Flavors](https://gpf-js.blogspot.com/2018/04/release-025-flavors.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.5/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.5) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.5/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.5) | +2018-02-28 | [0.2.4](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.4) | [Attributes](https://gpf-js.blogspot.com/2018/03/release-024-attributes.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.4/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.4) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.4/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.4) | +2017-12-20 | [0.2.3](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.3) | [Streams and Pipes](https://gpf-js.blogspot.com/2017/12/release-023-streams-and-pipes.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.3/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.3) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.3/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.3) | +2017-11-01 | [0.2.2](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.2) | [gpf.require](https://gpf-js.blogspot.com/2017/11/release-022-gpfrequire.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.2/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.2) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.2/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.2) | +2017-06-06 | [0.2.1](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.2.1) | [Side project support](https://gpf-js.blogspot.com/2017/06/release-021-side-project-support.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.1/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.2.1) | [lib](https://arnaudbuchholz.github.io/gpf/0.2.1/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.2.1) | +2017-04-29 | [0.1.9](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.9) | [Records files](https://gpf-js.blogspot.com/2017/04/release-019-records-files.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.9/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.9) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.9/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.9) | +2017-03-26 | [0.1.8](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.8) | [Interfaces](https://gpf-js.blogspot.com/2017/03/release-018.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.8/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.8) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.8/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.8) | +2017-03-02 | [0.1.7](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.7) | [Securing gpf.define](https://gpf-js.blogspot.com/2017/03/release-017.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.7/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.7) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.7/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.7) | +2017-02-05 | [0.1.6](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.6) | [gpf.define](https://gpf-js.blogspot.com/2017/02/release-016.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.6/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.6) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.6/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.6) | +2016-12-05 | [0.1.5](https://github.com/ArnaudBuchholz/gpf-js/tree/v0.1.5) | [The new core](https://gpf-js.blogspot.com/2016/12/release-015.html) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.5/gpf.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?release=0.1.5) | [lib](https://arnaudbuchholz.github.io/gpf/0.1.5/gpf-debug.js) / [test](https://arnaudbuchholz.github.io/gpf/test.html?debug=0.1.5) | ## Credits diff --git a/build/gpf-debug.js b/build/gpf-debug.js index 9c07e5db..fd257e72 100644 --- a/build/gpf-debug.js +++ b/build/gpf-debug.js @@ -41,7 +41,7 @@ * GPF Version * @since 0.1.5 */ - _gpfVersion = "0.2.9", _GPF_NOT_FOUND = -1, _GPF_START = 0, _GPF_FS_WSCRIPT_READING = 1, + _gpfVersion = "1.0.0", _GPF_NOT_FOUND = -1, _GPF_START = 0, _GPF_FS_WSCRIPT_READING = 1, /** * Host constants * @since 0.1.5 @@ -366,7 +366,7 @@ for (var property in object) { /* istanbul ignore else */ // hasOwnProperty.1 - if (object.hasOwnProperty(property)) { + if (Object.prototype.hasOwnProperty.call(object, property)) { callback.call(thisArg, object[property], property, object); } } @@ -377,7 +377,7 @@ "constructor", "toString" ].forEach(function (property) { - if (object.hasOwnProperty(property)) { + if (Object.prototype.hasOwnProperty.call(object, property)) { callback.call(thisArg, object[property], property, object); } }); @@ -692,7 +692,7 @@ function _gpfArrayForEachOwn(array, callback) { var len = array.length, idx = 0; while (idx < len) { - if (array.hasOwnProperty(idx)) { + if (Object.prototype.hasOwnProperty.call(array, idx)) { callback(array[idx], idx, array); } ++idx; @@ -701,7 +701,7 @@ function _gpfArrayEveryOwn(array, callback, startIdx) { var len = array.length, idx = startIdx; while (idx < len) { - if (array.hasOwnProperty(idx) && callback(array[idx], idx, array) !== true) { + if (Object.prototype.hasOwnProperty.call(array, idx) && callback(array[idx], idx, array) !== true) { return false; } ++idx; @@ -882,18 +882,26 @@ function _generateBindBuilderSource(length) { return "var me = this;\n" + "return function (" + _gpfBuildFunctionParameterList(length).join(", ") + ") {\n" + " var args = _gpfArraySlice(arguments);\n" + " return me.apply(thisArg, prependArgs.concat(args));\n" + "};"; } + function _generateSimpleBindBuilderSource(length) { + return "var me = this;\n" + "return function (" + _gpfBuildFunctionParameterList(length).join(", ") + ") {\n" + " return me.apply(thisArg, arguments);\n" + "};"; + } var _GPF_COMPATIBILITY_FUNCTION_MIN_LENGTH = 0; _gpfCompatibilityInstallMethods("Function", { on: Function, methods: { // Introduced with JavaScript 1.8.5 bind: function (thisArg) { - var me = this, prependArgs = _gpfArrayTail(arguments), length = Math.max(this.length - prependArgs.length, _GPF_COMPATIBILITY_FUNCTION_MIN_LENGTH), builderSource = _generateBindBuilderSource(length); - return _gpfFunc([ - "thisArg", - "prependArgs", - "_gpfArraySlice" - ], builderSource).call(me, thisArg, prependArgs, _gpfArraySlice); + var me = this, prependArgs = _gpfArrayTail(arguments), length = Math.max(this.length - prependArgs.length, _GPF_COMPATIBILITY_FUNCTION_MIN_LENGTH), builderSource; + if (prependArgs.length) { + builderSource = _generateBindBuilderSource(length); + return _gpfFunc([ + "thisArg", + "prependArgs", + "_gpfArraySlice" + ], builderSource).call(me, thisArg, prependArgs, _gpfArraySlice); + } + builderSource = _generateSimpleBindBuilderSource(length); + return _gpfFunc(["thisArg"], builderSource).call(me, thisArg); } } }); @@ -901,6 +909,15 @@ /*jshint validthis:true*/ this[memberName] = value; //eslint-disable-line no-invalid-this } + var _gpfStandardObjects = [ + Array, + Date, + Error, + Function, + Number, + RegExp, + String + ]; _gpfCompatibilityInstallMethods("Object", { on: Object, statics: { @@ -934,6 +951,11 @@ if (object.__proto__) { return object.__proto__; } + for (var index = 0; index < _gpfStandardObjects.length; ++index) { + if (object === _gpfStandardObjects[index].prototype) { + return Object.prototype; + } + } // May break if the constructor has been tampered with /* istanbul ignore next */ // wscript.node.1 @@ -943,7 +965,7 @@ keys: function (object) { var result = [], key; for (key in object) { - if (object.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(object, key)) { result.push(key); } } @@ -953,7 +975,7 @@ values: function (object) { var result = [], key; for (key in object) { - if (object.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(object, key)) { result.push(object[key]); } } @@ -1211,6 +1233,7 @@ } }; var _GpfPromise = gpf.Promise = function (fn) { + this._handlers = []; _gpfPromiseSafeResolve(fn, _gpfPromiseResolve.bind(this), _gpfPromiseReject.bind(this)); }; function _gpfPromiseHandler() { @@ -1245,6 +1268,13 @@ me.resolve(result); } var _GPF_COMPATIBILITY_PROMISE_NODELAY = 0; + var _gpfPromiseHandlersToProcess = []; + function _gpfPromiseProcessHandlers() { + while (_gpfPromiseHandlersToProcess.length) { + var that = _gpfPromiseHandlersToProcess.shift(), promise = _gpfPromiseHandlersToProcess.shift(); + _gpfPromiseAsyncProcess.call(that, promise); + } + } _gpfPromiseHandler.prototype = { onFulfilled: null, onRejected: null, @@ -1255,15 +1285,13 @@ var me = this; //eslint-disable-line no-invalid-this if (promise._state === null) { - /* istanbul ignore else */ - // hasOwnProperty.1 - if (!promise.hasOwnProperty("_handlers")) { - promise._handlers = []; - } promise._handlers.push(me); return; } - setTimeout(_gpfPromiseAsyncProcess.bind(me, promise), _GPF_COMPATIBILITY_PROMISE_NODELAY); + if (!_gpfPromiseHandlersToProcess.length) { + setTimeout(_gpfPromiseProcessHandlers, _GPF_COMPATIBILITY_PROMISE_NODELAY); + } + _gpfPromiseHandlersToProcess.push(me, promise); } }; _GpfPromise.prototype = { @@ -2748,7 +2776,7 @@ if (classDefinition._extend === classDefinition._resolvedConstructor) { return "var that = Reflect.construct(_classDef_._extend, arguments, _classDef_._instanceBuilder);\n"; } - return "var that,\n" + " $super = function () {\n" + " that = Reflect.construct(_classDef_._extend, arguments, _classDef_._instanceBuilder);\n" + " },\n" + " hasOwnProperty = function (name) {\n" + " return !!that && that.hasOwnProperty(name);\n" + " },\n" + " proxy = new Proxy({}, {\n" + " get: function (obj, property) {\n" + " if (property === \"hasOwnProperty\") {\n" + " return hasOwnProperty;\n" + " }\n" + " if (!that && property === \"$super\") {\n" + " return $super;\n" + " }\n" + " return that[property];\n" + " },\n" + " set: function (obj, property, value) {\n" + " if (property !== \"$super\") {\n" + " that[property] = value;\n" + " }\n" + " return true;\n" + " }\n" + " });\n" + "_classDef_._resolvedConstructor.apply(proxy, arguments);\n"; + return "var that,\n" + " $super = function () {\n" + " that = Reflect.construct(_classDef_._extend, arguments, _classDef_._instanceBuilder);\n" + " },\n" + " hasOwnProperty = function (name) {\n" + " return !!that && Object.prototype.hasOwnProperty.call(that, name);\n" + " },\n" + " proxy = new Proxy({}, {\n" + " get: function (obj, property) {\n" + " if (property === \"hasOwnProperty\") {\n" + " return hasOwnProperty;\n" + " }\n" + " if (!that && property === \"$super\") {\n" + " return $super;\n" + " }\n" + " return that[property];\n" + " },\n" + " set: function (obj, property, value) {\n" + " if (property !== \"$super\") {\n" + " that[property] = value;\n" + " }\n" + " return true;\n" + " }\n" + " });\n" + "_classDef_._resolvedConstructor.apply(proxy, arguments);\n"; } function _gpfDefineGetClassSecuredConstructorGetMainConstructionPattern(classDefinition) { if (_gpfIsClass(classDefinition._extend)) { @@ -2932,7 +2960,7 @@ * Body of superified method * @since 0.1.7 */ - _superifiedBody: "var _super_;\n" + "if (this.hasOwnProperty(\"$super\")) {\n" + " _super_ = this.$super;\n" + "}\n" + "this.$super = _classDef_._get$Super(this, _methodName_, _superMembers_);\n" + "try{\n" + " var _result_ = _method_.apply(this, arguments);\n" + "} finally {\n" + " if (undefined === _super_) {\n" + " delete this.$super;\n" + " } else {\n" + " this.$super = _super_;\n" + " }\n" + "}\n" + "return _result_;", + _superifiedBody: "var _super_;\n" + "if (Object.prototype.hasOwnProperty.call(this, \"$super\")) {\n" + " _super_ = this.$super;\n" + "}\n" + "this.$super = _classDef_._get$Super(this, _methodName_, _superMembers_);\n" + "try{\n" + " var _result_ = _method_.apply(this, arguments);\n" + "} finally {\n" + " if (undefined === _super_) {\n" + " delete this.$super;\n" + " } else {\n" + " this.$super = _super_;\n" + " }\n" + "}\n" + "return _result_;", /** * Generates context for the superified method * @@ -3051,7 +3079,7 @@ * @since 0.1.7 */ _resolveConstructor: function () { - if (this._initialDefinition.hasOwnProperty("constructor")) { + if (Object.prototype.hasOwnProperty.call(this._initialDefinition, "constructor")) { /* jshint -W069*/ /*eslint-disable dot-notation*/ this._resolvedConstructor = this._superify(this._initialDefinition["constructor"], "constructor"); /* jshint +W069*/ @@ -4367,12 +4395,19 @@ //eslint-disable-line no-invalid-this stream = me._stream; return new Promise(function (resolve, reject) { + var noDrain; me._reject = reject; me._checkIfValid(); - if (stream.write(buffer)) { - return resolve(); + noDrain = stream.write(buffer, function (error) { + if (!error && noDrain) { + resolve(); + } + }); + if (!noDrain) { + stream.once("drain", function () { + resolve(); + }); } - stream.once("drain", resolve); }); }) //endregion }); @@ -5736,6 +5771,9 @@ * - {@link gpf.stream.BufferedRead#_completeReadBuffer} * - {@link gpf.stream.BufferedRead#_setReadError} * + * Make sure to implement the {@link gpf.interfaces.IFlushableStream} interface + * to complete the buffer. + * * @constructor gpf.stream.BufferedRead * @implements {gpf.interfaces.IReadableStream} * @since 0.2.3 @@ -6587,6 +6625,12 @@ return Promise.resolve(); }), //endregion + /** + * Gets the array containing writen data + * + * @return {Array} array containing writen data + * @since 0.2.2 + */ toArray: function () { return this._buffer; }, @@ -6602,52 +6646,75 @@ function _gpfStreamPipeToFlushable(stream) { return _gpfInterfaceQuery(_gpfIFlushableStream, stream) || _gpfStreamPipeFakeFlushable; } - function _gpfStreamPipeAllocateState(intermediate, destination) { + function _gpfStreamPipeCouplerDebug(coupler, message) { + _gpfIgnore(coupler, message); // if (console.expects) { + // console.expects("log", /.*/, true); + // } + // console.log("gpf.stream.pipe/coupler@" + coupler.index + " [" + coupler.fromName + "::" + coupler.toName + "] " + // + message); + } + function _gpfStreamPipeAllocateCoupler(intermediate, destination) { + var toName; + if (destination._isCoupler === _gpfStreamPipeCouplerDebug) { + toName = "(coupler)"; + } else { + toName = _gpfGetFunctionName(destination.constructor); + } return { + from: intermediate, + fromName: _gpfGetFunctionName(intermediate.constructor), + to: destination, + toName: toName, iReadableIntermediate: _gpfStreamQueryReadable(intermediate), iWritableIntermediate: _gpfStreamQueryWritable(intermediate), iFlushableIntermediate: _gpfStreamPipeToFlushable(intermediate), iWritableDestination: _gpfStreamQueryWritable(destination), iFlushableDestination: _gpfStreamPipeToFlushable(destination), + readInProgress: false, readError: null, - rejectWrite: _gpfEmptyFunc + readPromise: Promise.resolve(), + rejectWrite: _gpfEmptyFunc, + flushed: false }; } - function _gpfStreamPipeAllocateRead(state) { + function _gpfStreamPipeCouplerDrain(coupler) { // Read errors must be transmitted up to the initial read, this is done by forwarding it to flush & write - var readingDone = true, iReadableIntermediate = state.iReadableIntermediate, iWritableDestination = state.iWritableDestination; - return function () { - if (readingDone) { - try { - readingDone = false; - iReadableIntermediate.read(iWritableDestination).then(function () { - readingDone = true; - }, function (reason) { - state.readError = reason; - state.rejectWrite(reason); - }); - } catch (e) { - state.readError = e; - } + var iReadableIntermediate = coupler.iReadableIntermediate, iWritableDestination = coupler.iWritableDestination; + if (coupler.readInProgress) { + _gpfStreamPipeCouplerDebug(coupler, "read in progress"); + } + if (!coupler.readInProgress) { + try { + coupler.readInProgress = true; + _gpfStreamPipeCouplerDebug(coupler, "read started"); + coupler.readPromise = iReadableIntermediate.read(iWritableDestination).then(function () { + _gpfStreamPipeCouplerDebug(coupler, "read ended"); + coupler.readInProgress = false; + }, function (reason) { + coupler.readError = reason; + coupler.rejectWrite(reason); + }); + } catch (e) { + coupler.readError = e; } - }; + } } - function _gpfStreamPipeWrapWrite(state, promise) { + function _gpfStreamPipeCouplerWrite(coupler, promise) { return new Promise(function (resolve, reject) { promise.then(function (value) { resolve(value); - state.rejectWrite = _gpfEmptyFunc; + coupler.rejectWrite = _gpfEmptyFunc; }, reject); - state.rejectWrite = reject; + coupler.rejectWrite = reject; }); } - function _gpfStreamPipeCheckIfReadError(state) { - if (state.readError) { - return Promise.reject(state.readError); + function _gpfStreamPipeCheckIfReadError(coupler) { + if (coupler.readError) { + return Promise.reject(coupler.readError); } } /** - * Create a flushable & writable stream by combining the intermediate stream with the writable destination + * Create a flushable & writable stream by coupling the intermediate stream with the writable destination * * @param {Object} intermediate Must implements IReadableStream interface. * If it implements the IFlushableStream interface, it is assumed that it retains data @@ -6657,35 +6724,47 @@ * least to pass it to the destination * @param {Object} destination Must implements IWritableStream interface. * If it implements the IFlushableStream, it will be called when the intermediate completes. + * @param {Number} index zero-based index of the coupler, helps for debugging. * * @return {Object} Implementing IWritableStream and IFlushableStream * @since 0.2.3 */ - function _gpfStreamPipeToFlushableWrite(intermediate, destination) { - var state = _gpfStreamPipeAllocateState(intermediate, destination), read = _gpfStreamPipeAllocateRead(state), iFlushableIntermediate = state.iFlushableIntermediate, iFlushableDestination = state.iFlushableDestination, iWritableIntermediate = state.iWritableIntermediate; - read(); + function _gpfStreamPipeWeldCoupler(intermediate, destination, index) { + var coupler = _gpfStreamPipeAllocateCoupler(intermediate, destination), iFlushableIntermediate = coupler.iFlushableIntermediate, iFlushableDestination = coupler.iFlushableDestination, iWritableIntermediate = coupler.iWritableIntermediate; + coupler.index = index; + _gpfStreamPipeCouplerDrain(coupler); return { + _isCoupler: _gpfStreamPipeCouplerDebug, flush: function () { - return _gpfStreamPipeCheckIfReadError(state) || iFlushableIntermediate.flush().then(function () { + _gpfAssert(!coupler.flushed, "A flushed coupler can't be flushed again"); + _gpfStreamPipeCouplerDebug(coupler, "flush"); + coupler.flushed = true; + return _gpfStreamPipeCheckIfReadError(coupler) || iFlushableIntermediate.flush().then(function () { + return coupler.readPromise; // Wait for any pending read + }).then(function () { return iFlushableDestination.flush(); + }).then(function () { + _gpfStreamPipeCouplerDebug(coupler, "flush ended"); }); }, write: function (data) { - read(); - return _gpfStreamPipeCheckIfReadError(state) || _gpfStreamPipeWrapWrite(state, iWritableIntermediate.write(data)); + _gpfAssert(!coupler.flushed, "A flushed coupler can't be written to"); + _gpfStreamPipeCouplerDebug(coupler, "write(" + JSON.stringify(data) + ")"); + _gpfStreamPipeCouplerDrain(coupler); + return _gpfStreamPipeCheckIfReadError(coupler) || _gpfStreamPipeCouplerWrite(coupler, iWritableIntermediate.write(data)); } }; } - function _gpfStreamPipeReduce(streams) { + function _gpfStreamPipeWeldCouplers(streams) { var idx = streams.length, iWritableStream = streams[--idx]; while (idx) { - iWritableStream = _gpfStreamPipeToFlushableWrite(streams[--idx], iWritableStream); + iWritableStream = _gpfStreamPipeWeldCoupler(streams[--idx], iWritableStream, idx); } return iWritableStream; } function _gpfStreamPipeToWritable(streams) { if (_gpfArrayTail(streams).length) { - return _gpfStreamPipeReduce(streams); + return _gpfStreamPipeWeldCouplers(streams); } return _gpfStreamQueryWritable(streams[_GPF_START]); } @@ -6693,7 +6772,9 @@ * Pipe streams. * * @param {gpf.interfaces.IReadableStream} source Source stream - * @param {...gpf.interfaces.IWritableStream} destination Writable streams + * @param {...gpf.interfaces.IWritableStream} destination streams to pipe data through. + * It is assumed that the last destination stream will not block data receiving if readable), + * every other intermediate stream must also implement {@link gpf.interfaces.IReadableStream} interface * @return {Promise} Resolved when reading (and subsequent writings) are done * @since 0.2.3 */ @@ -7189,7 +7270,7 @@ return this._extend && this._extend.prototype[name] !== undefined; }, _hasMember: function (name) { - return this._initialDefinition.hasOwnProperty(name) || this._hasInheritedMember(name); + return Object.prototype.hasOwnProperty.call(this._initialDefinition, name) || this._hasInheritedMember(name); }, /** * Given the member name, check if it exists @@ -7282,7 +7363,7 @@ */ function _gpfDefClassAttrBuild(member, attribute, newPrototype) { /*jshint validthis:true*/ - var attributeEntityDefinition = _gpfDefineEntitiesFindByConstructor(attribute.constructor); + var attributeEntityDefinition = _gpfDefineClassImport(attribute.constructor); if (!attributeEntityDefinition._singleton) { attribute._memberName = member; attribute._ClassConstructor = newPrototype.constructor; @@ -7370,11 +7451,7 @@ } }); function _gpfAttributesGetFromClass(classConstructor, baseAttributeClass) { - var entityDefinition = _gpfDefineEntitiesFindByConstructor(classConstructor); - if (entityDefinition) { - return entityDefinition.getAttributes(baseAttributeClass); - } - return {}; + return _gpfDefineClassImport(classConstructor).getAttributes(baseAttributeClass); } function _gpfAttributesGetConstructorFromTruthy(any) { if (typeof any !== "object") { @@ -8478,7 +8555,7 @@ */ _check: function (member, classDefinition) { _gpfIgnore(classDefinition); - this._property = _gpfSerialPropertyCheck(Object.assign({ name: _gpfAttributesSerializableExtractName(member) }, this._property)); + this._property = _gpfSerialPropertyCheck(Object.assign({ name: _gpfAttributesSerializableExtractName(member) }, this._property || {})); }, /** * @gpf:read _property @@ -8580,7 +8657,7 @@ function _gpfSerialRawFromProperties(instance, raw, converter) { var properties = _gpfSerialGetWithReadOnly(instance); _gpfObjectForEach(properties, function (property, member) { - if (raw.hasOwnProperty(property.name)) { + if (Object.prototype.hasOwnProperty.call(raw, property.name)) { _gpfSerialRawFromPropertyValue(instance, member, converter.call(instance, raw[property.name], property, member)); } }); diff --git a/build/gpf-node.js b/build/gpf-node.js index 67f69c86..7eca08de 100644 --- a/build/gpf-node.js +++ b/build/gpf-node.js @@ -1 +1 @@ -!function(t){"use strict";if("function"==typeof define&&define.amd)define(["exports"],t);else if("undefined"!=typeof exports)t(exports);else if("undefined"!=typeof module&&module.exports)t(module.exports);else{var e=Function("return this;")(),n={};t(n),e.gpf=n}}(function(o){"use strict";function c(){}var i,a,s,n,r,u=-1,f=0,t="browser",e="nashorn",l="nodejs",p="phantomjs",d="rhino",h="unknown",_="wscript",m=h,v=Function,b=new v("return this")();function g(t,e,n){return Array.prototype.slice.call(t,e,n||t.length)}"undefined"!=typeof WScript?m=_:"undefined"!=typeof print&&"undefined"!=typeof java?m="undefined"==typeof readFile?e:d:"undefined"!=typeof phantom&&phantom.version&&!document.currentScript?(m=p,b=window):"undefined"!=typeof module&&module.exports?(m=l,b=global):"undefined"!=typeof window&&(m=t,b=window),o.version=function(){return"0.2.9"},o.node={},l===m&&(n=require("path"),i=require("fs"),a=require("http"),s=require("https"),r=require("url"),"\\"===n.sep),o.hosts={browser:t,nashorn:e,nodejs:l,phantomjs:p,rhino:d,unknown:h,wscript:_},o.host=function(){return m};var y=1;function E(t){return g(t,y)}var w,x=Array.isArray;function O(t){return x(t)||function e(t){return!!t&&Math.floor(t.length)===t.length}(t)}function P(t,e,n){for(var r=0,i=t.length;r":">"};(function zr(t){var e=W(t);return D(e,function n(r){var i=["var C = this, l = arguments.length;","if (0 === l) { return new C();}"];return r.forEach(function(t,e){var n=1;n+=e,i.push("if ("+n+" === l) { return new C("+r.slice(f,n).join(", ")+");}")}),i.join("\n")}(e))})(10);var L=j+C+$+"+/=",U=63,X=18,V=12,z=6,Z=8,G=16,H=64,Q=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function J(t,e,n){var r=String.fromCharCode(t>>G&N);return e!==H?r+function i(t,e){return e===H?String.fromCharCode(t>>Z&N):String.fromCharCode(t>>Z&N,t&N)}(t,n):r}function K(t,e){return L.indexOf(t.charAt(e))}function Y(t,e){var n=t.charCodeAt(e);if(N>e&n)}function et(t,e){if(undefined!==t)return t[e]}function nt(t,e){var n=t[e];return undefined===n&&(n=t[e]={}),n}function rt(t,e){return function r(t,e){var n;return("gpf"===t[f]?(n=o,E(t)):(n=b,t)).reduce(e,n)}(t,e?nt:et)}F("atob",function Zr(t){var e,n,r,i,o,a=function f(t){var e=t.replace(/[\t\n\f\r ]+/g,"");if(!Q.test(e))throw new TypeError("The string to be decoded is not correctly encoded.");return e}(t),s=a.length,u=0,c="";for(a+="==";u"),gte:Qt("gte",">="),not:function(t){return"!"+zt(t.not)},like:function(t){var e=function n(t){return"/"+t.regexp+"/.exec("+zt(t.like)+")"}(t);return t.group?"("+e+"||[])["+t.group+"]":e},or:Qt("or","||"),and:Qt("and","&&"),undefined:function(t){return JSON.stringify(t)}},Kt=Object.keys(Jt);zt=function(t){var e=function n(t){if("object"==typeof t)return Object.keys(t).filter(function(t){return Kt.includes(t)})[f]}(t);return(0,Jt[e])(t)},o.createFilterFunction=function(t){return D(["i"],function e(t){return"return "+zt(t)}(t))};var Yt=Zt("ReadableStream",{"read":1}),te=Zt("WritableStream",{"write":1});function ee(t,e,n){return t||o.Error.interfaceExpected({name:n}),function i(t,e,n){var r=Xt(e,t);return r||o.Error.interfaceExpected({name:n}),r}(t,e,n)}function ne(t){return ee(t,Yt,"gpf.interfaces.IReadableStream")}function re(t){return ee(t,te,"gpf.interfaces.IWritableStream")}Zt("Enumerator",{"reset":0,"moveNext":0,"getCurrent":0}),Zt("FileStorage",{"getInfo":1,"openTextStream":2,"close":1,"explore":1,"createDirectory":1,"deleteFile":1,"deleteDirectory":1}),dt(0,{readInProgress:"A read operation is already in progress",writeInProgress:"A write operation is already in progress",invalidStreamState:"Stream is in an invalid state"}),o.stream={};var ie="gpf.stream#progress",oe=ie+"/read",ae=ie+"/write";function se(t){t.prototype[oe]=!1,t.prototype[ae]=!1}function ue(t,e,n){t[e]&&o.Error[n](),t[e]=!0}function ce(t){t[oe]=!1}function fe(t){t[ae]=!1}function le(t,e,n){return t.then(function(t){return n(e),Promise.resolve(t)},function(t){return n(e),Promise.reject(t)})}function pe(r){return function(t){var e=re(t);return function n(t){ue(t,oe,"readInProgress")}(this),le(r.call(this,e),this,ce)}}function de(n){return function(t){return function e(t){ue(t,ae,"writeInProgress")}(this),le(n.call(this,t),this,fe)}}var he=Lt({$class:"gpf.stream.ReadableString",constructor:function(t){this._buffer=t},read:pe(function(t){return t.write(this._buffer)}),_buffer:""}),_e=Lt({$class:"gpf.stream.WritableString",constructor:function(){this._buffer=[]},write:de(function(t){return this._buffer.push(t.toString()),Promise.resolve()}),toString:function(){return this._buffer.join("")},_buffer:[]});se(he),se(_e),dt(0,{incompatibleStream:"Incompatible stream"});var me={NOT_FOUND:0,DIRECTORY:1,FILE:2,UNKNOWN:3},ve=0,be=1,ge=null;function ye(t){t.length?t.pop():o.Error.unreachablePath()}function Ee(t){var e=function n(t){return t.includes("\\")?t.toLowerCase().split("\\"):t.split("/")}(t);return function r(t){var e=t.pop();e&&t.push(e)}(e),e}function we(t){return Ee(t).join("/")}function xe(t){return t?Ee(t).pop():""}function Oe(t){var e=xe(t),n=e.lastIndexOf(".");return n===u?"":e.substring(n)}o.fs={types:{notFound:me.NOT_FOUND,directory:me.DIRECTORY,file:me.FILE,unknown:me.UNKNOWN},openFor:{reading:ve,appending:be},getFileStorage:function(){return ge}},dt(0,{unreachablePath:"Unreachable path"});var Pe={"":function(t){t.length=0,t.push("")},".":c,"..":function(t){ye(t)}};function Se(t){var e=Ee(t);return E(arguments).forEach(function r(n,t){P(Ee(t),function(t){var e=Pe[t];e?e(n):n.push(t)})}.bind(null,e)),e.join("/")}function Ie(t,e){t.length*e.length&&function n(t,e){for(;t[f]===e[f];)t.shift(),e.shift()}(t,e)}function ke(t){var e=Ee(t);return ye(e),e.join("/")}o.path={join:Se,parent:ke,name:xe,nameOnly:function(t){var e=xe(t),n=e.lastIndexOf(".");return n===u?e:e.substring(f,n)},extension:Oe,relative:function Qr(t,e){var n,r=Ee(t),i=Ee(e);for(Ie(r,i),n=r.length;n--;)i.unshift("..");return i.join("/")}};var Ne=Lt({$class:"gpf.node.BaseStream",constructor:function(t,e){this._stream=t,"function"==typeof e&&(this._close=e),t.on("error",this._onError.bind(this))},_close:c,close:function(){return this._close()},_stream:null,_invalid:!1,_reject:o.Error.invalidStreamState,_checkIfValid:function(){this._invalid&&o.Error.invalidStreamState()},_onError:function(t){this._invalid=!0,this._reject(t)}}),Ce=Lt({$class:"gpf.node.ReadableStream",$extend:"gpf.node.BaseStream",read:pe(function(n){var r=this,i=r._stream;return new Promise(function(t,e){r._reject=e,r._checkIfValid(),i.on("data",r._onData.bind(r,n)).on("end",function(){r._invalid=!0,t()})})}),_onData:function(t,e){var n=this._stream;n.pause(),t.write(e).then(function(){n.resume()},this._reject)}}),je=Lt({$class:"gpf.node.WritableStream",$extend:"gpf.node.BaseStream",write:de(function(n){var r=this,i=r._stream;return new Promise(function(t,e){if(r._reject=e,r._checkIfValid(),i.write(n))return t();i.once("drain",t)})})});function $e(t,e){return new Promise(function(n,r){i[t].apply(i,e.concat([function(t,e){t?r(t):n(e)}]))})}function Ae(t,e){return $e(t,[we(e)])}function Re(t,e){return $e("open",[we(t),e.flags]).then(function(t){return new e.GpfStream(i[e.nodeStream]("",{fd:t,autoClose:!1}),$e.bind(null,"close",[t]))})}function De(t){return t.isDirectory()?me.DIRECTORY:function e(t){return t.isFile()?me.FILE:me.UNKNOWN}(t)}!function Jr(t,e){t===m&&(ge=new e)}(l,Lt({$class:"gpf.node.FileStorage",getInfo:function(t){var e=we(t);return new Promise(function(t){i.exists(e,t)}).then(function(t){return t?Ae("stat",e).then(function(t){return{fileName:n.basename(e),filePath:we(n.resolve(e)),size:t.size,createdDateTime:t.ctime,modifiedDateTime:t.mtime,type:De(t)}}):{type:me.NOT_FOUND}})},openTextStream:function(t,e){return ve===e?function n(t){return Re(t,{flags:"r",GpfStream:Ce,nodeStream:"createReadStream"})}(t):function r(t){return Re(t,{flags:"a",GpfStream:je,nodeStream:"createWriteStream"})}(t)},close:function Kr(e){return function(t){return t instanceof e?t.close():Promise.reject(new o.Error.IncompatibleStream)}}(Ne),explore:function(e){var n=this;return Ae("readdir",e).then(function(t){return function i(t,e){var n,r=-1;return{reset:function(){return r=-1,Promise.resolve()},moveNext:function(){return++r,n=undefined,r"+this._getChildrenAsString()+"":"/>"},toString:function(){return We(this._nodeName),"<"+this._nodeName+this._getAttributesAsString()+this._getClosingString()},_createElement:function(t){var e=t.ownerDocument,n=Fe(this._nodeName);return n?e.createElementNS(n.namespace,n.name):e.createElement(this._nodeName)},_setAttributesTo:function(r){w(this._attributes,function(t,e){var n=Fe(e);n?r.setAttributeNS(n.namespace,Le(n.name),t):r.setAttribute(Le(e),t)})},_appendChildrenTo:function(e){var n=e.ownerDocument;Ue(this._children,function(t){t instanceof Xe?t.appendTo(e):e.appendChild(n.createTextNode(t.toString()))})},appendTo:function(t){var e=this._createElement(t);return this._setAttributesTo(e),this._appendChildrenTo(e),t.appendChild(e)}});o.web.createTagFunction=function Yr(r){return r||o.Error.missingNodeName(),function(t){var e,n=0;return Me(t)&&(e=t,++n),new Xe(r,e,g(arguments,n))}},o.http={};var Ve="GET",ze="POST",Ze="PUT",Ge="OPTIONS",He="DELETE",Qe="HEAD";new RegExp("([^:\\s]+)\\s*: ?([^\\r]*)","gm");var Je,Ke;Zt("Thenable",{"then":2});function Ye(t){return o.interfaces.isImplementedBy(o.interfaces.IThenable,t)?t:Promise.resolve(t)}function tn(t,e){var n=Je;return t===m&&(Je=e),n}function en(n){return new Promise(function(t,e){Je(n,t,e)})}function nn(t,e,n){return en("string"==typeof e?{method:t,url:e,data:n}:Object.assign({method:t},e))}function rn(e,n){e.setEncoding("utf8");var r=new Ce(e);(function i(t){var e=new _e;return ne(t).read(e).then(function(){return e.toString()})})(r).then(function(t){r.close(),n({status:e.statusCode,headers:e.headers,responseText:t})})}function on(t){var e=Object.assign(r.parse(t.url),t);return function n(t,e){e&&(t.headers=Object.assign({"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(e)},t.headers))}(e,t.data),e}function an(t,e){var n=on(t);return function r(t){return"https:"===t.protocol?s:a}(n).request(n,function(t){rn(t,e)})}function sn(t,e){var n;return t.every(function(t){return(n=function i(t,e){var n,r=t.url;if(r.lastIndex=0,n=r.exec(e.url))return t.response.apply(t,[e].concat(E(n)))}(t,e))===undefined}),n}function un(t){return Ke[t]||(Ke[t]=[]),Ke[t]}o.promisify=Ye,o.promisifyDefined=function ti(t){if(undefined!==t)return Ye(t)},Object.assign(o.http,{methods:{get:Ve,post:ze,put:Ze,options:Ge,"delete":He,head:Qe},request:en,get:nn.bind(o.http,Ve),post:nn.bind(o.http,ze),put:nn.bind(o.http,Ze),options:nn.bind(o.http,Ge),"delete":nn.bind(o.http,He),head:nn.bind(o.http,Qe)}),tn(l,function ei(t,e,n){var r=an(t,e);r.on("error",n),function i(t,e){e?t.write(e,"utf8",function(){t.end()}):t.end()}(r,t.data)});var cn,fn=0;function ln(){Ke={}}function pn(){}ln(),o.http.mock=function ni(t){var e=t.method.toUpperCase(),n=e+"."+fn++;return un(e).unshift(Object.assign({id:n},t)),n},o.http.mock.remove=function ri(e){var t=e.substring(f,e.indexOf("."));Ke[t]=un(t).filter(function(t){return t.id!==e})},o.http.mock.reset=ln,cn=tn(m,function ii(t,e,n){var r=function i(t){return sn(un(t.method.toUpperCase()),t)}(t);undefined===r?cn(t,e,n):e(r)}),pn.prototype={execute:c};var dn=new pn,hn=new pn;dn.execute=function(t){t._readReject(t._readBuffer.shift())},hn.execute=function(t){t._readResolve()};var _n=Lt({$class:"gpf.stream.BufferedRead",constructor:function(){this._readBuffer=[]},_readBuffer:[],_readWriteToStream:null,_readResolve:null,_readReject:null,_readDataIsToken:function(t){return t instanceof pn&&(t.execute(this),!0)},_readWriteToOutput:function(){var t=this,e=t._readBuffer.shift();return t._readDataIsToken(e)?Promise.resolve():t._readWriteToStream.write(e).then(function(){if(t._readBuffer.length)return t._readWriteToOutput();t._readNotWriting=!0})},_readNotWriting:!0,_readSafeWrite:function(){var e=this;e._readNotWriting&&(e._readNotWriting=!1,e._readWriteToOutput().then(undefined,function(t){e._readReject(t)}))},_readCheckIfData:function(){this._readBuffer.length&&this._readSafeWrite()},_readCheckIfOutput:function(){this._readWriteToStream&&this._readCheckIfData()},_appendToReadBuffer:function(t){return this._readBuffer=this._readBuffer.concat(g(arguments)),this._readCheckIfOutput(),this},_completeReadBuffer:function(){this._readBuffer.push(hn),this._readCheckIfOutput()},_setReadError:function(t){this._readBuffer.push(dn,t),this._readCheckIfOutput()},read:pe(function(t){var n=this;return n._readWriteToStream=t,n._readCheckIfData(),new Promise(function(t,e){n._readResolve=t,n._readReject=e})})});se(_n);var mn=/\r\n/g,vn=(Lt({$class:"gpf.stream.LineAdapter",$extend:_n,constructor:function(){this.$super(),this._buffer=[]},write:de(function(t){return this._buffer.push(t.toString()),this._process(),Promise.resolve()}),flush:function(){return this._buffer.length&&(this._buffer.push("\n"),this._process()),this._completeReadBuffer(),Promise.resolve()},_buffer:[],_consolidateLines:function(){return this._buffer.join("").replace(mn,"\n").split("\n")},_pushBackLastLineIfNotEmpty:function(t){var e=t.pop();e.length&&this._buffer.push(e)},_process:function(){var e=this,t=e._consolidateLines();e._buffer.length=0,e._pushBackLastLineIfNotEmpty(t),P(t,function(t){e._appendToReadBuffer(t)})}}),Zt("FlushableStream",{"flush":0})),bn={};function gn(t){return bn(t)}o.read=gn,o.fs&&(o.fs.read=gn),function oi(t,e){t===m&&(bn=e)}(l,function ai(t){return new Promise(function(n,r){i.readFile(t,function(t,e){t?r(t):n(e.toString())})})});var yn={};function En(t,e){return Promise.resolve(e)}function wn(e){var n=this;return function r(t,e){var n=t.preload[e];return n?Promise.resolve(n):gn(e)}(n,e).then(function(t){return n.preprocess({name:e,content:t,type:Oe(e).toLowerCase()})}).then(function(t){return function e(t){return yn[t.type]||En}(t).call(n,t.name,t.content)})}function xn(t,e){return function r(t,e){return t._initialDefine=e.define,e.define=function n(){var t=this.gpf.require,e=this._initialDefine;return this.promise=e.apply(t,arguments),t.define=e,this.promise}.bind(t),t.gpf.require=e,t}(function n(){return{gpf:Object.create(o),promise:Promise.resolve(),_initialDefine:null}}(),Rn(t,{base:ke(e)}))}yn[".json"]=function(t,e){return JSON.parse(e)},dt(0,{noCommonJSDynamicRequire:"Dynamic require not supported"});var On=/[^.]\brequire\b\s*\(\s*(?:['|"]([^"']+)['|"]|[^)]+)\s*\)/g;var Pn,Sn=[null,function si(t){return{dependencies:[],factory:t}},function ui(t,e){return{dependencies:t,factory:e}},function ci(t,e,n){return{dependencies:e,factory:n}}];function In(t,e,n){var r={};return D(["gpf","define","module","require"],e)(t,function i(t,e,n){var r=Sn[arguments.length].apply(null,arguments);this.require.define(r.dependencies,function(t){return t.length=r.dependencies.length,r.factory.apply(null,g(t))})}.bind(t),r,function(t){return n[t]||o.Error.noCommonJSDynamicRequire()}),r.exports}Pn=t===m?function fi(t,e){var n=location.pathname.toString();return n.endsWith("/")||(n=ke(n)),"//# sourceURL="+location.origin+Se(n,t)+"?gpf.require\n"+e}:function li(t,e){return e},yn[".js"]=function(n,r){var i=xn(this,n);return function o(t,e){var n=bt(On,e);return n.length?xn(this,t).gpf.require.define(n.map(function(t){return t[1]}).filter(function(t){return t}).reduce(function(t,e){return t[e]=e,t},{}),function(t){return t}):Promise.resolve({})}.call(this,n,r).then(function(t){var e=In(i.gpf,Pn(n,r),t);return undefined===e?i.promise:e})},dt(0,{invalidRequireConfigureOption:"Invalid configuration option",invalidRequireConfigureOptionValue:"Invalid configuration option value"});var kn={},Nn=[];function Cn(t,e,n){n?Nn.unshift(t):Nn.push(t),kn[t]=e}function jn(e){!function r(t){P(Object.keys(t),function(t){kn[t]||o.Error.invalidRequireConfigureOption()})}(e);var n=this;P(Nn.filter(function(t){return e[t]!==undefined}),function(t){kn[t](n,e[t])})}function $n(t){return Se(this.base,t)}function An(e){var t;return this.cache[e]?this.cache[e]:(t=wn.call(this,e),(this.cache[e]=t)["catch"](function(t){return function n(t,e){Array.isArray(t.requires)||(t.requires=[]),t.requires.push(e)}(t,e),Promise.reject(t)}))}function Rn(t,e){var n=Object.create(t),r={};return r.define=function o(e,t){var n=this,r=[],i=Object.keys(e);return P(i,function(t){r.push(An.call(n,$n.call(n,e[t])))},n),Promise.all(r).then(function(n){var r;return"function"==typeof t?(r={},P(i,function(t,e){r[t]=n[e]}),t(r)):t})}.bind(n),r.resolve=$n.bind(n),r.configure=jn.bind(n),e&&r.configure(e),r}Cn("base",function pi(t,e){!function n(t){"string"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.base=e}),Cn("cache",function di(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),P(Object.keys(n),function(t){e.cache[t]=Promise.resolve(n[t])})}),Cn("clearCache",function hi(t,e){!function n(t){"boolean"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),e&&(t.cache={})},!0),Cn("preload",function _i(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),P(Object.keys(n),function(t){e.preload[t]=n[t]})}),Cn("preprocess",function mi(t,e){!function n(t){"function"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.preprocess=e}),o.require=Rn({base:"",cache:{},preload:{},preprocess:function(t){return Promise.resolve(t)}});var Dn=Lt({$class:"gpf.stream.ReadableArray",constructor:function(t){this._buffer=t},read:pe(function(t){var e=this._buffer,n=0;return function r(){return e.length===n?Promise.resolve():t.write(e[n++]).then(r)}()}),_buffer:[]}),Tn=Lt({$class:"gpf.stream.WritableArray",constructor:function(){this._buffer=[]},write:de(function(t){return this._buffer.push(t),Promise.resolve()}),toArray:function(){return this._buffer},_buffer:[]});se(Dn),se(Tn);var Mn={flush:Promise.resolve.bind(Promise)};function Bn(t){return Xt(vn,t)||Mn}function qn(t){if(t.readError)return Promise.reject(t.readError)}function Fn(t,e){var n=function s(t,e){return{iReadableIntermediate:ne(t),iWritableIntermediate:re(t),iFlushableIntermediate:Bn(t),iWritableDestination:re(e),iFlushableDestination:Bn(e),readError:null,rejectWrite:c}}(t,e),r=function u(e){var n=!0,r=e.iReadableIntermediate,i=e.iWritableDestination;return function(){if(n)try{n=!1,r.read(i).then(function(){n=!0},function(t){e.readError=t,e.rejectWrite(t)})}catch(t){e.readError=t}}}(n),i=n.iFlushableIntermediate,o=n.iFlushableDestination,a=n.iWritableIntermediate;return r(),{flush:function(){return qn(n)||i.flush().then(function(){return o.flush()})},write:function(t){return r(),qn(n)||function e(n,r){return new Promise(function(e,t){r.then(function(t){e(t),n.rejectWrite=c},t),n.rejectWrite=t})}(n,a.write(t))}}}function Wn(t){return E(t).length?function r(t){for(var e=t.length,n=t[--e];e;)n=Fn(t[--e],n);return n}(t):re(t[f])}o.stream.pipe=function vi(t,e){var n=ne(t),r=Wn(E(arguments)),i=Bn(r);try{return n.read(r).then(function(){return i.flush()})}catch(o){return Promise.reject(o)}};function Ln(t){return B(t,"regexp")}M.regexp={"\\":"\\\\","-":"\\-","[":"\\[","]":"\\]","/":"\\/","{":"\\{","}":"\\}","(":"\\(",")":"\\)","*":"\\*","+":"\\+","?":"\\?",".":"\\.","^":"\\^","$":"\\$","|":"\\|"},dt(0,{invalidCSV:"Invalid CSV syntax (bad quote sequence or missing end of file)"}),o.stream.csv={};var Un=";,\t ".split("");Lt({$class:"gpf.stream.csv.Parser",$extend:_n,constructor:function(t){this._readParserOptions(t),this._header?this._parseHeader():this._write=this._writeHeader},_readParserOptions:function(e){var n=this;e&&P(["header","separator","quote","newLine"],function(t){e[t]&&(n["_"+t]=e[t])})},_header:"",_separator:"",_deduceSeparator:function(){var e=this._header;this._separator=function a(t,e,n){for(var r,i=0,o=t.length;i"),t.content=!0)},_addContentToLastElement:function(){var t=this._elements[f];if(t)return this._addContentToElement(t)},_writeAttribute:function(t,e){this._appendToReadBuffer(" "+t+'="'),this._appendToReadBuffer(q(e.toString())),this._appendToReadBuffer('"')},_getNamespacePrefixes:function(){return this._elements.reduce(function(t,e){return t.concat(Object.keys(e.namespaces))},[])},_processAttributes:function(t){w(t,function(t,e){br(e,this._getNamespacePrefixes()),this._writeAttribute(e,t)},this)},_processNamespaces:function(t){w(t,function(t,e){e?this._writeAttribute("xmlns:"+e,t):this._writeAttribute("xmlns",t)},this)},characters:function(t){return this._checkState(!0),this._addContentToLastElement(),this._appendToReadBuffer(q(t.toString())),Promise.resolve()},endDocument:function(){return this._checkState(!1),this._checkIfStarted=o.Error.invalidXmlWriterState,this._completeReadBuffer(),Promise.resolve()},endElement:function(){this._checkState(!0);var t=this._elements.shift();return t.content?this._appendToReadBuffer(""):this._appendToReadBuffer("/>"),Promise.resolve()},endPrefixMapping:function(t){return this._checkState(),Promise.resolve()},processingInstruction:function(t,e){return this._checkState(!1),this._appendToReadBuffer("\n"),Promise.resolve()},startDocument:function(){return this._checkIfStarted=c,this.startDocument=o.Error.invalidXmlWriterState,this._checkState(!1),Promise.resolve()},startElement:function(t,e){var n=this._nextNamespaces;this._checkState(),this._addContentToLastElement(),this._elements.unshift({qName:t,namespaces:n}),this._nextNamespaces={},vr(t,this._getNamespacePrefixes()),this._appendToReadBuffer("<"+t),e&&this._processAttributes(e),this._processNamespaces(n)},startPrefixMapping:function(t,e){this._checkState(),function n(t){pr(t),dr(t),"xml"===t&&o.Error.invalidXmlUseOfPrefixXml()}(t),this._nextNamespaces[t]&&o.Error.invalidXmlWriterState(),this._nextNamespaces[t]=e}});o.forEachAsync=function(t,e,n){if(O(t))return function u(n,r,i){var o=0,a=n.length;return function s(){if(o===a)return Promise.resolve();var t=o++;try{return Ye(r.call(i,n[t],t,n)).then(s)}catch(e){return Promise.reject(e)}}()}(t,e,n);o.Error.invalidParameter()},dt(0,{invalidSerialName:"Invalid serial name",invalidSerialType:"Invalid serial type",invalidSerialRequired:"Invalid serial required",invalidSerialReadOnly:"Invalid serial readOnly"}),o.serial={};var gr={STRING:"string",INTEGER:"integer",DATETIME:"datetime"};o.serial.types={string:gr.STRING,integer:gr.INTEGER,datetime:gr.DATETIME};var yr=new RegExp("^[a-z][a-z0-9_]*$","i");function Er(t){!function e(t){"string"!=typeof t&&o.Error.invalidSerialName()}(t.name),function n(t){t.match(yr)||o.Error.invalidSerialName()}(t.name)}var wr=Object.keys(gr).map(function(t){return gr[t]});function xr(t){undefined===t.type?t.type=gr.STRING:function e(t){wr.includes(t)||o.Error.invalidSerialType()}(t.type)}function Or(t,e){"boolean"!=typeof t&&e()}function Pr(t){var e=Object.assign(t);return[Er,xr,function n(t){undefined===t.required?t.required=!1:Or(t.required,o.Error.invalidSerialRequired)},function r(t){undefined!==t.readOnly&&Or(t.readOnly,o.Error.invalidSerialReadOnly)}].forEach(function(t){t(e)}),e}function Sr(t){t&&o.Error.classAttributeOnly()}function Ir(t,e){var n=t._extend;n!==e&&function r(t,e){t instanceof e||o.Error.restrictedBaseClassAttribute()}(n.prototype,e)}function kr(t,e,n){E(function i(t,e,n){var r=e.getAttributes(n);return t?r[t]:r[zn]}(t,e,n)).length&&o.Error.uniqueAttributeUsedTwice()}dt(0,{classAttributeOnly:"Class attribute only",memberAttributeOnly:"Member attribute only",restrictedBaseClassAttribute:"Restricted base class attribute",uniqueAttributeUsedTwice:"Unique attribute used twice"});var Nr=Lt({$class:"gpf.attributes.AttributeAttribute",$extend:Xn,$abstract:!0,_check:function(t,e){Sr(t),Ir(e,Xn),kr(t,e,this.constructor)},_targetCheck:yt(),_overrideTargetCheck:function(t){var n=this,r=t._check;t._check=function(t,e){n._targetCheck(t,e,this),r.call(this,t,e)}},_build:function(t,e,n){this._overrideTargetCheck(n)}}),Cr=Lt({$class:"gpf.attributes.ClassAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(t,e){Sr(t)}});o.attributes.ClassAttribute=Cr;var jr=Lt({$class:"gpf.attributes.MemberAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(t,e){!function n(t){t||o.Error.memberAttributeOnly()}(t)}});o.attributes.MemberAttribute=jr;var $r=Lt({$class:"gpf.attributes.AttributeForInstanceOf",$extend:Nr,_BaseClass:null,constructor:function(t){"function"!=typeof t&&o.Error.invalidParameter(),this._BaseClass=t},_targetCheck:function(t,e){Ir(e,this._BaseClass)}});o.attributes.AttributeForInstanceOf=$r;var Ar=Lt({$class:"gpf.attributes.UniqueAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(t,e,n){kr(t,e,n.constructor)}});o.attributes.UniqueAttribute=Ar;var Rr,Dr=Lt({$class:"gpf.attributes.Serializable",$extend:Xn,$attributes:[new jr,new Ar],_property:null,constructor:function(t){this._property=t},_check:function(t,e){this._property=Pr(Object.assign({name:function n(t){return t.startsWith("_")?t.substring(1):t}(t)},this._property))},getProperty:function(){return Object.create(this._property)}});function Tr(t){var e=ir(t,Dr),n={};return w(e,function(t,e){n[e]=t[f].getProperty()}),n}function Mr(t,e){var n=Object.getOwnPropertyDescriptor(t,e);if(n)return!n.writable}function Br(n){var t=Tr(n);return w(t,function(t,e){t.readOnly===undefined&&(t.readOnly=Rr(n,e))}),t}function qr(t,e){if(!e.readOnly)return t}function Fr(n,t,i){var o={};return w(t,function(t,e){!function r(t,e,n){n!==undefined&&(t[e]=n)}(o,t.name,i.call(n,n[e],t,e))}),o}function Wr(n,i,o){var t=Br(n);w(t,function(t,e){i.hasOwnProperty(t.name)&&function r(t,e,n){n!==undefined&&(t[e]=n)}(n,e,o.call(n,i[t.name],t,e))})}function Lr(t,e,n){var r=function i(t){return t||zn}(e);t._attributes[r]=(t._attributes[r]||[]).concat(n),function o(e,n,t){t.forEach(function(t){Kn.call(e,n,t),nr(n,t,e._instanceBuilder.prototype)})}(t,e,n)}Rr=Object.getOwnPropertyDescriptor?function(t,e){for(var n,r=t;r!==Object&&n===undefined;)n=Mr(r,e),r=Object.getPrototypeOf(r);return n||!1}:function(){return!1},o.serial.get=Tr,o.serial.toRaw=function(t,e){return"function"==typeof t&&o.Error.invalidParameter(),function n(t,e){return Fr(t,Br(t),e||qr)}(t,e)},o.serial.fromRaw=function(t,e,n){return"function"==typeof t&&o.Error.invalidParameter(),function r(t,e,n){Wr(t,e,n||qr)}(t,e,n),t},dt(0,{es6classOnly:"ES6 class only"}),o.attributes.decorator=function Ei(){var n=g(arguments);return function(t,e){ht(t)||o.Error.es6classOnly(),Lr(kt(t),e,n)}}}); \ No newline at end of file +!function(e){"use strict";if("function"==typeof define&&define.amd)define(["exports"],e);else if("undefined"!=typeof exports)e(exports);else if("undefined"!=typeof module&&module.exports)e(module.exports);else{var t=Function("return this;")(),n={};e(n),t.gpf=n}}(function(o){"use strict";function u(){}var i,a,s,n,r,c=-1,f=0,e="browser",t="nashorn",l="nodejs",p="phantomjs",d="rhino",h="unknown",_="wscript",m=h,v=Function,b=new v("return this")();function g(e,t,n){return Array.prototype.slice.call(e,t,n||e.length)}"undefined"!=typeof WScript?m=_:"undefined"!=typeof print&&"undefined"!=typeof java?m="undefined"==typeof readFile?t:d:"undefined"!=typeof phantom&&phantom.version&&!document.currentScript?(m=p,b=window):"undefined"!=typeof module&&module.exports?(m=l,b=global):"undefined"!=typeof window&&(m=e,b=window),o.version=function(){return"1.0.0"},o.node={},l===m&&(n=require("path"),i=require("fs"),a=require("http"),s=require("https"),r=require("url"),"\\"===n.sep),o.hosts={browser:e,nashorn:t,nodejs:l,phantomjs:p,rhino:d,unknown:h,wscript:_},o.host=function(){return m};var y=1;function E(e){return g(e,y)}var w,x=Array.isArray;function O(e){return x(e)||function t(e){return!!e&&Math.floor(e.length)===e.length}(e)}function P(e,t,n){for(var r=0,i=e.length;r":">"};(function zr(e){var t=W(e);return D(t,function n(r){var i=["var C = this, l = arguments.length;","if (0 === l) { return new C();}"];return r.forEach(function(e,t){var n=1;n+=t,i.push("if ("+n+" === l) { return new C("+r.slice(f,n).join(", ")+");}")}),i.join("\n")}(t))})(10);var L=j+C+$+"+/=",U=63,X=18,V=12,z=6,Z=8,G=16,H=64,Q=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function J(e,t,n){var r=String.fromCharCode(e>>G&N);return t!==H?r+function i(e,t){return t===H?String.fromCharCode(e>>Z&N):String.fromCharCode(e>>Z&N,e&N)}(e,n):r}function K(e,t){return L.indexOf(e.charAt(t))}function Y(e,t){var n=e.charCodeAt(t);if(N>t&n)}function te(e,t){if(undefined!==e)return e[t]}function ne(e,t){var n=e[t];return undefined===n&&(n=e[t]={}),n}function re(e,t){return function r(e,t){var n;return("gpf"===e[f]?(n=o,E(e)):(n=b,e)).reduce(t,n)}(e,t?ne:te)}F("atob",function Zr(e){var t,n,r,i,o,a=function f(e){var t=e.replace(/[\t\n\f\r ]+/g,"");if(!Q.test(t))throw new TypeError("The string to be decoded is not correctly encoded.");return t}(e),s=a.length,u=0,c="";for(a+="==";u"),gte:He("gte",">="),not:function(e){return"!"+Ve(e.not)},like:function(e){var t=function n(e){return"/"+e.regexp+"/.exec("+Ve(e.like)+")"}(e);return e.group?"("+t+"||[])["+e.group+"]":t},or:He("or","||"),and:He("and","&&"),undefined:function(e){return JSON.stringify(e)}},Je=Object.keys(Qe);Ve=function(e){var t=function n(e){if("object"==typeof e)return Object.keys(e).filter(function(e){return Je.includes(e)})[f]}(e);return(0,Qe[t])(e)},o.createFilterFunction=function(e){return D(["i"],function t(e){return"return "+Ve(e)}(e))};var Ke=ze("ReadableStream",{"read":1}),Ye=ze("WritableStream",{"write":1});function et(e,t,n){return e||o.Error.interfaceExpected({name:n}),function i(e,t,n){var r=Ue(t,e);return r||o.Error.interfaceExpected({name:n}),r}(e,t,n)}function tt(e){return et(e,Ke,"gpf.interfaces.IReadableStream")}function nt(e){return et(e,Ye,"gpf.interfaces.IWritableStream")}ze("Enumerator",{"reset":0,"moveNext":0,"getCurrent":0}),ze("FileStorage",{"getInfo":1,"openTextStream":2,"close":1,"explore":1,"createDirectory":1,"deleteFile":1,"deleteDirectory":1}),de(0,{readInProgress:"A read operation is already in progress",writeInProgress:"A write operation is already in progress",invalidStreamState:"Stream is in an invalid state"}),o.stream={};var rt="gpf.stream#progress",it=rt+"/read",ot=rt+"/write";function at(e){e.prototype[it]=!1,e.prototype[ot]=!1}function st(e,t,n){e[t]&&o.Error[n](),e[t]=!0}function ut(e){e[it]=!1}function ct(e){e[ot]=!1}function ft(e,t,n){return e.then(function(e){return n(t),Promise.resolve(e)},function(e){return n(t),Promise.reject(e)})}function lt(r){return function(e){var t=nt(e);return function n(e){st(e,it,"readInProgress")}(this),ft(r.call(this,t),this,ut)}}function pt(n){return function(e){return function t(e){st(e,ot,"writeInProgress")}(this),ft(n.call(this,e),this,ct)}}var dt=We({$class:"gpf.stream.ReadableString",constructor:function(e){this._buffer=e},read:lt(function(e){return e.write(this._buffer)}),_buffer:""}),ht=We({$class:"gpf.stream.WritableString",constructor:function(){this._buffer=[]},write:pt(function(e){return this._buffer.push(e.toString()),Promise.resolve()}),toString:function(){return this._buffer.join("")},_buffer:[]});at(dt),at(ht),de(0,{incompatibleStream:"Incompatible stream"});var _t={NOT_FOUND:0,DIRECTORY:1,FILE:2,UNKNOWN:3},mt=0,vt=1,bt=null;function gt(e){e.length?e.pop():o.Error.unreachablePath()}function yt(e){var t=function n(e){return e.includes("\\")?e.toLowerCase().split("\\"):e.split("/")}(e);return function r(e){var t=e.pop();t&&e.push(t)}(t),t}function Et(e){return yt(e).join("/")}function wt(e){return e?yt(e).pop():""}function xt(e){var t=wt(e),n=t.lastIndexOf(".");return n===c?"":t.substring(n)}o.fs={types:{notFound:_t.NOT_FOUND,directory:_t.DIRECTORY,file:_t.FILE,unknown:_t.UNKNOWN},openFor:{reading:mt,appending:vt},getFileStorage:function(){return bt}},de(0,{unreachablePath:"Unreachable path"});var Ot={"":function(e){e.length=0,e.push("")},".":u,"..":function(e){gt(e)}};function Pt(e){var t=yt(e);return E(arguments).forEach(function r(n,e){P(yt(e),function(e){var t=Ot[e];t?t(n):n.push(e)})}.bind(null,t)),t.join("/")}function St(e,t){e.length*t.length&&function n(e,t){for(;e[f]===t[f];)e.shift(),t.shift()}(e,t)}function It(e){var t=yt(e);return gt(t),t.join("/")}o.path={join:Pt,parent:It,name:wt,nameOnly:function(e){var t=wt(e),n=t.lastIndexOf(".");return n===c?t:t.substring(f,n)},extension:xt,relative:function Qr(e,t){var n,r=yt(e),i=yt(t);for(St(r,i),n=r.length;n--;)i.unshift("..");return i.join("/")}};var kt=We({$class:"gpf.node.BaseStream",constructor:function(e,t){this._stream=e,"function"==typeof t&&(this._close=t),e.on("error",this._onError.bind(this))},_close:u,close:function(){return this._close()},_stream:null,_invalid:!1,_reject:o.Error.invalidStreamState,_checkIfValid:function(){this._invalid&&o.Error.invalidStreamState()},_onError:function(e){this._invalid=!0,this._reject(e)}}),Nt=We({$class:"gpf.node.ReadableStream",$extend:"gpf.node.BaseStream",read:lt(function(n){var r=this,i=r._stream;return new Promise(function(e,t){r._reject=t,r._checkIfValid(),i.on("data",r._onData.bind(r,n)).on("end",function(){r._invalid=!0,e()})})}),_onData:function(e,t){var n=this._stream;n.pause(),e.write(t).then(function(){n.resume()},this._reject)}}),Ct=We({$class:"gpf.node.WritableStream",$extend:"gpf.node.BaseStream",write:pt(function(r){var i=this,o=i._stream;return new Promise(function(t,e){var n;i._reject=e,i._checkIfValid(),(n=o.write(r,function(e){!e&&n&&t()}))||o.once("drain",function(){t()})})})});function jt(e,t){return new Promise(function(n,r){i[e].apply(i,t.concat([function(e,t){e?r(e):n(t)}]))})}function $t(e,t){return jt(e,[Et(t)])}function At(e,t){return jt("open",[Et(e),t.flags]).then(function(e){return new t.GpfStream(i[t.nodeStream]("",{fd:e,autoClose:!1}),jt.bind(null,"close",[e]))})}function Rt(e){return e.isDirectory()?_t.DIRECTORY:function t(e){return e.isFile()?_t.FILE:_t.UNKNOWN}(e)}!function Jr(e,t){e===m&&(bt=new t)}(l,We({$class:"gpf.node.FileStorage",getInfo:function(e){var t=Et(e);return new Promise(function(e){i.exists(t,e)}).then(function(e){return e?$t("stat",t).then(function(e){return{fileName:n.basename(t),filePath:Et(n.resolve(t)),size:e.size,createdDateTime:e.ctime,modifiedDateTime:e.mtime,type:Rt(e)}}):{type:_t.NOT_FOUND}})},openTextStream:function(e,t){return mt===t?function n(e){return At(e,{flags:"r",GpfStream:Nt,nodeStream:"createReadStream"})}(e):function r(e){return At(e,{flags:"a",GpfStream:Ct,nodeStream:"createWriteStream"})}(e)},close:function Kr(t){return function(e){return e instanceof t?e.close():Promise.reject(new o.Error.IncompatibleStream)}}(kt),explore:function(t){var n=this;return $t("readdir",t).then(function(e){return function i(e,t){var n,r=-1;return{reset:function(){return r=-1,Promise.resolve()},moveNext:function(){return++r,n=undefined,r"+this._getChildrenAsString()+"":"/>"},toString:function(){return Ft(this._nodeName),"<"+this._nodeName+this._getAttributesAsString()+this._getClosingString()},_createElement:function(e){var t=e.ownerDocument,n=qt(this._nodeName);return n?t.createElementNS(n.namespace,n.name):t.createElement(this._nodeName)},_setAttributesTo:function(r){w(this._attributes,function(e,t){var n=qt(t);n?r.setAttributeNS(n.namespace,Wt(n.name),e):r.setAttribute(Wt(t),e)})},_appendChildrenTo:function(t){var n=t.ownerDocument;Lt(this._children,function(e){e instanceof Ut?e.appendTo(t):t.appendChild(n.createTextNode(e.toString()))})},appendTo:function(e){var t=this._createElement(e);return this._setAttributesTo(t),this._appendChildrenTo(t),e.appendChild(t)}});o.web.createTagFunction=function Yr(r){return r||o.Error.missingNodeName(),function(e){var t,n=0;return Tt(e)&&(t=e,++n),new Ut(r,t,g(arguments,n))}},o.http={};var Xt="GET",Vt="POST",zt="PUT",Zt="OPTIONS",Gt="DELETE",Ht="HEAD";new RegExp("([^:\\s]+)\\s*: ?([^\\r]*)","gm");var Qt,Jt;ze("Thenable",{"then":2});function Kt(e){return o.interfaces.isImplementedBy(o.interfaces.IThenable,e)?e:Promise.resolve(e)}function Yt(e,t){var n=Qt;return e===m&&(Qt=t),n}function en(n){return new Promise(function(e,t){Qt(n,e,t)})}function tn(e,t,n){return en("string"==typeof t?{method:e,url:t,data:n}:Object.assign({method:e},t))}function nn(t,n){t.setEncoding("utf8");var r=new Nt(t);(function i(e){var t=new ht;return tt(e).read(t).then(function(){return t.toString()})})(r).then(function(e){r.close(),n({status:t.statusCode,headers:t.headers,responseText:e})})}function rn(e){var t=Object.assign(r.parse(e.url),e);return function n(e,t){t&&(e.headers=Object.assign({"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(t)},e.headers))}(t,e.data),t}function on(e,t){var n=rn(e);return function r(e){return"https:"===e.protocol?s:a}(n).request(n,function(e){nn(e,t)})}function an(e,t){var n;return e.every(function(e){return(n=function i(e,t){var n,r=e.url;if(r.lastIndex=0,n=r.exec(t.url))return e.response.apply(e,[t].concat(E(n)))}(e,t))===undefined}),n}function sn(e){return Jt[e]||(Jt[e]=[]),Jt[e]}o.promisify=Kt,o.promisifyDefined=function ei(e){if(undefined!==e)return Kt(e)},Object.assign(o.http,{methods:{get:Xt,post:Vt,put:zt,options:Zt,"delete":Gt,head:Ht},request:en,get:tn.bind(o.http,Xt),post:tn.bind(o.http,Vt),put:tn.bind(o.http,zt),options:tn.bind(o.http,Zt),"delete":tn.bind(o.http,Gt),head:tn.bind(o.http,Ht)}),Yt(l,function ti(e,t,n){var r=on(e,t);r.on("error",n),function i(e,t){t?e.write(t,"utf8",function(){e.end()}):e.end()}(r,e.data)});var un,cn=0;function fn(){Jt={}}function ln(){}fn(),o.http.mock=function ni(e){var t=e.method.toUpperCase(),n=t+"."+cn++;return sn(t).unshift(Object.assign({id:n},e)),n},o.http.mock.remove=function ri(t){var e=t.substring(f,t.indexOf("."));Jt[e]=sn(e).filter(function(e){return e.id!==t})},o.http.mock.reset=fn,un=Yt(m,function ii(e,t,n){var r=function i(e){return an(sn(e.method.toUpperCase()),e)}(e);undefined===r?un(e,t,n):t(r)}),ln.prototype={execute:u};var pn=new ln,dn=new ln;pn.execute=function(e){e._readReject(e._readBuffer.shift())},dn.execute=function(e){e._readResolve()};var hn=We({$class:"gpf.stream.BufferedRead",constructor:function(){this._readBuffer=[]},_readBuffer:[],_readWriteToStream:null,_readResolve:null,_readReject:null,_readDataIsToken:function(e){return e instanceof ln&&(e.execute(this),!0)},_readWriteToOutput:function(){var e=this,t=e._readBuffer.shift();return e._readDataIsToken(t)?Promise.resolve():e._readWriteToStream.write(t).then(function(){if(e._readBuffer.length)return e._readWriteToOutput();e._readNotWriting=!0})},_readNotWriting:!0,_readSafeWrite:function(){var t=this;t._readNotWriting&&(t._readNotWriting=!1,t._readWriteToOutput().then(undefined,function(e){t._readReject(e)}))},_readCheckIfData:function(){this._readBuffer.length&&this._readSafeWrite()},_readCheckIfOutput:function(){this._readWriteToStream&&this._readCheckIfData()},_appendToReadBuffer:function(e){return this._readBuffer=this._readBuffer.concat(g(arguments)),this._readCheckIfOutput(),this},_completeReadBuffer:function(){this._readBuffer.push(dn),this._readCheckIfOutput()},_setReadError:function(e){this._readBuffer.push(pn,e),this._readCheckIfOutput()},read:lt(function(e){var n=this;return n._readWriteToStream=e,n._readCheckIfData(),new Promise(function(e,t){n._readResolve=e,n._readReject=t})})});at(hn);var _n=/\r\n/g,mn=(We({$class:"gpf.stream.LineAdapter",$extend:hn,constructor:function(){this.$super(),this._buffer=[]},write:pt(function(e){return this._buffer.push(e.toString()),this._process(),Promise.resolve()}),flush:function(){return this._buffer.length&&(this._buffer.push("\n"),this._process()),this._completeReadBuffer(),Promise.resolve()},_buffer:[],_consolidateLines:function(){return this._buffer.join("").replace(_n,"\n").split("\n")},_pushBackLastLineIfNotEmpty:function(e){var t=e.pop();t.length&&this._buffer.push(t)},_process:function(){var t=this,e=t._consolidateLines();t._buffer.length=0,t._pushBackLastLineIfNotEmpty(e),P(e,function(e){t._appendToReadBuffer(e)})}}),ze("FlushableStream",{"flush":0})),vn={};function bn(e){return vn(e)}o.read=bn,o.fs&&(o.fs.read=bn),function oi(e,t){e===m&&(vn=t)}(l,function ai(e){return new Promise(function(n,r){i.readFile(e,function(e,t){e?r(e):n(t.toString())})})});var gn={};function yn(e,t){return Promise.resolve(t)}function En(t){var n=this;return function r(e,t){var n=e.preload[t];return n?Promise.resolve(n):bn(t)}(n,t).then(function(e){return n.preprocess({name:t,content:e,type:xt(t).toLowerCase()})}).then(function(e){return function t(e){return gn[e.type]||yn}(e).call(n,e.name,e.content)})}function wn(e,t){return function r(e,t){return e._initialDefine=t.define,t.define=function n(){var e=this.gpf.require,t=this._initialDefine;return this.promise=t.apply(e,arguments),e.define=t,this.promise}.bind(e),e.gpf.require=t,e}(function n(){return{gpf:Object.create(o),promise:Promise.resolve(),_initialDefine:null}}(),An(e,{base:It(t)}))}gn[".json"]=function(e,t){return JSON.parse(t)},de(0,{noCommonJSDynamicRequire:"Dynamic require not supported"});var xn=/[^.]\brequire\b\s*\(\s*(?:['|"]([^"']+)['|"]|[^)]+)\s*\)/g;var On,Pn=[null,function si(e){return{dependencies:[],factory:e}},function ui(e,t){return{dependencies:e,factory:t}},function ci(e,t,n){return{dependencies:t,factory:n}}];function Sn(e,t,n){var r={};return D(["gpf","define","module","require"],t)(e,function i(e,t,n){var r=Pn[arguments.length].apply(null,arguments);this.require.define(r.dependencies,function(e){return e.length=r.dependencies.length,r.factory.apply(null,g(e))})}.bind(e),r,function(e){return n[e]||o.Error.noCommonJSDynamicRequire()}),r.exports}On=e===m?function fi(e,t){var n=location.pathname.toString();return n.endsWith("/")||(n=It(n)),"//# sourceURL="+location.origin+Pt(n,e)+"?gpf.require\n"+t}:function li(e,t){return t},gn[".js"]=function(n,r){var i=wn(this,n);return function o(e,t){var n=be(xn,t);return n.length?wn(this,e).gpf.require.define(n.map(function(e){return e[1]}).filter(function(e){return e}).reduce(function(e,t){return e[t]=t,e},{}),function(e){return e}):Promise.resolve({})}.call(this,n,r).then(function(e){var t=Sn(i.gpf,On(n,r),e);return undefined===t?i.promise:t})},de(0,{invalidRequireConfigureOption:"Invalid configuration option",invalidRequireConfigureOptionValue:"Invalid configuration option value"});var In={},kn=[];function Nn(e,t,n){n?kn.unshift(e):kn.push(e),In[e]=t}function Cn(t){!function r(e){P(Object.keys(e),function(e){In[e]||o.Error.invalidRequireConfigureOption()})}(t);var n=this;P(kn.filter(function(e){return t[e]!==undefined}),function(e){In[e](n,t[e])})}function jn(e){return Pt(this.base,e)}function $n(t){var e;return this.cache[t]?this.cache[t]:(e=En.call(this,t),(this.cache[t]=e)["catch"](function(e){return function n(e,t){Array.isArray(e.requires)||(e.requires=[]),e.requires.push(t)}(e,t),Promise.reject(e)}))}function An(e,t){var n=Object.create(e),r={};return r.define=function o(t,e){var n=this,r=[],i=Object.keys(t);return P(i,function(e){r.push($n.call(n,jn.call(n,t[e])))},n),Promise.all(r).then(function(n){var r;return"function"==typeof e?(r={},P(i,function(e,t){r[e]=n[t]}),e(r)):e})}.bind(n),r.resolve=jn.bind(n),r.configure=Cn.bind(n),t&&r.configure(t),r}Nn("base",function pi(e,t){!function n(e){"string"!=typeof e&&o.Error.invalidRequireConfigureOptionValue()}(t),e.base=t}),Nn("cache",function di(t,n){!function r(e){"object"!=typeof e&&o.Error.invalidRequireConfigureOptionValue()}(n),P(Object.keys(n),function(e){t.cache[e]=Promise.resolve(n[e])})}),Nn("clearCache",function hi(e,t){!function n(e){"boolean"!=typeof e&&o.Error.invalidRequireConfigureOptionValue()}(t),t&&(e.cache={})},!0),Nn("preload",function _i(t,n){!function r(e){"object"!=typeof e&&o.Error.invalidRequireConfigureOptionValue()}(n),P(Object.keys(n),function(e){t.preload[e]=n[e]})}),Nn("preprocess",function mi(e,t){!function n(e){"function"!=typeof e&&o.Error.invalidRequireConfigureOptionValue()}(t),e.preprocess=t}),o.require=An({base:"",cache:{},preload:{},preprocess:function(e){return Promise.resolve(e)}});var Rn=We({$class:"gpf.stream.ReadableArray",constructor:function(e){this._buffer=e},read:lt(function(e){var t=this._buffer,n=0;return function r(){return t.length===n?Promise.resolve():e.write(t[n++]).then(r)}()}),_buffer:[]}),Dn=We({$class:"gpf.stream.WritableArray",constructor:function(){this._buffer=[]},write:pt(function(e){return this._buffer.push(e),Promise.resolve()}),toArray:function(){return this._buffer},_buffer:[]});at(Rn),at(Dn);var Tn={flush:Promise.resolve.bind(Promise)};function Mn(e){return Ue(mn,e)||Tn}function Bn(t){var e=t.iReadableIntermediate,n=t.iWritableDestination;if(!t.readInProgress)try{t.readInProgress=!0,t.readPromise=e.read(n).then(function(){t.readInProgress=!1},function(e){t.readError=e,t.rejectWrite(e)})}catch(r){t.readError=r}}function qn(e){if(e.readError)return Promise.reject(e.readError)}function Fn(e,t,n){var r=function s(e,t){return{iReadableIntermediate:tt(e),iWritableIntermediate:nt(e),iFlushableIntermediate:Mn(e),iWritableDestination:nt(t),iFlushableDestination:Mn(t),readInProgress:!1,readError:null,readPromise:Promise.resolve(),rejectWrite:u,flushed:!1}}(e,t),i=r.iFlushableIntermediate,o=r.iFlushableDestination,a=r.iWritableIntermediate;return Bn(r),{flush:function(){return r.flushed=!0,qn(r)||i.flush().then(function(){return r.readPromise}).then(function(){return o.flush()})},write:function(e){return Bn(r),qn(r)||function t(n,r){return new Promise(function(t,e){r.then(function(e){t(e),n.rejectWrite=u},e),n.rejectWrite=e})}(r,a.write(e))}}}function Wn(e){return E(e).length?function r(e){for(var t=e.length,n=e[--t];t;)n=Fn(e[--t],n);return n}(e):nt(e[f])}o.stream.pipe=function vi(e,t){var n=tt(e),r=Wn(E(arguments)),i=Mn(r);try{return n.read(r).then(function(){return i.flush()})}catch(o){return Promise.reject(o)}};function Ln(e){return B(e,"regexp")}M.regexp={"\\":"\\\\","-":"\\-","[":"\\[","]":"\\]","/":"\\/","{":"\\{","}":"\\}","(":"\\(",")":"\\)","*":"\\*","+":"\\+","?":"\\?",".":"\\.","^":"\\^","$":"\\$","|":"\\|"},de(0,{invalidCSV:"Invalid CSV syntax (bad quote sequence or missing end of file)"}),o.stream.csv={};var Un=";,\t ".split("");We({$class:"gpf.stream.csv.Parser",$extend:hn,constructor:function(e){this._readParserOptions(e),this._header?this._parseHeader():this._write=this._writeHeader},_readParserOptions:function(t){var n=this;t&&P(["header","separator","quote","newLine"],function(e){t[e]&&(n["_"+e]=t[e])})},_header:"",_separator:"",_deduceSeparator:function(){var t=this._header;this._separator=function a(e,t,n){for(var r,i=0,o=e.length;i"),e.content=!0)},_addContentToLastElement:function(){var e=this._elements[f];if(e)return this._addContentToElement(e)},_writeAttribute:function(e,t){this._appendToReadBuffer(" "+e+'="'),this._appendToReadBuffer(q(t.toString())),this._appendToReadBuffer('"')},_getNamespacePrefixes:function(){return this._elements.reduce(function(e,t){return e.concat(Object.keys(t.namespaces))},[])},_processAttributes:function(e){w(e,function(e,t){br(t,this._getNamespacePrefixes()),this._writeAttribute(t,e)},this)},_processNamespaces:function(e){w(e,function(e,t){t?this._writeAttribute("xmlns:"+t,e):this._writeAttribute("xmlns",e)},this)},characters:function(e){return this._checkState(!0),this._addContentToLastElement(),this._appendToReadBuffer(q(e.toString())),Promise.resolve()},endDocument:function(){return this._checkState(!1),this._checkIfStarted=o.Error.invalidXmlWriterState,this._completeReadBuffer(),Promise.resolve()},endElement:function(){this._checkState(!0);var e=this._elements.shift();return e.content?this._appendToReadBuffer(""):this._appendToReadBuffer("/>"),Promise.resolve()},endPrefixMapping:function(e){return this._checkState(),Promise.resolve()},processingInstruction:function(e,t){return this._checkState(!1),this._appendToReadBuffer("\n"),Promise.resolve()},startDocument:function(){return this._checkIfStarted=u,this.startDocument=o.Error.invalidXmlWriterState,this._checkState(!1),Promise.resolve()},startElement:function(e,t){var n=this._nextNamespaces;this._checkState(),this._addContentToLastElement(),this._elements.unshift({qName:e,namespaces:n}),this._nextNamespaces={},vr(e,this._getNamespacePrefixes()),this._appendToReadBuffer("<"+e),t&&this._processAttributes(t),this._processNamespaces(n)},startPrefixMapping:function(e,t){this._checkState(),function n(e){pr(e),dr(e),"xml"===e&&o.Error.invalidXmlUseOfPrefixXml()}(e),this._nextNamespaces[e]&&o.Error.invalidXmlWriterState(),this._nextNamespaces[e]=t}});o.forEachAsync=function(e,t,n){if(O(e))return function u(n,r,i){var o=0,a=n.length;return function s(){if(o===a)return Promise.resolve();var e=o++;try{return Kt(r.call(i,n[e],e,n)).then(s)}catch(t){return Promise.reject(t)}}()}(e,t,n);o.Error.invalidParameter()},de(0,{invalidSerialName:"Invalid serial name",invalidSerialType:"Invalid serial type",invalidSerialRequired:"Invalid serial required",invalidSerialReadOnly:"Invalid serial readOnly"}),o.serial={};var gr={STRING:"string",INTEGER:"integer",DATETIME:"datetime"};o.serial.types={string:gr.STRING,integer:gr.INTEGER,datetime:gr.DATETIME};var yr=new RegExp("^[a-z][a-z0-9_]*$","i");function Er(e){!function t(e){"string"!=typeof e&&o.Error.invalidSerialName()}(e.name),function n(e){e.match(yr)||o.Error.invalidSerialName()}(e.name)}var wr=Object.keys(gr).map(function(e){return gr[e]});function xr(e){undefined===e.type?e.type=gr.STRING:function t(e){wr.includes(e)||o.Error.invalidSerialType()}(e.type)}function Or(e,t){"boolean"!=typeof e&&t()}function Pr(e){var t=Object.assign(e);return[Er,xr,function n(e){undefined===e.required?e.required=!1:Or(e.required,o.Error.invalidSerialRequired)},function r(e){undefined!==e.readOnly&&Or(e.readOnly,o.Error.invalidSerialReadOnly)}].forEach(function(e){e(t)}),t}function Sr(e){e&&o.Error.classAttributeOnly()}function Ir(e,t){var n=e._extend;n!==t&&function r(e,t){e instanceof t||o.Error.restrictedBaseClassAttribute()}(n.prototype,t)}function kr(e,t,n){E(function i(e,t,n){var r=t.getAttributes(n);return e?r[e]:r[zn]}(e,t,n)).length&&o.Error.uniqueAttributeUsedTwice()}de(0,{classAttributeOnly:"Class attribute only",memberAttributeOnly:"Member attribute only",restrictedBaseClassAttribute:"Restricted base class attribute",uniqueAttributeUsedTwice:"Unique attribute used twice"});var Nr=We({$class:"gpf.attributes.AttributeAttribute",$extend:Xn,$abstract:!0,_check:function(e,t){Sr(e),Ir(t,Xn),kr(e,t,this.constructor)},_targetCheck:ye(),_overrideTargetCheck:function(e){var n=this,r=e._check;e._check=function(e,t){n._targetCheck(e,t,this),r.call(this,e,t)}},_build:function(e,t,n){this._overrideTargetCheck(n)}}),Cr=We({$class:"gpf.attributes.ClassAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(e,t){Sr(e)}});o.attributes.ClassAttribute=Cr;var jr=We({$class:"gpf.attributes.MemberAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(e,t){!function n(e){e||o.Error.memberAttributeOnly()}(e)}});o.attributes.MemberAttribute=jr;var $r=We({$class:"gpf.attributes.AttributeForInstanceOf",$extend:Nr,_BaseClass:null,constructor:function(e){"function"!=typeof e&&o.Error.invalidParameter(),this._BaseClass=e},_targetCheck:function(e,t){Ir(t,this._BaseClass)}});o.attributes.AttributeForInstanceOf=$r;var Ar=We({$class:"gpf.attributes.UniqueAttribute",$extend:Nr,$singleton:!0,_targetCheck:function(e,t,n){kr(e,t,n.constructor)}});o.attributes.UniqueAttribute=Ar;var Rr,Dr=We({$class:"gpf.attributes.Serializable",$extend:Xn,$attributes:[new jr,new Ar],_property:null,constructor:function(e){this._property=e},_check:function(e,t){this._property=Pr(Object.assign({name:function n(e){return e.startsWith("_")?e.substring(1):e}(e)},this._property||{}))},getProperty:function(){return Object.create(this._property)}});function Tr(e){var t=ir(e,Dr),n={};return w(t,function(e,t){n[t]=e[f].getProperty()}),n}function Mr(e,t){var n=Object.getOwnPropertyDescriptor(e,t);if(n)return!n.writable}function Br(n){var e=Tr(n);return w(e,function(e,t){e.readOnly===undefined&&(e.readOnly=Rr(n,t))}),e}function qr(e,t){if(!t.readOnly)return e}function Fr(n,e,i){var o={};return w(e,function(e,t){!function r(e,t,n){n!==undefined&&(e[t]=n)}(o,e.name,i.call(n,n[t],e,t))}),o}function Wr(n,i,o){var e=Br(n);w(e,function(e,t){Object.prototype.hasOwnProperty.call(i,e.name)&&function r(e,t,n){n!==undefined&&(e[t]=n)}(n,t,o.call(n,i[e.name],e,t))})}function Lr(e,t,n){var r=function i(e){return e||zn}(t);e._attributes[r]=(e._attributes[r]||[]).concat(n),function o(t,n,e){e.forEach(function(e){Kn.call(t,n,e),nr(n,e,t._instanceBuilder.prototype)})}(e,t,n)}Rr=Object.getOwnPropertyDescriptor?function(e,t){for(var n,r=e;r!==Object&&n===undefined;)n=Mr(r,t),r=Object.getPrototypeOf(r);return n||!1}:function(){return!1},o.serial.get=Tr,o.serial.toRaw=function(e,t){return"function"==typeof e&&o.Error.invalidParameter(),function n(e,t){return Fr(e,Br(e),t||qr)}(e,t)},o.serial.fromRaw=function(e,t,n){return"function"==typeof e&&o.Error.invalidParameter(),function r(e,t,n){Wr(e,t,n||qr)}(e,t,n),e},de(0,{es6classOnly:"ES6 class only"}),o.attributes.decorator=function Ei(){var n=g(arguments);return function(e,t){he(e)||o.Error.es6classOnly(),Lr(Ie(e),t,n)}}}); \ No newline at end of file diff --git a/build/gpf-require.js b/build/gpf-require.js index 760eaf19..eaee9235 100644 --- a/build/gpf-require.js +++ b/build/gpf-require.js @@ -1 +1 @@ -!function(e){"use strict";if("function"==typeof define&&define.amd)define(["exports"],e);else if("undefined"!=typeof exports)e(exports);else if("undefined"!=typeof module&&module.exports)e(module.exports);else{var t=Function("return this;")(),n={};e(n),t.gpf=n}}(function(o){"use strict";function c(){}var i,n,r=-1,a=0,e="browser",t="nashorn",u="nodejs",s="phantomjs",f="rhino",l="unknown",p="wscript",d=l,h=Function,_=new h("return this")();function m(e,t,n){return Array.prototype.slice.call(e,t,n||e.length)}"undefined"!=typeof WScript?d=p:"undefined"!=typeof print&&"undefined"!=typeof java?d="undefined"==typeof readFile?t:f:"undefined"!=typeof phantom&&phantom.version&&!document.currentScript?(d=s,_=window):"undefined"!=typeof module&&module.exports?(d=u,_=global):"undefined"!=typeof window&&(d=e,_=window),o.version=function(){return"0.2.9"},e===d&&(function(e){window.location="https://arnaudbuchholz.github.io/gpf/exit.html?"+e},window,document),o.node={},u===d&&(n=require("path"),i=require("fs"),require("http"),require("https"),require("url"),"\\"===n.sep),o.hosts={browser:e,nashorn:t,nodejs:u,phantomjs:s,rhino:f,unknown:l,wscript:p},o.host=function(){return d};var v=1;function y(e){return m(e,v)}var g,b=Array.isArray;function w(e){return b(e)||function t(e){return!!e&&Math.floor(e.length)===e.length}(e)}function E(e,t,n){for(var r=0,i=e.length;r":">"};var Z=1;function G(t,e){var n=function r(t){return t[Z]}(e);return undefined!==n?t.bind(n):t}function Q(t,e){for(var n=t.length,r=0;rrt.length&&(rt=nt(e.length)),rt.apply(t,e)}(Ct,arguments)}var Nt,kt="2003-01-22T22:45:34.075Z",At="2003-01-22";function $t(t,e,n){var r=!0;function i(e){return function(t){r&&(r=!1,e(t))}}try{t(i(e),i(n))}catch(e_){r&&(r=!1,n(e_))}}function Rt(){var e=this;e._handlers.forEach(function(t){t.process(e)}),e._handlers=[]}function Tt(t){this._state=!1,this._value=t,Rt.call(this)}function Dt(t){if(t&&["object","function"].includes(typeof t))return function n(t,e){if("function"==typeof e)return $t(e.bind(t),Nt.bind(this),Tt.bind(this)),!0}.call(this,t,t.then)}!function $o(){var t,e;!function n(){C(["prototype","UTC","parse","now"],function(t){It[t]=Ct[t]})}();try{t=ht(new Date(kt)),e=ht(new Date(At))}catch(e_){}t===kt&&e===At+"T00:00:00.000Z"||(b.Date=It)}(),Nt=function(t){var e=this;try{if(Dt.call(e,t))return;e._state=!0,e._value=t,Rt.call(e)}catch(e_){Tt.call(e,e_)}};var Ft=o.Promise=function(t){$t(t,Nt.bind(this),Tt.bind(this))};function Mt(){}Mt.prototype={onFulfilled:null,onRejected:null,resolve:null,reject:null,process:function(t){if(null===t._state)return t.hasOwnProperty("_handlers")||(t._handlers=[]),void t._handlers.push(this);setTimeout(function a(t){var e,n=this,r=function i(t,e){return e._state?t.onFulfilled:t.onRejected}(n,t);if(null===r)return function o(t,e){e._state?t.resolve(e._value):t.reject(e._value)}(n,t);try{e=r(t._value)}catch(e_){return void n.reject(e_)}n.resolve(e)}.bind(this,t),0)}},Ft.prototype={_state:null,_value:null,_handlers:[],then:function(r,i){var o=this;return new Ft(function(t,e){var n=new Mt;undefined!==r&&(n.onFulfilled=r),undefined!==i&&(n.onRejected=i),n.resolve=t,n.reject=e,n.process(o)})},"catch":function(t){return this.then(null,t)}},Ft.resolve=function(e){return new Ft(function(t){t(e)})},Ft.reject=function(n){return new Ft(function(t,e){e(n)})},Ft.all=function(n){return n.length?new Ft(function(t,e){n.forEach(function o(t,e){var n=this;try{if(t instanceof Ft)return void t.then(function(t){o.call(n,t,e)},n.reject);!function r(t,e,n){t.promises[e]=n,--t.remaining||t.resolve(t.promises)}(n,e,t)}catch(e_){n.reject(e_)}}.bind({resolve:t,reject:e,remaining:n.length,promises:n}))}):Ft.resolve([])},Ft.race=function(t){return new Ft(function(e,n){t.forEach(function(t){t.then(e,n)})})},H("Promise",Ft);var qt={};function Bt(t){java.lang.Thread.sleep(t)}qt[m]=function(t){WScript.Sleep(t)},qt[d]=Bt,qt[e]=Bt;var Wt,Ut=[],Lt=0,Xt=qt[v]||c;function Vt(t,e){return t.dt===e.dt?t.id-e.id:t.dt-e.dt}function zt(t){return t.toString()}function Ht(t,e){return e?"\n"+e+t.join(",\n"+e)+"\n":t.join(",")}function Zt(t,e,n){return null===t?"null":function a(t,r,i){var o,u=[];return o=i?": ":":",O(t,function(t,e){var n=r(e,t);n=Wt[typeof n](t,r,i),undefined!==n&&u.push(L(e)+o+n)}),"{"+Ht(u,i)+"}"}(t,e,n)}o.handleTimeout=function Ro(){for(var t,e;Ut.length;){for(t=Ut.shift(),e=(new Date).getTime();t.dt>e;)Xt(t.dt-e),e=(new Date).getTime();t.cb()}},H("setTimeout",function To(t,e){var n={id:++Lt,dt:(new Date).getTime()+e,cb:t};return Ut.push(n),Ut.sort(Vt),Lt}),H("clearTimeout",function Do(e){Ut=Ut.filter(function(t){return t.id!==e})}),Wt={undefined:c,"function":c,number:zt,"boolean":zt,string:function(t){return L(t)},object:function(t,e,n){return P(t)?function u(t,r,i){var o=[];return C(t,function(t,e){var n=r(e.toString(),t);n=undefined===n?"null":Wt[typeof n](n,r,i),o.push(n)}),"["+Ht(o,i)+"]"}(t,e,n):Zt(t,e,n)}};var Gt=10;H("JSON",{parse:function Fo(t,e){var n=M("return "+t)();return e?function i(n,t,r){return"object"==typeof n&&O(n,function(t,e){n[e]=i(t,e,r)}),r(t,n)}(n,"",e):n},stringify:function Mo(t,e,n){return Wt[typeof t](t,function r(n){return P(n)?function(t,e){if(n.includes(t))return e}:function e(t){return"function"==typeof t?t:function(t,e){return e}}(n)}(e),function i(t){return"number"==typeof t?"".padEnd(Math.min(t,Gt)," "):t||""}(n))}});var Qt=R+$+T+"+/=",Jt=63,Yt=18,Kt=12,te=6,ee=8,ne=16,re=64,ie=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function oe(t,e,n){var r=String.fromCharCode(t>>ne&A);return e!==re?r+function i(t,e){return e===re?String.fromCharCode(t>>ee&A):String.fromCharCode(t>>ee&A,t&A)}(t,n):r}function ue(t,e){return Qt.indexOf(t.charAt(e))}function ae(t,e){var n=t.charCodeAt(e);if(A>e&n)}function ce(t,e){if(undefined!==t)return t[e]}function fe(t,e){var n=t[e];return undefined===n&&(n=t[e]={}),n}function le(t,e){return function r(t,e){var n;return("gpf"===t[l]?(n=o,S(t)):(n=b,t)).reduce(e,n)}(t,e?fe:ce)}H("atob",function qo(t){var e,n,r,i,o,u=function f(t){var e=t.replace(/[\t\n\f\r ]+/g,"");if(!ie.test(e))throw new TypeError("The string to be decoded is not correctly encoded.");return e}(t),a=u.length,s=0,c="";for(u+="==";s"),gte:on("gte",">="),not:function(t){return"!"+tn(t.not)},like:function(t){var e=function n(t){return"/"+t.regexp+"/.exec("+tn(t.like)+")"}(t);return t.group?"("+e+"||[])["+t.group+"]":e},or:on("or","||"),and:on("and","&&"),undefined:function(t){return JSON.stringify(t)}},an=Object.keys(un);tn=function(t){var e=function n(t){if("object"==typeof t)return Object.keys(t).filter(function(t){return an.includes(t)})[l]}(t);return(0,un[e])(t)},o.createFilterFunction=function(t){return M(["i"],function e(t){return"return "+tn(t)}(t))};var sn=en("ReadableStream",{"read":1}),cn=en("WritableStream",{"write":1});function fn(t,e,n){return t||o.Error.interfaceExpected({name:n}),function i(t,e,n){var r=Ye(e,t);return r||o.Error.interfaceExpected({name:n}),r}(t,e,n)}function ln(t){return fn(t,sn,"gpf.interfaces.IReadableStream")}function hn(t){return fn(t,cn,"gpf.interfaces.IWritableStream")}en("Enumerator",{"reset":0,"moveNext":0,"getCurrent":0}),en("FileStorage",{"getInfo":1,"openTextStream":2,"close":1,"explore":1,"createDirectory":1,"deleteFile":1,"deleteDirectory":1}),we(0,{readInProgress:"A read operation is already in progress",writeInProgress:"A write operation is already in progress",invalidStreamState:"Stream is in an invalid state"}),o.stream={};var pn="gpf.stream#progress",dn=pn+"/read",_n=pn+"/write";function mn(t){t.prototype[dn]=!1,t.prototype[_n]=!1}function vn(t,e,n){t[e]&&o.Error[n](),t[e]=!0}function gn(t){t[dn]=!1}function bn(t){t[_n]=!1}function yn(t,e,n){return t.then(function(t){return n(e),Promise.resolve(t)},function(t){return n(e),Promise.reject(t)})}function wn(r){return function(t){var e=hn(t);return function n(t){vn(t,dn,"readInProgress")}(this),yn(r.call(this,e),this,gn)}}function En(n){return function(t){return function e(t){vn(t,_n,"writeInProgress")}(this),yn(n.call(this,t),this,bn)}}var xn=Qe({$class:"gpf.stream.ReadableString",constructor:function(t){this._buffer=t},read:wn(function(t){return t.write(this._buffer)}),_buffer:""}),Sn=Qe({$class:"gpf.stream.WritableString",constructor:function(){this._buffer=[]},write:En(function(t){return this._buffer.push(t.toString()),Promise.resolve()}),toString:function(){return this._buffer.join("")},_buffer:[]});mn(xn),mn(Sn),we(0,{incompatibleStream:"Incompatible stream"});var On={NOT_FOUND:0,DIRECTORY:1,FILE:2,UNKNOWN:3},Pn=0,jn=1,Cn=null;function In(t,e){t===v&&(Cn=new e)}function Nn(t){t.length?t.pop():o.Error.unreachablePath()}function kn(t){var e=function n(t){return t.includes("\\")?t.toLowerCase().split("\\"):t.split("/")}(t);return function r(t){var e=t.pop();e&&t.push(e)}(e),e}function An(t){return kn(t).join("/")}function $n(t){return t?kn(t).pop():""}function Rn(t){var e=$n(t),n=e.lastIndexOf(".");return n===f?"":e.substring(n)}o.fs={types:{notFound:On.NOT_FOUND,directory:On.DIRECTORY,file:On.FILE,unknown:On.UNKNOWN},openFor:{reading:Pn,appending:jn},getFileStorage:function(){return Cn}},we(0,{unreachablePath:"Unreachable path"});var Tn={"":function(t){t.length=0,t.push("")},".":c,"..":function(t){Nn(t)}};function Dn(t){var e=kn(t);return S(arguments).forEach(function r(n,t){C(kn(t),function(t){var e=Tn[t];e?e(n):n.push(t)})}.bind(null,e)),e.join("/")}function Fn(t,e){t.length*e.length&&function n(t,e){for(;t[l]===e[l];)t.shift(),e.shift()}(t,e)}function Mn(t){var e=kn(t);return Nn(e),e.join("/")}o.path={join:Dn,parent:Mn,name:$n,nameOnly:function(t){var e=$n(t),n=e.lastIndexOf(".");return n===f?e:e.substring(l,n)},extension:Rn,relative:function Uo(t,e){var n,r=kn(t),i=kn(e);for(Fn(r,i),n=r.length;n--;)i.unshift("..");return i.join("/")}};function qn(t,e){var n,r=-1;return{reset:function(){return r=-1,Promise.resolve()},moveNext:function(){return++r,n=undefined,r"+this._getChildrenAsString()+"":"/>"},toString:function(){return ur(this._nodeName),"<"+this._nodeName+this._getAttributesAsString()+this._getClosingString()},_createElement:function(t){var e=t.ownerDocument,n=or(this._nodeName);return n?e.createElementNS(n.namespace,n.name):e.createElement(this._nodeName)},_setAttributesTo:function(r){O(this._attributes,function(t,e){var n=or(e);n?r.setAttributeNS(n.namespace,ar(n.name),t):r.setAttribute(ar(e),t)})},_appendChildrenTo:function(e){var n=e.ownerDocument;sr(this._children,function(t){t instanceof cr?t.appendTo(e):e.appendChild(n.createTextNode(t.toString()))})},appendTo:function(t){var e=this._createElement(t);return this._setAttributesTo(e),this._appendChildrenTo(e),t.appendChild(e)}});o.web.createTagFunction=function Xo(r){return r||o.Error.missingNodeName(),function(t){var e,n=0;return nr(t)&&(e=t,++n),new cr(r,e,E(arguments,n))}},o.http={};var fr="GET",lr="POST",hr="PUT",pr="OPTIONS",dr="DELETE",_r="HEAD",mr=/([^:\s]+)\s*: ?([^\r]*)/gm,vr=1,gr=2;function br(r){return function(e,n){n&&Object.keys(n).forEach(function(t){e[r](t,n[t])})}}function yr(n){return function(t,e){e?t[n](e):t[n]()}}function wr(e,r,i){return function(t){return{status:t[e],headers:function n(t){var e={};return C(Pe(mr,t),function(t){e[t[vr]]=t[gr]}),e}(t[r]()),responseText:t[i]}}}var Er;en("Thenable",{"then":2});function xr(t){return o.interfaces.isImplementedBy(o.interfaces.IThenable,t)?t:Promise.resolve(t)}function Sr(t,e){var n=Er;return t===v&&(Er=e),n}function Or(n){return new Promise(function(t,e){Er(n,t,e)})}function Pr(t,e,n){return Or("string"==typeof e?{method:t,url:e,data:n}:Object.assign({method:t},e))}o.promisify=xr,o.promisifyDefined=function Vo(t){if(undefined!==t)return xr(t)},Object.assign(o.http,{methods:{get:fr,post:lr,put:hr,options:pr,"delete":dr,head:_r},request:Or,get:Pr.bind(o.http,fr),post:Pr.bind(o.http,lr),put:Pr.bind(o.http,hr),options:Pr.bind(o.http,pr),"delete":Pr.bind(o.http,dr),head:Pr.bind(o.http,_r)});var jr=4,Cr=br("setRequestHeader"),Ir=yr("send"),Nr=wr("status","getAllResponseHeaders","responseText");function kr(t,e){var n=function r(t){var e=new XMLHttpRequest;return e.open(t.method,t.url),e}(t);Cr(n,t.headers),function i(t,e){t.onreadystatechange=function(){t.readyState===jr&&e(Nr(t))}}(n,e),Ir(n,t.data)}function Ar(t){var e=new Sn;return ln(t).read(e).then(function(){return e.toString()})}function $r(t){var e=Object.assign(r.parse(t.url),t);return function n(t,e){e&&(t.headers=Object.assign({"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(e)},t.headers))}(e,t.data),e}function Rr(t,e){var n=$r(t);return function r(t){return"https:"===t.protocol?s:a}(n).request(n,function(t){!function i(e,n){e.setEncoding("utf8");var r=new Wn(e);Ar(r).then(function(t){r.close(),n({status:e.statusCode,headers:e.headers,responseText:t})})}(t,e)})}Sr(t,kr),Sr(p,kr),Sr(h,function zo(t,e,n){var r=Rr(t,e);r.on("error",n),function i(t,e){e?t.write(e,"utf8",function(){t.end()}):t.end()}(r,t.data)});var Tr=br("setRequestHeader"),Dr=yr("Send"),Fr=wr("Status","GetAllResponseHeaders","ResponseText");Sr(m,function Ho(t,e){var n=function r(t){var e=new ActiveXObject("WinHttp.WinHttpRequest.5.1");return e.Open(t.method,t.url),e}(t);Tr(n,t.headers),Dr(n,t.data),function i(t,e){e(Fr(t))}(n,e)});var Mr,qr=Qe({$class:"gpf.java.BaseStream",constructor:function(t){this._stream=t},close:function(){return this._stream.close(),Promise.resolve()},_stream:null}),Br=Qe({$class:"gpf.java.ReadableStream",$extend:qr,_handleError:function(t){return t instanceof java.util.NoSuchElementException||t.message.startsWith("java.util.NoSuchElementException")?Promise.resolve():Promise.reject(t)},read:wn(function(t){try{var e=new java.util.Scanner(this._stream);return t.write(String(e.useDelimiter("\\A").next()))}catch(e_){return this._handleError(e_)}})}),Wr=Qe({$class:"gpf.java.WritableStream",$extend:qr,constructor:function(t){this.$super(t),this._writer=new java.io.OutputStreamWriter(t)},write:En(function(t){var e=this._writer;return e.write(t),e.flush(),Promise.resolve()}),close:function(){return this._writer.close(),this.$super()},_writer:null}),Ur=br("setRequestProperty");function Lr(e,n){(function r(t){var e=new Br(function n(t){try{return t.getInputStream()}catch(e_){return t.getErrorStream()}}(t));return Ar(e).then(function(t){return e.close(),t})})(e).then(function(t){n({status:e.getResponseCode(),headers:function r(t){var e={},n=t.getHeaderFields();return C(n.keySet().toArray(),function(t){e[String(t)]=String(n.get(t).get(l))}),e}(e),responseText:t})})}function Xr(t,e){var n=new java.net.URL(t.url).openConnection();n.setRequestMethod(t.method),Ur(n,t.headers),function r(t,e){if(e){t.setDoOutput(!0);var n=new Wr(t.getOutputStream());return n.write(e).then(function(){n.close()})}return Promise.resolve()}(n,t.data).then(function(){Lr(n,e)})}function Vr(t,e){var n;return t.every(function(t){return(n=function i(t,e){var n,r=t.url;if(r.lastIndex=0,n=r.exec(e.url))return t.response.apply(t,[e].concat(S(n)))}(t,e))===undefined}),n}function zr(t){return Mr[t]||(Mr[t]=[]),Mr[t]}Sr(d,Xr),Sr(e,Xr);var Hr,Zr=0;function Gr(){Mr={}}function Qr(){}Gr(),o.http.mock=function Zo(t){var e=t.method.toUpperCase(),n=e+"."+Zr++;return zr(e).unshift(Object.assign({id:n},t)),n},o.http.mock.remove=function Go(e){var t=e.substring(l,e.indexOf("."));Mr[t]=zr(t).filter(function(t){return t.id!==e})},o.http.mock.reset=Gr,Hr=Sr(v,function Qo(t,e,n){var r=function i(t){return Vr(zr(t.method.toUpperCase()),t)}(t);undefined===r?Hr(t,e,n):e(r)}),Qr.prototype={execute:c};var Jr=new Qr,Yr=new Qr;Jr.execute=function(t){t._readReject(t._readBuffer.shift())},Yr.execute=function(t){t._readResolve()};var Kr=Qe({$class:"gpf.stream.BufferedRead",constructor:function(){this._readBuffer=[]},_readBuffer:[],_readWriteToStream:null,_readResolve:null,_readReject:null,_readDataIsToken:function(t){return t instanceof Qr&&(t.execute(this),!0)},_readWriteToOutput:function(){var t=this,e=t._readBuffer.shift();return t._readDataIsToken(e)?Promise.resolve():t._readWriteToStream.write(e).then(function(){if(t._readBuffer.length)return t._readWriteToOutput();t._readNotWriting=!0})},_readNotWriting:!0,_readSafeWrite:function(){var e=this;e._readNotWriting&&(e._readNotWriting=!1,e._readWriteToOutput().then(undefined,function(t){e._readReject(t)}))},_readCheckIfData:function(){this._readBuffer.length&&this._readSafeWrite()},_readCheckIfOutput:function(){this._readWriteToStream&&this._readCheckIfData()},_appendToReadBuffer:function(t){return this._readBuffer=this._readBuffer.concat(E(arguments)),this._readCheckIfOutput(),this},_completeReadBuffer:function(){this._readBuffer.push(Yr),this._readCheckIfOutput()},_setReadError:function(t){this._readBuffer.push(Jr,t),this._readCheckIfOutput()},read:wn(function(t){var n=this;return n._readWriteToStream=t,n._readCheckIfData(),new Promise(function(t,e){n._readResolve=t,n._readReject=e})})});mn(Kr);var ti=/\r\n/g,ei=(Qe({$class:"gpf.stream.LineAdapter",$extend:Kr,constructor:function(){this.$super(),this._buffer=[]},write:En(function(t){return this._buffer.push(t.toString()),this._process(),Promise.resolve()}),flush:function(){return this._buffer.length&&(this._buffer.push("\n"),this._process()),this._completeReadBuffer(),Promise.resolve()},_buffer:[],_consolidateLines:function(){return this._buffer.join("").replace(ti,"\n").split("\n")},_pushBackLastLineIfNotEmpty:function(t){var e=t.pop();e.length&&this._buffer.push(e)},_process:function(){var e=this,t=e._consolidateLines();e._buffer.length=0,e._pushBackLastLineIfNotEmpty(t),C(t,function(t){e._appendToReadBuffer(t)})}}),en("FlushableStream",{"flush":0})),ni={};function ri(t,e){t===v&&(ni=e)}function ii(t){return ni(t)}o.read=ii,o.fs&&(o.fs.read=ii);ri(t,function Jo(t){return Or({method:fr,url:t}).then(function(t){if(2!==Math.floor(t.status/100))throw new Error(t.responseText);return t.responseText})}),ri(e,function Yo(t){var o=java.nio.file.Paths.get(t);return java.nio.file.Files.exists(o)?new Promise(function(t,e){var n=java.nio.file.Files.newInputStream(o),r=new Br(n),i=new Sn;return r.read(i).then(function(){t(i.toString())})["catch"](e)}):Promise.reject(new Error("File not found"))}),ri(h,function Ko(t){return new Promise(function(n,r){u.readFile(t,function(t,e){t?r(t):n(e.toString())})})}),ri(p,function tu(r){return new Promise(function(t,e){try{t(u.read(r))}catch(e_){e(new Error(e_))}})}),ri(d,function eu(e){return new Promise(function(t){t(readFile(e))})}),ri(m,function nu(n){return new Promise(function(t){var e=i.OpenTextFile(n,1,!1);t(e.ReadAll()),e.Close()})});var oi={};function ui(t,e){return Promise.resolve(e)}function ai(e){var n=this;return function r(t,e){var n=t.preload[e];return n?Promise.resolve(n):ii(e)}(n,e).then(function(t){return n.preprocess({name:e,content:t,type:Rn(e).toLowerCase()})}).then(function(t){return function e(t){return oi[t.type]||ui}(t).call(n,t.name,t.content)})}function si(t,e){return function r(t,e){return t._initialDefine=e.define,e.define=function n(){var t=this.gpf.require,e=this._initialDefine;return this.promise=e.apply(t,arguments),t.define=e,this.promise}.bind(t),t.gpf.require=e,t}(function n(){return{gpf:Object.create(o),promise:Promise.resolve(),_initialDefine:null}}(),bi(t,{base:Mn(e)}))}oi[".json"]=function(t,e){return JSON.parse(e)},we(0,{noCommonJSDynamicRequire:"Dynamic require not supported"});var ci=/[^.]\brequire\b\s*\(\s*(?:['|"]([^"']+)['|"]|[^)]+)\s*\)/g;var fi,li=[null,function ru(t){return{dependencies:[],factory:t}},function iu(t,e){return{dependencies:t,factory:e}},function ou(t,e,n){return{dependencies:e,factory:n}}];function hi(t,e,n){var r={};return M(["gpf","define","module","require"],e)(t,function i(t,e,n){var r=li[arguments.length].apply(null,arguments);this.require.define(r.dependencies,function(t){return t.length=r.dependencies.length,r.factory.apply(null,E(t))})}.bind(t),r,function(t){return n[t]||o.Error.noCommonJSDynamicRequire()}),r.exports}fi=t===v?function uu(t,e){var n=location.pathname.toString();return n.endsWith("/")||(n=Mn(n)),"//# sourceURL="+location.origin+Dn(n,t)+"?gpf.require\n"+e}:function au(t,e){return e},oi[".js"]=function(n,r){var i=si(this,n);return function o(t,e){var n=Pe(ci,e);return n.length?si(this,t).gpf.require.define(n.map(function(t){return t[1]}).filter(function(t){return t}).reduce(function(t,e){return t[e]=e,t},{}),function(t){return t}):Promise.resolve({})}.call(this,n,r).then(function(t){var e=hi(i.gpf,fi(n,r),t);return undefined===e?i.promise:e})},we(0,{invalidRequireConfigureOption:"Invalid configuration option",invalidRequireConfigureOptionValue:"Invalid configuration option value"});var pi={},di=[];function _i(t,e,n){n?di.unshift(t):di.push(t),pi[t]=e}function mi(e){!function r(t){C(Object.keys(t),function(t){pi[t]||o.Error.invalidRequireConfigureOption()})}(e);var n=this;C(di.filter(function(t){return e[t]!==undefined}),function(t){pi[t](n,e[t])})}function vi(t){return Dn(this.base,t)}function gi(e){var t;return this.cache[e]?this.cache[e]:(t=ai.call(this,e),(this.cache[e]=t)["catch"](function(t){return function n(t,e){Array.isArray(t.requires)||(t.requires=[]),t.requires.push(e)}(t,e),Promise.reject(t)}))}function bi(t,e){var n=Object.create(t),r={};return r.define=function o(e,t){var n=this,r=[],i=Object.keys(e);return C(i,function(t){r.push(gi.call(n,vi.call(n,e[t])))},n),Promise.all(r).then(function(n){var r;return"function"==typeof t?(r={},C(i,function(t,e){r[t]=n[e]}),t(r)):t})}.bind(n),r.resolve=vi.bind(n),r.configure=mi.bind(n),e&&r.configure(e),r}_i("base",function su(t,e){!function n(t){"string"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.base=e}),_i("cache",function cu(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),C(Object.keys(n),function(t){e.cache[t]=Promise.resolve(n[t])})}),_i("clearCache",function fu(t,e){!function n(t){"boolean"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),e&&(t.cache={})},!0),_i("preload",function lu(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),C(Object.keys(n),function(t){e.preload[t]=n[t]})}),_i("preprocess",function hu(t,e){!function n(t){"function"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.preprocess=e}),o.require=bi({base:"",cache:{},preload:{},preprocess:function(t){return Promise.resolve(t)}});var yi=Qe({$class:"gpf.stream.ReadableArray",constructor:function(t){this._buffer=t},read:wn(function(t){var e=this._buffer,n=0;return function r(){return e.length===n?Promise.resolve():t.write(e[n++]).then(r)}()}),_buffer:[]}),wi=Qe({$class:"gpf.stream.WritableArray",constructor:function(){this._buffer=[]},write:En(function(t){return this._buffer.push(t),Promise.resolve()}),toArray:function(){return this._buffer},_buffer:[]});mn(yi),mn(wi);var Ei={flush:Promise.resolve.bind(Promise)};function xi(t){return Ye(ei,t)||Ei}function Si(t){if(t.readError)return Promise.reject(t.readError)}function Oi(t,e){var n=function a(t,e){return{iReadableIntermediate:ln(t),iWritableIntermediate:hn(t),iFlushableIntermediate:xi(t),iWritableDestination:hn(e),iFlushableDestination:xi(e),readError:null,rejectWrite:c}}(t,e),r=function s(e){var n=!0,r=e.iReadableIntermediate,i=e.iWritableDestination;return function(){if(n)try{n=!1,r.read(i).then(function(){n=!0},function(t){e.readError=t,e.rejectWrite(t)})}catch(e_){e.readError=e_}}}(n),i=n.iFlushableIntermediate,o=n.iFlushableDestination,u=n.iWritableIntermediate;return r(),{flush:function(){return Si(n)||i.flush().then(function(){return o.flush()})},write:function(t){return r(),Si(n)||function e(n,r){return new Promise(function(e,t){r.then(function(t){e(t),n.rejectWrite=c},t),n.rejectWrite=t})}(n,u.write(t))}}}function Pi(t){return S(t).length?function r(t){for(var e=t.length,n=t[--e];e;)n=Oi(t[--e],n);return n}(t):hn(t[l])}o.stream.pipe=function pu(t,e){var n=ln(t),r=Pi(S(arguments)),i=xi(r);try{return n.read(r).then(function(){return i.flush()})}catch(e_){return Promise.reject(e_)}};function ji(t){return W(t,"regexp")}B.regexp={"\\":"\\\\","-":"\\-","[":"\\[","]":"\\]","/":"\\/","{":"\\{","}":"\\}","(":"\\(",")":"\\)","*":"\\*","+":"\\+","?":"\\?",".":"\\.","^":"\\^","$":"\\$","|":"\\|"},we(0,{invalidCSV:"Invalid CSV syntax (bad quote sequence or missing end of file)"}),o.stream.csv={};var Ci=";,\t ".split("");Qe({$class:"gpf.stream.csv.Parser",$extend:Kr,constructor:function(t){this._readParserOptions(t),this._header?this._parseHeader():this._write=this._writeHeader},_readParserOptions:function(e){var n=this;e&&C(["header","separator","quote","newLine"],function(t){e[t]&&(n["_"+t]=e[t])})},_header:"",_separator:"",_deduceSeparator:function(){var e=this._header;this._separator=function u(t,e,n){for(var r,i=0,o=t.length;i"),t.content=!0)},_addContentToLastElement:function(){var t=this._elements[l];if(t)return this._addContentToElement(t)},_writeAttribute:function(t,e){this._appendToReadBuffer(" "+t+'="'),this._appendToReadBuffer(X(e.toString())),this._appendToReadBuffer('"')},_getNamespacePrefixes:function(){return this._elements.reduce(function(t,e){return t.concat(Object.keys(e.namespaces))},[])},_processAttributes:function(t){O(t,function(t,e){ro(e,this._getNamespacePrefixes()),this._writeAttribute(e,t)},this)},_processNamespaces:function(t){O(t,function(t,e){e?this._writeAttribute("xmlns:"+e,t):this._writeAttribute("xmlns",t)},this)},characters:function(t){return this._checkState(!0),this._addContentToLastElement(),this._appendToReadBuffer(X(t.toString())),Promise.resolve()},endDocument:function(){return this._checkState(!1),this._checkIfStarted=o.Error.invalidXmlWriterState,this._completeReadBuffer(),Promise.resolve()},endElement:function(){this._checkState(!0);var t=this._elements.shift();return t.content?this._appendToReadBuffer(""):this._appendToReadBuffer("/>"),Promise.resolve()},endPrefixMapping:function(t){return this._checkState(),Promise.resolve()},processingInstruction:function(t,e){return this._checkState(!1),this._appendToReadBuffer("\n"),Promise.resolve()},startDocument:function(){return this._checkIfStarted=c,this.startDocument=o.Error.invalidXmlWriterState,this._checkState(!1),Promise.resolve()},startElement:function(t,e){var n=this._nextNamespaces;this._checkState(),this._addContentToLastElement(),this._elements.unshift({qName:t,namespaces:n}),this._nextNamespaces={},no(t,this._getNamespacePrefixes()),this._appendToReadBuffer("<"+t),e&&this._processAttributes(e),this._processNamespaces(n)},startPrefixMapping:function(t,e){this._checkState(),function n(t){Ji(t),Yi(t),"xml"===t&&o.Error.invalidXmlUseOfPrefixXml()}(t),this._nextNamespaces[t]&&o.Error.invalidXmlWriterState(),this._nextNamespaces[t]=e}});o.forEachAsync=function(t,e,n){if(j(t))return function s(n,r,i){var o=0,u=n.length;return function a(){if(o===u)return Promise.resolve();var t=o++;try{return xr(r.call(i,n[t],t,n)).then(a)}catch(e_){return Promise.reject(e_)}}()}(t,e,n);o.Error.invalidParameter()},we(0,{invalidSerialName:"Invalid serial name",invalidSerialType:"Invalid serial type",invalidSerialRequired:"Invalid serial required",invalidSerialReadOnly:"Invalid serial readOnly"}),o.serial={};var io={STRING:"string",INTEGER:"integer",DATETIME:"datetime"};o.serial.types={string:io.STRING,integer:io.INTEGER,datetime:io.DATETIME};var oo=/^[a-z][a-z0-9_]*$/i;function uo(t){!function e(t){"string"!=typeof t&&o.Error.invalidSerialName()}(t.name),function n(t){t.match(oo)||o.Error.invalidSerialName()}(t.name)}var ao=Object.keys(io).map(function(t){return io[t]});function so(t){undefined===t.type?t.type=io.STRING:function e(t){ao.includes(t)||o.Error.invalidSerialType()}(t.type)}function co(t,e){"boolean"!=typeof t&&e()}function fo(t){var e=Object.assign(t);return[uo,so,function n(t){undefined===t.required?t.required=!1:co(t.required,o.Error.invalidSerialRequired)},function r(t){undefined!==t.readOnly&&co(t.readOnly,o.Error.invalidSerialReadOnly)}].forEach(function(t){t(e)}),e}function lo(t){t&&o.Error.classAttributeOnly()}function ho(t,e){var n=t._extend;n!==e&&function r(t,e){t instanceof e||o.Error.restrictedBaseClassAttribute()}(n.prototype,e)}function po(t,e,n){S(function i(t,e,n){var r=e.getAttributes(n);return t?r[t]:r[ki]}(t,e,n)).length&&o.Error.uniqueAttributeUsedTwice()}we(0,{classAttributeOnly:"Class attribute only",memberAttributeOnly:"Member attribute only",restrictedBaseClassAttribute:"Restricted base class attribute",uniqueAttributeUsedTwice:"Unique attribute used twice"});var _o=Qe({$class:"gpf.attributes.AttributeAttribute",$extend:Ii,$abstract:!0,_check:function(t,e){lo(t),ho(e,Ii),po(t,e,this.constructor)},_targetCheck:Ce(),_overrideTargetCheck:function(t){var n=this,r=t._check;t._check=function(t,e){n._targetCheck(t,e,this),r.call(this,t,e)}},_build:function(t,e,n){this._overrideTargetCheck(n)}}),mo=Qe({$class:"gpf.attributes.ClassAttribute",$extend:_o,$singleton:!0,_targetCheck:function(t,e){lo(t)}});o.attributes.ClassAttribute=mo;var vo=Qe({$class:"gpf.attributes.MemberAttribute",$extend:_o,$singleton:!0,_targetCheck:function(t,e){!function n(t){t||o.Error.memberAttributeOnly()}(t)}});o.attributes.MemberAttribute=vo;var go=Qe({$class:"gpf.attributes.AttributeForInstanceOf",$extend:_o,_BaseClass:null,constructor:function(t){"function"!=typeof t&&o.Error.invalidParameter(),this._BaseClass=t},_targetCheck:function(t,e){ho(e,this._BaseClass)}});o.attributes.AttributeForInstanceOf=go;var bo=Qe({$class:"gpf.attributes.UniqueAttribute",$extend:_o,$singleton:!0,_targetCheck:function(t,e,n){po(t,e,n.constructor)}});o.attributes.UniqueAttribute=bo;var yo,wo=Qe({$class:"gpf.attributes.Serializable",$extend:Ii,$attributes:[new vo,new bo],_property:null,constructor:function(t){this._property=t},_check:function(t,e){this._property=fo(Object.assign({name:function n(t){return t.startsWith("_")?t.substring(1):t}(t)},this._property))},getProperty:function(){return Object.create(this._property)}});function Eo(t){var e=Li(t,wo),n={};return O(e,function(t,e){n[e]=t[l].getProperty()}),n}function xo(t,e){var n=Object.getOwnPropertyDescriptor(t,e);if(n)return!n.writable}function So(n){var t=Eo(n);return O(t,function(t,e){t.readOnly===undefined&&(t.readOnly=yo(n,e))}),t}function Oo(t,e){if(!e.readOnly)return t}function Po(n,t,i){var o={};return O(t,function(t,e){!function r(t,e,n){n!==undefined&&(t[e]=n)}(o,t.name,i.call(n,n[e],t,e))}),o}function jo(n,i,o){var t=So(n);O(t,function(t,e){i.hasOwnProperty(t.name)&&function r(t,e,n){n!==undefined&&(t[e]=n)}(n,e,o.call(n,i[t.name],t,e))})}function Co(t,e,n){var r=function i(t){return t||ki}(e);t._attributes[r]=(t._attributes[r]||[]).concat(n),function o(e,n,t){t.forEach(function(t){Fi.call(e,n,t),Wi(n,t,e._instanceBuilder.prototype)})}(t,e,n)}yo=Object.getOwnPropertyDescriptor?function(t,e){for(var n,r=t;r!==Object&&n===undefined;)n=xo(r,e),r=Object.getPrototypeOf(r);return n||!1}:function(){return!1},o.serial.get=Eo,o.serial.toRaw=function(t,e){return"function"==typeof t&&o.Error.invalidParameter(),function n(t,e){return Po(t,So(t),e||Oo)}(t,e)},o.serial.fromRaw=function(t,e,n){return"function"==typeof t&&o.Error.invalidParameter(),function r(t,e,n){jo(t,e,n||Oo)}(t,e,n),t},we(0,{es6classOnly:"ES6 class only"}),o.attributes.decorator=function vu(){var n=E(arguments);return function(t,e){Ee(t)||o.Error.es6classOnly(),Co(De(t),e,n)}}}); \ No newline at end of file +!function(t){"use strict";if("function"==typeof define&&define.amd)define(["exports"],t);else if("undefined"!=typeof exports)t(exports);else if("undefined"!=typeof module&&module.exports)t(module.exports);else{var e=Function("return this;")(),n={};t(n),e.gpf=n}}(function(o){"use strict";function s(){}var i,a,u,c,n,r,f=-1,l=0,t="browser",e="nashorn",p="nodejs",h="phantomjs",d="rhino",_="unknown",m="wscript",v=_,g=Function,b=new g("return this")();function y(e){return{log:function(t){e(" "+t)},info:function(t){e("[?] "+t)},warn:function(t){e("/!\\ "+t)},error:function(t){e("(X) "+t)}}}function w(){"\\"===String(java.lang.System.getProperty("file.separator")),b.console=y(print),function(t){java.lang.System.exit(t)}}function E(t,e,n){return Array.prototype.slice.call(t,e,n||t.length)}"undefined"!=typeof WScript?v=m:"undefined"!=typeof print&&"undefined"!=typeof java?v="undefined"==typeof readFile?e:d:"undefined"!=typeof phantom&&phantom.version&&!document.currentScript?(v=h,b=window):"undefined"!=typeof module&&module.exports?(v=p,b=global):"undefined"!=typeof window&&(v=t,b=window),o.version=function(){return"1.0.0"},t===v&&(function(t){window.location="https://arnaudbuchholz.github.io/gpf/exit.html?"+t},window,document),o.node={},p===v&&(n=require("path"),a=require("fs"),u=require("http"),c=require("https"),r=require("url"),"\\"===n.sep),h===v&&("\\"===require("fs").separator,function(t){phantom.exit(t)},window,document,a=require("fs")),o.java={},o.rhino=o.java,d===v&&w(),e===v&&w(),o.wscript={},m===v&&(!0,i=new ActiveXObject("Scripting.FileSystemObject"),b.console=y(function Ro(t){WScript.Echo(t)})),o.hosts={browser:t,nashorn:e,nodejs:p,phantomjs:h,rhino:d,unknown:_,wscript:m},o.host=function(){return v};var x=1;function O(t){return E(t,x)}var S,P=Array.isArray;function j(t){return P(t)||function e(t){return!!t&&Math.floor(t.length)===t.length}(t)}function I(t,e,n){for(var r=0,i=t.length;r":">"};var Z=1;function G(t,e){var n=function r(t){return t[Z]}(e);return undefined!==n?t.bind(n):t}function Q(t,e){for(var n=t.length,r=0;rrt.length&&(rt=nt(e.length)),rt.apply(t,e)}(Ct,arguments)}var kt,At="2003-01-22T22:45:34.075Z",Rt="2003-01-22";function $t(t,e,n){var r=!0;function i(e){return function(t){r&&(r=!1,e(t))}}try{t(i(e),i(n))}catch(e_){r&&(r=!1,n(e_))}}function Tt(){var e=this;e._handlers.forEach(function(t){t.process(e)}),e._handlers=[]}function Dt(t){this._state=!1,this._value=t,Tt.call(this)}function Ft(t){if(t&&["object","function"].includes(typeof t))return function n(t,e){if("function"==typeof e)return $t(e.bind(t),kt.bind(this),Dt.bind(this)),!0}.call(this,t,t.then)}!function Fo(){var t,e;!function n(){I(["prototype","UTC","parse","now"],function(t){Nt[t]=Ct[t]})}();try{t=ht(new Date(At)),e=ht(new Date(Rt))}catch(e_){}t===At&&e===Rt+"T00:00:00.000Z"||(b.Date=Nt)}(),kt=function(t){var e=this;try{if(Ft.call(e,t))return;e._state=!0,e._value=t,Tt.call(e)}catch(e_){Dt.call(e,e_)}};var Mt=o.Promise=function(t){this._handlers=[],$t(t,kt.bind(this),Dt.bind(this))};function qt(){}function Bt(t){var e,n=this,r=function i(t,e){return e._state?t.onFulfilled:t.onRejected}(n,t);if(null===r)return function o(t,e){e._state?t.resolve(e._value):t.reject(e._value)}(n,t);try{e=r(t._value)}catch(e_){return void n.reject(e_)}n.resolve(e)}var Wt=[];function Ut(){for(;Wt.length;){var t=Wt.shift(),e=Wt.shift();Bt.call(t,e)}}qt.prototype={onFulfilled:null,onRejected:null,resolve:null,reject:null,process:function(t){null!==t._state?(Wt.length||setTimeout(Ut,0),Wt.push(this,t)):t._handlers.push(this)}},Mt.prototype={_state:null,_value:null,_handlers:[],then:function(r,i){var o=this;return new Mt(function(t,e){var n=new qt;undefined!==r&&(n.onFulfilled=r),undefined!==i&&(n.onRejected=i),n.resolve=t,n.reject=e,n.process(o)})},"catch":function(t){return this.then(null,t)}},Mt.resolve=function(e){return new Mt(function(t){t(e)})},Mt.reject=function(n){return new Mt(function(t,e){e(n)})},Mt.all=function(n){return n.length?new Mt(function(t,e){n.forEach(function o(t,e){var n=this;try{if(t instanceof Mt)return void t.then(function(t){o.call(n,t,e)},n.reject);!function r(t,e,n){t.promises[e]=n,--t.remaining||t.resolve(t.promises)}(n,e,t)}catch(e_){n.reject(e_)}}.bind({resolve:t,reject:e,remaining:n.length,promises:n}))}):Mt.resolve([])},Mt.race=function(t){return new Mt(function(e,n){t.forEach(function(t){t.then(e,n)})})},H("Promise",Mt);var Lt={};function Xt(t){java.lang.Thread.sleep(t)}Lt[m]=function(t){WScript.Sleep(t)},Lt[d]=Xt,Lt[e]=Xt;var Vt,zt=[],Ht=0,Zt=Lt[v]||s;function Gt(t,e){return t.dt===e.dt?t.id-e.id:t.dt-e.dt}function Qt(t){return t.toString()}function Jt(t,e){return e?"\n"+e+t.join(",\n"+e)+"\n":t.join(",")}function Yt(t,e,n){return null===t?"null":function u(t,r,i){var o,a=[];return o=i?": ":":",S(t,function(t,e){var n=r(e,t);n=Vt[typeof n](t,r,i),undefined!==n&&a.push(L(e)+o+n)}),"{"+Jt(a,i)+"}"}(t,e,n)}o.handleTimeout=function Mo(){for(var t,e;zt.length;){for(t=zt.shift(),e=(new Date).getTime();t.dt>e;)Zt(t.dt-e),e=(new Date).getTime();t.cb()}},H("setTimeout",function qo(t,e){var n={id:++Ht,dt:(new Date).getTime()+e,cb:t};return zt.push(n),zt.sort(Gt),Ht}),H("clearTimeout",function Bo(e){zt=zt.filter(function(t){return t.id!==e})}),Vt={undefined:s,"function":s,number:Qt,"boolean":Qt,string:function(t){return L(t)},object:function(t,e,n){return P(t)?function a(t,r,i){var o=[];return I(t,function(t,e){var n=r(e.toString(),t);n=undefined===n?"null":Vt[typeof n](n,r,i),o.push(n)}),"["+Jt(o,i)+"]"}(t,e,n):Yt(t,e,n)}};var Kt=10;H("JSON",{parse:function Wo(t,e){var n=M("return "+t)();return e?function i(n,t,r){return"object"==typeof n&&S(n,function(t,e){n[e]=i(t,e,r)}),r(t,n)}(n,"",e):n},stringify:function Uo(t,e,n){return Vt[typeof t](t,function r(n){return P(n)?function(t,e){if(n.includes(t))return e}:function e(t){return"function"==typeof t?t:function(t,e){return e}}(n)}(e),function i(t){return"number"==typeof t?"".padEnd(Math.min(t,Kt)," "):t||""}(n))}});var te=$+R+T+"+/=",ee=63,ne=18,re=12,ie=6,oe=8,ae=16,ue=64,se=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function ce(t,e,n){var r=String.fromCharCode(t>>ae&A);return e!==ue?r+function i(t,e){return e===ue?String.fromCharCode(t>>oe&A):String.fromCharCode(t>>oe&A,t&A)}(t,n):r}function fe(t,e){return te.indexOf(t.charAt(e))}function le(t,e){var n=t.charCodeAt(e);if(A>e&n)}function he(t,e){if(undefined!==t)return t[e]}function de(t,e){var n=t[e];return undefined===n&&(n=t[e]={}),n}function _e(t,e){return function r(t,e){var n;return("gpf"===t[l]?(n=o,O(t)):(n=b,t)).reduce(e,n)}(t,e?de:he)}H("atob",function Lo(t){var e,n,r,i,o,a=function f(t){var e=t.replace(/[\t\n\f\r ]+/g,"");if(!se.test(e))throw new TypeError("The string to be decoded is not correctly encoded.");return e}(t),u=a.length,s=0,c="";for(a+="==";s"),gte:sn("gte",">="),not:function(t){return"!"+rn(t.not)},like:function(t){var e=function n(t){return"/"+t.regexp+"/.exec("+rn(t.like)+")"}(t);return t.group?"("+e+"||[])["+t.group+"]":e},or:sn("or","||"),and:sn("and","&&"),undefined:function(t){return JSON.stringify(t)}},fn=Object.keys(cn);rn=function(t){var e=function n(t){if("object"==typeof t)return Object.keys(t).filter(function(t){return fn.includes(t)})[l]}(t);return(0,cn[e])(t)},o.createFilterFunction=function(t){return M(["i"],function e(t){return"return "+rn(t)}(t))};var ln=on("ReadableStream",{"read":1}),pn=on("WritableStream",{"write":1});function hn(t,e,n){return t||o.Error.interfaceExpected({name:n}),function i(t,e,n){var r=en(e,t);return r||o.Error.interfaceExpected({name:n}),r}(t,e,n)}function dn(t){return hn(t,ln,"gpf.interfaces.IReadableStream")}function _n(t){return hn(t,pn,"gpf.interfaces.IWritableStream")}on("Enumerator",{"reset":0,"moveNext":0,"getCurrent":0}),on("FileStorage",{"getInfo":1,"openTextStream":2,"close":1,"explore":1,"createDirectory":1,"deleteFile":1,"deleteDirectory":1}),Se(0,{readInProgress:"A read operation is already in progress",writeInProgress:"A write operation is already in progress",invalidStreamState:"Stream is in an invalid state"}),o.stream={};var mn="gpf.stream#progress",vn=mn+"/read",gn=mn+"/write";function bn(t){t.prototype[vn]=!1,t.prototype[gn]=!1}function yn(t,e,n){t[e]&&o.Error[n](),t[e]=!0}function wn(t){t[vn]=!1}function En(t){t[gn]=!1}function xn(t,e,n){return t.then(function(t){return n(e),Promise.resolve(t)},function(t){return n(e),Promise.reject(t)})}function On(r){return function(t){var e=_n(t);return function n(t){yn(t,vn,"readInProgress")}(this),xn(r.call(this,e),this,wn)}}function Sn(n){return function(t){return function e(t){yn(t,gn,"writeInProgress")}(this),xn(n.call(this,t),this,En)}}var Pn=Ke({$class:"gpf.stream.ReadableString",constructor:function(t){this._buffer=t},read:On(function(t){return t.write(this._buffer)}),_buffer:""}),jn=Ke({$class:"gpf.stream.WritableString",constructor:function(){this._buffer=[]},write:Sn(function(t){return this._buffer.push(t.toString()),Promise.resolve()}),toString:function(){return this._buffer.join("")},_buffer:[]});bn(Pn),bn(jn),Se(0,{incompatibleStream:"Incompatible stream"});var In={NOT_FOUND:0,DIRECTORY:1,FILE:2,UNKNOWN:3},Cn=0,Nn=1,kn=null;function An(t,e){t===v&&(kn=new e)}function Rn(t){t.length?t.pop():o.Error.unreachablePath()}function $n(t){var e=function n(t){return t.includes("\\")?t.toLowerCase().split("\\"):t.split("/")}(t);return function r(t){var e=t.pop();e&&t.push(e)}(e),e}function Tn(t){return $n(t).join("/")}function Dn(t){return t?$n(t).pop():""}function Fn(t){var e=Dn(t),n=e.lastIndexOf(".");return n===f?"":e.substring(n)}o.fs={types:{notFound:In.NOT_FOUND,directory:In.DIRECTORY,file:In.FILE,unknown:In.UNKNOWN},openFor:{reading:Cn,appending:Nn},getFileStorage:function(){return kn}},Se(0,{unreachablePath:"Unreachable path"});var Mn={"":function(t){t.length=0,t.push("")},".":s,"..":function(t){Rn(t)}};function qn(t){var e=$n(t);return O(arguments).forEach(function r(n,t){I($n(t),function(t){var e=Mn[t];e?e(n):n.push(t)})}.bind(null,e)),e.join("/")}function Bn(t,e){t.length*e.length&&function n(t,e){for(;t[l]===e[l];)t.shift(),e.shift()}(t,e)}function Wn(t){var e=$n(t);return Rn(e),e.join("/")}o.path={join:qn,parent:Wn,name:Dn,nameOnly:function(t){var e=Dn(t),n=e.lastIndexOf(".");return n===f?e:e.substring(l,n)},extension:Fn,relative:function zo(t,e){var n,r=$n(t),i=$n(e);for(Bn(r,i),n=r.length;n--;)i.unshift("..");return i.join("/")}};function Un(t,e){var n,r=-1;return{reset:function(){return r=-1,Promise.resolve()},moveNext:function(){return++r,n=undefined,r"+this._getChildrenAsString()+"":"/>"},toString:function(){return cr(this._nodeName),"<"+this._nodeName+this._getAttributesAsString()+this._getClosingString()},_createElement:function(t){var e=t.ownerDocument,n=sr(this._nodeName);return n?e.createElementNS(n.namespace,n.name):e.createElement(this._nodeName)},_setAttributesTo:function(r){S(this._attributes,function(t,e){var n=sr(e);n?r.setAttributeNS(n.namespace,fr(n.name),t):r.setAttribute(fr(e),t)})},_appendChildrenTo:function(e){var n=e.ownerDocument;lr(this._children,function(t){t instanceof pr?t.appendTo(e):e.appendChild(n.createTextNode(t.toString()))})},appendTo:function(t){var e=this._createElement(t);return this._setAttributesTo(e),this._appendChildrenTo(e),t.appendChild(e)}});o.web.createTagFunction=function Zo(r){return r||o.Error.missingNodeName(),function(t){var e,n=0;return or(t)&&(e=t,++n),new pr(r,e,E(arguments,n))}},o.http={};var hr="GET",dr="POST",_r="PUT",mr="OPTIONS",vr="DELETE",gr="HEAD",br=/([^:\s]+)\s*: ?([^\r]*)/gm,yr=1,wr=2;function Er(r){return function(e,n){n&&Object.keys(n).forEach(function(t){e[r](t,n[t])})}}function xr(n){return function(t,e){e?t[n](e):t[n]()}}function Or(e,r,i){return function(t){return{status:t[e],headers:function n(t){var e={};return I(Ne(br,t),function(t){e[t[yr]]=t[wr]}),e}(t[r]()),responseText:t[i]}}}var Sr;on("Thenable",{"then":2});function Pr(t){return o.interfaces.isImplementedBy(o.interfaces.IThenable,t)?t:Promise.resolve(t)}function jr(t,e){var n=Sr;return t===v&&(Sr=e),n}function Ir(n){return new Promise(function(t,e){Sr(n,t,e)})}function Cr(t,e,n){return Ir("string"==typeof e?{method:t,url:e,data:n}:Object.assign({method:t},e))}o.promisify=Pr,o.promisifyDefined=function Go(t){if(undefined!==t)return Pr(t)},Object.assign(o.http,{methods:{get:hr,post:dr,put:_r,options:mr,"delete":vr,head:gr},request:Ir,get:Cr.bind(o.http,hr),post:Cr.bind(o.http,dr),put:Cr.bind(o.http,_r),options:Cr.bind(o.http,mr),"delete":Cr.bind(o.http,vr),head:Cr.bind(o.http,gr)});var Nr=4,kr=Er("setRequestHeader"),Ar=xr("send"),Rr=Or("status","getAllResponseHeaders","responseText");function $r(t,e){var n=function r(t){var e=new XMLHttpRequest;return e.open(t.method,t.url),e}(t);kr(n,t.headers),function i(t,e){t.onreadystatechange=function(){t.readyState===Nr&&e(Rr(t))}}(n,e),Ar(n,t.data)}function Tr(t){var e=new jn;return dn(t).read(e).then(function(){return e.toString()})}function Dr(t){var e=Object.assign(r.parse(t.url),t);return function n(t,e){e&&(t.headers=Object.assign({"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(e)},t.headers))}(e,t.data),e}function Fr(t,e){var n=Dr(t);return function r(t){return"https:"===t.protocol?c:u}(n).request(n,function(t){!function i(e,n){e.setEncoding("utf8");var r=new Xn(e);Tr(r).then(function(t){r.close(),n({status:e.statusCode,headers:e.headers,responseText:t})})}(t,e)})}jr(t,$r),jr(h,$r),jr(p,function Qo(t,e,n){var r=Fr(t,e);r.on("error",n),function i(t,e){e?t.write(e,"utf8",function(){t.end()}):t.end()}(r,t.data)});var Mr=Er("setRequestHeader"),qr=xr("Send"),Br=Or("Status","GetAllResponseHeaders","ResponseText");jr(m,function Jo(t,e){var n=function r(t){var e=new ActiveXObject("WinHttp.WinHttpRequest.5.1");return e.Open(t.method,t.url),e}(t);Mr(n,t.headers),qr(n,t.data),function i(t,e){e(Br(t))}(n,e)});var Wr,Ur=Ke({$class:"gpf.java.BaseStream",constructor:function(t){this._stream=t},close:function(){return this._stream.close(),Promise.resolve()},_stream:null}),Lr=Ke({$class:"gpf.java.ReadableStream",$extend:Ur,_handleError:function(t){return t instanceof java.util.NoSuchElementException||t.message.startsWith("java.util.NoSuchElementException")?Promise.resolve():Promise.reject(t)},read:On(function(t){try{var e=new java.util.Scanner(this._stream);return t.write(String(e.useDelimiter("\\A").next()))}catch(e_){return this._handleError(e_)}})}),Xr=Ke({$class:"gpf.java.WritableStream",$extend:Ur,constructor:function(t){this.$super(t),this._writer=new java.io.OutputStreamWriter(t)},write:Sn(function(t){var e=this._writer;return e.write(t),e.flush(),Promise.resolve()}),close:function(){return this._writer.close(),this.$super()},_writer:null}),Vr=Er("setRequestProperty");function zr(e,n){(function r(t){var e=new Lr(function n(t){try{return t.getInputStream()}catch(e_){return t.getErrorStream()}}(t));return Tr(e).then(function(t){return e.close(),t})})(e).then(function(t){n({status:e.getResponseCode(),headers:function r(t){var e={},n=t.getHeaderFields();return I(n.keySet().toArray(),function(t){e[String(t)]=String(n.get(t).get(l))}),e}(e),responseText:t})})}function Hr(t,e){var n=new java.net.URL(t.url).openConnection();n.setRequestMethod(t.method),Vr(n,t.headers),function r(t,e){if(e){t.setDoOutput(!0);var n=new Xr(t.getOutputStream());return n.write(e).then(function(){n.close()})}return Promise.resolve()}(n,t.data).then(function(){zr(n,e)})}function Zr(t,e){var n;return t.every(function(t){return(n=function i(t,e){var n,r=t.url;if(r.lastIndex=0,n=r.exec(e.url))return t.response.apply(t,[e].concat(O(n)))}(t,e))===undefined}),n}function Gr(t){return Wr[t]||(Wr[t]=[]),Wr[t]}jr(d,Hr),jr(e,Hr);var Qr,Jr=0;function Yr(){Wr={}}function Kr(){}Yr(),o.http.mock=function Yo(t){var e=t.method.toUpperCase(),n=e+"."+Jr++;return Gr(e).unshift(Object.assign({id:n},t)),n},o.http.mock.remove=function Ko(e){var t=e.substring(l,e.indexOf("."));Wr[t]=Gr(t).filter(function(t){return t.id!==e})},o.http.mock.reset=Yr,Qr=jr(v,function ta(t,e,n){var r=function i(t){return Zr(Gr(t.method.toUpperCase()),t)}(t);undefined===r?Qr(t,e,n):e(r)}),Kr.prototype={execute:s};var ti=new Kr,ei=new Kr;ti.execute=function(t){t._readReject(t._readBuffer.shift())},ei.execute=function(t){t._readResolve()};var ni=Ke({$class:"gpf.stream.BufferedRead",constructor:function(){this._readBuffer=[]},_readBuffer:[],_readWriteToStream:null,_readResolve:null,_readReject:null,_readDataIsToken:function(t){return t instanceof Kr&&(t.execute(this),!0)},_readWriteToOutput:function(){var t=this,e=t._readBuffer.shift();return t._readDataIsToken(e)?Promise.resolve():t._readWriteToStream.write(e).then(function(){if(t._readBuffer.length)return t._readWriteToOutput();t._readNotWriting=!0})},_readNotWriting:!0,_readSafeWrite:function(){var e=this;e._readNotWriting&&(e._readNotWriting=!1,e._readWriteToOutput().then(undefined,function(t){e._readReject(t)}))},_readCheckIfData:function(){this._readBuffer.length&&this._readSafeWrite()},_readCheckIfOutput:function(){this._readWriteToStream&&this._readCheckIfData()},_appendToReadBuffer:function(t){return this._readBuffer=this._readBuffer.concat(E(arguments)),this._readCheckIfOutput(),this},_completeReadBuffer:function(){this._readBuffer.push(ei),this._readCheckIfOutput()},_setReadError:function(t){this._readBuffer.push(ti,t),this._readCheckIfOutput()},read:On(function(t){var n=this;return n._readWriteToStream=t,n._readCheckIfData(),new Promise(function(t,e){n._readResolve=t,n._readReject=e})})});bn(ni);var ri=/\r\n/g,ii=(Ke({$class:"gpf.stream.LineAdapter",$extend:ni,constructor:function(){this.$super(),this._buffer=[]},write:Sn(function(t){return this._buffer.push(t.toString()),this._process(),Promise.resolve()}),flush:function(){return this._buffer.length&&(this._buffer.push("\n"),this._process()),this._completeReadBuffer(),Promise.resolve()},_buffer:[],_consolidateLines:function(){return this._buffer.join("").replace(ri,"\n").split("\n")},_pushBackLastLineIfNotEmpty:function(t){var e=t.pop();e.length&&this._buffer.push(e)},_process:function(){var e=this,t=e._consolidateLines();e._buffer.length=0,e._pushBackLastLineIfNotEmpty(t),I(t,function(t){e._appendToReadBuffer(t)})}}),on("FlushableStream",{"flush":0})),oi={};function ai(t,e){t===v&&(oi=e)}function ui(t){return oi(t)}o.read=ui,o.fs&&(o.fs.read=ui);ai(t,function ea(t){return Ir({method:hr,url:t}).then(function(t){if(2!==Math.floor(t.status/100))throw new Error(t.responseText);return t.responseText})}),ai(e,function na(t){var o=java.nio.file.Paths.get(t);return java.nio.file.Files.exists(o)?new Promise(function(t,e){var n=java.nio.file.Files.newInputStream(o),r=new Lr(n),i=new jn;return r.read(i).then(function(){t(i.toString())})["catch"](e)}):Promise.reject(new Error("File not found"))}),ai(p,function ra(t){return new Promise(function(n,r){a.readFile(t,function(t,e){t?r(t):n(e.toString())})})}),ai(h,function ia(r){return new Promise(function(t,e){try{t(a.read(r))}catch(e_){e(new Error(e_))}})}),ai(d,function oa(e){return new Promise(function(t){t(readFile(e))})}),ai(m,function aa(n){return new Promise(function(t){var e=i.OpenTextFile(n,1,!1);t(e.ReadAll()),e.Close()})});var si={};function ci(t,e){return Promise.resolve(e)}function fi(e){var n=this;return function r(t,e){var n=t.preload[e];return n?Promise.resolve(n):ui(e)}(n,e).then(function(t){return n.preprocess({name:e,content:t,type:Fn(e).toLowerCase()})}).then(function(t){return function e(t){return si[t.type]||ci}(t).call(n,t.name,t.content)})}function li(t,e){return function r(t,e){return t._initialDefine=e.define,e.define=function n(){var t=this.gpf.require,e=this._initialDefine;return this.promise=e.apply(t,arguments),t.define=e,this.promise}.bind(t),t.gpf.require=e,t}(function n(){return{gpf:Object.create(o),promise:Promise.resolve(),_initialDefine:null}}(),Ei(t,{base:Wn(e)}))}si[".json"]=function(t,e){return JSON.parse(e)},Se(0,{noCommonJSDynamicRequire:"Dynamic require not supported"});var pi=/[^.]\brequire\b\s*\(\s*(?:['|"]([^"']+)['|"]|[^)]+)\s*\)/g;var hi,di=[null,function ua(t){return{dependencies:[],factory:t}},function sa(t,e){return{dependencies:t,factory:e}},function ca(t,e,n){return{dependencies:e,factory:n}}];function _i(t,e,n){var r={};return M(["gpf","define","module","require"],e)(t,function i(t,e,n){var r=di[arguments.length].apply(null,arguments);this.require.define(r.dependencies,function(t){return t.length=r.dependencies.length,r.factory.apply(null,E(t))})}.bind(t),r,function(t){return n[t]||o.Error.noCommonJSDynamicRequire()}),r.exports}hi=t===v?function fa(t,e){var n=location.pathname.toString();return n.endsWith("/")||(n=Wn(n)),"//# sourceURL="+location.origin+qn(n,t)+"?gpf.require\n"+e}:function la(t,e){return e},si[".js"]=function(n,r){var i=li(this,n);return function o(t,e){var n=Ne(pi,e);return n.length?li(this,t).gpf.require.define(n.map(function(t){return t[1]}).filter(function(t){return t}).reduce(function(t,e){return t[e]=e,t},{}),function(t){return t}):Promise.resolve({})}.call(this,n,r).then(function(t){var e=_i(i.gpf,hi(n,r),t);return undefined===e?i.promise:e})},Se(0,{invalidRequireConfigureOption:"Invalid configuration option",invalidRequireConfigureOptionValue:"Invalid configuration option value"});var mi={},vi=[];function gi(t,e,n){n?vi.unshift(t):vi.push(t),mi[t]=e}function bi(e){!function r(t){I(Object.keys(t),function(t){mi[t]||o.Error.invalidRequireConfigureOption()})}(e);var n=this;I(vi.filter(function(t){return e[t]!==undefined}),function(t){mi[t](n,e[t])})}function yi(t){return qn(this.base,t)}function wi(e){var t;return this.cache[e]?this.cache[e]:(t=fi.call(this,e),(this.cache[e]=t)["catch"](function(t){return function n(t,e){Array.isArray(t.requires)||(t.requires=[]),t.requires.push(e)}(t,e),Promise.reject(t)}))}function Ei(t,e){var n=Object.create(t),r={};return r.define=function o(e,t){var n=this,r=[],i=Object.keys(e);return I(i,function(t){r.push(wi.call(n,yi.call(n,e[t])))},n),Promise.all(r).then(function(n){var r;return"function"==typeof t?(r={},I(i,function(t,e){r[t]=n[e]}),t(r)):t})}.bind(n),r.resolve=yi.bind(n),r.configure=bi.bind(n),e&&r.configure(e),r}gi("base",function pa(t,e){!function n(t){"string"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.base=e}),gi("cache",function ha(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),I(Object.keys(n),function(t){e.cache[t]=Promise.resolve(n[t])})}),gi("clearCache",function da(t,e){!function n(t){"boolean"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),e&&(t.cache={})},!0),gi("preload",function _a(e,n){!function r(t){"object"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(n),I(Object.keys(n),function(t){e.preload[t]=n[t]})}),gi("preprocess",function ma(t,e){!function n(t){"function"!=typeof t&&o.Error.invalidRequireConfigureOptionValue()}(e),t.preprocess=e}),o.require=Ei({base:"",cache:{},preload:{},preprocess:function(t){return Promise.resolve(t)}});var xi=Ke({$class:"gpf.stream.ReadableArray",constructor:function(t){this._buffer=t},read:On(function(t){var e=this._buffer,n=0;return function r(){return e.length===n?Promise.resolve():t.write(e[n++]).then(r)}()}),_buffer:[]}),Oi=Ke({$class:"gpf.stream.WritableArray",constructor:function(){this._buffer=[]},write:Sn(function(t){return this._buffer.push(t),Promise.resolve()}),toArray:function(){return this._buffer},_buffer:[]});bn(xi),bn(Oi);var Si={flush:Promise.resolve.bind(Promise)};function Pi(t){return en(ii,t)||Si}function ji(e){var t=e.iReadableIntermediate,n=e.iWritableDestination;if(!e.readInProgress)try{e.readInProgress=!0,e.readPromise=t.read(n).then(function(){e.readInProgress=!1},function(t){e.readError=t,e.rejectWrite(t)})}catch(e_){e.readError=e_}}function Ii(t){if(t.readError)return Promise.reject(t.readError)}function Ci(t,e,n){var r=function u(t,e){return{iReadableIntermediate:dn(t),iWritableIntermediate:_n(t),iFlushableIntermediate:Pi(t),iWritableDestination:_n(e),iFlushableDestination:Pi(e),readInProgress:!1,readError:null,readPromise:Promise.resolve(),rejectWrite:s,flushed:!1}}(t,e),i=r.iFlushableIntermediate,o=r.iFlushableDestination,a=r.iWritableIntermediate;return ji(r),{flush:function(){return r.flushed=!0,Ii(r)||i.flush().then(function(){return r.readPromise}).then(function(){return o.flush()})},write:function(t){return ji(r),Ii(r)||function e(n,r){return new Promise(function(e,t){r.then(function(t){e(t),n.rejectWrite=s},t),n.rejectWrite=t})}(r,a.write(t))}}}function Ni(t){return O(t).length?function r(t){for(var e=t.length,n=t[--e];e;)n=Ci(t[--e],n);return n}(t):_n(t[l])}o.stream.pipe=function va(t,e){var n=dn(t),r=Ni(O(arguments)),i=Pi(r);try{return n.read(r).then(function(){return i.flush()})}catch(e_){return Promise.reject(e_)}};function ki(t){return W(t,"regexp")}B.regexp={"\\":"\\\\","-":"\\-","[":"\\[","]":"\\]","/":"\\/","{":"\\{","}":"\\}","(":"\\(",")":"\\)","*":"\\*","+":"\\+","?":"\\?",".":"\\.","^":"\\^","$":"\\$","|":"\\|"},Se(0,{invalidCSV:"Invalid CSV syntax (bad quote sequence or missing end of file)"}),o.stream.csv={};var Ai=";,\t ".split("");Ke({$class:"gpf.stream.csv.Parser",$extend:ni,constructor:function(t){this._readParserOptions(t),this._header?this._parseHeader():this._write=this._writeHeader},_readParserOptions:function(e){var n=this;e&&I(["header","separator","quote","newLine"],function(t){e[t]&&(n["_"+t]=e[t])})},_header:"",_separator:"",_deduceSeparator:function(){var e=this._header;this._separator=function a(t,e,n){for(var r,i=0,o=t.length;i"),t.content=!0)},_addContentToLastElement:function(){var t=this._elements[l];if(t)return this._addContentToElement(t)},_writeAttribute:function(t,e){this._appendToReadBuffer(" "+t+'="'),this._appendToReadBuffer(X(e.toString())),this._appendToReadBuffer('"')},_getNamespacePrefixes:function(){return this._elements.reduce(function(t,e){return t.concat(Object.keys(e.namespaces))},[])},_processAttributes:function(t){S(t,function(t,e){uo(e,this._getNamespacePrefixes()),this._writeAttribute(e,t)},this)},_processNamespaces:function(t){S(t,function(t,e){e?this._writeAttribute("xmlns:"+e,t):this._writeAttribute("xmlns",t)},this)},characters:function(t){return this._checkState(!0),this._addContentToLastElement(),this._appendToReadBuffer(X(t.toString())),Promise.resolve()},endDocument:function(){return this._checkState(!1),this._checkIfStarted=o.Error.invalidXmlWriterState,this._completeReadBuffer(),Promise.resolve()},endElement:function(){this._checkState(!0);var t=this._elements.shift();return t.content?this._appendToReadBuffer(""):this._appendToReadBuffer("/>"),Promise.resolve()},endPrefixMapping:function(t){return this._checkState(),Promise.resolve()},processingInstruction:function(t,e){return this._checkState(!1),this._appendToReadBuffer("\n"),Promise.resolve()},startDocument:function(){return this._checkIfStarted=s,this.startDocument=o.Error.invalidXmlWriterState,this._checkState(!1),Promise.resolve()},startElement:function(t,e){var n=this._nextNamespaces;this._checkState(),this._addContentToLastElement(),this._elements.unshift({qName:t,namespaces:n}),this._nextNamespaces={},ao(t,this._getNamespacePrefixes()),this._appendToReadBuffer("<"+t),e&&this._processAttributes(e),this._processNamespaces(n)},startPrefixMapping:function(t,e){this._checkState(),function n(t){eo(t),no(t),"xml"===t&&o.Error.invalidXmlUseOfPrefixXml()}(t),this._nextNamespaces[t]&&o.Error.invalidXmlWriterState(),this._nextNamespaces[t]=e}});o.forEachAsync=function(t,e,n){if(j(t))return function s(n,r,i){var o=0,a=n.length;return function u(){if(o===a)return Promise.resolve();var t=o++;try{return Pr(r.call(i,n[t],t,n)).then(u)}catch(e_){return Promise.reject(e_)}}()}(t,e,n);o.Error.invalidParameter()},Se(0,{invalidSerialName:"Invalid serial name",invalidSerialType:"Invalid serial type",invalidSerialRequired:"Invalid serial required",invalidSerialReadOnly:"Invalid serial readOnly"}),o.serial={};var so={STRING:"string",INTEGER:"integer",DATETIME:"datetime"};o.serial.types={string:so.STRING,integer:so.INTEGER,datetime:so.DATETIME};var co=/^[a-z][a-z0-9_]*$/i;function fo(t){!function e(t){"string"!=typeof t&&o.Error.invalidSerialName()}(t.name),function n(t){t.match(co)||o.Error.invalidSerialName()}(t.name)}var lo=Object.keys(so).map(function(t){return so[t]});function po(t){undefined===t.type?t.type=so.STRING:function e(t){lo.includes(t)||o.Error.invalidSerialType()}(t.type)}function ho(t,e){"boolean"!=typeof t&&e()}function _o(t){var e=Object.assign(t);return[fo,po,function n(t){undefined===t.required?t.required=!1:ho(t.required,o.Error.invalidSerialRequired)},function r(t){undefined!==t.readOnly&&ho(t.readOnly,o.Error.invalidSerialReadOnly)}].forEach(function(t){t(e)}),e}function mo(t){t&&o.Error.classAttributeOnly()}function vo(t,e){var n=t._extend;n!==e&&function r(t,e){t instanceof e||o.Error.restrictedBaseClassAttribute()}(n.prototype,e)}function go(t,e,n){O(function i(t,e,n){var r=e.getAttributes(n);return t?r[t]:r[Ti]}(t,e,n)).length&&o.Error.uniqueAttributeUsedTwice()}Se(0,{classAttributeOnly:"Class attribute only",memberAttributeOnly:"Member attribute only",restrictedBaseClassAttribute:"Restricted base class attribute",uniqueAttributeUsedTwice:"Unique attribute used twice"});var bo=Ke({$class:"gpf.attributes.AttributeAttribute",$extend:Ri,$abstract:!0,_check:function(t,e){mo(t),vo(e,Ri),go(t,e,this.constructor)},_targetCheck:Ae(),_overrideTargetCheck:function(t){var n=this,r=t._check;t._check=function(t,e){n._targetCheck(t,e,this),r.call(this,t,e)}},_build:function(t,e,n){this._overrideTargetCheck(n)}}),yo=Ke({$class:"gpf.attributes.ClassAttribute",$extend:bo,$singleton:!0,_targetCheck:function(t,e){mo(t)}});o.attributes.ClassAttribute=yo;var wo=Ke({$class:"gpf.attributes.MemberAttribute",$extend:bo,$singleton:!0,_targetCheck:function(t,e){!function n(t){t||o.Error.memberAttributeOnly()}(t)}});o.attributes.MemberAttribute=wo;var Eo=Ke({$class:"gpf.attributes.AttributeForInstanceOf",$extend:bo,_BaseClass:null,constructor:function(t){"function"!=typeof t&&o.Error.invalidParameter(),this._BaseClass=t},_targetCheck:function(t,e){vo(e,this._BaseClass)}});o.attributes.AttributeForInstanceOf=Eo;var xo=Ke({$class:"gpf.attributes.UniqueAttribute",$extend:bo,$singleton:!0,_targetCheck:function(t,e,n){go(t,e,n.constructor)}});o.attributes.UniqueAttribute=xo;var Oo,So=Ke({$class:"gpf.attributes.Serializable",$extend:Ri,$attributes:[new wo,new xo],_property:null,constructor:function(t){this._property=t},_check:function(t,e){this._property=_o(Object.assign({name:function n(t){return t.startsWith("_")?t.substring(1):t}(t)},this._property||{}))},getProperty:function(){return Object.create(this._property)}});function Po(t){var e=Hi(t,So),n={};return S(e,function(t,e){n[e]=t[l].getProperty()}),n}function jo(t,e){var n=Object.getOwnPropertyDescriptor(t,e);if(n)return!n.writable}function Io(n){var t=Po(n);return S(t,function(t,e){t.readOnly===undefined&&(t.readOnly=Oo(n,e))}),t}function Co(t,e){if(!e.readOnly)return t}function No(n,t,i){var o={};return S(t,function(t,e){!function r(t,e,n){n!==undefined&&(t[e]=n)}(o,t.name,i.call(n,n[e],t,e))}),o}function ko(n,i,o){var t=Io(n);S(t,function(t,e){Object.prototype.hasOwnProperty.call(i,t.name)&&function r(t,e,n){n!==undefined&&(t[e]=n)}(n,e,o.call(n,i[t.name],t,e))})}function Ao(t,e,n){var r=function i(t){return t||Ti}(e);t._attributes[r]=(t._attributes[r]||[]).concat(n),function o(e,n,t){t.forEach(function(t){Wi.call(e,n,t),Vi(n,t,e._instanceBuilder.prototype)})}(t,e,n)}Oo=Object.getOwnPropertyDescriptor?function(t,e){for(var n,r=t;r!==Object&&n===undefined;)n=jo(r,e),r=Object.getPrototypeOf(r);return n||!1}:function(){return!1},o.serial.get=Po,o.serial.toRaw=function(t,e){return"function"==typeof t&&o.Error.invalidParameter(),function n(t,e){return No(t,Io(t),e||Co)}(t,e)},o.serial.fromRaw=function(t,e,n){return"function"==typeof t&&o.Error.invalidParameter(),function r(t,e,n){ko(t,e,n||Co)}(t,e,n),t},Se(0,{es6classOnly:"ES6 class only"}),o.attributes.decorator=function wa(){var n=E(arguments);return function(t,e){Pe(t)||o.Error.es6classOnly(),Ao(qe(t),e,n)}}}); \ No newline at end of file diff --git a/build/plato.history.zip b/build/plato.history.zip index c5b56855..5d26d94b 100644 Binary files a/build/plato.history.zip and b/build/plato.history.zip differ diff --git a/build/releases.json b/build/releases.json index 1674f96b..ba271705 100644 --- a/build/releases.json +++ b/build/releases.json @@ -418,5 +418,35 @@ "tests": 1090, "sources": 144 } + }, + { + "version": "1.0.0", + "label": "First productive version", + "date": "2019-10-30", + "notes": "", + "milestone": 18, + "metrics": { + "coverage": { + "statements": { + "total": 100, + "ignored": 0.32 + }, + "functions": { + "total": 100, + "ignored": 0.6 + }, + "branches": { + "total": 100, + "ignored": 0.68 + } + }, + "maintainability": 83.64, + "lines": { + "total": 13443, + "average": 93 + }, + "tests": 1109, + "sources": 144 + } } -] +] \ No newline at end of file diff --git a/build/tests.js b/build/tests.js index 5deabbe7..dbd64038 100644 --- a/build/tests.js +++ b/build/tests.js @@ -1 +1 @@ -!function(){"use strict";var safeFunc=Function,context=safeFunc("return this;")(),_includes={"isclass.es6":'"use strict";describe("isclass.es6",function(){class A{}describe("gpf.isclass",function(){it("recognizes ES6 classes",function(){assert(gpf.isClass(A))})})});',"define/class/abstract.es6":'"use strict";describe("define/class/abstract.es6",function(){describe("$abstract",function(){class A{get member(){return this._member}constructor(t){t&&(this._member=t)}}let t,e;before(function(){t=gpf.define({$class:"B",$extend:A,$abstract:!0});e=class extends t{}}),it("prevents instantiation of abstract class (B)",function(){!function(t){var e;try{var s=new t;throw new Error(s.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractClass)}(t)}),it("enables instantiation on subclass (C)",function(){const t=new e("defaultValue");assert("defaultValue"===t.member)})})});',"define/class/singleton.es6":'"use strict";describe("define/class/singleton.es6",function(){describe("$singleton",function(){describe("in a sub class",function(){class B{get uniqueObject(){return this._unique}constructor(){this._unique={}}}let e;before(function(){e=gpf.define({$class:"C",$extend:B,$singleton:!0})}),it("does not alter base class behavior",function(){var n=new B,s=new e,t=s.uniqueObject,i=new B,u=new e;assert(n!==i),assert(n.uniqueObject!==i.uniqueObject),assert(s===u),assert(t===u.uniqueObject)})})})});',"define.es6":'"use strict";describe("define.es6",function(){describe("gpf.define",function(){describe("Class definition",function(){describe("Implementation",function(){describe("Subclassing an ES6 class",function(){class A{constructor(t){this._a="A",this._value=t}a(){return this._a}value(){return this._value}}class B extends A{constructor(t){super(t),this._b="B"}b(){return this._b}}let t,e;before(function(){t=gpf.define({$class:"C",$extend:B,"constructor":function(t){this.$super(t)},a:function(){return this.$super()},c:function(){return this.a()+this.b()}}),e=new t(3475)}),it("handles instanceof",function(){assert(e instanceof A),assert(e instanceof B),assert(e instanceof t)}),it("calls the constructor function",function(){assert(3475===e.value())}),it("offers a way to call named base method",function(){assert("AB"===e.c())}),it("does not leak $super",function(){assert(void 0===e.$super)})})})})})});',"serial/raw/to.propertydescriptor":'"use strict";describe("serial/raw/to.propertydescriptor",function(){describe("gpf.serial.toRaw",function(){var e,t;function a(e){var t=gpf.serial.toRaw(e,function(t,a,r){return assert(this===e),"_id"===r?(assert("id"===a.name),assert(!0===a.readOnly),assert("123"===t),"ID"):"_name"===r?(assert("name"===a.name),assert(!1===a.readOnly),assert("Test"===t),"TEST"):"_created"===r?(assert("created"===a.name),void assert(!0===a.readOnly)):"_modified"===r?t.toISOString():void assert(!1)});assert(3===Object.keys(t).length),assert("ID"===t.id),assert("TEST"===t.name),assert("2018-09-19T12:50:12.000Z"===t.modified)}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable],_name:"","[_created]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_created:null,"[_modified]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,a){Object.defineProperty(this,"_id",{value:e,writable:!1}),this._name=t,this.__created=new Date,this._modified=a||null}}),Object.defineProperty(e.prototype,"_created",{configurable:!1,get:function(){return this.__created}}),t=gpf.define({$class:"B",$extend:e})}),it("converts properties\' value",function(){a(new e("123","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))))}),it("converts properties\' value (sub class)",function(){a(new t("123","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))))})})});',"serial/raw/from.propertydescriptor":'"use strict";describe("serial/raw/from.propertydescriptor",function(){describe("gpf.serial.fromRaw",function(){var e,t;function i(e){var t=e._created;gpf.serial.fromRaw(e,{id:"ID",name:void 0,created:"",modified:"2018-09-19T12:50:12.000Z"},function(t,i,r){return assert(this===e),"_id"===r?(assert("id"===i.name),void assert(!0===i.readOnly)):"_name"===r?(assert("name"===i.name),assert(!1===i.readOnly),assert(void 0===t),"Test"):"_created"===r?(assert("created"===i.name),void assert(!0===i.readOnly)):r.type===gpf.serial.datetime?(assert("_modified"===r),new Date(t)):void assert(!1)}),assert("123"===e._id),assert("Test"===e._name),assert(e._created===t),assert(2018===e._modified.getUTCFullYear()),assert(8===e._modified.getUTCMonth()),assert(19===e._modified.getUTCDate()),assert(12===e._modified.getUTCHours()),assert(50===e._modified.getUTCMinutes()),assert(12===e._modified.getUTCSeconds())}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable],_name:"","[_created]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_created:null,"[_modified]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,i){Object.defineProperty(this,"_id",{value:e,writable:!1}),this._name=t,this.__created=new Date,this._modified=i||null}}),Object.defineProperty(e.prototype,"_created",{configurable:!1,get:function(){return this.__created}}),t=gpf.define({$class:"B",$extend:e})}),it("converts properties\' value",function(){i(new e("123"))}),it("converts properties\' value (sub class)",function(){i(new t("123"))})})});',"attributes/decorator.es6":'"use strict";describe("attributes/decorator.es6",function(){before(function(){gpf.require.configure({base:config.testPath+"require"})}),describe("Defining attributes on an ES6 class using decorators",function(){var e,s,t;before(function(r){gpf.require.configure({clearCache:!0}),gpf.require.define({classes:"es6/class_with_attributes.js"},function(a){e=a.classes.Attribute,s=a.classes.Test,t=a.classes.SubclassOfTest,r()}).then(void 0,r)}),it("offers decorators to add attributes on class",function(){var t=gpf.attributes.get(s);assert(2===Object.keys(t).length),assert(1===t.id.length),assert(t.id[0]instanceof e),assert(1===t.id[0].value),assert(1===t.reset.length),assert(t.reset[0]instanceof e),assert(2===t.reset[0].value)}),it("works on sub classes",function(){var s=gpf.attributes.get(t);assert(2===Object.keys(s).length),assert(1===s.id.length),assert(2===s.reset.length);var r=0;s.reset.forEach(function(s){assert(s instanceof e),assert(2===s.value||3===s.value),r+=s.value}),assert(5===r)})})});'};context.include=function(source){eval(_includes[source])}}();"use strict";describe("console",function(){if(gpf.internals){var n=gpf.internals._gpfConsoleGenerate;describe("_gpfConsoleGenerate",function(){it("generates an object mocking the console",function(){var e=n();assert("function"==typeof e.log),assert("function"==typeof e.info),assert("function"==typeof e.warn),assert("function"==typeof e.error)}),it("generates a log function prefixing text with padding",function(){var t="";n(function(e){t=e}).log("test"),assert(" test"===t)}),it("generates an info function prefixing text with [?]",function(){var t="";n(function(e){t=e}).info("test"),assert("[?] test"===t)}),it("generates a warn function prefixing text with /!\\",function(){var t="";n(function(e){t=e}).warn("test"),assert("/!\\ test"===t)}),it("generates an error function prefixing text with (X)",function(){var t="";n(function(e){t=e}).error("test"),assert("(X) test"===t)})})}}),describe("arraylike",function(){describe("gpf.isArrayLike",function(){it("checks if an object looks like an array",function(){assert(!0===gpf.isArrayLike([]))}),it("recognizes a simulated array",function(){assert(!0===gpf.isArrayLike({length:2,0:0,1:1}))}),it("recognizes a simulated empty array",function(){assert(!0===gpf.isArrayLike({length:0}))}),it("recognizes a simulated incomplete array",function(){assert(!0===gpf.isArrayLike({length:2,1:1}))}),it("recognizes a simulated non empty array with no items",function(){assert(!0===gpf.isArrayLike({length:2}))}),it("accepts a string as an array like",function(){assert(!0===gpf.isArrayLike("abc"))}),[null,undefined,0,1,!1,!0,{},new Date].forEach(function(e){it("rejects any non fitting value ("+JSON.stringify(e)+")",function(){assert(!1===gpf.isArrayLike(e))})}),it("rejects a simulated array with an invalid length property",function(){assert(!1===gpf.isArrayLike({length:2.5,0:0,1:1}))})})}),describe("foreach",function(){var e="Hello World!",i=[0,1,2,3,4,5,6,7,8,9],a={"number":1,"string":e,"null":null,"object":{member:"value"},"function":function(){return e}};describe("gpf.forEach",function(){it("enumerates array content",function(){var r=0,s=0;gpf.forEach(i,function(e,t,n){assert("number"==typeof t),assert(n===i),++r,s+=e}),assert(i.length===r),assert(45===s)}),it("transmits scope on array content",function(){var e,r=0,s=0;e=gpf.forEach(i,function(e,t,n){assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e},a),assert(undefined===e),assert(i.length===r),assert(45===s)}),it("enumerates object content and handles null value",function(){var r=[],s=!0;gpf.forEach(a,function(e,t,n){assert("string"==typeof t),assert(n===a),r.push(t),"null"===t&&null!==e&&(s=!1)}),r=r.join(","),assert("number,string,null,object,function"===r),assert(!0===s)}),it("transmits scope on object content",function(){var e=gpf.forEach(a,function(){assert(this===a)},a);assert(undefined===e)}),it("does not skip undefined values",function(){var e=new Array(3),t=0;gpf.forEach(e,function(e){assert(undefined===e),++t}),assert(3===t)}),it("does not enumerate inherited values",function(){var e=Object.create({inherited:1});e.own=2,gpf.forEach(e,function(e,t){assert(2===e),assert("own"===t)})})}),gpf.internals&&describe("(internal)",function(){describe("_gpfObjectForEach",function(){var e=gpf.internals._gpfObjectForEach;it("enumerates object keys and values",function(){var r=0;e(a,function(e,t,n){++r,assert(n===a),assert(e===a[t])}),assert(5===r)})}),describe("_gpfArrayForEachFalsy",function(){var t=gpf.internals._gpfArrayForEachFalsy;it("enumerates all values if no truthy result",function(){var r=0,e=t(i,function(e,t,n){++r,assert(n===i),assert(e===i[t])});assert(e===undefined),assert(r===i.length)}),it("stops on first truthy value and return it",function(){var r=0,s={},e=t(i,function(e,t,n){if(4===e)return s;++r,assert(n===i),assert(e===i[t])});assert(e===s),assert(4===r)})})})}),describe("assert",function(){describe("gpf.assert",function(){it("does not accept no message",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.assert(!0)}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)}),[!0,42,"Hello World!",{}].forEach(function(e){it("does nothing on a truthy condition - "+typeof e+" ("+e.toString()+")",function(){gpf.assert(e,"It works")})}),[!1,0,"",undefined,null].forEach(function(n){var e;e=undefined===n?"undefined":null===n?"null":n.toString(),it("throws an exception on a falsy condition - "+typeof n+" ("+e+")",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.assert(n,"It fails")}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)})})}),describe("gpf.asserts",function(){it("works with a message / boolean dictionary",function(){gpf.asserts({"It works":!0,"It also works":!0})}),it("fails on first falsy",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.asserts({"It works":!0,"It fails":!1})}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)})}),describe("gpf.preventAssertWarnings",function(){it("prevents assertion warnings",function(){var e;gpf.preventAssertWarnings(!0);try{gpf.assert(!1,"It fails")}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed),gpf.preventAssertWarnings(!1)})})}),describe("constants",function(){describe("gpf",function(){it("does not expose any 'private' member",function(){!function s(e,t){var n,r;for(n in e)e.hasOwnProperty(n)&&(assert("_"!==n.charAt(0)),"object"==typeof(r=e[n])&&-1===t.indexOf(r)&&(t.push(r),s(r,t)))}(gpf,[gpf,gpf.internals])}),it("should expose a version",function(){assert("function"==typeof gpf.version),assert("string"==typeof gpf.version());var e=gpf.version();assert(-1!==e.indexOf(".")),assert(null!==e.match(/[0-9]+\.[0-9]+d?/))}),it("should expose the host type",function(){assert("function"==typeof gpf.host),assert("string"==typeof gpf.host());var e=gpf.host();assert(-1!==[gpf.hosts.browser,gpf.hosts.nashorn,gpf.hosts.nodejs,gpf.hosts.phantomjs,gpf.hosts.rhino,gpf.hosts.unknown,gpf.hosts.wscript].indexOf(e))}),describe("gpf.hosts enumeration",function(){["browser","nodejs","phantomjs","unknown","wscript"].forEach(function(e){it("declares gpf.hosts."+e,function(){assert(undefined!==gpf.hosts[e])})})})}),gpf.internals&&(describe("(internal) _gpfIsUnsignedByte",function(){var r=gpf.internals._gpfIsUnsignedByte;gpf.forEach({0:!0,"-25":!1,128:!0,256:!1,255:!0},function(e,t){var n=parseInt(t,10);e?it("accepts "+t,function(){assert(!0===r(n))}):it("rejects "+t,function(){assert(!1===r(n))})})}),describe("(internal) _gpfFuncImpl",function(){var n=gpf.internals._gpfFuncImpl;it("fails if function can't be generated",function(){var e;try{n([],"{")}catch(e_){e=e_}assert(e)})}))}),describe("string/capitalize",function(){gpf.internals&&describe("(internal) _gpfStringCapitalize",function(){var e=gpf.internals._gpfStringCapitalize;it("does nothing on empty string",function(){assert(""===e(""))}),it("uppercases the first letter",function(){assert("Word"===e("word")),assert("Two words"===e("two words")),assert("Two words"===e("Two words"))}),it("also handles accents",function(){assert("\xc9ric"===e("\xe9ric"))})})}),describe("string/replaceex",function(){gpf.internals&&describe("(internal) _gpfStringReplaceEx",function(){var e=gpf.internals._gpfStringReplaceEx;it("replaces strings recursively",function(){assert("add"===e("abc",{"a":"abc","b":"dc","c":""}))})})}),describe("string/escapefor",function(){gpf.internals&&describe("(internal) _gpfStringEscapeFor",function(){var e=gpf.internals._gpfStringEscapeFor;it("escapes for JavaScript",function(){assert('"abc\\r\\ndef"'===e("abc\r\ndef","javascript"))}),it("escapes for xml",function(){assert("<a&b>"===e("","xml"))}),it("escapes for html",function(){assert("<a&b:éèêáà>"===e("","html"))})})}),describe("compatibility",function(){function e(e){var t=new Array(5);t[2]=undefined,t[3]=3,e.call(t,function(e,t){assert(2===t||3===t),2===t?assert(undefined===e):assert(3===e)})}var r={Array:{every:{length:1,"must return true when it goes over all items":function(e){var t,n=0;t=e.call([1,2,3,-6,10],function(e){return n+=e,!0}),assert(!0===t),assert(10===n)},"must return false when it stops on a given item":function(e){var t,n=0;t=e.call([1,2,3,-6,10],function(e){return 0n)throw new Error("Triggered too soon ("+e+" does not respect the timeout delay of "+this._delay+")");this._done()}catch(e_){this._error=e_,this._done(e_)}},clear:function(){a.clearTimeout(this._id),delete this._allowed},clean:function(){this._triggered||this.clear();var e,t=c.list.length;for(e=0;e 10)",function(){var e=t({a:2},null,11);assert('{\n "a": 2\n}'===e)})}function n(r){it("has the expected arity",function(){assert(2===r.length)}),e.forEach(function(t){!1!==t.parse&&it("works on "+t.label,function(){var e=r(t.json);assert(!0===s(e,t.obj))})}),it("supports reviver parameter - simple",function(){var e=r('{"a": 5, "b": "6"}',function(e,t){return"number"==typeof t?2*t:t});assert(!0===s(e,{a:10,b:"6"}))}),it("supports reviver parameter - traversing",function(){var n=[];r('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}',function(e,t){return n.push(e.toString()),t}),assert(7===n.length),["1","2","4","6","5","3",""].forEach(function(e,t){assert(n[t]===e)})})}describe("JSON object",function(){it("exists",function(){assert("undefined"!=typeof JSON)})}),describe("JSON.stringify",function(){t(JSON.stringify)}),describe("JSON.parse",function(){n(JSON.parse.bind(JSON))}),gpf.internals&&describe("(internal)",function(){describe("_gpfJsonStringifyPolyfill",function(){t(gpf.internals._gpfJsonStringifyPolyfill)}),describe("_gpfJsonParsePolyfill",function(){n(gpf.internals._gpfJsonParsePolyfill)})})}),describe("compatibility/base64",function(){var r={"Hello":"SGVsbG8=","Hello ":"SGVsbG8g","Hello World !":"SGVsbG8gV29ybGQgIQ==","!@#$%?&*()":"IUAjJCU/JiooKQ=="};function e(e){return function(){describe("atob",function(){var n=e.atob;Object.keys(r).forEach(function(e){var t=r[e];it("turns "+JSON.stringify(t)+" into "+JSON.stringify(e),function(){assert(n(t)===e)})}),it("rejects strings with invalid characters",function(){var e;try{n("<")}catch(e_){e=e_}assert(e)})}),describe("btoa",function(){var n=e.btoa;Object.keys(r).forEach(function(e){var t=r[e];it("turns "+JSON.stringify(e)+" into "+JSON.stringify(t),function(){assert(n(e)===t)})}),it("rejects strings with non latin characters",function(){var e;try{n("\u2665")}catch(e_){e=e_}assert(e)})})}}describe("exposed API",e({atob:atob,btoa:btoa})),gpf.internals&&atob!==gpf.internals._gpfAtob&&describe("(internal)",e({atob:gpf.internals._gpfAtob,btoa:gpf.internals._gpfBtoa}))}),describe("context",function(){describe("gpf.context",function(){var t=Function;it("resolves the global context",function(){if(assert("function"==typeof gpf.context),assert(null!==gpf.context()),gpf.hosts.browser===gpf.host())assert(window===gpf.context());else if(gpf.hosts.nodejs===gpf.host()||gpf.hosts.phantomjs===gpf.host())assert(global===gpf.context());else{var e=t("return this;")();assert(e===gpf.context())}}),it("resolves gpf",function(){assert(gpf===gpf.context("gpf"))}),it("resolves any symbol",function(){assert(gpf.context===gpf.context("gpf.context"))}),it("returns undefined if not existing",function(){assert(undefined===gpf.context("gpf.not-existing"))}),it("returns undefined if not existing (deep dive)",function(){assert(undefined===gpf.context("gpf.not-existing.really-not"))})}),gpf.internals&&describe("_gpfContext",function(){var r=gpf.internals._gpfContext;it("can build a context",function(){var e=gpf.context(),t={};e.testContextJS=t;var n=r(["testContextJS","folder","name"],!0);assert(t.folder.name===n),delete e.testContextJS})})}),describe("function",function(){if(gpf.internals){var t=gpf.internals._gpfFunctionDescribe,n=gpf.internals._gpfFunctionBuild,r=gpf.internals._gpfExtractFunctionName;describe("_gpfFunctionDescribe",function(){it("describes a named function",function(){var e=t(function(e,t){return e+t});assert("test"===e.name),assert(2===e.parameters.length),assert("a"===e.parameters[0]),assert("b"===e.parameters[1]),assert(-1!==e.body.indexOf("return a + b;"))}),it("identifies an unnamed function",function(){var e=t(function(){return 0});assert(!e.name),assert(!e.parameters),assert(-1!==e.body.indexOf("return 0;"))}),it("identifies empty function",function(){var e=t(function(){});assert(undefined===e.body)}),it("filters out comments",function(){var e=t(function r(e,t,n){return e+t+n});assert("test2"===e.name),assert(3===e.parameters.length),assert("a"===e.parameters[0]),assert("b"===e.parameters[1]),assert("c"===e.parameters[2]),assert(-1===e.body.indexOf("comments are removed"))})}),describe("_gpfFunctionBuild",function(){it("builds an empty anonymous function",function(){var e=n({});assert("function"==typeof e),assert(""===r(e))}),it("builds a named function",function(){var e=n({name:"test"});assert("test"===r(e))}),it("builds a function with named parameters",function(){var e=n({parameters:["a","b","c"],body:"return a + b + c;"});assert(3===e.length),assert(6===e(1,2,3))}),it("builds a function with external context",function(){var e=n({body:"return a;"},{a:"Hello World!"});assert(0===e.length),assert("Hello World!"===e())})}),describe("_gpfExtractFunctionName",function(){it("gets function name",function(){assert("thisName"===r(function e(){}))}),it("supports empty name",function(){assert(""===r(function(){}))})})}}),describe("error",function(){describe("gpf.Error",function(){it("is used as an exception",function(){var e;try{gpf.Error.abstractMethod()}catch(e_){e=e_}assert(e instanceof Error),assert(e instanceof gpf.Error),assert(e instanceof gpf.Error.AbstractMethod),assert(e.constructor===gpf.Error.AbstractMethod)}),it("is documented",function(){var e;try{gpf.Error.abstractMethod()}catch(e_){e=e_}assert(e.code===gpf.Error.CODE_ABSTRACTMETHOD),assert(e.code===gpf.Error.abstractMethod.CODE),assert("abstractMethod"===e.name),assert("Abstract method"===e.message)}),it("can use substitution for message",function(){var e;try{gpf.Error.assertionFailed({message:"Test"})}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed),assert(e.code===gpf.Error.CODE_ASSERTIONFAILED),assert(e.code===gpf.Error.assertionFailed.CODE),assert("assertionFailed"===e.name),assert("Assertion failed: Test"===e.message)})})}),describe("isclass",function(){describe("gpf.isclass",function(){[undefined,null,!1,!0,"","Hello World!",0,1,function(){}].forEach(function(e){it("fails on "+JSON.stringify(e),function(){assert(!gpf.isClass(e))})})})}),config.features.es6class&&include("isclass.es6"),describe("abstract",function(){if(gpf.internals){var r=gpf.internals._gpfCreateAbstractFunction;describe("_gpfCreateAbstractFunction",function(){it("generates a function with a given signature",function(){var e=r(3);assert(3===e.length)}),it("generates a function that throws the abstractMethod exception",function(){var e,t=r(0);try{t()}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractMethod)})})}}),describe("define/check",function(){gpf.internals&&describe("(internal) _GpfEntityDefinition",function(){var t=gpf.internals._GpfEntityDefinition,r=gpf.internals._gpfDefineBuildTypedEntity;it("must have an entity type",function(){var e;try{r({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntityType)}),it("checks for a valid name",function(){var e;try{r({$type:"class"})}catch(e_){e=e_}assert(e instanceof gpf.Error.MissingEntityName)}),it("validates minimal requirement (type and name)",function(){r({$type:"class",$name:"Test"})}),it("rejects invalid properties",function(){var e;try{r({$type:"class",$name:"Test",$fail:!0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntity$Property)}),it("converts $class into _type and _name",function(){var e=r({$class:"Test"});assert(e instanceof t),assert("class"===e._type),assert("Test"===e._name)}),it("converts $class into _type, _name and _namespace (absolute)",function(){var e=r({$class:"gpf.test.Test"});assert("class"===e._type),assert("Test"===e._name),assert("gpf.test"===e._namespace)}),it("converts $class into _type, _name and _namespace (relative)",function(){var e=r({$class:"test.Test",$namespace:"gpf"});assert("class"===e._type),assert("Test"===e._name),assert("gpf.test"===e._namespace)}),it("prioritize $class over $name",function(){var e=r({$class:"Test",$name:"Any"});assert("class"===e._type),assert("Test"===e._name)}),it("validates namespace",function(){r({$class:"Test",$namespace:"lowerCamelCase.$accepted._also.numbers456"}),r({$class:"Test",$namespace:"simple"}),r({$class:"Test",$namespace:""})}),["endingPointIsNotOK.","startingNumberIsNotOK.4test","$isOKOnlyAtBeginning.test$","_isOKOnlyAtBeginning.test_","CapitalFirstLetterIsNotOK"].forEach(function(n){it("rejects invalid namespace ("+n+")",function(){var e;try{r({$class:"Test",$namespace:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntityNamespace)})})})}),describe("define/class/check",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var t=gpf.internals._GpfClassDefinition,s=gpf.internals._gpfDefineBuildTypedEntity;it("is used for class definition",function(){var e=s({$class:"Test"});assert(e instanceof t)}),it("accepts a valid class definition",function(){s({$class:"Test",member:function(){}})}),["startingWithLowercaseLetterIsNotOK","The$signIsForbbidenIfNotAtTheBeginning","The_signIsForbbidenIfNotAtTheBeginning"].forEach(function(n){it("rejects invalid class name ("+n+")",function(){var e;try{s({$class:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassName)})}),["StartingWithUppercaseLetterIsNotOK","the$signIsForbbidenIfNotAtTheBeginning","the_signIsForbbidenIfNotAtTheBeginning","class"].forEach(function(r){it("rejects invalid property name ("+r+")",function(){var e,t={$class:"Test"};t[r]=!0;try{s(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassProperty)})}),it("rejects invalid $extend",function(){var e;try{s({$class:"Test",$extend:12})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassExtend)}),it("accepts native $extend",function(){s({$class:"Test",$extend:String})}),it("accepts contextual $extend",function(){s({$class:"Test",$extend:"String"})})})}),describe("define/class/abstract",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var r=gpf.internals._gpfDefineBuildTypedEntity;[undefined,!1,0,"",{},1,"Hello World!"].forEach(function(n){it("supports only $abstract = true ("+JSON.stringify(n)+")",function(){var e;try{r({$type:"class",$name:"Test",$abstract:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClass$AbstractSpecification)})})}),describe("$abstract",function(){var e,t,n;function r(e){var t;try{var n=new e;throw new Error(n.toString())}catch(e_){t=e_}assert(t instanceof gpf.Error.AbstractClass)}before(function(){e=gpf.define({$class:"A",$abstract:!0,_member:"defaultValue",getMember:function(){return this._member},"constructor":function(e){e&&(this._member=e)}}),t=gpf.define({$class:"B",$extend:e}),n=gpf.define({$class:"C",$extend:t,$abstract:!0})}),it("prevents instantiation of abstract class (A)",function(){r(e)}),it("enables instantiation on subclass (B)",function(){var e=new t;assert("defaultValue"===e.getMember())}),it("prevents instantiation of abstract class (C)",function(){r(n)})})}),config.features.es6class&&include("define/class/abstract.es6"),describe("define/class/singleton",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var r=gpf.internals._gpfDefineBuildTypedEntity;[undefined,!1,0,"",{},1,"Hello World!"].forEach(function(n){it("supports only $singleton = true ("+JSON.stringify(n)+")",function(){var e;try{r({$type:"class",$name:"Test",$singleton:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClass$SingletonSpecification)})})}),describe("$singleton",function(){var r,e={_unique:null,getUniqueObject:function(){return this._unique},"constructor":function(){this._unique={}}};before(function(){r=gpf.define(Object.assign({$class:"A",$singleton:!0},e))}),it("allows only one instantation of the class",function(){var e=new r,t=e.getUniqueObject(),n=new r;assert(e===n),assert(t===n.getUniqueObject())}),describe("in a sub class",function(){var i,a;before(function(){i=gpf.define(Object.assign({$class:"B"},e)),a=gpf.define({$class:"C",$extend:i,$singleton:!0})}),it("does not alter base class behavior",function(){var e=new i,t=new a,n=t.getUniqueObject(),r=new i,s=new a;assert(e!==r),assert(e.getUniqueObject()!==r.getUniqueObject()),assert(t===s),assert(n===s.getUniqueObject())})})})}),config.features.es6class&&include("define/class/singleton.es6"),describe("define",function(){var s={};function e(s,i,t){Object.keys(t).filter(function(e){return!t[e]}).forEach(function(r){it("rejects invalid "+s+" name ("+r+")",function(){var e,t={};t["$"+s]=r;try{gpf.define(t)}catch(e_){e=e_}assert(e instanceof i)})}),Object.keys(t).filter(function(e){return t[e]}).forEach(function(r){it("accepts valid "+s+" name ("+r+")",function(){var e,t={};t["$"+s]=r;try{gpf.define(t)}catch(e_){e=e_}assert(undefined===e)})})}function t(n){it(n.it,function(){var e;try{gpf.define(n.definition)}catch(e_){e=e_}assert(e instanceof n.exception)})}before(function(){gpf.context().test=s}),after(function(){delete gpf.context().test}),describe("gpf.define",function(){it("accepts only one parameter",function(){assert("function"==typeof gpf.define),assert(1===gpf.define.length)}),describe("Common validation",function(){t({it:"checks that the entity type is specified",definition:{},exception:gpf.Error.InvalidEntityType})}),describe("Class definition",function(){describe("Validation",function(){e("class",gpf.Error.InvalidClassName,{"1NumberAtTheBeginningIsNotOK":!1,"noUppercaseFirstLetterIsNotOK":!1,"DollarSignAnywhereIsNotOK$":!1,"A":!0,"$B":!0,"_C":!0,"Test123":!0}),[{it:"rejects invalid $ property names",definition:{$class:"Test",$test:!1},exception:gpf.Error.InvalidEntity$Property},{it:"rejects invalid property names (reserved keywords)",definition:{$class:"Test","super":!1},exception:gpf.Error.InvalidClassProperty},{it:"rejects constructor property if not a method",definition:{$class:"Test",constructor:!1},exception:gpf.Error.InvalidClassConstructor}].forEach(t)}),describe("Implementation",function(){var r,e;before(function(){r=gpf.define({$class:"A",_member:"defaultValue",getMember:function(){return this._member},"constructor":function(e){e&&(this._member=e),this._constructorOfA=!0},funcWith3params:function(e,t,n){return e+t+n},throwError:function(){throw new Error("error")}}),e=new r}),it("prevents constructor functions to be used without new",function(){var e;try{r()}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassConstructorFunction)}),it("creates a constructor with the same signature than the constructor property",function(){assert(1===r.length)}),it("handles instanceof",function(){assert(e instanceof r)}),it("calls constructor property",function(){assert(e._constructorOfA)}),it("exposes methods",function(){assert("function"==typeof e.getMember),assert("defaultValue"===e.getMember())}),describe("Subclassing",function(){var t,n;it("prevents invalid override",function(){var e;try{gpf.define({$class:"Test",$extend:r,getMember:!1})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassOverride)}),before(function(){t=gpf.define({$class:"test.B",$extend:r,"constructor":function(e){this.$super("valueOfB"),this._constructorOfB=e},getMember:function(){return this.$super()+"-inB"},setMember:function(e){this._member=e},baseTest:function(){return this.$super.getMember()},invalidSuperMember:function(){return this.$super.doesntExist()},noSuperMember:function(){return this.$super()},differentBinding:function(){return this.$super.getMember.call({_member:"different"})},checkSignature:function(){assert(3===this.$super.funcWith3params.length)},throwError:function(){this.$super()}}),n=new t(3475)}),it("handles instanceof",function(){assert(n instanceof r),assert(n instanceof t)}),it("handles namespace",function(){assert(s.B===t)}),it("calls the constructor function",function(){assert(3475===n._constructorOfB)}),it("calls the proper $super()",function(){assert(n._constructorOfA),assert("valueOfB-inB"===n.getMember())}),it("offers a way to call named base method",function(){assert("valueOfB"===n.baseTest())}),it("fails when accessing an unknown $super member",function(){var e;try{n.invalidSuperMember()}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassSuperMember)}),it("fails when accessing inexistent $super",function(){var e;try{n.noSuperMember()}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassSuper)}),it("allows calling $super member with a different binding",function(){assert("different"===n.differentBinding())}),it("respects methods signature",function(){n.checkSignature()}),it("does not leak $super",function(){assert(undefined===n.$super)}),it("does not leak $super on exception",function(){try{n.throwError()}catch(e_){}assert(undefined===n.$super)}),it("handles several versions of $super",function(){var e=new(gpf.define({$class:"C",$extend:t,testMethod:function(){return this.$super.getMember()}}));assert("valueOfB-inB"===e.testMethod())})})})}),describe("Interface definition",function(){describe("Validation",function(){e("interface",gpf.Error.InvalidInterfaceName,{"1NumberAtTheBeginningIsNotOK":!1,"noUppercaseFirstLetterIsNotOK":!1,"DollarSignAnywhereIsNotOK$":!1,"NotStartingWithUppercaseI":!1,"A":!1,"$B":!1,"_C":!1,"Test123":!1,"ISample":!0,"IS":!0}),[{it:"rejects interface if all members are not methods",definition:{$interface:"ITest",member:!1},exception:gpf.Error.InvalidInterfaceProperty},{it:"rejects invalid property names (reserved keywords)",definition:{$interface:"ITest","super":function(){}},exception:gpf.Error.InvalidInterfaceProperty},{it:"rejects constructor property",definition:{$interface:"ITest",constructor:function(){}},exception:gpf.Error.InvalidInterfaceProperty}].forEach(t)}),describe("Implementation",function(){var n=gpf.define({$interface:"ITest",test:function(e){return e}});it("can't be used as a class extend",function(){var e;try{gpf.define({$class:"Test",$extend:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassExtend)})})})})}),config.features.es6class&&include("define.es6"),describe("interfaces",function(){describe("gpf.interfaces.IUnknown",function(){it("exists",function(){assert("function"==typeof gpf.interfaces.IUnknown)}),it("is an interface",function(){var e;try{var t=new gpf.interfaces.IUnknown;assert("function"==typeof t.queryInterface)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceConstructorFunction)})}),describe("gpf.interfaces.isImplementedBy",function(){function t(){}t.prototype={queryInterface:function(e){return e}};var n=gpf.define({$class:"TestGPFClass",queryInterface:function(e){return e}});it("validates literal objects (using interface constructor)",function(){assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,{queryInterface:function(e){return e}}))}),it("validates instances from a raw JavaScript class (using interface name)",function(){var e=new t;assert(!0===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",e))}),it("validates a raw JavaScript class",function(){assert(!0===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",t))}),it("validates instances from a GPF class",function(){var e=new n;assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,e))}),it("validates a GPF class",function(){assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,n))}),[!1,null,undefined,0,NaN,""].forEach(function(e){it("rejects "+JSON.stringify(e),function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",e))})}),it("rejects member if not a method",function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",{queryInterface:"Not a method"}))}),it("rejects member if parameters count does not match (none)",function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",{queryInterface:function(){}}))}),it("rejects member if parameters count does not match (more)",function(){assert(!1===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,{queryInterface:function(e,t,n){return e+t+n}}))})}),describe("gpf.interfaces.query",function(){function t(){}t.prototype.test=function(e,t){return e+t},it("returns the object if it implements the interface (using interface name)",function(){var e={queryInterface:function(e){return e}};assert(e===gpf.interfaces.query("gpf.interfaces.IUnknown",e))}),it("returns the object if it implements the interface (using interface specifier)",function(){var e={test:function(e,t){}};assert(e===gpf.interfaces.query(t,e))}),it("returns null if IUnknown is implemented but not the expected interface",function(){assert(null===gpf.interfaces.query(t,{queryInterface:function(e){return null}}))}),it("uses IUnknown to get the expected interface",function(){assert(null!==gpf.interfaces.query(t,{queryInterface:function(e){return assert(e===t),{test:function(e,t){}}}}))}),it("returns undefined if neither the expected interface or IUnknown are implemented",function(){assert(undefined===gpf.interfaces.query(t,{queryInterface:function(){return null}}))})})}),describe("sort",function(){var n=[{id:0,num:5,str:"e",group:1},{id:1,num:1,str:"b",group:0},{id:2,num:4,str:"a",group:1},{id:3,num:2,str:"d",group:0},{id:4,num:3,str:"c",group:1}];describe("gpf.createSortFunction",function(){[{label:"sort on numeric values (ascending)",sort:{property:"num"},expected:[1,3,4,2,0]},{label:"sort on string values (descending)",sort:[{property:"str",type:"string",ascending:!1}],expected:[0,3,4,1,2]},{label:"sort on multiple values",sort:[{property:"group",type:"number",ascending:!0},{property:"num",ascending:!1}],expected:[3,1,0,2,4]}].forEach(function(e){it(e.label,function(){!function t(e,n){assert(e.every(function(e,t){return e.id===n[t]}))}(n.sort(gpf.createSortFunction(e.sort)),e.expected)})})})}),describe("filter",function(){var n=[{id:0,num:5,str:"e",group:1,search:"first"},{id:1,num:1,str:"b",group:0,search:"second"},{id:2,num:4,str:"a",group:1,search:"third"},{id:3,num:2,str:"d",group:0,search:"fourth"},{id:4,num:3,str:"c",group:1,search:"fifth"}];describe("gpf.createFilterFunction",function(){[{label:"filters on numeric values",filter:{eq:[{property:"num"},1]},expected:[1]},{label:"filters on own values",filter:{eq:[{property:"num"},{property:"id"}]},expected:[1]},{label:"filters on string values",filter:{eq:[{property:"str"},"c"]},expected:[4]},{label:"filters on string values (ne)",filter:{ne:[{property:"str"},"c"]},expected:[0,1,2,3]},{label:"filters with lower than (lt)",filter:{lt:[{property:"num"},3]},expected:[1,3]},{label:"filters with lower than or equal (lte)",filter:{lte:[{property:"num"},3]},expected:[1,3,4]},{label:"filters with greater than (gt)",filter:{gt:[{property:"num"},3]},expected:[0,2]},{label:"filters with greater than or equal (lte)",filter:{gte:[{property:"num"},3]},expected:[0,2,4]},{label:"filters on string values (not eq)",filter:{not:{eq:[{property:"str"},"c"]}},expected:[0,1,2,3]},{label:"filters on string values (like)",filter:{like:{property:"str"},regexp:"[a|c]"},expected:[2,4]},{label:"filters on string values (like with capturing group)",filter:{eq:[{like:{property:"search"},regexp:"f([a-z]*)th",group:1},"if"]},expected:[4]},{label:"filters with or (one condition)",filter:{or:[{eq:[{property:"num"},1]}]},expected:[1]},{label:"filters with or (two conditions)",filter:{or:[{eq:[{property:"num"},1]},{eq:[{property:"str"},"c"]}]},expected:[1,4]},{label:"filters with or (three conditions)",filter:{or:[{eq:[{property:"num"},1]},{eq:[{property:"str"},"c"]},{eq:[{property:"group"},0]}]},expected:[1,3,4]},{label:"filters with and (one condition)",filter:{and:[{eq:[{property:"group"},1]}]},expected:[0,2,4]},{label:"filters with and (two conditions)",filter:{and:[{eq:[{property:"group"},1]},{eq:[{property:"str"},"c"]}]},expected:[4]},{label:"filters with and (three conditions)",filter:{and:[{eq:[{property:"group"},1]},{eq:[{property:"str"},"c"]},{eq:[{property:"num"},3]}]},expected:[4]}].forEach(function(e){it(e.label,function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e.id===n[t]}))}(n.filter(gpf.createFilterFunction(e.filter)),e.expected)})})})}),describe("stream",function(){if(gpf.internals){var r=gpf.internals._gpfStreamQueryReadable,s=gpf.internals._gpfStreamQueryWritable,e=gpf.internals._gpfStreamSecureInstallProgressFlag,t=gpf.internals._gpfStreamSecureRead,n=gpf.internals._gpfStreamSecureWrite,i=["","Hello World !",!1,!0,null,undefined,0,1];describe("(internal)",function(){describe("_gpfStreamQueryReadable",function(){it("checks if the parameters implements gpf.interfaces.IReadableStream",function(){assert(r({read:function(e){assert(e)}}))}),it("fails when the parameters does not implement gpf.interfaces.IReadableStream",function(){var e;try{r({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),i.forEach(function(n){it("fails when the parameters is invalid - "+JSON.stringify(n),function(){var e;try{r(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})}),describe("_gpfStreamQueryWritable",function(){it("checks if the parameters implements gpf.interfaces.IWritableStream",function(){assert(s({write:function(e){assert(e)}}))}),it("fails when the parameters does not implement gpf.interfaces.IWritaableStream",function(){var e;try{s({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),i.forEach(function(n){it("fails when the parameters is invalid - "+JSON.stringify(n),function(){var e;try{s(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})}),describe("_gpfStreamSecureRead",function(){function s(){}s.prototype={read:t(function(e){return e.write("TEST")})},e(s),it("accepts only IWritableStream",function(){var e,t=new s;try{t.read({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("is protected against parallel calls",function(){var e,t={write:function(e){return assert("TEST"===e),new Promise(function(){})}},n=new s;try{n.read(t),n.read(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.ReadInProgress)}),it("writes to an IWritableStream",function(e){var t={write:function(e){return assert("TEST"===e),Promise.resolve()}};(new s).read(t).then(function(){e()})}),it("forwards any error",function(r){var e={write:function(e){return assert("string"==typeof e),Promise.reject(1)}};(new s).read(e).then(function(){},function(e){var t;try{assert(1===e)}catch(e_){t=e_}r(t)})})}),describe("_gpfStreamSecureWrite",function(){function s(){}s.prototype={write:n(function(e){return"OK"===e?Promise.resolve():Promise.reject(e)})},e(s),it("is protected against parallel calls",function(){var e,t=new s;try{t.write("OK"),t.write("OK")}catch(e_){e=e_}assert(e instanceof gpf.Error.WriteInProgress)}),it("forwards any error",function(r){(new s).write("KO").then(function(){},function(e){var t;try{assert("KO"===e)}catch(e_){t=e_}r(t)})})})})}}),describe("stream/string",function(){describe("gpf.stream.ReadableString",function(){it("writes to an IWritableStream",function(e){var t=new gpf.stream.WritableString;new gpf.stream.ReadableString("Hello World").read(t).then(function(){assert("Hello World"===t.toString()),e()})})}),describe("gpf.stream.WritableString",function(){it("supports multiple sequenced calls",function(e){var t=new gpf.stream.WritableString;t.write("Hell").then(function(){return t.write("o ")}).then(function(){return t.write("World")}).then(function(){assert("Hello World"===t.toString()),e()})})})}),describe("fs",function(){var n="test/data";describe("gpf.fs.getFileStorage",function(){function r(e){assert(e.type===gpf.fs.types.file),assert("file.bin"===e.fileName),assert(-1!==e.filePath.indexOf(n+"/file.bin")),assert(256===e.size),assert(e.createdDateTime instanceof Date),assert(2010Hello World!"===e("Hello World!").toString())}),it("generates closed tags when empty",function(){var e=gpf.web.createTagFunction("div");assert("
"===e().toString())}),it("supports tree building (parameters)",function(){var e=gpf.web.createTagFunction("div")({className:"test1"},"Hello ",gpf.web.createTagFunction("span")({className:"test2"},"World!"));assert('
Hello World!
'===e.toString())}),it("supports tree building (array parameter)",function(){var e=gpf.web.createTagFunction("div"),t=gpf.web.createTagFunction("span"),n=e({width:"80%"},"Hello ",[t("Wor"),t("ld!")]);assert('
Hello World!
'===n.toString())}),it("allows DOM injection",function(){var e=s.createElement("any"),t=gpf.web.createTagFunction("div")({className:"test"},"Hello ",gpf.web.createTagFunction("span")("World!")).appendTo(e);assert(t instanceof n),assert(t.ownerDocument===s),assert("div"===t.nodeName),assert("test"===t._hasAttribute("","class")),assert(2===t._children.length),assert("Hello "===t._children[0]),assert(t._children[1]instanceof n),assert("World!"===t._children[1]._children[0])}),describe("Namespace handling",function(){it("permits namespaces for node appending",function(){var e=s.createElement("any"),t=gpf.web.createTagFunction("svg:image")({x:0,y:0,"xlink:href":"test.png"}).appendTo(e);assert(t instanceof n),assert(t.ownerDocument===s),assert("image"===t.nodeName),assert("http://www.w3.org/2000/svg"===t._namespace),assert("test.png"===t._hasAttribute("http://www.w3.org/1999/xlink","href")),assert(0===t._hasAttribute("","x"))}),it("fails if namespace is unknown",function(){var e,t=s.createElement("any"),n=gpf.web.createTagFunction("svg2:image")({x:0,y:0,"xlink:href":"test.png"});try{n.appendTo(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.UnknownNamespacePrefix)}),it("fails when used for string generation",function(){var e,t=gpf.web.createTagFunction("svg:image")({x:0,y:0,"xlink:href":"test.png"});try{t.toString()}catch(e_){e=e_}assert(e instanceof gpf.Error.UnableToUseNamespaceInString)})})})}),describe("interfaces/thenable",function(){describe("gpf.interfaces.IThenable",function(){function e(e){var s=gpf[e].bind(gpf);[null,0,"",!1,!0,{},"Hello World!",7].forEach(function(n){it("converts "+JSON.stringify(n)+" into a promise",function(t){try{s(n).then(function(e){assert(n===e),t()})}catch(e_){t(e_)}})}),it("returns the promise parameter",function(){var e=Promise.resolve();assert(e===s(e))}),it("returns the IThenable parameter",function(t){try{var e={then:function(e,t){!function n(e){return e}(t),e("ok")}},n=s(e);assert(e===n),n.then(function(e){assert("ok"===e),t()})}catch(e_){t(e_)}})}describe("gpf.promisify",function(){it("converts undefined into a promise",function(t){try{gpf.promisify().then(function(e){assert(undefined===e),t()})}catch(e_){t(e_)}}),e("promisify")}),describe("gpf.promisifyDefined",function(){it("returns undefined with undefined",function(){assert(gpf.promisifyDefined(undefined)===undefined)}),e("promisifyDefined")})})}),describe("http",function(){it("knows config.httpPort",function(){assert("object"==typeof config&&"number"==typeof config.httpPort)}),describe("gpf.http",function(){var i;0!==config.httpPort?(before(function(){i="http://localhost:"+config.httpPort+"/echo/?"}),describe("basics",function(){it("allows the GET operation",function(n){gpf.http.request({method:gpf.http.methods.get,url:i+"status=200"}).then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("GET"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)}),it("offers the GET shortcut (using string parameter)",function(n){gpf.http.get(i+"status=200").then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("GET"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)}),it("offers the GET shortcut (using object parameter)",function(t){gpf.http.get({url:i+"status=200&response=Hello%20World"}).then(function(e){assert(200===e.status),assert("Hello World"===e.responseText),t()})["catch"](t)}),it("succeeds when the HTTP request fails",function(t){gpf.http.get(i+"status=500").then(function(e){assert(500===e.status),t()})["catch"](t)}),it("succeeds when the HTTP response is empty",function(t){gpf.http.get(i+"response=").then(function(e){assert(""===e.responseText),t()})["catch"](t)})}),describe("headers",function(){it("forwards request headers",function(t){gpf.http.request({method:gpf.http.methods.get,url:i+"status=200",headers:{"x-test":"Value"}}).then(function(e){assert(200===e.status),assert("Value"===e.headers["x-test"]),t()})["catch"](t)}),it("gives access to response headers",function(t){gpf.http.request({method:gpf.http.methods.get,url:i+'status=200&headers={"x-test-1":"OK","x-test-2":123}'}).then(function(e){assert(200===e.status),assert("OK"===e.headers["x-test-1"]),assert("123"===e.headers["x-test-2"]),t()})["catch"](t)})}),describe("methods",function(){["post","put","options","delete","head"].forEach(function(e,t){var n,r,s=e.toUpperCase();t<2&&(n="Hello World"),r="head"===e?function(){}:function(e){var t=JSON.parse(e);assert(t.method===s),assert("/echo/?status=200"===t.url),n?assert(t.body===n):assert(!t.body)},it("allows the "+s+" operation",function(t){gpf.http.request({method:gpf.http.methods[e],url:i+"status=200",data:n}).then(function(e){assert(200===e.status),r(e.responseText),t()})["catch"](t)}),it("offers the "+s+" shortcut",function(t){gpf.http[e](i+"status=200",n).then(function(e){assert(200===e.status),r(e.responseText),t()})["catch"](t)})}),-1!==[gpf.hosts.nodejs].indexOf(gpf.host())&&it("allows any verb (MERGE)",function(n){gpf.http.request({method:"merge",url:i+"status=200"}).then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("MERGE"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)})}),gpf.hosts.browser!==gpf.host()&&describe("https",function(){it("handles https access",function(t){gpf.http.get("https://www.google.com/").then(function(e){assert(200===e.status),t()})["catch"](t)})})):it("is not tested in this environment because config.httpPorty = 0",function(){assert(!0)})})}),describe("stream/java",function(){gpf.hosts.rhino===gpf.host()&&describe("gpf.java.ReadableStream",function(){it("forwards any error",function(n){new gpf.java.ReadableStream({close:function(){}}).read({_ignore:function(){},write:function(e){this._ignore(e)}}).then(function(){n(new Error("Not expected"))},function(e){try{assert(e),n()}catch(e_){n(e_)}})})})}),describe("gpf.http.mock",function(){var r;before(function(){r="http://localhost:"+config.httpPort+"/echo/"}),it("exposes a method to mock requests",function(){assert("function"==typeof gpf.http.mock)}),it("exposes a method to remove one specific mocking",function(){assert("function"==typeof gpf.http.mock.remove)}),it("exposes a method to reset all mocking",function(){assert("function"==typeof gpf.http.mock.reset)}),describe("Simple mocking example",function(){var e;beforeEach(function(){e=gpf.http.mock({method:gpf.http.methods.get,url:/echo\/\?status=([0-9]+)/,response:function(e,t){if("400"!==t)return{status:parseInt(t,10)+1,headers:{"x-mock":!0},responseText:"It works"}}})}),afterEach(function(){e&&gpf.http.mock.remove(e)}),it("matches request URL and method",function(t){gpf.http.get(r+"?status=200").then(function(e){assert(201===e.status),assert(!0===e.headers["x-mock"]),assert("It works"===e.responseText),t()})["catch"](t)}),0!==config.httpPort&&(it("matches request URL and method (non matching URL)",function(t){gpf.http.get(r).then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("matches request URL and method (non matching method)",function(t){gpf.http.put(r,"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("may decide to not mock",function(t){gpf.http.get(r+"?status=400").then(function(e){assert(400===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not mock once removed",function(t){gpf.http.mock.remove(e),e=undefined,gpf.http.get(r+"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not mock once removed (reset)",function(t){gpf.http.mock.reset(),e=undefined,gpf.http.get(r+"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not fail if removed twice",function(){gpf.http.mock.reset(),gpf.http.mock.remove(e),e=undefined}))}),describe("Advanced mocking example",function(){var n;beforeEach(function(){function e(e){return function(){return{status:200,headers:{},responseText:"answer-"+e}}}gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(1)}),gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(2)}),n=gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(3)}),gpf.http.mock({method:gpf.http.methods.put,url:/echo\/lifo/,response:e(4)}),gpf.http.mock({method:gpf.http.methods.get,url:/echo\/redirect/,response:function(e){return gpf.http.get(e.url.replace("/redirect","/lifo"))}})}),afterEach(function(){gpf.http.mock.reset()}),it("uses LIFO priority",function(t){gpf.http.get(r+"lifo").then(function(e){assert(200===e.status),assert("answer-3"===e.responseText),t()})["catch"](t)}),it("preserves the order when removing a mocked request",function(t){gpf.http.mock.remove(n),gpf.http.get(r+"lifo").then(function(e){assert(200===e.status),assert("answer-2"===e.responseText),t()})["catch"](t)}),it("allows redirection",function(t){gpf.http.get(r+"redirect").then(function(e){assert(200===e.status),assert("answer-3"===e.responseText),t()})["catch"](t)})})}),describe("stream/bufferedread",function(){describe("gpf.stream.BufferedRead",function(){function r(e){return e}var s=gpf.define({$class:"TestReadable",$extend:"gpf.stream.BufferedRead",appendToReadBuffer:function(e){return r(e),this._appendToReadBuffer.apply(this,arguments)},completeReadBuffer:function(){return this._completeReadBuffer()},setReadError:function(e){return this._setReadError(e)}});function i(e){var t=new gpf.stream.WritableArray;return gpf.stream.pipe(e,t).then(function(){return t.toArray()})}function n(e,t){i(e).then(function(e){assert(2===e.length),assert("Hello"===e[0]),assert("World!"===e[1]),t()})["catch"](t)}it("exposes IReadableStream",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IReadableStream,s))}),describe("data output",function(){it("outputs data before reading",function(e){var t=new s;t.appendToReadBuffer("Hello","World!").completeReadBuffer(),n(t,e)}),it("outputs data while reading",function(e){var t=new s;t.appendToReadBuffer("Hello"),n(t,e),t.appendToReadBuffer("World!").completeReadBuffer()}),it("outputs data after reading",function(e){var t=new s;n(t,e),t.appendToReadBuffer("Hello","World!").completeReadBuffer()})}),describe("error management",function(){function n(e,t){i(e).then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}function t(e,t){var n=new s;n.appendToReadBuffer("Hello","World!").completeReadBuffer(),gpf.stream.pipe(n,e).then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}it("generates errors before reading",function(e){var t=new s;t.appendToReadBuffer("Hello","World!").setReadError(new Error("FAIL")),n(t,e)}),it("generates errors while reading",function(e){var t=new s;t.appendToReadBuffer("Hello"),n(t,e),t.appendToReadBuffer("World!").setReadError(new Error("FAIL"))}),it("generates errors after reading",function(e){var t=new s;n(t,e),t.appendToReadBuffer("Hello","World!").setReadError(new Error("FAIL"))}),it("forwards errors (exception)",function(e){t({write:function(e){throw r(e),new Error("FAIL")}},e)}),it("forwards errors (reject)",function(e){t({write:function(e){return r(e),Promise.reject(new Error("FAIL"))}},e)})})})}),describe("stream/line",function(){function r(e){return e.write("abc").then(function(){return e.write("def\n")}).then(function(){return e.write("gh")}).then(function(){return e.write("ijkl\r")})}function s(e){return e.write("\nmnopqr\n").then(function(){return e.write("stuvwx\nyz")})}var i=["abcdef","ghijkl","mnopqr","stuvwx","yz"];function a(){return{_index:0,write:function(e){return e!==i[this._index]?Promise.reject("No match"):(++this._index,Promise.resolve())}}}it("generates lines out of any stream (read first)",function(e){var t=new gpf.stream.LineAdapter,n=a();t.read(n).then(function(){assert(n._index===i.length),e()})["catch"](e),r(t).then(function(){return s(t)}).then(function(){t.flush()})}),it("generates lines out of any stream (write first)",function(e){var t=new gpf.stream.LineAdapter,n=a();r(t).then(function(){return s(t)}).then(function(){return t.write("\n")}).then(function(){return t.flush()}).then(function(){return t.read(n)}).then(function(){assert(n._index===i.length),e()})["catch"](e)}),it("generates lines out of any stream (mixed)",function(e){var t=new gpf.stream.LineAdapter,n=a();r(t).then(function(){t.read(n).then(function(){assert(n._index===i.length),e()})["catch"](e),s(t).then(function(){t.flush()})})})}),describe("read",function(){var e=config.testPath+"data";describe("gpf.read",function(){it("gives a generic read access to the file system",function(n){gpf.read(gpf.path.join(e,"folder/hello world.txt")).then(function(e){try{assert("hello world\n"===e),n()}catch(e_){n(e_)}},n)}),it("fails if the file does not exist",function(n){gpf.read(gpf.path.join(e,"nope")).then(function(){n(new Error("Should not happen"))},function(e){try{assert(e instanceof Error),n()}catch(e_){n(e_)}})})})}),describe("require",function(){var a=config.testPath+"require";before(function(){gpf.require.configure({base:a})}),describe("gpf.require.resolve",function(){it("resolves relative path",function(){assert(gpf.require.resolve("file.js")===a+"/file.js")}),it("resolves relative path with folders",function(){assert(gpf.require.resolve("folder/file.js")===a+"/folder/file.js")}),it("resolves relative path with folders (use of ..)",function(){assert(gpf.require.resolve("../file.js")===a.split("/").slice(0,-1).join("/")+"/file.js")})}),describe("gpf.require.configure",function(){it("fails on invalid options",function(){var e;try{gpf.require.configure({unknown:!0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidRequireConfigureOption)});var e=[0,1,!1,!0,"","Hello World",{},new Date,function(){}];function t(e){return"object"!=typeof e}var n={base:function r(e){return"string"!=typeof e},cache:t,clearCache:function s(e){return"boolean"!=typeof e},preload:t,preprocess:function i(e){return"function"!=typeof e}};Object.keys(n).forEach(function(s){e.filter(n[s]).forEach(function(r){it("fails on invalid option value: "+s+"="+JSON.stringify(r),function(){var e;try{var t={};t[s]=r,gpf.require.configure(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidRequireConfigureOptionValue)})})}),after(function(){gpf.require.configure({base:a})})}),describe("gpf.require.define",function(){function r(e){assert("object"==typeof e),assert("value"===e.member)}function t(e,t,n){assert("object"==typeof e),assert(t===e.type),n&&r(e.data)}describe("Asynchronous loading",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),it("loads JSON file as an object",function(e){gpf.require.define({data:"data.json"},function(e){r(e.data)}).then(e,e)}),it("supports CommonJS format (static requires)",function(e){gpf.require.define({commonjs:"commonjs.js"},function(e){t(e.commonjs,"commonjs",!0)}).then(e,e)}),it("doesn't supports CommonJS format with static and dynamic requires",function(e){gpf.require.define({commonjs:"mixed_commonjs.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof gpf.Error.NoCommonJSDynamicRequire)}).then(e,e)}),it("supports independant CommonJS format (no require)",function(e){gpf.require.define({commonjs:"indep_commonjs.js"},function(e){t(e.commonjs,"indep_commonjs",!0)}).then(e,e)}),it("doesn't supports CommonJS format with only dynamic requires",function(e){gpf.require.define({commonjs:"dynamic_commonjs.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof gpf.Error.NoCommonJSDynamicRequire)}).then(e,e)}),it("supports AMD format (named with factory)",function(e){gpf.require.define({amd:"amd.js"},function(e){t(e.amd,"amd",!0)}).then(e,e)}),it("supports AMD format (no name)",function(e){gpf.require.define({amd:"anonymous_amd.js"},function(e){t(e.amd,"amd",!1),assert(""===e.amd.name)}).then(e,e)}),it("supports AMD format (anonymous static)",function(e){gpf.require.define({amd:"static_amd.js"},function(e){t(e.amd,"amd",!1),assert("static"===e.amd.name)}).then(e,e)}),it("supports GPF modules (gpf is defined)",function(e){gpf.require.define({gpf:"gpf.js"},function(e){t(e.gpf,"gpf",!0)}).then(e,e)}),it("supports GPF modules without constant value",function(e){gpf.require.define({constants:"constants.js"},function(e){assert("World!"===e.constants.hello)}).then(e,e)}),it("supports JavaScript file (no result)",function(e){gpf.context().test={},gpf.require.define({js:"empty.js"},function(e){try{assert(e.js===undefined),assert(gpf.context().test.empty)}finally{delete gpf.context().test}}).then(e,e)}),it("supports text file (no processor)",function(e){gpf.require.define({text:"../data/folder/hello world.txt"},function(e){assert("hello world\n"===e.text)}).then(e,e)})}),describe("Recursive loading",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),it("loads everything recursively",function(e){gpf.require.define({all:"folder/all.js"},function(e){t(e.all.amd,"amd",!0),t(e.all.commonjs,"commonjs",!0),r(e.all.data),t(e.all.gpf,"gpf",!0)}).then(e,e)})}),describe("Error handling",function(){it("fails if resource does not exist",function(e){gpf.require.define({notFound:"notFound.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof Error),assert("Should not happen"!==e.message)}).then(e,e)}),it("fails if one javascript resource fails",function(e){gpf.require.define({error:"error.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof Error),assert("FAIL!"===e.message)}).then(e,e)})})}),describe("caching",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),describe("caching of loaded parts",function(){var t={};beforeEach(function(e){gpf.require.define({data:"data.json"},function(e){e.data.additional=t}).then(e,e)}),it("keeps modified objects",function(e){gpf.require.define({data:"data.json"},function(e){assert(t===e.data.additional)}).then(e,e)})}),describe("cache injection",function(){var t={};function e(){it("keeps injected objects",function(e){gpf.require.define({data:"data.json"},function(e){assert(t===e.data)}).then(e,e)})}beforeEach(function(){var e={};e[gpf.require.resolve("data.json")]=t,gpf.require.configure({clearCache:!0,cache:e})}),e(),describe("clearCache = false",function(){beforeEach(function(){gpf.require.configure({clearCache:!1})}),e()})}),describe("error documentation",function(){function r(e,t,n){assert(e instanceof Error),assert(Array.isArray(e.requires)),assert(e.requires.length>t),assert(-1!==e.requires[t].indexOf(n))}it("documents the failing resource name (missing json)",function(e){gpf.require.define({test:"notFound.json"}).then(function(){return Promise.reject(0)})["catch"](function(e){r(e,0,"require/notFound.json")}).then(e,e)}),it("documents the failing resource name (error in javascript)",function(e){gpf.require.define({test:"syntax_error.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){r(e,0,"require/syntax_error.js")}).then(e,e)}),it("documents the loading stack",function(n){gpf.require.define({test:"error_stack.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){try{r(e,0,"require/syntax_error.js"),r(e,1,"require/error_stack.js"),n()}catch(e_){n(e_)}})}),"function"==typeof SyntaxError&&it("transmits the native error",function(n){gpf.require.define({test:"syntax_error.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){try{r(e,0,"require/syntax_error.js"),assert(e instanceof SyntaxError),n()}catch(e_){n(e_)}})})})}),describe("preloading",function(){function e(){gpf.require.define({data:"data.js"},function(e){return e.data})}function t(){module.exports="Hello World!"}function n(e){var t=e.toString(),n=t.indexOf("{"),r=t.lastIndexOf("}");return t.substring(n+1,r)}beforeEach(function(){gpf.require.configure({clearCache:!0,base:"",preload:{"preload/test.js":n(e),"preload/data.js":n(t)}})}),it("loads everything recursively",function(e){gpf.require.define({result:"preload/test.js"},function(e){assert("Hello World!"===e.result)}).then(e,e)})}),describe("preprocessing",function(){it("allows on the fly modification of a resource",function(e){gpf.require.configure({clearCache:!0,base:a,preprocess:function(e){return e.name.endsWith("preprocess.ext")&&(assert(e.content.startsWith("WILL BE REPLACED")),assert(".ext"===e.type),e.content="module.exports = 'Hello World!';",e.type=".js"),Promise.resolve(e)}}),gpf.require.define({result:"preprocess.ext"},function(e){assert("Hello World!"===e.result)}).then(e,e)})})}),describe("stream/array",function(){var s=["Hell","o ","World",null,{}];function i(n,e){try{assert(s.length===n.length),s.forEach(function(e,t){assert(e===n[t])}),e()}catch(e_){e(e_)}}describe("gpf.stream.ReadableArray",function(){it("writes each array item sequentially",function(e){var t=new gpf.stream.ReadableArray(s),n=[];t.read({write:function(e){return n.push(e),Promise.resolve()}}).then(function(){i(n,e)},e)})}),describe("gpf.stream.WritableArray",function(){it("stores each call as an array item",function(e){var t=new gpf.stream.WritableArray,n=0;!function r(){s.length===n?i(t.toArray(),e):t.write(s[n++]).then(r,e)}()})})}),describe("stream/pipe",function(){function t(e){return e}function r(e){return t(e),Promise.reject("FAIL")}function s(e){throw t(e),new Error("FAIL")}function i(e){return t(e),Promise.reject("FAIL")}function a(e){throw t(e),new Error("FAIL")}function o(e,t){e.then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e),t()})["catch"](t)}function c(e,t){e.then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}function f(){var r,s,i,a,o;function t(){if(i||(i=new Promise(function(e,t){a=e,o=t})),s&&r){var e=i,t=a,n=o;return s.write(r).then(t,n),r=undefined,s=undefined,i=undefined,a=undefined,o=undefined,e}return i}return{read:function(e){if(s)throw new Error("Already reading");return s=e,t()},write:function(e){if(r)throw new Error("Buffer full");return r=e,t()}}}function u(e){var t=new gpf.stream.ReadableArray(["Hello ","World!","\n","Goodbye!"]),n=new gpf.stream.WritableArray;return gpf.stream.pipe.apply(gpf.stream,[t].concat(e,n)).then(function(){return n})}function n(e,n){u(e).then(function(e){var t=e.toArray();assert(2===t.length),assert("Hello World!"===t[0]),assert("Goodbye!"===t[1]),n()})["catch"](n)}describe("parameters validation",function(){function n(e){t(e)}function r(e){t(e)}it("fails if the first parameter is not an IReadableStream",function(){var e;try{gpf.stream.pipe({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("fails if no destination",function(){var e;try{gpf.stream.pipe({read:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),describe("handling a sequence with more than two streams",function(){it("misses intermediate read",function(){var e;try{gpf.stream.pipe({read:n},{write:r},{write:r})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("misses intermediate write",function(){var e;try{gpf.stream.pipe({read:n},{read:n},{write:r})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("does not end with write",function(){var e;try{gpf.stream.pipe({read:n},{read:n,write:r},{})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})}),describe("IReadableStream -> IWritableStream",function(){it("Transfer data",function(e){var t=new gpf.stream.WritableString;gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t).then(function(){assert("Hello World"===t.toString()),e()})["catch"](e)}),it("Triggers flush when the read ends",function(e){var t=new gpf.stream.WritableString,n=!1;t.flush=function(){return n=!0,Promise.resolve()},gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t).then(function(){assert("Hello World"===t.toString()),assert(n),e()})["catch"](e)}),it("Forward errors (read - reject)",function(e){var t=new gpf.stream.WritableString,n={read:r};o(gpf.stream.pipe(n,t),e)}),it("Forward errors (read - exception)",function(e){var t=new gpf.stream.WritableString,n={read:s};c(gpf.stream.pipe(n,t),e)}),it("Forward errors (write - reject)",function(e){var t={write:i};o(gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t),e)}),it("Forward errors (write - exception)",function(e){var t={write:a};c(gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t),e)})}),describe("IReadableStream -> IReadableStream/IWritableStream* -> IWritableStream",function(){it("handles the whole stream",function(e){n([new gpf.stream.LineAdapter],e)}),it("handles non flushable intermediate stream",function(e){n([f(),new gpf.stream.LineAdapter],e)}),it("Forward errors (read - reject)",function(e){var t=f();t.read=r,o(u([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (read - exception)",function(e){var t=f();t.read=s,c(u([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (write - reject)",function(e){var t=f();t.write=i,o(u([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (write - exception)",function(e){var t=f();t.write=a,c(u([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second read - reject)",function(e){var t=f(),n=f();n.read=r,o(u([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second read - exception)",function(e){var t=f(),n=f();n.read=s,c(u([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second write - reject)",function(e){var t=f(),n=f();n.write=i,o(u([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second write - exception)",function(e){var t=f(),n=f();n.write=a,c(u([t,n,new gpf.stream.LineAdapter]),e)})})}),describe("stream/csv/parser",function(){describe("gpf.stream.csv.Parser",function(){function e(e){var t=new gpf.stream.ReadableArray(e.lines),n=new gpf.stream.WritableArray;return gpf.stream.pipe(t,e.parser,n).then(function(){return n.toArray()})}function t(s,t){e(s).then(function(e){assert(e.length===s.expected.length),e.forEach(function(t,e){var n=s.expected[e],r=Object.keys(t);assert(r.join(",")===Object.keys(n).join(",")),r.forEach(function(e){assert(t[e]===n[e])})}),t()})["catch"](t)}it("reads a one-column CSV file",function(e){t({lines:["LINE","0","1"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0"},{LINE:"1"}]},e)}),it("reads a CSV file",function(e){t({lines:["LINE;VALUE","0;ABC","1;DEF"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"}]},e)}),it("supports value quoting",function(e){t({lines:["LINE;VALUE",'0;"ABC"',"1;DEF",'2;GH"I','3;"JK""L"','4;"MN','O"'],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"},{LINE:"2",VALUE:'GH"I'},{LINE:"3",VALUE:'JK"L'},{LINE:"4",VALUE:"MN\nO"}]},e)}),it("supports quoting the separator as well",function(e){t({lines:["LINE;VALUE",'0;"A;BC"'],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"A;BC"}]},e)}),it("supports header being specified as an option",function(e){t({lines:["0;ABC","1;DEF"],parser:new gpf.stream.csv.Parser({header:"LINE;VALUE"}),expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"}]},e)}),it("supports empty values",function(e){t({lines:["LINE;VALUE;VALUE2",";AB;CD","1;;EF","2;GH"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"",VALUE:"AB",VALUE2:"CD"},{LINE:"1",VALUE:"",VALUE2:"EF"},{LINE:"2",VALUE:"GH"}]},e)}),it("detects unterminated quoted string",function(t){e({lines:["LINE;VALUE",'0;"A',"BC"],parser:new gpf.stream.csv.Parser}).then(function(){t(new Error("Should fail"))},function(e){assert(e instanceof gpf.Error.InvalidCSV),t()})["catch"](t)}),it("detects invalid quoted string",function(t){e({lines:["LINE;VALUE",'0;"A"BC"'],parser:new gpf.stream.csv.Parser}).then(function(){t(new Error("Should fail"))},function(e){assert(e instanceof gpf.Error.InvalidCSV),t()})["catch"](t)}),it("supports different separator, quote and new line specifiers",function(e){t({lines:["LINE\tVALUE\tVALUE2","0\t\t'A''B","\tC'"],parser:new gpf.stream.csv.Parser({separator:"\t",quote:"'",newLine:"\r\n"}),expected:[{LINE:"0",VALUE:"",VALUE2:"A'B\r\n\tC"}]},e)})})}),describe("attributes/attribute",function(){it("is abstract",function(){var e;try{var t=new gpf.attributes.Attribute;throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractClass)}),describe("basic usage",function(){var e,t,n,r,s;before(function(){e=gpf.define({$class:"MyAttribute",$extend:gpf.attributes.Attribute}),n=new e,r=new e,s=new e,t=gpf.define({$class:"MyClassWithAttributes",$attributes:[r],"[member]":[s],member:"Hello World"})}),it("does not provide any information when not used",function(){assert(n.getClassConstructor()===undefined),assert(n.getMemberName()===undefined)}),it("provides class constructor information",function(){assert(r.getClassConstructor()===t),assert(s.getClassConstructor()===t)}),it("provides member name information",function(){assert(r.getMemberName()===undefined),assert("member"===s.getMemberName())})}),describe("$singleton usage",function(){var e,t,n;before(function(){e=gpf.define({$class:"MyAttribute",$extend:gpf.attributes.Attribute,$singleton:!0}),t=new e,n=new e,gpf.define({$class:"MyClassWithAttributes",$attributes:[t],"[member]":[n],member:"Hello World"})}),it("does not provide class constructor information",function(){assert(t.getClassConstructor()===undefined),assert(n.getClassConstructor()===undefined)}),it("does not provide member name information",function(){assert(t.getMemberName()===undefined),assert(n.getMemberName()===undefined)})})}),describe("define/class/attributes/check",function(){var t=gpf.define({$class:"MyAttribute",$extend:"gpf.attributes.Attribute",_value:undefined,getValue:function(){return this._value},constructor:function(e){this._value=e}});describe("attributes validation",function(){it("allows only existing members",function(){var e;try{gpf.define({$class:"Test1","[t3st]":[],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.UnknownAttributesSpecification)}),it("allows only an array (of attributes) - member",function(){var e;try{gpf.define({$class:"Test1","[test]":{},test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array (of attributes) - class",function(){var e;try{gpf.define({$class:"Test1",$attributes:{},test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array of attributes - member",function(){var e;try{gpf.define({$class:"Test1","[test]":[{}],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array of attributes - class",function(){var e;try{gpf.define({$class:"Test1",$attributes:[{}],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)})}),describe("attributes definition",function(){it("does not expose new members",function(){var e=gpf.define({$class:"MyClassWithAttributes",$attributes:[new t("class")],"[test]":[new t("member")],test:0});assert(undefined===e.prototype["[test]"])})})}),describe("attributes",function(){var t,e={$extend:"gpf.attributes.Attribute",_value:undefined,getValue:function(){return this._value},constructor:function(e){this._value=e}},n=gpf.define(Object.assign({$class:"MyAttribute1"},e)),r=gpf.define(Object.assign({$class:"MyAttribute2"},e)),s=gpf.define({$class:"MyClassWithoutAttributes"}),i=gpf.define({$class:"MyClass",$attributes:[new n("A"),new n("B"),new r("C")],"[value]":[new n("D")],value:0}),a=gpf.define({$class:"MyClass",$extend:i,$attributes:[new n("E"),new r("F")],"[value]":[new r("G")],"[value2]":[new n("H")],value2:1});function o(){i.apply(this,arguments)}o.prototype=Object.create(i.prototype),Object.assign(o.prototype,{value3:2}),t=gpf.define({$class:"MyClass",$extend:o,$attributes:[new n("E"),new r("F")],"[value]":[new r("G")],"[value3]":[new n("I"),new n("J")],"[value2]":[new n("H")],value2:1}),describe("gpf.attributes.get",function(){[undefined,null,0,1,!1,!0,"","Hello World"].forEach(function(n){it("fails if the parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.attributes.get(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("returns an empty object if the class was not allocated by gpf.define",function(){var e=gpf.attributes.get(String);assert(0===Object.keys(e).length)}),it("returns an empty object if no attributes",function(){var e=gpf.attributes.get(s);assert(0===Object.keys(e).length)}),it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(i);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())}),it("retrieves all attributes (on instance)",function(){var e=new i,t=gpf.attributes.get(e);assert(2===Object.keys(t).length),assert(3===t.$attributes.length),assert(1===t.value.length),assert("D"===t.value[0].getValue())}),it("filters on a given attribute class",function(){var e=gpf.attributes.get(i,r);assert(1===Object.keys(e).length),assert(1===e.$attributes.length),assert("C"===e.$attributes[0].getValue())}),describe("with native inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(o);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())}),describe("and then with GPF inheritance",function(){var e=gpf.attributes.get(o);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())}),describe("followed by GPF inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(t);assert(4===Object.keys(e).length),assert(5===e.$attributes.length),assert(2===e.value.length),assert(2===e.value3.length),assert("H"===e.value2[0].getValue())})})}),describe("with GPF inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(a);assert(3===Object.keys(e).length),assert(5===e.$attributes.length),assert(2===e.value.length),assert("H"===e.value2[0].getValue())}),it("filters on a given attribute class",function(){var e=gpf.attributes.get(a,n);assert(3===Object.keys(e).length),assert(3===e.$attributes.length),assert("H"===e.value2[0].getValue())})})})}),describe("stream/filter",function(){var a=[{id:0,num:5,str:"e",group:1,search:"first"},{id:1,num:1,str:"b",group:0,search:"second"},{id:2,num:4,str:"a",group:1,search:"third"},{id:3,num:2,str:"d",group:0,search:"fourth"},{id:4,num:3,str:"c",group:1,search:"fifth"}];function t(e,n,r){var t=new gpf.stream.ReadableArray(a),s=new gpf.stream.Filter(e),i=new gpf.stream.WritableArray;gpf.stream.pipe(t,s,i).then(function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e.id===n[t]}))}(i.toArray(),n),r()})["catch"](r)}describe("gpf.stream.Filter",function(){it("forwards errors",function(t){var e=new gpf.stream.ReadableArray(a),n=new gpf.stream.Filter(function(){return!0}),r={write:function(e){return Promise.reject("KO")}};gpf.stream.pipe(e,n,r).then(function(){throw new Error("Not expected")},function(e){assert("KO"===e),t()})["catch"](t)}),it("filters data - no result",function(e){t(function(){return!1},[],e)}),it("filters data - one result",function(e){t(function(e){return 1===e.num},[1],e)}),it("filters data - several results",function(e){t(function(e){return 1===e.group},[0,2,4],e)}),it("filters data - all results",function(e){t(function(){return!0},[0,1,2,3,4],e)})})}),describe("stream/map",function(){var a=[{id:0},{id:1},{id:2},{id:3},{id:4}];function r(e,n,r){var t=new gpf.stream.ReadableArray(a),s=new gpf.stream.Map(e),i=new gpf.stream.WritableArray;gpf.stream.pipe(t,s,i).then(function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e===n[t]}))}(i.toArray(),n),r()})["catch"](r)}function s(e){return e}describe("gpf.stream.Map",function(){it("forwards errors",function(t){var e=new gpf.stream.ReadableArray(a),n=new gpf.stream.Map(s),r={write:function(e){return s(e),Promise.reject("KO")}};gpf.stream.pipe(e,n,r).then(function(){throw new Error("Not expected")},function(e){assert("KO"===e),t()})["catch"](t)}),it("maps data - identity",function(e){r(s,a,e)}),it("filters data - one substitution",function(e){var t={};function n(e){return 2===e.id?t:e}r(n,a.map(n),e)}),it("filters data - several substitutions",function(e){r(function(e){return e.id},[0,1,2,3,4],e)})})}),describe("interfaces/promisify",function(){describe("gpf.interfaces.promisify",function(){var n,r,s;before(function(){n=gpf.define({$interface:"ISample",test:function(e){!function t(e){return e}(e)}}),r=gpf.interfaces.promisify(n),s=gpf.define({$class:"SampleImpl",test:function(e){if(0===e)throw new Error("OK");return e+1}})}),it("accepts only an object implementing the interface",function(){var e;try{r({notTheExpectedTestMethod:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("leverages IUnkown",function(){var e;try{r({queryInterface:function(e){if(e===n)return new s}})}catch(e_){e=e_}assert(!e)}),it("allows chaining",function(t){r(new s).test(1).test(2).test(3).then(function(e){assert(4===e),t()})["catch"](t)}),it("forwards errors",function(n){r(new s).test(1).test(0).test(3).then(function(){assert(!1)})["catch"](function(e){try{assert("OK"===e.message),n()}catch(e_){n(e_)}})}),it("offers advanced promise chaining",function(t){r(new s).test(1).test(2).then(function(){return 0}).then(function(e){assert(0===e)}).test(3).then(function(e){assert(4===e),t()})["catch"](t)})})}),describe("xml/writer",function(){var s;function n(t,n){var e=new gpf.xml.Writer,r=new gpf.stream.WritableString;return gpf.stream.pipe(e,r).then(function(){try{n(r.toString()),t()}catch(e_){t(e_)}}),s||(s=gpf.interfaces.promisify(gpf.interfaces.IXmlContentHandler)),s(e)}function r(){assert(!1)}function i(n,r){return function(e){try{assert(e instanceof r),n()}catch(e_){n(e_)}}}function t(e){return i(e,gpf.Error.InvalidXmlWriterState)}function a(e){return i(e,gpf.Error.InvalidXmlUseOfPrefixXml)}describe("Interface specification",function(){it("implements gpf.interfaces.IXmlContentHandler",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IXmlContentHandler,gpf.xml.Writer))}),it("implements gpf.interfaces.IReadableStream",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IReadableStream,gpf.xml.Writer))}),it("can be piped",function(e){n(e,function(e){assert(""===e)}).startDocument().startElement("document").endElement().endDocument()["catch"](e)})}),describe("Basic manipulations",function(){it("allows processing instructions",function(e){n(e,function(e){assert("\n"===e)}).startDocument().processingInstruction("test","test-data").startElement("document").endElement().endDocument()["catch"](e)}),it("supports attributes (string value)",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{"test":"value"}).endElement().endDocument()["catch"](e)}),it("supports attributes (number value)",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{"test":2}).endElement().endDocument()["catch"](e)}),it("supports multiple attributes",function(e){n(e,function(e){assert(''===e||''===e)}).startDocument().startElement("document",{"test1":"value1","test2":"value2"}).endElement().endDocument()["catch"](e)}),it("supports nodes hierarchy",function(e){n(e,function(e){assert(""===e)}).startDocument().startElement("document").startElement("a").startElement("b").endElement().endElement().startElement("c").endElement().endElement().endDocument()["catch"](e)}),it("escapes attributes value",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{test:"<&>"}).endElement().endDocument()["catch"](e)}),it("escapes text value",function(e){n(e,function(e){assert("<&>"===e)}).startDocument().startElement("document").characters("<&>").endElement().endDocument()["catch"](e)})}),describe("Namespacing",function(){it("qualifies elements (using prefix)",function(e){n(e,function(e){assert(''===e)}).startDocument().startPrefixMapping("test","namespace-uri").startElement("test:document").endElement().endPrefixMapping("test").endDocument()["catch"](e)}),it("qualifies elements (default namespace)",function(e){n(e,function(e){assert(''===e)}).startDocument().startPrefixMapping("","namespace-uri").startElement("document").endElement().endPrefixMapping("").endDocument()["catch"](e)}),it("qualifies attributes",function(e){n(e,function(e){assert(''===e||''===e)}).startDocument().startPrefixMapping("ns0","namespace-uri").startElement("document",{"ns0:test":"value"}).endElement().endPrefixMapping("ns0").endDocument()["catch"](e)}),it("allows xml namespace prefix",function(e){n(e,function(e){assert(' '===e)}).startDocument().startElement("document",{"xml:space":"preserve"}).characters(" ").endElement().endDocument()["catch"](e)})}),describe("Invalid XML state",function(){it("must start with a document",function(e){n(e,r).startElement("document")["catch"](t(e))}),it("forbids processing instructions once an element is added",function(e){n(e,r).startDocument().startElement("document").processingInstruction("test","test-data")["catch"](t(e))}),it("makes sure all opened elements are closed (endElement)",function(e){n(e,r).startDocument().startElement("document").endElement().endElement()["catch"](t(e))}),it("makes sure all opened elements are closed (endDocument)",function(e){n(e,r).startDocument().startElement("document").endDocument()["catch"](t(e))}),it("makes sure a namespace prefix is declared before usage",function(e){n(e,r).startDocument().startElement("test:document")["catch"](function t(e){return i(e,gpf.Error.UnknownXmlNamespacePrefix)}(e))}),it("prevents overloading a namespace prefix at the same level",function(e){n(e,r).startDocument().startPrefixMapping("test","namespace-uri").startPrefixMapping("test","namespace-uri2").endDocument()["catch"](t(e))}),it("prevents overloading of predefined namespace prefix (xml)",function(e){n(e,r).startDocument().startPrefixMapping("xml","namespace-uri")["catch"](a(e))}),it("prevents overloading of predefined namespace prefix (xmlns)",function(e){n(e,r).startDocument().startPrefixMapping("xmlns","namespace-uri")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlUseOfPrefixXmlns)}(e))}),it("validates element name",function(e){n(e,r).startDocument().startElement("docu/ment")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlElementName)}(e))}),it("validates element name (using xml prefix)",function(e){n(e,r).startDocument().startElement("xml:document")["catch"](a(e))}),it("validates attribute name",function(e){n(e,r).startDocument().startElement("document",{"te/st":"value"})["catch"](function t(e){return i(e,gpf.Error.InvalidXmlAttributeName)}(e))}),it("validates namespace prefix",function(e){n(e,r).startDocument().startPrefixMapping("te/st","namespace-uri")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlNamespacePrefix)}(e))}),it("allows only xml:space attribute",function(e){n(e,r).startDocument().startElement("document",{"xml:lang":"en"})["catch"](a(e))})})}),describe("foreachasync",function(){var i=[0,1,2,3,4,5,6,7,8,9],a={};describe("gpf.forEachAsync",function(){[undefined,0,1,!1,!0,null].forEach(function(n){it("rejects invalid parameter ("+JSON.stringify(n)+")",function(){var e;try{gpf.forEachAsync(n,function(){assert(!0)})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("enumerates an array synchronously",function(e){var r=0,s=0;gpf.forEachAsync(i,function(e,t,n){assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e},a).then(function(){assert(i.length===r),assert(45===s),e()})["catch"](e)}),it("enumerates an array asynchronously",function(e){var r=0,s=0;gpf.forEachAsync(i,function(e,t,n){return assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e,Promise.resolve()},a).then(function(){assert(i.length===r),assert(45===s),e()})["catch"](e)}),it("catches any error",function(t){gpf.forEachAsync(i,function(){throw new Error("OK")}).then(function(){t(new Error("Not expected"))},function(e){assert("OK"===e.message),t()})["catch"](t)}),it("catches any rejected promise",function(t){gpf.forEachAsync(i,function(){return Promise.reject("OK")}).then(function(){t(new Error("Not expected"))},function(e){assert("OK"===e),t()})["catch"](t)})})}),describe("serial/property",function(){if(gpf.internals){var r=gpf.internals._gpfSerialPropertyCheck,e=["",0,1,{},new Date,!0,!1,"123"];describe("_gpfSerialPropertyCheck",function(){it("validates name and default properties",function(){var e=r({name:"OK"});assert(e.type===gpf.serial.types.string),assert(!1===e.required),assert(e.readOnly===undefined)}),it("validates properties",function(){var e;try{r({name:"OK",type:gpf.serial.types.string,required:!1,readOnly:!1})}catch(e_){e=e_}assert(!e)}),e.concat(undefined).forEach(function(n){it("rejects invalid 'name' ("+JSON.stringify(n)+")",function(){var e;try{r({name:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialName)})}),e.forEach(function(n){it("rejects invalid 'type' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",type:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialType)})}),e.filter(function(e){return"boolean"!=typeof e}).forEach(function(n){it("rejects invalid 'required' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",required:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialRequired)})}),e.filter(function(e){return"boolean"!=typeof e}).forEach(function(n){it("rejects invalid 'readOnly' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",readOnly:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialReadOnly)})})})}}),describe("attributes/classattribute",function(){describe("gpf.attributes.ClassAttribute",function(){it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[new gpf.attributes.ClassAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[new gpf.attributes.ClassAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.ClassAttribute,new gpf.attributes.ClassAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,n;before(function(){e=gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.ClassAttribute]}),n=new e}),it("fails definition if used at member level",function(){var e;try{gpf.define({$class:"Test","[test]":[n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("accepts definition if used at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[n]})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/memberattribute",function(){describe("gpf.attributes.MemberAttribute",function(){it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[new gpf.attributes.MemberAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[new gpf.attributes.MemberAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$attributes:[new gpf.attributes.MemberAttribute,new gpf.attributes.MemberAttribute],$extend:gpf.attributes.Attribute,test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,n;before(function(){e=gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.MemberAttribute]}),n=new e}),it("fails definition if used at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[n]})}catch(e_){e=e_}assert(e instanceof gpf.Error.MemberAttributeOnly)}),it("accepts definition if used at member level",function(){var e;try{gpf.define({$class:"Test","[test]":[n],test:function(){}})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/attributeforinstanceof",function(){describe("gpf.attributes.AttributeForInstanceOf",function(){var s,n;before(function(){s=gpf.define({$class:"A",$abstract:!0}),n=new gpf.attributes.AttributeForInstanceOf(s)}),it("requires a base class (no parameter)",function(){var e;try{var t=new gpf.attributes.AttributeForInstanceOf;throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)}),it("requires a base class (not a function)",function(){var e;try{var t=new gpf.attributes.AttributeForInstanceOf(0);throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)}),it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[n]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[n,n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,r;before(function(){e=gpf.define({$class:"AttributeForA",$extend:gpf.attributes.Attribute,$attributes:[n]}),r=new e}),it("fails definition if used on the wrong class",function(){var e;try{gpf.define({$class:"NotAChildOfA",$attributes:[r]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("accepts definition if used on direct child class",function(){var e;try{gpf.define({$class:"DirectChildOfA",$extend:s,$attributes:[r]})}catch(e_){e=e_}assert(!e)}),it("accepts definition if used on child class",function(){var e;try{var t=gpf.define({$class:"DirectChildOfA",$extend:s,$attributes:[r]});gpf.define({$class:"SubChildOfA",$extend:t,$attributes:[r]})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/uniqueattribute",function(){describe("gpf.attributes.UniqueAttribute",function(){it("can't be used on a non-unique class",function(){var e;try{gpf.define({$class:"Any",$attributes:[new gpf.attributes.UniqueAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an unique class",function(){var e;try{gpf.define({$class:"UniqueAttribute",$extend:gpf.attributes.UniqueAttribute,"[test]":[new gpf.attributes.UniqueAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),describe("When used properly",function(){var r,s;before(function(){var e=gpf.define({$class:"AttributeThatShouldBeUnique",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.UniqueAttribute]}),t=gpf.define({$class:"AnyAttribute",$extend:gpf.attributes.Attribute});r=new e,s=new t}),it("fails definition if used twice at class level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r,r]})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("fails definition if used twice at member level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,"[test]":[s,r,r],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("accepts definition if used once at any level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r],"[test]":[s,r],test:function(){}})}catch(e_){e=e_}assert(!e)}),describe("using inheritance",function(){var n;before(function(){n=gpf.define({$class:"BaseTestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r],"[test]":[s,r],test:function(){}})}),it("fails definition if used twice at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[r],$extend:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("fails definition if used twice at member level",function(){var e;try{gpf.define({$class:"Test",$extend:n,"[test]":[r],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)})})})})}),describe("attributes/serializable",function(){var r;before(function(){r=gpf.define({$class:"A","[_member1]":[new gpf.attributes.Serializable({type:gpf.serial.types.string,required:!0})],_member1:"0","[member2]":[new gpf.attributes.Serializable],member2:""})}),describe("gpf.attributes.Serializable",function(){it("provides serialization information on members",function(){var e=gpf.attributes.get(r,gpf.attributes.Serializable),t=e._member1[0].getProperty(),n=e.member2[0].getProperty();assert("member1"===t.name),assert(t.type===gpf.serial.types.string),assert(t.required),assert("member2"===n.name),assert(n.type===gpf.serial.types.string),assert(!n.required)})})}),describe("serial/get",function(){describe("gpf.serial.getProperties",function(){var e;function t(e){assert(2===Object.keys(e).length),assert("id"===e._id.name),assert("name"===e._name.name)}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:""})}),it("lists serializable properties (on class)",function(){t(gpf.serial.get(e))}),it("lists serializable properties (on instance)",function(){t(gpf.serial.get(new e))}),it("returns an empty object if no serializable attributes",function(){var e=gpf.serial.get(new Date);assert(0===Object.keys(e).length)})})}),describe("serial/raw/to",function(){describe("gpf.serial.toRaw",function(){var n;before(function(){n=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0,readOnly:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:"","[_created]":[new gpf.attributes.Serializable({name:"created",type:gpf.serial.datetime,readOnly:!0})],_created:null,"[_modified]":[new gpf.attributes.Serializable({name:"modified",type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,n){this._id=e,this._name=t,this._created=new Date,this._modified=n||null}})}),[undefined,null,0,1,!1,!0,"","Hello World",function(){}].forEach(function(n){it("fails if the parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.serial.toRaw(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("generates an object containing only the serializable properties",function(){var e=new n("id","Test"),t=gpf.serial.toRaw(e);assert(2===Object.keys(t).length),assert("Test"===t.name)}),it("converts properties' value",function(){var r=new n("id","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))),e=gpf.serial.toRaw(r,function(e,t,n){return assert(this===r),"_id"===n?(assert("id"===t.name),assert(!0===t.readOnly),assert("id"===e),"ID"):"_name"===n?(assert("name"===t.name),assert(!1===t.readOnly),assert("Test"===e),"TEST"):n.type===gpf.serial.datetime?(assert("_created"===n||"_modified"===n),e.toISOString()):void assert(!1)});assert(4===Object.keys(e).length),assert("ID"===e.id),assert("TEST"===e.name),assert("2018-09-19T12:50:12.000Z"===e.modified)})})}),config.features.propertydescriptor&&include("serial/raw/to.propertydescriptor"),describe("serial/raw/from",function(){describe("gpf.serial.fromRaw",function(){var n;before(function(){n=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0,readOnly:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:"","[_created]":[new gpf.attributes.Serializable({name:"created",type:gpf.serial.datetime,readOnly:!0})],_created:null,"[_modified]":[new gpf.attributes.Serializable({name:"modified",type:gpf.serial.datetime})],_modified:null})}),[undefined,null,0,1,!1,!0,"","Hello World",function(){}].forEach(function(n){it("fails if the first parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.serial.fromRaw(n,{})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("initializes the instance from the object containing the serializable properties",function(){var e=new n,t=gpf.serial.fromRaw(e,{id:"id",name:"Test"});assert(e===t),assert(""===e._id),assert("Test"===e._name)}),it("converts properties' value",function(){var r=new n;gpf.serial.fromRaw(r,{id:"ID",name:undefined,modified:"2018-09-19T12:50:12.000Z"},function(e,t,n){return assert(this===r),"_id"===n?(assert("id"===t.name),assert(!0===t.readOnly),assert("ID"===e),"id"):"_name"===n?(assert("name"===t.name),assert(!1===t.readOnly),assert(e===undefined),"Test"):n.type===gpf.serial.datetime?(assert("_modified"===n),new Date(e)):void assert(!1)}),assert("id"===r._id),assert("Test"===r._name),assert(2018===r._modified.getUTCFullYear()),assert(8===r._modified.getUTCMonth()),assert(19===r._modified.getUTCDate()),assert(12===r._modified.getUTCHours()),assert(50===r._modified.getUTCMinutes()),assert(12===r._modified.getUTCSeconds())})})}),config.features.propertydescriptor&&include("serial/raw/from.propertydescriptor"),describe("attributes/decorator",function(){describe("gpf.attributes.decorator",function(){function n(){}it("can't be used on a non-es6 class",function(){var e;try{gpf.attributes.decorator()(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.Es6classOnly)})})}),config.features.es6class&&include("attributes/decorator.es6"); \ No newline at end of file +!function(){"use strict";var safeFunc=Function,context=safeFunc("return this;")(),_includes={"isclass.es6":'"use strict";describe("isclass.es6",function(){class A{}describe("gpf.isclass",function(){it("recognizes ES6 classes",function(){assert(gpf.isClass(A))})})});',"define/class/abstract.es6":'"use strict";describe("define/class/abstract.es6",function(){describe("$abstract",function(){class A{get member(){return this._member}constructor(t){t&&(this._member=t)}}let t,e;before(function(){t=gpf.define({$class:"B",$extend:A,$abstract:!0});e=class extends t{}}),it("prevents instantiation of abstract class (B)",function(){!function(t){var e;try{var s=new t;throw new Error(s.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractClass)}(t)}),it("enables instantiation on subclass (C)",function(){const t=new e("defaultValue");assert("defaultValue"===t.member)})})});',"define/class/singleton.es6":'"use strict";describe("define/class/singleton.es6",function(){describe("$singleton",function(){describe("in a sub class",function(){class B{get uniqueObject(){return this._unique}constructor(){this._unique={}}}let e;before(function(){e=gpf.define({$class:"C",$extend:B,$singleton:!0})}),it("does not alter base class behavior",function(){var n=new B,s=new e,t=s.uniqueObject,i=new B,u=new e;assert(n!==i),assert(n.uniqueObject!==i.uniqueObject),assert(s===u),assert(t===u.uniqueObject)})})})});',"define.es6":'"use strict";describe("define.es6",function(){describe("gpf.define",function(){describe("Class definition",function(){describe("Implementation",function(){describe("Subclassing an ES6 class",function(){class A{constructor(t){this._a="A",this._value=t}a(){return this._a}value(){return this._value}}class B extends A{constructor(t){super(t),this._b="B"}b(){return this._b}}let t,e;before(function(){t=gpf.define({$class:"C",$extend:B,"constructor":function(t){this.$super(t)},a:function(){return this.$super()},c:function(){return this.a()+this.b()}}),e=new t(3475)}),it("handles instanceof",function(){assert(e instanceof A),assert(e instanceof B),assert(e instanceof t)}),it("calls the constructor function",function(){assert(3475===e.value())}),it("offers a way to call named base method",function(){assert("AB"===e.c())}),it("does not leak $super",function(){assert(void 0===e.$super)})})})})})});',"attributes.es6":'"use strict";describe("attributes.es6",function(){var t={$extend:"gpf.attributes.Attribute",_value:void 0,getValue:function(){return this._value},constructor:function(t){this._value=t}},e=gpf.define(Object.assign({$class:"MyAttribute1"},t)),s=gpf.define(Object.assign({$class:"MyAttribute2"},t)),a=gpf.define({$class:"MyClass",$attributes:[new e("A"),new e("B"),new s("C")],"[value]":[new e("D")],value:0});class MyNativeClass extends a{}describe("gpf.attributes.get",function(){describe("with native inheritance",function(){it("retrieves all attributes (on class)",function(){var t=gpf.attributes.get(MyNativeClass);assert(2===Object.keys(t).length),assert(3===t.$attributes.length),assert(1===t.value.length),assert("D"===t.value[0].getValue())}),it("retrieves all attributes (on instance)",function(){var t=new MyNativeClass,e=gpf.attributes.get(t);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())})})})});',"serial/raw/to.propertydescriptor":'"use strict";describe("serial/raw/to.propertydescriptor",function(){describe("gpf.serial.toRaw",function(){var e,t;function a(e){var t=gpf.serial.toRaw(e,function(t,a,r){return assert(this===e),"_id"===r?(assert("id"===a.name),assert(!0===a.readOnly),assert("123"===t),"ID"):"_name"===r?(assert("name"===a.name),assert(!1===a.readOnly),assert("Test"===t),"TEST"):"_created"===r?(assert("created"===a.name),void assert(!0===a.readOnly)):"_modified"===r?t.toISOString():void assert(!1)});assert(3===Object.keys(t).length),assert("ID"===t.id),assert("TEST"===t.name),assert("2018-09-19T12:50:12.000Z"===t.modified)}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable],_name:"","[_created]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_created:null,"[_modified]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,a){Object.defineProperty(this,"_id",{value:e,writable:!1}),this._name=t,this.__created=new Date,this._modified=a||null}}),Object.defineProperty(e.prototype,"_created",{configurable:!1,get:function(){return this.__created}}),t=gpf.define({$class:"B",$extend:e})}),it("converts properties\' value",function(){a(new e("123","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))))}),it("converts properties\' value (sub class)",function(){a(new t("123","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))))})})});',"serial/raw/from.propertydescriptor":'"use strict";describe("serial/raw/from.propertydescriptor",function(){describe("gpf.serial.fromRaw",function(){var e,t;function i(e){var t=e._created;gpf.serial.fromRaw(e,{id:"ID",name:void 0,created:"",modified:"2018-09-19T12:50:12.000Z"},function(t,i,r){return assert(this===e),"_id"===r?(assert("id"===i.name),void assert(!0===i.readOnly)):"_name"===r?(assert("name"===i.name),assert(!1===i.readOnly),assert(void 0===t),"Test"):"_created"===r?(assert("created"===i.name),void assert(!0===i.readOnly)):r.type===gpf.serial.datetime?(assert("_modified"===r),new Date(t)):void assert(!1)}),assert("123"===e._id),assert("Test"===e._name),assert(e._created===t),assert(2018===e._modified.getUTCFullYear()),assert(8===e._modified.getUTCMonth()),assert(19===e._modified.getUTCDate()),assert(12===e._modified.getUTCHours()),assert(50===e._modified.getUTCMinutes()),assert(12===e._modified.getUTCSeconds())}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable],_name:"","[_created]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_created:null,"[_modified]":[new gpf.attributes.Serializable({type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,i){Object.defineProperty(this,"_id",{value:e,writable:!1}),this._name=t,this.__created=new Date,this._modified=i||null}}),Object.defineProperty(e.prototype,"_created",{configurable:!1,get:function(){return this.__created}}),t=gpf.define({$class:"B",$extend:e})}),it("converts properties\' value",function(){i(new e("123"))}),it("converts properties\' value (sub class)",function(){i(new t("123"))})})});',"attributes/decorator.es6":'"use strict";describe("attributes/decorator.es6",function(){before(function(){gpf.require.configure({base:config.testPath+"require"})}),describe("Defining attributes on an ES6 class using decorators",function(){var e,s,t;before(function(r){gpf.require.configure({clearCache:!0}),gpf.require.define({classes:"es6/class_with_attributes.js"},function(a){e=a.classes.Attribute,s=a.classes.Test,t=a.classes.SubclassOfTest,r()}).then(void 0,r)}),it("offers decorators to add attributes on class",function(){var t=gpf.attributes.get(s);assert(2===Object.keys(t).length),assert(1===t.id.length),assert(t.id[0]instanceof e),assert(1===t.id[0].value),assert(1===t.reset.length),assert(t.reset[0]instanceof e),assert(2===t.reset[0].value)}),it("works on sub classes",function(){var s=gpf.attributes.get(t);assert(2===Object.keys(s).length),assert(1===s.id.length),assert(2===s.reset.length);var r=0;s.reset.forEach(function(s){assert(s instanceof e),assert(2===s.value||3===s.value),r+=s.value}),assert(5===r)})})});'};context.include=function(source){eval(_includes[source])}}();"use strict";describe("console",function(){if(gpf.internals){var n=gpf.internals._gpfConsoleGenerate;describe("_gpfConsoleGenerate",function(){it("generates an object mocking the console",function(){var e=n();assert("function"==typeof e.log),assert("function"==typeof e.info),assert("function"==typeof e.warn),assert("function"==typeof e.error)}),it("generates a log function prefixing text with padding",function(){var t="";n(function(e){t=e}).log("test"),assert(" test"===t)}),it("generates an info function prefixing text with [?]",function(){var t="";n(function(e){t=e}).info("test"),assert("[?] test"===t)}),it("generates a warn function prefixing text with /!\\",function(){var t="";n(function(e){t=e}).warn("test"),assert("/!\\ test"===t)}),it("generates an error function prefixing text with (X)",function(){var t="";n(function(e){t=e}).error("test"),assert("(X) test"===t)})})}}),describe("arraylike",function(){describe("gpf.isArrayLike",function(){it("checks if an object looks like an array",function(){assert(!0===gpf.isArrayLike([]))}),it("recognizes a simulated array",function(){assert(!0===gpf.isArrayLike({length:2,0:0,1:1}))}),it("recognizes a simulated empty array",function(){assert(!0===gpf.isArrayLike({length:0}))}),it("recognizes a simulated incomplete array",function(){assert(!0===gpf.isArrayLike({length:2,1:1}))}),it("recognizes a simulated non empty array with no items",function(){assert(!0===gpf.isArrayLike({length:2}))}),it("accepts a string as an array like",function(){assert(!0===gpf.isArrayLike("abc"))}),[null,undefined,0,1,!1,!0,{},new Date].forEach(function(e){it("rejects any non fitting value ("+JSON.stringify(e)+")",function(){assert(!1===gpf.isArrayLike(e))})}),it("rejects a simulated array with an invalid length property",function(){assert(!1===gpf.isArrayLike({length:2.5,0:0,1:1}))})})}),describe("foreach",function(){var e="Hello World!",i=[0,1,2,3,4,5,6,7,8,9],a={"number":1,"string":e,"null":null,"object":{member:"value"},"function":function(){return e}};describe("gpf.forEach",function(){it("enumerates array content",function(){var r=0,s=0;gpf.forEach(i,function(e,t,n){assert("number"==typeof t),assert(n===i),++r,s+=e}),assert(i.length===r),assert(45===s)}),it("transmits scope on array content",function(){var e,r=0,s=0;e=gpf.forEach(i,function(e,t,n){assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e},a),assert(undefined===e),assert(i.length===r),assert(45===s)}),it("enumerates object content and handles null value",function(){var r=[],s=!0;gpf.forEach(a,function(e,t,n){assert("string"==typeof t),assert(n===a),r.push(t),"null"===t&&null!==e&&(s=!1)}),r=r.join(","),assert("number,string,null,object,function"===r),assert(!0===s)}),it("transmits scope on object content",function(){var e=gpf.forEach(a,function(){assert(this===a)},a);assert(undefined===e)}),it("does not skip undefined values",function(){var e=new Array(3),t=0;gpf.forEach(e,function(e){assert(undefined===e),++t}),assert(3===t)}),it("does not enumerate inherited values",function(){var e=Object.create({inherited:1});e.own=2,gpf.forEach(e,function(e,t){assert(2===e),assert("own"===t)})})}),gpf.internals&&describe("(internal)",function(){describe("_gpfObjectForEach",function(){var e=gpf.internals._gpfObjectForEach;it("enumerates object keys and values",function(){var r=0;e(a,function(e,t,n){++r,assert(n===a),assert(e===a[t])}),assert(5===r)})}),describe("_gpfArrayForEachFalsy",function(){var t=gpf.internals._gpfArrayForEachFalsy;it("enumerates all values if no truthy result",function(){var r=0,e=t(i,function(e,t,n){++r,assert(n===i),assert(e===i[t])});assert(e===undefined),assert(r===i.length)}),it("stops on first truthy value and return it",function(){var r=0,s={},e=t(i,function(e,t,n){if(4===e)return s;++r,assert(n===i),assert(e===i[t])});assert(e===s),assert(4===r)})})})}),describe("assert",function(){describe("gpf.assert",function(){it("does not accept no message",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.assert(!0)}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)}),[!0,42,"Hello World!",{}].forEach(function(e){it("does nothing on a truthy condition - "+typeof e+" ("+e.toString()+")",function(){gpf.assert(e,"It works")})}),[!1,0,"",undefined,null].forEach(function(n){var e;e=undefined===n?"undefined":null===n?"null":n.toString(),it("throws an exception on a falsy condition - "+typeof n+" ("+e+")",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.assert(n,"It fails")}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)})})}),describe("gpf.asserts",function(){it("works with a message / boolean dictionary",function(){gpf.asserts({"It works":!0,"It also works":!0})}),it("fails on first falsy",function(){var e;try{console.expects&&console.expects("warn",/.*/),gpf.asserts({"It works":!0,"It fails":!1})}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed)})}),describe("gpf.preventAssertWarnings",function(){it("prevents assertion warnings",function(){var e;gpf.preventAssertWarnings(!0);try{gpf.assert(!1,"It fails")}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed),gpf.preventAssertWarnings(!1)})})}),describe("constants",function(){describe("gpf",function(){it("does not expose any 'private' member",function(){!function s(e,t){var n,r;for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(assert("_"!==n.charAt(0)),"object"==typeof(r=e[n])&&-1===t.indexOf(r)&&(t.push(r),s(r,t)))}(gpf,[gpf,gpf.internals])}),it("should expose a version",function(){assert("function"==typeof gpf.version),assert("string"==typeof gpf.version());var e=gpf.version();assert(-1!==e.indexOf(".")),assert(null!==e.match(/[0-9]+\.[0-9]+d?/))}),it("should expose the host type",function(){assert("function"==typeof gpf.host),assert("string"==typeof gpf.host());var e=gpf.host();assert(-1!==[gpf.hosts.browser,gpf.hosts.nashorn,gpf.hosts.nodejs,gpf.hosts.phantomjs,gpf.hosts.rhino,gpf.hosts.unknown,gpf.hosts.wscript].indexOf(e))}),describe("gpf.hosts enumeration",function(){["browser","nodejs","phantomjs","unknown","wscript"].forEach(function(e){it("declares gpf.hosts."+e,function(){assert(undefined!==gpf.hosts[e])})})})}),gpf.internals&&(describe("(internal) _gpfIsUnsignedByte",function(){var r=gpf.internals._gpfIsUnsignedByte;gpf.forEach({0:!0,"-25":!1,128:!0,256:!1,255:!0},function(e,t){var n=parseInt(t,10);e?it("accepts "+t,function(){assert(!0===r(n))}):it("rejects "+t,function(){assert(!1===r(n))})})}),describe("(internal) _gpfFuncImpl",function(){var n=gpf.internals._gpfFuncImpl;it("fails if function can't be generated",function(){var e;try{n([],"{")}catch(e_){e=e_}assert(e)})}))}),describe("string/capitalize",function(){gpf.internals&&describe("(internal) _gpfStringCapitalize",function(){var e=gpf.internals._gpfStringCapitalize;it("does nothing on empty string",function(){assert(""===e(""))}),it("uppercases the first letter",function(){assert("Word"===e("word")),assert("Two words"===e("two words")),assert("Two words"===e("Two words"))}),it("also handles accents",function(){assert("\xc9ric"===e("\xe9ric"))})})}),describe("string/replaceex",function(){gpf.internals&&describe("(internal) _gpfStringReplaceEx",function(){var e=gpf.internals._gpfStringReplaceEx;it("replaces strings recursively",function(){assert("add"===e("abc",{"a":"abc","b":"dc","c":""}))})})}),describe("string/escapefor",function(){gpf.internals&&describe("(internal) _gpfStringEscapeFor",function(){var e=gpf.internals._gpfStringEscapeFor;it("escapes for JavaScript",function(){assert('"abc\\r\\ndef"'===e("abc\r\ndef","javascript"))}),it("escapes for xml",function(){assert("<a&b>"===e("","xml"))}),it("escapes for html",function(){assert("<a&b:éèêáà>"===e("","html"))})})}),describe("compatibility",function(){function e(e){var t=new Array(5);t[2]=undefined,t[3]=3,e.call(t,function(e,t){assert(2===t||3===t),2===t?assert(undefined===e):assert(3===e)})}var r={Array:{every:{length:1,"must return true when it goes over all items":function(e){var t,n=0;t=e.call([1,2,3,-6,10],function(e){return n+=e,!0}),assert(!0===t),assert(10===n)},"must return false when it stops on a given item":function(e){var t,n=0;t=e.call([1,2,3,-6,10],function(e){return 0n)throw new Error("Triggered too soon ("+e+" does not respect the timeout delay of "+this._delay+")");this._done()}catch(e_){this._error=e_,this._done(e_)}},clear:function(){a.clearTimeout(this._id),delete this._allowed},clean:function(){this._triggered||this.clear();var e,t=c.list.length;for(e=0;e 10)",function(){var e=t({a:2},null,11);assert('{\n "a": 2\n}'===e)})}function n(r){it("has the expected arity",function(){assert(2===r.length)}),e.forEach(function(t){!1!==t.parse&&it("works on "+t.label,function(){var e=r(t.json);assert(!0===s(e,t.obj))})}),it("supports reviver parameter - simple",function(){var e=r('{"a": 5, "b": "6"}',function(e,t){return"number"==typeof t?2*t:t});assert(!0===s(e,{a:10,b:"6"}))}),it("supports reviver parameter - traversing",function(){var n=[];r('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}',function(e,t){return n.push(e.toString()),t}),assert(7===n.length),["1","2","4","6","5","3",""].forEach(function(e,t){assert(n[t]===e)})})}describe("JSON object",function(){it("exists",function(){assert("undefined"!=typeof JSON)})}),describe("JSON.stringify",function(){t(JSON.stringify)}),describe("JSON.parse",function(){n(JSON.parse.bind(JSON))}),gpf.internals&&describe("(internal)",function(){describe("_gpfJsonStringifyPolyfill",function(){t(gpf.internals._gpfJsonStringifyPolyfill)}),describe("_gpfJsonParsePolyfill",function(){n(gpf.internals._gpfJsonParsePolyfill)})})}),describe("compatibility/base64",function(){var r={"Hello":"SGVsbG8=","Hello ":"SGVsbG8g","Hello World !":"SGVsbG8gV29ybGQgIQ==","!@#$%?&*()":"IUAjJCU/JiooKQ=="};function e(e){return function(){describe("atob",function(){var n=e.atob;Object.keys(r).forEach(function(e){var t=r[e];it("turns "+JSON.stringify(t)+" into "+JSON.stringify(e),function(){assert(n(t)===e)})}),it("rejects strings with invalid characters",function(){var e;try{n("<")}catch(e_){e=e_}assert(e)})}),describe("btoa",function(){var n=e.btoa;Object.keys(r).forEach(function(e){var t=r[e];it("turns "+JSON.stringify(e)+" into "+JSON.stringify(t),function(){assert(n(e)===t)})}),it("rejects strings with non latin characters",function(){var e;try{n("\u2665")}catch(e_){e=e_}assert(e)})})}}describe("exposed API",e({atob:atob,btoa:btoa})),gpf.internals&&atob!==gpf.internals._gpfAtob&&describe("(internal)",e({atob:gpf.internals._gpfAtob,btoa:gpf.internals._gpfBtoa}))}),describe("context",function(){describe("gpf.context",function(){var t=Function;it("resolves the global context",function(){if(assert("function"==typeof gpf.context),assert(null!==gpf.context()),gpf.hosts.browser===gpf.host())assert(window===gpf.context());else if(gpf.hosts.nodejs===gpf.host()||gpf.hosts.phantomjs===gpf.host())assert(global===gpf.context());else{var e=t("return this;")();assert(e===gpf.context())}}),it("resolves gpf",function(){assert(gpf===gpf.context("gpf"))}),it("resolves any symbol",function(){assert(gpf.context===gpf.context("gpf.context"))}),it("returns undefined if not existing",function(){assert(undefined===gpf.context("gpf.not-existing"))}),it("returns undefined if not existing (deep dive)",function(){assert(undefined===gpf.context("gpf.not-existing.really-not"))})}),gpf.internals&&describe("_gpfContext",function(){var r=gpf.internals._gpfContext;it("can build a context",function(){var e=gpf.context(),t={};e.testContextJS=t;var n=r(["testContextJS","folder","name"],!0);assert(t.folder.name===n),delete e.testContextJS})})}),describe("function",function(){if(gpf.internals){var t=gpf.internals._gpfFunctionDescribe,n=gpf.internals._gpfFunctionBuild,r=gpf.internals._gpfExtractFunctionName;describe("_gpfFunctionDescribe",function(){it("describes a named function",function(){var e=t(function(e,t){return e+t});assert("test"===e.name),assert(2===e.parameters.length),assert("a"===e.parameters[0]),assert("b"===e.parameters[1]),assert(-1!==e.body.indexOf("return a + b;"))}),it("identifies an unnamed function",function(){var e=t(function(){return 0});assert(!e.name),assert(!e.parameters),assert(-1!==e.body.indexOf("return 0;"))}),it("identifies empty function",function(){var e=t(function(){});assert(undefined===e.body)}),it("filters out comments",function(){var e=t(function r(e,t,n){return e+t+n});assert("test2"===e.name),assert(3===e.parameters.length),assert("a"===e.parameters[0]),assert("b"===e.parameters[1]),assert("c"===e.parameters[2]),assert(-1===e.body.indexOf("comments are removed"))})}),describe("_gpfFunctionBuild",function(){it("builds an empty anonymous function",function(){var e=n({});assert("function"==typeof e),assert(""===r(e))}),it("builds a named function",function(){var e=n({name:"test"});assert("test"===r(e))}),it("builds a function with named parameters",function(){var e=n({parameters:["a","b","c"],body:"return a + b + c;"});assert(3===e.length),assert(6===e(1,2,3))}),it("builds a function with external context",function(){var e=n({body:"return a;"},{a:"Hello World!"});assert(0===e.length),assert("Hello World!"===e())})}),describe("_gpfExtractFunctionName",function(){it("gets function name",function(){assert("thisName"===r(function e(){}))}),it("supports empty name",function(){assert(""===r(function(){}))})})}}),describe("error",function(){describe("gpf.Error",function(){it("is used as an exception",function(){var e;try{gpf.Error.abstractMethod()}catch(e_){e=e_}assert(e instanceof Error),assert(e instanceof gpf.Error),assert(e instanceof gpf.Error.AbstractMethod),assert(e.constructor===gpf.Error.AbstractMethod)}),it("is documented",function(){var e;try{gpf.Error.abstractMethod()}catch(e_){e=e_}assert(e.code===gpf.Error.CODE_ABSTRACTMETHOD),assert(e.code===gpf.Error.abstractMethod.CODE),assert("abstractMethod"===e.name),assert("Abstract method"===e.message)}),it("can use substitution for message",function(){var e;try{gpf.Error.assertionFailed({message:"Test"})}catch(e_){e=e_}assert(e instanceof gpf.Error.AssertionFailed),assert(e.code===gpf.Error.CODE_ASSERTIONFAILED),assert(e.code===gpf.Error.assertionFailed.CODE),assert("assertionFailed"===e.name),assert("Assertion failed: Test"===e.message)})})}),describe("isclass",function(){describe("gpf.isclass",function(){[undefined,null,!1,!0,"","Hello World!",0,1,function(){}].forEach(function(e){it("fails on "+JSON.stringify(e),function(){assert(!gpf.isClass(e))})})})}),config.features.es6class&&include("isclass.es6"),describe("abstract",function(){if(gpf.internals){var r=gpf.internals._gpfCreateAbstractFunction;describe("_gpfCreateAbstractFunction",function(){it("generates a function with a given signature",function(){var e=r(3);assert(3===e.length)}),it("generates a function that throws the abstractMethod exception",function(){var e,t=r(0);try{t()}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractMethod)})})}}),describe("define/check",function(){gpf.internals&&describe("(internal) _GpfEntityDefinition",function(){var t=gpf.internals._GpfEntityDefinition,r=gpf.internals._gpfDefineBuildTypedEntity;it("must have an entity type",function(){var e;try{r({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntityType)}),it("checks for a valid name",function(){var e;try{r({$type:"class"})}catch(e_){e=e_}assert(e instanceof gpf.Error.MissingEntityName)}),it("validates minimal requirement (type and name)",function(){r({$type:"class",$name:"Test"})}),it("rejects invalid properties",function(){var e;try{r({$type:"class",$name:"Test",$fail:!0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntity$Property)}),it("converts $class into _type and _name",function(){var e=r({$class:"Test"});assert(e instanceof t),assert("class"===e._type),assert("Test"===e._name)}),it("converts $class into _type, _name and _namespace (absolute)",function(){var e=r({$class:"gpf.test.Test"});assert("class"===e._type),assert("Test"===e._name),assert("gpf.test"===e._namespace)}),it("converts $class into _type, _name and _namespace (relative)",function(){var e=r({$class:"test.Test",$namespace:"gpf"});assert("class"===e._type),assert("Test"===e._name),assert("gpf.test"===e._namespace)}),it("prioritize $class over $name",function(){var e=r({$class:"Test",$name:"Any"});assert("class"===e._type),assert("Test"===e._name)}),it("validates namespace",function(){r({$class:"Test",$namespace:"lowerCamelCase.$accepted._also.numbers456"}),r({$class:"Test",$namespace:"simple"}),r({$class:"Test",$namespace:""})}),["endingPointIsNotOK.","startingNumberIsNotOK.4test","$isOKOnlyAtBeginning.test$","_isOKOnlyAtBeginning.test_","CapitalFirstLetterIsNotOK"].forEach(function(n){it("rejects invalid namespace ("+n+")",function(){var e;try{r({$class:"Test",$namespace:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidEntityNamespace)})})})}),describe("define/class/check",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var t=gpf.internals._GpfClassDefinition,s=gpf.internals._gpfDefineBuildTypedEntity;it("is used for class definition",function(){var e=s({$class:"Test"});assert(e instanceof t)}),it("accepts a valid class definition",function(){s({$class:"Test",member:function(){}})}),["startingWithLowercaseLetterIsNotOK","The$signIsForbbidenIfNotAtTheBeginning","The_signIsForbbidenIfNotAtTheBeginning"].forEach(function(n){it("rejects invalid class name ("+n+")",function(){var e;try{s({$class:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassName)})}),["StartingWithUppercaseLetterIsNotOK","the$signIsForbbidenIfNotAtTheBeginning","the_signIsForbbidenIfNotAtTheBeginning","class"].forEach(function(r){it("rejects invalid property name ("+r+")",function(){var e,t={$class:"Test"};t[r]=!0;try{s(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassProperty)})}),it("rejects invalid $extend",function(){var e;try{s({$class:"Test",$extend:12})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassExtend)}),it("accepts native $extend",function(){s({$class:"Test",$extend:String})}),it("accepts contextual $extend",function(){s({$class:"Test",$extend:"String"})})})}),describe("define/class/abstract",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var r=gpf.internals._gpfDefineBuildTypedEntity;[undefined,!1,0,"",{},1,"Hello World!"].forEach(function(n){it("supports only $abstract = true ("+JSON.stringify(n)+")",function(){var e;try{r({$type:"class",$name:"Test",$abstract:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClass$AbstractSpecification)})})}),describe("$abstract",function(){var e,t,n;function r(e){var t;try{var n=new e;throw new Error(n.toString())}catch(e_){t=e_}assert(t instanceof gpf.Error.AbstractClass)}before(function(){e=gpf.define({$class:"A",$abstract:!0,_member:"defaultValue",getMember:function(){return this._member},"constructor":function(e){e&&(this._member=e)}}),t=gpf.define({$class:"B",$extend:e}),n=gpf.define({$class:"C",$extend:t,$abstract:!0})}),it("prevents instantiation of abstract class (A)",function(){r(e)}),it("enables instantiation on subclass (B)",function(){var e=new t;assert("defaultValue"===e.getMember())}),it("prevents instantiation of abstract class (C)",function(){r(n)})})}),config.features.es6class&&include("define/class/abstract.es6"),describe("define/class/singleton",function(){gpf.internals&&describe("(internal) _GpfClassDefinition",function(){var r=gpf.internals._gpfDefineBuildTypedEntity;[undefined,!1,0,"",{},1,"Hello World!"].forEach(function(n){it("supports only $singleton = true ("+JSON.stringify(n)+")",function(){var e;try{r({$type:"class",$name:"Test",$singleton:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClass$SingletonSpecification)})})}),describe("$singleton",function(){var r,e={_unique:null,getUniqueObject:function(){return this._unique},"constructor":function(){this._unique={}}};before(function(){r=gpf.define(Object.assign({$class:"A",$singleton:!0},e))}),it("allows only one instantation of the class",function(){var e=new r,t=e.getUniqueObject(),n=new r;assert(e===n),assert(t===n.getUniqueObject())}),describe("in a sub class",function(){var i,a;before(function(){i=gpf.define(Object.assign({$class:"B"},e)),a=gpf.define({$class:"C",$extend:i,$singleton:!0})}),it("does not alter base class behavior",function(){var e=new i,t=new a,n=t.getUniqueObject(),r=new i,s=new a;assert(e!==r),assert(e.getUniqueObject()!==r.getUniqueObject()),assert(t===s),assert(n===s.getUniqueObject())})})})}),config.features.es6class&&include("define/class/singleton.es6"),describe("define",function(){var s={};function e(s,i,t){Object.keys(t).filter(function(e){return!t[e]}).forEach(function(r){it("rejects invalid "+s+" name ("+r+")",function(){var e,t={};t["$"+s]=r;try{gpf.define(t)}catch(e_){e=e_}assert(e instanceof i)})}),Object.keys(t).filter(function(e){return t[e]}).forEach(function(r){it("accepts valid "+s+" name ("+r+")",function(){var e,t={};t["$"+s]=r;try{gpf.define(t)}catch(e_){e=e_}assert(undefined===e)})})}function t(n){it(n.it,function(){var e;try{gpf.define(n.definition)}catch(e_){e=e_}assert(e instanceof n.exception)})}before(function(){gpf.context().test=s}),after(function(){delete gpf.context().test}),describe("gpf.define",function(){it("accepts only one parameter",function(){assert("function"==typeof gpf.define),assert(1===gpf.define.length)}),describe("Common validation",function(){t({it:"checks that the entity type is specified",definition:{},exception:gpf.Error.InvalidEntityType})}),describe("Class definition",function(){describe("Validation",function(){e("class",gpf.Error.InvalidClassName,{"1NumberAtTheBeginningIsNotOK":!1,"noUppercaseFirstLetterIsNotOK":!1,"DollarSignAnywhereIsNotOK$":!1,"A":!0,"$B":!0,"_C":!0,"Test123":!0}),[{it:"rejects invalid $ property names",definition:{$class:"Test",$test:!1},exception:gpf.Error.InvalidEntity$Property},{it:"rejects invalid property names (reserved keywords)",definition:{$class:"Test","super":!1},exception:gpf.Error.InvalidClassProperty},{it:"rejects constructor property if not a method",definition:{$class:"Test",constructor:!1},exception:gpf.Error.InvalidClassConstructor}].forEach(t)}),describe("Implementation",function(){var r,e;before(function(){r=gpf.define({$class:"A",_member:"defaultValue",getMember:function(){return this._member},"constructor":function(e){e&&(this._member=e),this._constructorOfA=!0},funcWith3params:function(e,t,n){return e+t+n},throwError:function(){throw new Error("error")}}),e=new r}),it("prevents constructor functions to be used without new",function(){var e;try{r()}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassConstructorFunction)}),it("creates a constructor with the same signature than the constructor property",function(){assert(1===r.length)}),it("handles instanceof",function(){assert(e instanceof r)}),it("calls constructor property",function(){assert(e._constructorOfA)}),it("exposes methods",function(){assert("function"==typeof e.getMember),assert("defaultValue"===e.getMember())}),describe("Subclassing",function(){var t,n;it("prevents invalid override",function(){var e;try{gpf.define({$class:"Test",$extend:r,getMember:!1})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassOverride)}),before(function(){t=gpf.define({$class:"test.B",$extend:r,"constructor":function(e){this.$super("valueOfB"),this._constructorOfB=e},getMember:function(){return this.$super()+"-inB"},setMember:function(e){this._member=e},baseTest:function(){return this.$super.getMember()},invalidSuperMember:function(){return this.$super.doesntExist()},noSuperMember:function(){return this.$super()},differentBinding:function(){return this.$super.getMember.call({_member:"different"})},checkSignature:function(){assert(3===this.$super.funcWith3params.length)},throwError:function(){this.$super()}}),n=new t(3475)}),it("handles instanceof",function(){assert(n instanceof r),assert(n instanceof t)}),it("handles namespace",function(){assert(s.B===t)}),it("calls the constructor function",function(){assert(3475===n._constructorOfB)}),it("calls the proper $super()",function(){assert(n._constructorOfA),assert("valueOfB-inB"===n.getMember())}),it("offers a way to call named base method",function(){assert("valueOfB"===n.baseTest())}),it("fails when accessing an unknown $super member",function(){var e;try{n.invalidSuperMember()}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassSuperMember)}),it("fails when accessing inexistent $super",function(){var e;try{n.noSuperMember()}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassSuper)}),it("allows calling $super member with a different binding",function(){assert("different"===n.differentBinding())}),it("respects methods signature",function(){n.checkSignature()}),it("does not leak $super",function(){assert(undefined===n.$super)}),it("does not leak $super on exception",function(){try{n.throwError()}catch(e_){}assert(undefined===n.$super)}),it("handles several versions of $super",function(){var e=new(gpf.define({$class:"C",$extend:t,testMethod:function(){return this.$super.getMember()}}));assert("valueOfB-inB"===e.testMethod())})})})}),describe("Interface definition",function(){describe("Validation",function(){e("interface",gpf.Error.InvalidInterfaceName,{"1NumberAtTheBeginningIsNotOK":!1,"noUppercaseFirstLetterIsNotOK":!1,"DollarSignAnywhereIsNotOK$":!1,"NotStartingWithUppercaseI":!1,"A":!1,"$B":!1,"_C":!1,"Test123":!1,"ISample":!0,"IS":!0}),[{it:"rejects interface if all members are not methods",definition:{$interface:"ITest",member:!1},exception:gpf.Error.InvalidInterfaceProperty},{it:"rejects invalid property names (reserved keywords)",definition:{$interface:"ITest","super":function(){}},exception:gpf.Error.InvalidInterfaceProperty},{it:"rejects constructor property",definition:{$interface:"ITest",constructor:function(){}},exception:gpf.Error.InvalidInterfaceProperty}].forEach(t)}),describe("Implementation",function(){var n=gpf.define({$interface:"ITest",test:function(e){return e}});it("can't be used as a class extend",function(){var e;try{gpf.define({$class:"Test",$extend:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidClassExtend)})})})})}),config.features.es6class&&include("define.es6"),describe("interfaces",function(){describe("gpf.interfaces.IUnknown",function(){it("exists",function(){assert("function"==typeof gpf.interfaces.IUnknown)}),it("is an interface",function(){var e;try{var t=new gpf.interfaces.IUnknown;assert("function"==typeof t.queryInterface)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceConstructorFunction)})}),describe("gpf.interfaces.isImplementedBy",function(){function t(){}t.prototype={queryInterface:function(e){return e}};var n=gpf.define({$class:"TestGPFClass",queryInterface:function(e){return e}});it("validates literal objects (using interface constructor)",function(){assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,{queryInterface:function(e){return e}}))}),it("validates instances from a raw JavaScript class (using interface name)",function(){var e=new t;assert(!0===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",e))}),it("validates a raw JavaScript class",function(){assert(!0===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",t))}),it("validates instances from a GPF class",function(){var e=new n;assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,e))}),it("validates a GPF class",function(){assert(!0===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,n))}),[!1,null,undefined,0,NaN,""].forEach(function(e){it("rejects "+JSON.stringify(e),function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",e))})}),it("rejects member if not a method",function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",{queryInterface:"Not a method"}))}),it("rejects member if parameters count does not match (none)",function(){assert(!1===gpf.interfaces.isImplementedBy("gpf.interfaces.IUnknown",{queryInterface:function(){}}))}),it("rejects member if parameters count does not match (more)",function(){assert(!1===gpf.interfaces.isImplementedBy(gpf.interfaces.IUnknown,{queryInterface:function(e,t,n){return e+t+n}}))})}),describe("gpf.interfaces.query",function(){function t(){}t.prototype.test=function(e,t){return e+t},it("returns the object if it implements the interface (using interface name)",function(){var e={queryInterface:function(e){return e}};assert(e===gpf.interfaces.query("gpf.interfaces.IUnknown",e))}),it("returns the object if it implements the interface (using interface specifier)",function(){var e={test:function(e,t){}};assert(e===gpf.interfaces.query(t,e))}),it("returns null if IUnknown is implemented but not the expected interface",function(){assert(null===gpf.interfaces.query(t,{queryInterface:function(e){return null}}))}),it("uses IUnknown to get the expected interface",function(){assert(null!==gpf.interfaces.query(t,{queryInterface:function(e){return assert(e===t),{test:function(e,t){}}}}))}),it("returns undefined if neither the expected interface or IUnknown are implemented",function(){assert(undefined===gpf.interfaces.query(t,{queryInterface:function(){return null}}))})})}),describe("sort",function(){var n=[{id:0,num:5,str:"e",group:1},{id:1,num:1,str:"b",group:0},{id:2,num:4,str:"a",group:1},{id:3,num:2,str:"d",group:0},{id:4,num:3,str:"c",group:1}];describe("gpf.createSortFunction",function(){[{label:"sort on numeric values (ascending)",sort:{property:"num"},expected:[1,3,4,2,0]},{label:"sort on string values (descending)",sort:[{property:"str",type:"string",ascending:!1}],expected:[0,3,4,1,2]},{label:"sort on multiple values",sort:[{property:"group",type:"number",ascending:!0},{property:"num",ascending:!1}],expected:[3,1,0,2,4]}].forEach(function(e){it(e.label,function(){!function t(e,n){assert(e.every(function(e,t){return e.id===n[t]}))}(n.sort(gpf.createSortFunction(e.sort)),e.expected)})})})}),describe("filter",function(){var n=[{id:0,num:5,str:"e",group:1,search:"first"},{id:1,num:1,str:"b",group:0,search:"second"},{id:2,num:4,str:"a",group:1,search:"third"},{id:3,num:2,str:"d",group:0,search:"fourth"},{id:4,num:3,str:"c",group:1,search:"fifth"}];describe("gpf.createFilterFunction",function(){[{label:"filters on numeric values",filter:{eq:[{property:"num"},1]},expected:[1]},{label:"filters on own values",filter:{eq:[{property:"num"},{property:"id"}]},expected:[1]},{label:"filters on string values",filter:{eq:[{property:"str"},"c"]},expected:[4]},{label:"filters on string values (ne)",filter:{ne:[{property:"str"},"c"]},expected:[0,1,2,3]},{label:"filters with lower than (lt)",filter:{lt:[{property:"num"},3]},expected:[1,3]},{label:"filters with lower than or equal (lte)",filter:{lte:[{property:"num"},3]},expected:[1,3,4]},{label:"filters with greater than (gt)",filter:{gt:[{property:"num"},3]},expected:[0,2]},{label:"filters with greater than or equal (lte)",filter:{gte:[{property:"num"},3]},expected:[0,2,4]},{label:"filters on string values (not eq)",filter:{not:{eq:[{property:"str"},"c"]}},expected:[0,1,2,3]},{label:"filters on string values (like)",filter:{like:{property:"str"},regexp:"[a|c]"},expected:[2,4]},{label:"filters on string values (like with capturing group)",filter:{eq:[{like:{property:"search"},regexp:"f([a-z]*)th",group:1},"if"]},expected:[4]},{label:"filters with or (one condition)",filter:{or:[{eq:[{property:"num"},1]}]},expected:[1]},{label:"filters with or (two conditions)",filter:{or:[{eq:[{property:"num"},1]},{eq:[{property:"str"},"c"]}]},expected:[1,4]},{label:"filters with or (three conditions)",filter:{or:[{eq:[{property:"num"},1]},{eq:[{property:"str"},"c"]},{eq:[{property:"group"},0]}]},expected:[1,3,4]},{label:"filters with and (one condition)",filter:{and:[{eq:[{property:"group"},1]}]},expected:[0,2,4]},{label:"filters with and (two conditions)",filter:{and:[{eq:[{property:"group"},1]},{eq:[{property:"str"},"c"]}]},expected:[4]},{label:"filters with and (three conditions)",filter:{and:[{eq:[{property:"group"},1]},{eq:[{property:"str"},"c"]},{eq:[{property:"num"},3]}]},expected:[4]}].forEach(function(e){it(e.label,function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e.id===n[t]}))}(n.filter(gpf.createFilterFunction(e.filter)),e.expected)})})})}),describe("stream",function(){if(gpf.internals){var r=gpf.internals._gpfStreamQueryReadable,s=gpf.internals._gpfStreamQueryWritable,e=gpf.internals._gpfStreamSecureInstallProgressFlag,t=gpf.internals._gpfStreamSecureRead,n=gpf.internals._gpfStreamSecureWrite,i=["","Hello World !",!1,!0,null,undefined,0,1];describe("(internal)",function(){describe("_gpfStreamQueryReadable",function(){it("checks if the parameters implements gpf.interfaces.IReadableStream",function(){assert(r({read:function(e){assert(e)}}))}),it("fails when the parameters does not implement gpf.interfaces.IReadableStream",function(){var e;try{r({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),i.forEach(function(n){it("fails when the parameters is invalid - "+JSON.stringify(n),function(){var e;try{r(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})}),describe("_gpfStreamQueryWritable",function(){it("checks if the parameters implements gpf.interfaces.IWritableStream",function(){assert(s({write:function(e){assert(e)}}))}),it("fails when the parameters does not implement gpf.interfaces.IWritaableStream",function(){var e;try{s({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),i.forEach(function(n){it("fails when the parameters is invalid - "+JSON.stringify(n),function(){var e;try{s(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})}),describe("_gpfStreamSecureRead",function(){function s(){}s.prototype={read:t(function(e){return e.write("TEST")})},e(s),it("accepts only IWritableStream",function(){var e,t=new s;try{t.read({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("is protected against parallel calls",function(){var e,t={write:function(e){return assert("TEST"===e),new Promise(function(){})}},n=new s;try{n.read(t),n.read(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.ReadInProgress)}),it("writes to an IWritableStream",function(e){var t={write:function(e){return assert("TEST"===e),Promise.resolve()}};(new s).read(t).then(function(){e()})}),it("forwards any error",function(r){var e={write:function(e){return assert("string"==typeof e),Promise.reject(1)}};(new s).read(e).then(function(){},function(e){var t;try{assert(1===e)}catch(e_){t=e_}r(t)})})}),describe("_gpfStreamSecureWrite",function(){function s(){}s.prototype={write:n(function(e){return"OK"===e?Promise.resolve():Promise.reject(e)})},e(s),it("is protected against parallel calls",function(){var e,t=new s;try{t.write("OK"),t.write("OK")}catch(e_){e=e_}assert(e instanceof gpf.Error.WriteInProgress)}),it("forwards any error",function(r){(new s).write("KO").then(function(){},function(e){var t;try{assert("KO"===e)}catch(e_){t=e_}r(t)})})})})}}),describe("stream/string",function(){describe("gpf.stream.ReadableString",function(){it("writes to an IWritableStream",function(e){var t=new gpf.stream.WritableString;new gpf.stream.ReadableString("Hello World").read(t).then(function(){assert("Hello World"===t.toString()),e()})})}),describe("gpf.stream.WritableString",function(){it("supports multiple sequenced calls",function(e){var t=new gpf.stream.WritableString;t.write("Hell").then(function(){return t.write("o ")}).then(function(){return t.write("World")}).then(function(){assert("Hello World"===t.toString()),e()})})})}),describe("fs",function(){if(config.performance)it("is not relevant for performance testing",function(){assert(!0)});else{var n="test/data";describe("gpf.fs.getFileStorage",function(){function r(e){assert(e.type===gpf.fs.types.file),assert("file.bin"===e.fileName),assert(-1!==e.filePath.indexOf(n+"/file.bin")),assert(256===e.size),assert(e.createdDateTime instanceof Date),assert(2010Hello World!
"===e("Hello World!").toString())}),it("generates closed tags when empty",function(){var e=gpf.web.createTagFunction("div");assert("
"===e().toString())}),it("supports tree building (parameters)",function(){var e=gpf.web.createTagFunction("div")({className:"test1"},"Hello ",gpf.web.createTagFunction("span")({className:"test2"},"World!"));assert('
Hello World!
'===e.toString())}),it("supports tree building (array parameter)",function(){var e=gpf.web.createTagFunction("div"),t=gpf.web.createTagFunction("span"),n=e({width:"80%"},"Hello ",[t("Wor"),t("ld!")]);assert('
Hello World!
'===n.toString())}),it("allows DOM injection",function(){var e=s.createElement("any"),t=gpf.web.createTagFunction("div")({className:"test"},"Hello ",gpf.web.createTagFunction("span")("World!")).appendTo(e);assert(t instanceof n),assert(t.ownerDocument===s),assert("div"===t.nodeName),assert("test"===t._hasAttribute("","class")),assert(2===t._children.length),assert("Hello "===t._children[0]),assert(t._children[1]instanceof n),assert("World!"===t._children[1]._children[0])}),describe("Namespace handling",function(){it("permits namespaces for node appending",function(){var e=s.createElement("any"),t=gpf.web.createTagFunction("svg:image")({x:0,y:0,"xlink:href":"test.png"}).appendTo(e);assert(t instanceof n),assert(t.ownerDocument===s),assert("image"===t.nodeName),assert("http://www.w3.org/2000/svg"===t._namespace),assert("test.png"===t._hasAttribute("http://www.w3.org/1999/xlink","href")),assert(0===t._hasAttribute("","x"))}),it("fails if namespace is unknown",function(){var e,t=s.createElement("any"),n=gpf.web.createTagFunction("svg2:image")({x:0,y:0,"xlink:href":"test.png"});try{n.appendTo(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.UnknownNamespacePrefix)}),it("fails when used for string generation",function(){var e,t=gpf.web.createTagFunction("svg:image")({x:0,y:0,"xlink:href":"test.png"});try{t.toString()}catch(e_){e=e_}assert(e instanceof gpf.Error.UnableToUseNamespaceInString)})})})}),describe("interfaces/thenable",function(){describe("gpf.interfaces.IThenable",function(){function e(e){var s=gpf[e].bind(gpf);[null,0,"",!1,!0,{},"Hello World!",7].forEach(function(n){it("converts "+JSON.stringify(n)+" into a promise",function(t){try{s(n).then(function(e){assert(n===e),t()})}catch(e_){t(e_)}})}),it("returns the promise parameter",function(){var e=Promise.resolve();assert(e===s(e))}),it("returns the IThenable parameter",function(t){try{var e={then:function(e,t){!function n(e){return e}(t),e("ok")}},n=s(e);assert(e===n),n.then(function(e){assert("ok"===e),t()})}catch(e_){t(e_)}})}describe("gpf.promisify",function(){it("converts undefined into a promise",function(t){try{gpf.promisify().then(function(e){assert(undefined===e),t()})}catch(e_){t(e_)}}),e("promisify")}),describe("gpf.promisifyDefined",function(){it("returns undefined with undefined",function(){assert(gpf.promisifyDefined(undefined)===undefined)}),e("promisifyDefined")})})}),describe("http",function(){it("knows config.httpPort",function(){assert("object"==typeof config&&"number"==typeof config.httpPort)}),describe("gpf.http",function(){var i;config.performance?it("is not relevant for performance testing",function(){assert(!0)}):0!==config.httpPort?(before(function(){i="http://localhost:"+config.httpPort+"/echo/?"}),describe("basics",function(){it("allows the GET operation",function(n){gpf.http.request({method:gpf.http.methods.get,url:i+"status=200"}).then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("GET"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)}),it("offers the GET shortcut (using string parameter)",function(n){gpf.http.get(i+"status=200").then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("GET"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)}),it("offers the GET shortcut (using object parameter)",function(t){gpf.http.get({url:i+"status=200&response=Hello%20World"}).then(function(e){assert(200===e.status),assert("Hello World"===e.responseText),t()})["catch"](t)}),it("succeeds when the HTTP request fails",function(t){gpf.http.get(i+"status=500").then(function(e){assert(500===e.status),t()})["catch"](t)}),it("succeeds when the HTTP response is empty",function(t){gpf.http.get(i+"response=").then(function(e){assert(""===e.responseText),t()})["catch"](t)})}),describe("headers",function(){it("forwards request headers",function(t){gpf.http.request({method:gpf.http.methods.get,url:i+"status=200",headers:{"x-test":"Value"}}).then(function(e){assert(200===e.status),assert("Value"===e.headers["x-test"]),t()})["catch"](t)}),it("gives access to response headers",function(t){gpf.http.request({method:gpf.http.methods.get,url:i+'status=200&headers={"x-test-1":"OK","x-test-2":123}'}).then(function(e){assert(200===e.status),assert("OK"===e.headers["x-test-1"]),assert("123"===e.headers["x-test-2"]),t()})["catch"](t)})}),describe("methods",function(){["post","put","options","delete","head"].forEach(function(e,t){var n,r,s=e.toUpperCase();t<2&&(n="Hello World"),r="head"===e?function(){}:function(e){var t=JSON.parse(e);assert(t.method===s),assert("/echo/?status=200"===t.url),n?assert(t.body===n):assert(!t.body)},it("allows the "+s+" operation",function(t){gpf.http.request({method:gpf.http.methods[e],url:i+"status=200",data:n}).then(function(e){assert(200===e.status),r(e.responseText),t()})["catch"](t)}),it("offers the "+s+" shortcut",function(t){gpf.http[e](i+"status=200",n).then(function(e){assert(200===e.status),r(e.responseText),t()})["catch"](t)})}),-1!==[gpf.hosts.nodejs].indexOf(gpf.host())&&it("allows any verb (MERGE)",function(n){gpf.http.request({method:"merge",url:i+"status=200"}).then(function(e){assert(200===e.status);var t=JSON.parse(e.responseText);assert("MERGE"===t.method),assert("/echo/?status=200"===t.url),n()})["catch"](n)})}),gpf.hosts.browser!==gpf.host()&&describe("https",function(){it("handles https access",function(t){gpf.http.get("https://www.google.com/").then(function(e){assert(200===e.status),t()})["catch"](t)})})):it("is not tested in this environment because config.httpPort = 0",function(){assert(!0)})})}),describe("stream/java",function(){gpf.hosts.rhino===gpf.host()&&describe("gpf.java.ReadableStream",function(){it("forwards any error",function(n){new gpf.java.ReadableStream({close:function(){}}).read({_ignore:function(){},write:function(e){this._ignore(e)}}).then(function(){n(new Error("Not expected"))},function(e){try{assert(e),n()}catch(e_){n(e_)}})})})}),describe("gpf.http.mock",function(){var r;before(function(){r="http://localhost:"+config.httpPort+"/echo/"}),it("exposes a method to mock requests",function(){assert("function"==typeof gpf.http.mock)}),it("exposes a method to remove one specific mocking",function(){assert("function"==typeof gpf.http.mock.remove)}),it("exposes a method to reset all mocking",function(){assert("function"==typeof gpf.http.mock.reset)}),describe("Simple mocking example",function(){var e;beforeEach(function(){e=gpf.http.mock({method:gpf.http.methods.get,url:/echo\/\?status=([0-9]+)/,response:function(e,t){if("400"!==t)return{status:parseInt(t,10)+1,headers:{"x-mock":!0},responseText:"It works"}}})}),afterEach(function(){e&&gpf.http.mock.remove(e)}),it("matches request URL and method",function(t){gpf.http.get(r+"?status=200").then(function(e){assert(201===e.status),assert(!0===e.headers["x-mock"]),assert("It works"===e.responseText),t()})["catch"](t)}),0===config.httpPort||config.performance||(it("matches request URL and method (non matching URL)",function(t){gpf.http.get(r).then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("matches request URL and method (non matching method)",function(t){gpf.http.put(r,"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("may decide to not mock",function(t){gpf.http.get(r+"?status=400").then(function(e){assert(400===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not mock once removed",function(t){gpf.http.mock.remove(e),e=undefined,gpf.http.get(r+"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not mock once removed (reset)",function(t){gpf.http.mock.reset(),e=undefined,gpf.http.get(r+"?status=200").then(function(e){assert(200===e.status),assert(e.headers["x-mock"]===undefined),t()})["catch"](t)}),it("does not fail if removed twice",function(){gpf.http.mock.reset(),gpf.http.mock.remove(e),e=undefined}))}),describe("Advanced mocking example",function(){var n;beforeEach(function(){function e(e){return function(){return{status:200,headers:{},responseText:"answer-"+e}}}gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(1)}),gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(2)}),n=gpf.http.mock({method:gpf.http.methods.get,url:/echo\/lifo/,response:e(3)}),gpf.http.mock({method:gpf.http.methods.put,url:/echo\/lifo/,response:e(4)}),gpf.http.mock({method:gpf.http.methods.get,url:/echo\/redirect/,response:function(e){return gpf.http.get(e.url.replace("/redirect","/lifo"))}})}),afterEach(function(){gpf.http.mock.reset()}),it("uses LIFO priority",function(t){gpf.http.get(r+"lifo").then(function(e){assert(200===e.status),assert("answer-3"===e.responseText),t()})["catch"](t)}),it("preserves the order when removing a mocked request",function(t){gpf.http.mock.remove(n),gpf.http.get(r+"lifo").then(function(e){assert(200===e.status),assert("answer-2"===e.responseText),t()})["catch"](t)}),it("allows redirection",function(t){gpf.http.get(r+"redirect").then(function(e){assert(200===e.status),assert("answer-3"===e.responseText),t()})["catch"](t)})})}),describe("stream/bufferedread",function(){describe("gpf.stream.BufferedRead",function(){function r(e){return e}var s=gpf.define({$class:"TestReadable",$extend:"gpf.stream.BufferedRead",appendToReadBuffer:function(e){return r(e),this._appendToReadBuffer.apply(this,arguments)},completeReadBuffer:function(){return this._completeReadBuffer()},setReadError:function(e){return this._setReadError(e)}});function i(e){var t=new gpf.stream.WritableArray;return gpf.stream.pipe(e,t).then(function(){return t.toArray()})}function n(e,t){i(e).then(function(e){assert(2===e.length),assert("Hello"===e[0]),assert("World!"===e[1]),t()})["catch"](t)}it("exposes IReadableStream",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IReadableStream,s))}),describe("data output",function(){it("outputs data before reading",function(e){var t=new s;t.appendToReadBuffer("Hello","World!").completeReadBuffer(),n(t,e)}),it("outputs data while reading",function(e){var t=new s;t.appendToReadBuffer("Hello"),n(t,e),t.appendToReadBuffer("World!").completeReadBuffer()}),it("outputs data after reading",function(e){var t=new s;n(t,e),t.appendToReadBuffer("Hello","World!").completeReadBuffer()})}),describe("error management",function(){function n(e,t){i(e).then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}function t(e,t){var n=new s;n.appendToReadBuffer("Hello","World!").completeReadBuffer(),gpf.stream.pipe(n,e).then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}it("generates errors before reading",function(e){var t=new s;t.appendToReadBuffer("Hello","World!").setReadError(new Error("FAIL")),n(t,e)}),it("generates errors while reading",function(e){var t=new s;t.appendToReadBuffer("Hello"),n(t,e),t.appendToReadBuffer("World!").setReadError(new Error("FAIL"))}),it("generates errors after reading",function(e){var t=new s;n(t,e),t.appendToReadBuffer("Hello","World!").setReadError(new Error("FAIL"))}),it("forwards errors (exception)",function(e){t({write:function(e){throw r(e),new Error("FAIL")}},e)}),it("forwards errors (reject)",function(e){t({write:function(e){return r(e),Promise.reject(new Error("FAIL"))}},e)})})})}),describe("stream/line",function(){function r(e){return e.write("abc").then(function(){return e.write("def\n")}).then(function(){return e.write("gh")}).then(function(){return e.write("ijkl\r")})}function s(e){return e.write("\nmnopqr\n").then(function(){return e.write("stuvwx\nyz")})}var i=["abcdef","ghijkl","mnopqr","stuvwx","yz"];function a(){return{_index:0,write:function(e){return e!==i[this._index]?Promise.reject("No match"):(++this._index,Promise.resolve())}}}it("generates lines out of any stream (read first)",function(e){var t=new gpf.stream.LineAdapter,n=a();t.read(n).then(function(){assert(n._index===i.length),e()})["catch"](e),r(t).then(function(){return s(t)}).then(function(){t.flush()})}),it("generates lines out of any stream (write first)",function(e){var t=new gpf.stream.LineAdapter,n=a();r(t).then(function(){return s(t)}).then(function(){return t.write("\n")}).then(function(){return t.flush()}).then(function(){return t.read(n)}).then(function(){assert(n._index===i.length),e()})["catch"](e)}),it("generates lines out of any stream (mixed)",function(e){var t=new gpf.stream.LineAdapter,n=a();r(t).then(function(){t.read(n).then(function(){assert(n._index===i.length),e()})["catch"](e),s(t).then(function(){t.flush()})})})}),describe("read",function(){var e=config.testPath+"data";describe("gpf.read",function(){it("gives a generic read access to the file system",function(n){gpf.read(gpf.path.join(e,"folder/hello world.txt")).then(function(e){try{assert("hello world\n"===e),n()}catch(e_){n(e_)}},n)}),it("fails if the file does not exist",function(n){gpf.read(gpf.path.join(e,"nope")).then(function(){n(new Error("Should not happen"))},function(e){try{assert(e instanceof Error),n()}catch(e_){n(e_)}})})})}),describe("require",function(){var a=config.testPath+"require";before(function(){gpf.require.configure({base:a})}),describe("gpf.require.resolve",function(){it("resolves relative path",function(){assert(gpf.require.resolve("file.js")===a+"/file.js")}),it("resolves relative path with folders",function(){assert(gpf.require.resolve("folder/file.js")===a+"/folder/file.js")}),it("resolves relative path with folders (use of ..)",function(){assert(gpf.require.resolve("../file.js")===a.split("/").slice(0,-1).join("/")+"/file.js")})}),describe("gpf.require.configure",function(){it("fails on invalid options",function(){var e;try{gpf.require.configure({unknown:!0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidRequireConfigureOption)});var e=[0,1,!1,!0,"","Hello World",{},new Date,function(){}];function t(e){return"object"!=typeof e}var n={base:function r(e){return"string"!=typeof e},cache:t,clearCache:function s(e){return"boolean"!=typeof e},preload:t,preprocess:function i(e){return"function"!=typeof e}};Object.keys(n).forEach(function(s){e.filter(n[s]).forEach(function(r){it("fails on invalid option value: "+s+"="+JSON.stringify(r),function(){var e;try{var t={};t[s]=r,gpf.require.configure(t)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidRequireConfigureOptionValue)})})}),after(function(){gpf.require.configure({base:a})})}),describe("gpf.require.define",function(){function r(e){assert("object"==typeof e),assert("value"===e.member)}function t(e,t,n){assert("object"==typeof e),assert(t===e.type),n&&r(e.data)}describe("Asynchronous loading",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),it("loads JSON file as an object",function(e){gpf.require.define({data:"data.json"},function(e){r(e.data)}).then(e,e)}),it("supports CommonJS format (static requires)",function(e){gpf.require.define({commonjs:"commonjs.js"},function(e){t(e.commonjs,"commonjs",!0)}).then(e,e)}),it("doesn't supports CommonJS format with static and dynamic requires",function(e){gpf.require.define({commonjs:"mixed_commonjs.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof gpf.Error.NoCommonJSDynamicRequire)}).then(e,e)}),it("supports independant CommonJS format (no require)",function(e){gpf.require.define({commonjs:"indep_commonjs.js"},function(e){t(e.commonjs,"indep_commonjs",!0)}).then(e,e)}),it("doesn't supports CommonJS format with only dynamic requires",function(e){gpf.require.define({commonjs:"dynamic_commonjs.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof gpf.Error.NoCommonJSDynamicRequire)}).then(e,e)}),it("supports AMD format (named with factory)",function(e){gpf.require.define({amd:"amd.js"},function(e){t(e.amd,"amd",!0)}).then(e,e)}),it("supports AMD format (no name)",function(e){gpf.require.define({amd:"anonymous_amd.js"},function(e){t(e.amd,"amd",!1),assert(""===e.amd.name)}).then(e,e)}),it("supports AMD format (anonymous static)",function(e){gpf.require.define({amd:"static_amd.js"},function(e){t(e.amd,"amd",!1),assert("static"===e.amd.name)}).then(e,e)}),it("supports GPF modules (gpf is defined)",function(e){gpf.require.define({gpf:"gpf.js"},function(e){t(e.gpf,"gpf",!0)}).then(e,e)}),it("supports GPF modules without constant value",function(e){gpf.require.define({constants:"constants.js"},function(e){assert("World!"===e.constants.hello)}).then(e,e)}),it("supports JavaScript file (no result)",function(e){gpf.context().test={},gpf.require.define({js:"empty.js"},function(e){try{assert(e.js===undefined),assert(gpf.context().test.empty)}finally{delete gpf.context().test}}).then(e,e)}),it("supports text file (no processor)",function(e){gpf.require.define({text:"../data/folder/hello world.txt"},function(e){assert("hello world\n"===e.text)}).then(e,e)})}),describe("Recursive loading",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),it("loads everything recursively",function(e){gpf.require.define({all:"folder/all.js"},function(e){t(e.all.amd,"amd",!0),t(e.all.commonjs,"commonjs",!0),r(e.all.data),t(e.all.gpf,"gpf",!0)}).then(e,e)})}),describe("Error handling",function(){it("fails if resource does not exist",function(e){gpf.require.define({notFound:"notFound.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof Error),assert("Should not happen"!==e.message)}).then(e,e)}),it("fails if one javascript resource fails",function(e){gpf.require.define({error:"error.js"}).then(function(){e(new Error("Should not happen"))},function(e){assert(e instanceof Error),assert("FAIL!"===e.message)}).then(e,e)})})}),describe("caching",function(){beforeEach(function(){gpf.require.configure({clearCache:!0})}),describe("caching of loaded parts",function(){var t={};beforeEach(function(e){gpf.require.define({data:"data.json"},function(e){e.data.additional=t}).then(e,e)}),it("keeps modified objects",function(e){gpf.require.define({data:"data.json"},function(e){assert(t===e.data.additional)}).then(e,e)})}),describe("cache injection",function(){var t={};function e(){it("keeps injected objects",function(e){gpf.require.define({data:"data.json"},function(e){assert(t===e.data)}).then(e,e)})}beforeEach(function(){var e={};e[gpf.require.resolve("data.json")]=t,gpf.require.configure({clearCache:!0,cache:e})}),e(),describe("clearCache = false",function(){beforeEach(function(){gpf.require.configure({clearCache:!1})}),e()})}),describe("error documentation",function(){function r(e,t,n){assert(e instanceof Error),assert(Array.isArray(e.requires)),assert(e.requires.length>t),assert(-1!==e.requires[t].indexOf(n))}it("documents the failing resource name (missing json)",function(e){gpf.require.define({test:"notFound.json"}).then(function(){return Promise.reject(0)})["catch"](function(e){r(e,0,"require/notFound.json")}).then(e,e)}),it("documents the failing resource name (error in javascript)",function(e){gpf.require.define({test:"syntax_error.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){r(e,0,"require/syntax_error.js")}).then(e,e)}),it("documents the loading stack",function(n){gpf.require.define({test:"error_stack.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){try{r(e,0,"require/syntax_error.js"),r(e,1,"require/error_stack.js"),n()}catch(e_){n(e_)}})}),"function"==typeof SyntaxError&&it("transmits the native error",function(n){gpf.require.define({test:"syntax_error.js"}).then(function(){return Promise.reject(0)})["catch"](function(e){try{r(e,0,"require/syntax_error.js"),assert(e instanceof SyntaxError),n()}catch(e_){n(e_)}})})})}),describe("preloading",function(){function e(){gpf.require.define({data:"data.js"},function(e){return e.data})}function t(){module.exports="Hello World!"}function n(e){var t=e.toString(),n=t.indexOf("{"),r=t.lastIndexOf("}");return t.substring(n+1,r)}beforeEach(function(){gpf.require.configure({clearCache:!0,base:"",preload:{"preload/test.js":n(e),"preload/data.js":n(t)}})}),it("loads everything recursively",function(e){gpf.require.define({result:"preload/test.js"},function(e){assert("Hello World!"===e.result)}).then(e,e)})}),describe("preprocessing",function(){it("allows on the fly modification of a resource",function(e){gpf.require.configure({clearCache:!0,base:a,preprocess:function(e){return e.name.endsWith("preprocess.ext")&&(assert(e.content.startsWith("WILL BE REPLACED")),assert(".ext"===e.type),e.content="module.exports = 'Hello World!';",e.type=".js"),Promise.resolve(e)}}),gpf.require.define({result:"preprocess.ext"},function(e){assert("Hello World!"===e.result)}).then(e,e)})})}),describe("stream/array",function(){var s=["Hell","o ","World",null,{}];function i(n,e){try{assert(s.length===n.length),s.forEach(function(e,t){assert(e===n[t])}),e()}catch(e_){e(e_)}}describe("gpf.stream.ReadableArray",function(){it("writes each array item sequentially",function(e){var t=new gpf.stream.ReadableArray(s),n=[];t.read({write:function(e){return n.push(e),Promise.resolve()}}).then(function(){i(n,e)},e)})}),describe("gpf.stream.WritableArray",function(){it("stores each call as an array item",function(e){var t=new gpf.stream.WritableArray,n=0;!function r(){s.length===n?i(t.toArray(),e):t.write(s[n++]).then(r,e)}()})})}),describe("stream/pipe",function(){function t(e){return e}describe("parameters validation",function(){function n(e){t(e)}function r(e){t(e)}it("fails if the first parameter is not an IReadableStream",function(){var e;try{gpf.stream.pipe({})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("fails if no destination",function(){var e;try{gpf.stream.pipe({read:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),describe("handling a sequence with more than two streams",function(){it("misses intermediate read",function(){var e;try{gpf.stream.pipe({read:n},{write:r},{write:r})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("misses intermediate write",function(){var e;try{gpf.stream.pipe({read:n},{read:n},{write:r})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("does not end with write",function(){var e;try{gpf.stream.pipe({read:n},{read:n,write:r},{})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)})})});var r={_readRejectError:function(e){return t(e),Promise.reject("FAIL")},_readThrowError:function(e){throw t(e),new Error("FAIL")},_writeRejectError:function(e){return t(e),Promise.reject("FAIL")},_writeThrowError:function(e){throw t(e),new Error("FAIL")},_wrapForRejectionHandler:function(e,t){e.then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e),t()})["catch"](t)},_wrapForExceptionHandler:function(e,t){e.then(function(){throw new Error("Should fail")},function(e){assert("FAIL"===e.message),t()})["catch"](t)}};function s(){var r,s,i,a,o;function t(){if(i||(i=new Promise(function(e,t){a=e,o=t})),s&&r){var e=i,t=a,n=o;return s.write(r).then(t,n),r=undefined,s=undefined,i=undefined,a=undefined,o=undefined,e}return i}return{read:function(e){if(s)throw new Error("Already reading");return s=e,t()},write:function(e){if(r)throw new Error("Buffer full");return r=e,t()}}}function i(e){var t=new gpf.stream.ReadableArray(["Hello ","World!","\n","Goodbye!"]),n=new gpf.stream.WritableArray;return gpf.stream.pipe.apply(gpf.stream,[t].concat(e,n)).then(function(){return n})}function n(e,n){i(e).then(function(e){var t=e.toArray();assert(2===t.length),assert("Hello World!"===t[0]),assert("Goodbye!"===t[1]),n()})["catch"](n)}describe("IReadableStream -> IWritableStream",function(){it("Transfer data",function(e){var t=new gpf.stream.WritableString;gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t).then(function(){assert("Hello World"===t.toString()),e()})["catch"](e)}),it("Triggers flush when the read ends",function(e){var t=new gpf.stream.WritableString,n=!1;t.flush=function(){return n=!0,Promise.resolve()},gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t).then(function(){assert("Hello World"===t.toString()),assert(n),e()})["catch"](e)}),it("Forward errors (read - reject)",function(e){var t=new gpf.stream.WritableString,n={read:r._readRejectError};r._wrapForRejectionHandler(gpf.stream.pipe(n,t),e)}),it("Forward errors (read - exception)",function(e){var t=new gpf.stream.WritableString,n={read:r._readThrowError};r._wrapForExceptionHandler(gpf.stream.pipe(n,t),e)}),it("Forward errors (write - reject)",function(e){var t={write:r._writeRejectError};r._wrapForRejectionHandler(gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t),e)}),it("Forward errors (write - exception)",function(e){var t={write:r._writeThrowError};r._wrapForExceptionHandler(gpf.stream.pipe(new gpf.stream.ReadableString("Hello World"),t),e)})}),describe("IReadableStream -> IReadableStream/IWritableStream* -> IWritableStream",function(){it("handles the whole stream",function(e){n([new gpf.stream.LineAdapter],e)}),it("handles non flushable intermediate stream",function(e){n([s(),new gpf.stream.LineAdapter],e)}),it("Forward errors (read - reject)",function(e){var t=s();t.read=r._readRejectError,r._wrapForRejectionHandler(i([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (read - exception)",function(e){var t=s();t.read=r._readThrowError,r._wrapForExceptionHandler(i([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (write - reject)",function(e){var t=s();t.write=r._writeRejectError,r._wrapForRejectionHandler(i([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (write - exception)",function(e){var t=s();t.write=r._writeThrowError,r._wrapForExceptionHandler(i([t,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second read - reject)",function(e){var t=s(),n=s();n.read=r._readRejectError,r._wrapForRejectionHandler(i([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second read - exception)",function(e){var t=s(),n=s();n.read=r._readThrowError,r._wrapForExceptionHandler(i([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second write - reject)",function(e){var t=s(),n=s();n.write=r._writeRejectError,r._wrapForRejectionHandler(i([t,n,new gpf.stream.LineAdapter]),e)}),it("Forward errors (second write - exception)",function(e){var t=s(),n=s();n.write=r._writeThrowError,r._wrapForExceptionHandler(i([t,n,new gpf.stream.LineAdapter]),e)})}),gpf.stream.BufferedRead&&gpf.stream.ReadableArray&&gpf.stream.WritableArray&&(describe("Data demultiplexing (one read generates several writes)",function(){var n;before(function(){n=gpf.define({$class:"Demultiplexer",$extend:"gpf.stream.BufferedRead",write:function(e){return this._appendToReadBuffer(3*e),this._appendToReadBuffer(3*e+1),this._appendToReadBuffer(3*e+2),Promise.resolve()},flush:function(){return this._completeReadBuffer(),Promise.resolve()}})}),it("Waits for all data to be processed",function(r){var e=new gpf.stream.ReadableArray([0,1,2]),t=new n,s=new gpf.stream.WritableArray;gpf.stream.pipe(e,t,s).then(function(){try{var e,t=s.toArray();for(assert(9===t.length),e=0;e<9;++e)assert(t[e]===e);r()}catch(e_){r(e_)}})})}),describe("Data multiplexing (several reads generate one write)",function(){var n;before(function(){n=gpf.define({$class:"Multiplexer",$extend:"gpf.stream.BufferedRead",write:function(e){return e%3==2&&this._appendToReadBuffer((e-2)/3),Promise.resolve()},flush:function(){return this._completeReadBuffer(),Promise.resolve()}})}),it("Waits for all data to be processed",function(r){var e=new gpf.stream.ReadableArray([0,1,2,3,4,5,6,7,8]),t=new n,s=new gpf.stream.WritableArray;gpf.stream.pipe(e,t,s).then(function(){try{var e,t=s.toArray();for(assert(3===t.length),e=0;e<3;++e)assert(t[e]===e);r()}catch(e_){r(e_)}})})}))}),describe("stream/csv/parser",function(){describe("gpf.stream.csv.Parser",function(){function e(e){var t=new gpf.stream.ReadableArray(e.lines),n=new gpf.stream.WritableArray;return gpf.stream.pipe(t,e.parser,n).then(function(){return n.toArray()})}function t(s,t){e(s).then(function(e){assert(e.length===s.expected.length),e.forEach(function(t,e){var n=s.expected[e],r=Object.keys(t);assert(r.join(",")===Object.keys(n).join(",")),r.forEach(function(e){assert(t[e]===n[e])})}),t()})["catch"](t)}it("reads a one-column CSV file",function(e){t({lines:["LINE","0","1"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0"},{LINE:"1"}]},e)}),it("reads a CSV file",function(e){t({lines:["LINE;VALUE","0;ABC","1;DEF"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"}]},e)}),it("supports value quoting",function(e){t({lines:["LINE;VALUE",'0;"ABC"',"1;DEF",'2;GH"I','3;"JK""L"','4;"MN','O"'],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"},{LINE:"2",VALUE:'GH"I'},{LINE:"3",VALUE:'JK"L'},{LINE:"4",VALUE:"MN\nO"}]},e)}),it("supports quoting the separator as well",function(e){t({lines:["LINE;VALUE",'0;"A;BC"'],parser:new gpf.stream.csv.Parser,expected:[{LINE:"0",VALUE:"A;BC"}]},e)}),it("supports header being specified as an option",function(e){t({lines:["0;ABC","1;DEF"],parser:new gpf.stream.csv.Parser({header:"LINE;VALUE"}),expected:[{LINE:"0",VALUE:"ABC"},{LINE:"1",VALUE:"DEF"}]},e)}),it("supports empty values",function(e){t({lines:["LINE;VALUE;VALUE2",";AB;CD","1;;EF","2;GH"],parser:new gpf.stream.csv.Parser,expected:[{LINE:"",VALUE:"AB",VALUE2:"CD"},{LINE:"1",VALUE:"",VALUE2:"EF"},{LINE:"2",VALUE:"GH"}]},e)}),it("detects unterminated quoted string",function(t){e({lines:["LINE;VALUE",'0;"A',"BC"],parser:new gpf.stream.csv.Parser}).then(function(){t(new Error("Should fail"))},function(e){assert(e instanceof gpf.Error.InvalidCSV),t()})["catch"](t)}),it("detects invalid quoted string",function(t){e({lines:["LINE;VALUE",'0;"A"BC"'],parser:new gpf.stream.csv.Parser}).then(function(){t(new Error("Should fail"))},function(e){assert(e instanceof gpf.Error.InvalidCSV),t()})["catch"](t)}),it("supports different separator, quote and new line specifiers",function(e){t({lines:["LINE\tVALUE\tVALUE2","0\t\t'A''B","\tC'"],parser:new gpf.stream.csv.Parser({separator:"\t",quote:"'",newLine:"\r\n"}),expected:[{LINE:"0",VALUE:"",VALUE2:"A'B\r\n\tC"}]},e)})})}),describe("attributes/attribute",function(){it("is abstract",function(){var e;try{var t=new gpf.attributes.Attribute;throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.AbstractClass)}),describe("basic usage",function(){var e,t,n,r,s;before(function(){e=gpf.define({$class:"MyAttribute",$extend:gpf.attributes.Attribute}),n=new e,r=new e,s=new e,t=gpf.define({$class:"MyClassWithAttributes",$attributes:[r],"[member]":[s],member:"Hello World"})}),it("does not provide any information when not used",function(){assert(n.getClassConstructor()===undefined),assert(n.getMemberName()===undefined)}),it("provides class constructor information",function(){assert(r.getClassConstructor()===t),assert(s.getClassConstructor()===t)}),it("provides member name information",function(){assert(r.getMemberName()===undefined),assert("member"===s.getMemberName())})}),describe("$singleton usage",function(){var e,t,n;before(function(){e=gpf.define({$class:"MyAttribute",$extend:gpf.attributes.Attribute,$singleton:!0}),t=new e,n=new e,gpf.define({$class:"MyClassWithAttributes",$attributes:[t],"[member]":[n],member:"Hello World"})}),it("does not provide class constructor information",function(){assert(t.getClassConstructor()===undefined),assert(n.getClassConstructor()===undefined)}),it("does not provide member name information",function(){assert(t.getMemberName()===undefined),assert(n.getMemberName()===undefined)})})}),describe("define/class/attributes/check",function(){var t=gpf.define({$class:"MyAttribute",$extend:"gpf.attributes.Attribute",_value:undefined,getValue:function(){return this._value},constructor:function(e){this._value=e}});describe("attributes validation",function(){it("allows only existing members",function(){var e;try{gpf.define({$class:"Test1","[t3st]":[],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.UnknownAttributesSpecification)}),it("allows only an array (of attributes) - member",function(){var e;try{gpf.define({$class:"Test1","[test]":{},test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array (of attributes) - class",function(){var e;try{gpf.define({$class:"Test1",$attributes:{},test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array of attributes - member",function(){var e;try{gpf.define({$class:"Test1","[test]":[{}],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)}),it("allows only an array of attributes - class",function(){var e;try{gpf.define({$class:"Test1",$attributes:[{}],test:0})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidAttributesSpecification)})}),describe("attributes definition",function(){it("does not expose new members",function(){var e=gpf.define({$class:"MyClassWithAttributes",$attributes:[new t("class")],"[test]":[new t("member")],test:0});assert(undefined===e.prototype["[test]"])})})}),describe("attributes",function(){var t,e={$extend:"gpf.attributes.Attribute",_value:undefined,getValue:function(){return this._value},constructor:function(e){this._value=e}},n=gpf.define(Object.assign({$class:"MyAttribute1"},e)),r=gpf.define(Object.assign({$class:"MyAttribute2"},e)),s=gpf.define({$class:"MyClassWithoutAttributes"}),i=gpf.define({$class:"MyClass",$attributes:[new n("A"),new n("B"),new r("C")],"[value]":[new n("D")],value:0}),a=gpf.define({$class:"MyClass",$extend:i,$attributes:[new n("E"),new r("F")],"[value]":[new r("G")],"[value2]":[new n("H")],value2:1});function o(){i.apply(this,arguments)}o.prototype=Object.create(i.prototype),Object.assign(o.prototype,{constructor:o,value3:2}),t=gpf.define({$class:"MyClass",$extend:o,$attributes:[new n("E"),new r("F")],"[value]":[new r("G")],"[value3]":[new n("I"),new n("J")],"[value2]":[new n("H")],value2:1}),describe("gpf.attributes.get",function(){[undefined,null,0,1,!1,!0,"","Hello World"].forEach(function(n){it("fails if the parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.attributes.get(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("returns an empty object if the class was not allocated by gpf.define",function(){var e=gpf.attributes.get(String);assert(0===Object.keys(e).length)}),it("returns an empty object if no attributes",function(){var e=gpf.attributes.get(s);assert(0===Object.keys(e).length)}),it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(i);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())}),it("retrieves all attributes (on instance)",function(){var e=new i,t=gpf.attributes.get(e);assert(2===Object.keys(t).length),assert(3===t.$attributes.length),assert(1===t.value.length),assert("D"===t.value[0].getValue())}),it("filters on a given attribute class",function(){var e=gpf.attributes.get(i,r);assert(1===Object.keys(e).length),assert(1===e.$attributes.length),assert("C"===e.$attributes[0].getValue())}),describe("with native inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(o);assert(2===Object.keys(e).length),assert(3===e.$attributes.length),assert(1===e.value.length),assert("D"===e.value[0].getValue())}),it("retrieves all attributes (on instance)",function(){var e=new o,t=gpf.attributes.get(e);assert(2===Object.keys(t).length),assert(3===t.$attributes.length),assert(1===t.value.length),assert("D"===t.value[0].getValue())}),describe("followed by GPF inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(t);assert(4===Object.keys(e).length),assert(5===e.$attributes.length),assert(2===e.value.length),assert(2===e.value3.length),assert("H"===e.value2[0].getValue())})})}),describe("with GPF inheritance",function(){it("retrieves all attributes (on class)",function(){var e=gpf.attributes.get(a);assert(3===Object.keys(e).length),assert(5===e.$attributes.length),assert(2===e.value.length),assert("H"===e.value2[0].getValue())}),it("filters on a given attribute class",function(){var e=gpf.attributes.get(a,n);assert(3===Object.keys(e).length),assert(3===e.$attributes.length),assert("H"===e.value2[0].getValue())})})})}),config.features.es6class&&include("attributes.es6"),describe("stream/filter",function(){var a=[{id:0,num:5,str:"e",group:1,search:"first"},{id:1,num:1,str:"b",group:0,search:"second"},{id:2,num:4,str:"a",group:1,search:"third"},{id:3,num:2,str:"d",group:0,search:"fourth"},{id:4,num:3,str:"c",group:1,search:"fifth"}];function t(e,n,r){var t=new gpf.stream.ReadableArray(a),s=new gpf.stream.Filter(e),i=new gpf.stream.WritableArray;gpf.stream.pipe(t,s,i).then(function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e.id===n[t]}))}(i.toArray(),n),r()})["catch"](r)}describe("gpf.stream.Filter",function(){it("forwards errors",function(t){var e=new gpf.stream.ReadableArray(a),n=new gpf.stream.Filter(function(){return!0}),r={write:function(e){return Promise.reject("KO")}};gpf.stream.pipe(e,n,r).then(function(){throw new Error("Not expected")},function(e){assert("KO"===e),t()})["catch"](t)}),it("filters data - no result",function(e){t(function(){return!1},[],e)}),it("filters data - one result",function(e){t(function(e){return 1===e.num},[1],e)}),it("filters data - several results",function(e){t(function(e){return 1===e.group},[0,2,4],e)}),it("filters data - all results",function(e){t(function(){return!0},[0,1,2,3,4],e)})})}),describe("stream/map",function(){var a=[{id:0},{id:1},{id:2},{id:3},{id:4}];function r(e,n,r){var t=new gpf.stream.ReadableArray(a),s=new gpf.stream.Map(e),i=new gpf.stream.WritableArray;gpf.stream.pipe(t,s,i).then(function(){!function t(e,n){assert(e.length===n.length),assert(e.every(function(e,t){return e===n[t]}))}(i.toArray(),n),r()})["catch"](r)}function s(e){return e}describe("gpf.stream.Map",function(){it("forwards errors",function(t){var e=new gpf.stream.ReadableArray(a),n=new gpf.stream.Map(s),r={write:function(e){return s(e),Promise.reject("KO")}};gpf.stream.pipe(e,n,r).then(function(){throw new Error("Not expected")},function(e){assert("KO"===e),t()})["catch"](t)}),it("maps data - identity",function(e){r(s,a,e)}),it("filters data - one substitution",function(e){var t={};function n(e){return 2===e.id?t:e}r(n,a.map(n),e)}),it("filters data - several substitutions",function(e){r(function(e){return e.id},[0,1,2,3,4],e)})})}),describe("interfaces/promisify",function(){describe("gpf.interfaces.promisify",function(){var n,r,s;before(function(){n=gpf.define({$interface:"ISample",test:function(e){!function t(e){return e}(e)}}),r=gpf.interfaces.promisify(n),s=gpf.define({$class:"SampleImpl",test:function(e){if(0===e)throw new Error("OK");return e+1}})}),it("accepts only an object implementing the interface",function(){var e;try{r({notTheExpectedTestMethod:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.InterfaceExpected)}),it("leverages IUnkown",function(){var e;try{r({queryInterface:function(e){if(e===n)return new s}})}catch(e_){e=e_}assert(!e)}),it("allows chaining",function(t){r(new s).test(1).test(2).test(3).then(function(e){assert(4===e),t()})["catch"](t)}),it("forwards errors",function(n){r(new s).test(1).test(0).test(3).then(function(){assert(!1)})["catch"](function(e){try{assert("OK"===e.message),n()}catch(e_){n(e_)}})}),it("offers advanced promise chaining",function(t){r(new s).test(1).test(2).then(function(){return 0}).then(function(e){assert(0===e)}).test(3).then(function(e){assert(4===e),t()})["catch"](t)})})}),describe("xml/writer",function(){var s;function n(t,n){var e=new gpf.xml.Writer,r=new gpf.stream.WritableString;return gpf.stream.pipe(e,r).then(function(){try{n(r.toString()),t()}catch(e_){t(e_)}}),s||(s=gpf.interfaces.promisify(gpf.interfaces.IXmlContentHandler)),s(e)}function r(){assert(!1)}function i(n,r){return function(e){try{assert(e instanceof r),n()}catch(e_){n(e_)}}}function t(e){return i(e,gpf.Error.InvalidXmlWriterState)}function a(e){return i(e,gpf.Error.InvalidXmlUseOfPrefixXml)}describe("Interface specification",function(){it("implements gpf.interfaces.IXmlContentHandler",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IXmlContentHandler,gpf.xml.Writer))}),it("implements gpf.interfaces.IReadableStream",function(){assert(gpf.interfaces.isImplementedBy(gpf.interfaces.IReadableStream,gpf.xml.Writer))}),it("can be piped",function(e){n(e,function(e){assert(""===e)}).startDocument().startElement("document").endElement().endDocument()["catch"](e)})}),describe("Basic manipulations",function(){it("allows processing instructions",function(e){n(e,function(e){assert("\n"===e)}).startDocument().processingInstruction("test","test-data").startElement("document").endElement().endDocument()["catch"](e)}),it("supports attributes (string value)",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{"test":"value"}).endElement().endDocument()["catch"](e)}),it("supports attributes (number value)",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{"test":2}).endElement().endDocument()["catch"](e)}),it("supports multiple attributes",function(e){n(e,function(e){assert(''===e||''===e)}).startDocument().startElement("document",{"test1":"value1","test2":"value2"}).endElement().endDocument()["catch"](e)}),it("supports nodes hierarchy",function(e){n(e,function(e){assert(""===e)}).startDocument().startElement("document").startElement("a").startElement("b").endElement().endElement().startElement("c").endElement().endElement().endDocument()["catch"](e)}),it("escapes attributes value",function(e){n(e,function(e){assert(''===e)}).startDocument().startElement("document",{test:"<&>"}).endElement().endDocument()["catch"](e)}),it("escapes text value",function(e){n(e,function(e){assert("<&>"===e)}).startDocument().startElement("document").characters("<&>").endElement().endDocument()["catch"](e)})}),describe("Namespacing",function(){it("qualifies elements (using prefix)",function(e){n(e,function(e){assert(''===e)}).startDocument().startPrefixMapping("test","namespace-uri").startElement("test:document").endElement().endPrefixMapping("test").endDocument()["catch"](e)}),it("qualifies elements (default namespace)",function(e){n(e,function(e){assert(''===e)}).startDocument().startPrefixMapping("","namespace-uri").startElement("document").endElement().endPrefixMapping("").endDocument()["catch"](e)}),it("qualifies attributes",function(e){n(e,function(e){assert(''===e||''===e)}).startDocument().startPrefixMapping("ns0","namespace-uri").startElement("document",{"ns0:test":"value"}).endElement().endPrefixMapping("ns0").endDocument()["catch"](e)}),it("allows xml namespace prefix",function(e){n(e,function(e){assert(' '===e)}).startDocument().startElement("document",{"xml:space":"preserve"}).characters(" ").endElement().endDocument()["catch"](e)})}),describe("Invalid XML state",function(){it("must start with a document",function(e){n(e,r).startElement("document")["catch"](t(e))}),it("forbids processing instructions once an element is added",function(e){n(e,r).startDocument().startElement("document").processingInstruction("test","test-data")["catch"](t(e))}),it("makes sure all opened elements are closed (endElement)",function(e){n(e,r).startDocument().startElement("document").endElement().endElement()["catch"](t(e))}),it("makes sure all opened elements are closed (endDocument)",function(e){n(e,r).startDocument().startElement("document").endDocument()["catch"](t(e))}),it("makes sure a namespace prefix is declared before usage",function(e){n(e,r).startDocument().startElement("test:document")["catch"](function t(e){return i(e,gpf.Error.UnknownXmlNamespacePrefix)}(e))}),it("prevents overloading a namespace prefix at the same level",function(e){n(e,r).startDocument().startPrefixMapping("test","namespace-uri").startPrefixMapping("test","namespace-uri2").endDocument()["catch"](t(e))}),it("prevents overloading of predefined namespace prefix (xml)",function(e){n(e,r).startDocument().startPrefixMapping("xml","namespace-uri")["catch"](a(e))}),it("prevents overloading of predefined namespace prefix (xmlns)",function(e){n(e,r).startDocument().startPrefixMapping("xmlns","namespace-uri")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlUseOfPrefixXmlns)}(e))}),it("validates element name",function(e){n(e,r).startDocument().startElement("docu/ment")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlElementName)}(e))}),it("validates element name (using xml prefix)",function(e){n(e,r).startDocument().startElement("xml:document")["catch"](a(e))}),it("validates attribute name",function(e){n(e,r).startDocument().startElement("document",{"te/st":"value"})["catch"](function t(e){return i(e,gpf.Error.InvalidXmlAttributeName)}(e))}),it("validates namespace prefix",function(e){n(e,r).startDocument().startPrefixMapping("te/st","namespace-uri")["catch"](function t(e){return i(e,gpf.Error.InvalidXmlNamespacePrefix)}(e))}),it("allows only xml:space attribute",function(e){n(e,r).startDocument().startElement("document",{"xml:lang":"en"})["catch"](a(e))})})}),describe("foreachasync",function(){var i=[0,1,2,3,4,5,6,7,8,9],a={};describe("gpf.forEachAsync",function(){[undefined,0,1,!1,!0,null].forEach(function(n){it("rejects invalid parameter ("+JSON.stringify(n)+")",function(){var e;try{gpf.forEachAsync(n,function(){assert(!0)})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("enumerates an array synchronously",function(e){var r=0,s=0;gpf.forEachAsync(i,function(e,t,n){assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e},a).then(function(){assert(i.length===r),assert(45===s),e()})["catch"](e)}),it("enumerates an array asynchronously",function(e){var r=0,s=0;gpf.forEachAsync(i,function(e,t,n){return assert(this===a),assert("number"==typeof t),assert(n===i),++r,s+=e,Promise.resolve()},a).then(function(){assert(i.length===r),assert(45===s),e()})["catch"](e)}),it("catches any error",function(t){gpf.forEachAsync(i,function(){throw new Error("OK")}).then(function(){t(new Error("Not expected"))},function(e){assert("OK"===e.message),t()})["catch"](t)}),it("catches any rejected promise",function(t){gpf.forEachAsync(i,function(){return Promise.reject("OK")}).then(function(){t(new Error("Not expected"))},function(e){assert("OK"===e),t()})["catch"](t)})})}),describe("serial/property",function(){if(gpf.internals){var r=gpf.internals._gpfSerialPropertyCheck,e=["",0,1,{},new Date,!0,!1,"123"];describe("_gpfSerialPropertyCheck",function(){it("validates name and default properties",function(){var e=r({name:"OK"});assert(e.type===gpf.serial.types.string),assert(!1===e.required),assert(e.readOnly===undefined)}),it("validates properties",function(){var e;try{r({name:"OK",type:gpf.serial.types.string,required:!1,readOnly:!1})}catch(e_){e=e_}assert(!e)}),e.concat(undefined).forEach(function(n){it("rejects invalid 'name' ("+JSON.stringify(n)+")",function(){var e;try{r({name:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialName)})}),e.forEach(function(n){it("rejects invalid 'type' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",type:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialType)})}),e.filter(function(e){return"boolean"!=typeof e}).forEach(function(n){it("rejects invalid 'required' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",required:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialRequired)})}),e.filter(function(e){return"boolean"!=typeof e}).forEach(function(n){it("rejects invalid 'readOnly' ("+JSON.stringify(n)+")",function(){var e;try{r({name:"OK",readOnly:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidSerialReadOnly)})})})}}),describe("attributes/classattribute",function(){describe("gpf.attributes.ClassAttribute",function(){it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[new gpf.attributes.ClassAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[new gpf.attributes.ClassAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.ClassAttribute,new gpf.attributes.ClassAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,n;before(function(){e=gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.ClassAttribute]}),n=new e}),it("fails definition if used at member level",function(){var e;try{gpf.define({$class:"Test","[test]":[n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("accepts definition if used at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[n]})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/memberattribute",function(){describe("gpf.attributes.MemberAttribute",function(){it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[new gpf.attributes.MemberAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[new gpf.attributes.MemberAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$attributes:[new gpf.attributes.MemberAttribute,new gpf.attributes.MemberAttribute],$extend:gpf.attributes.Attribute,test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,n;before(function(){e=gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.MemberAttribute]}),n=new e}),it("fails definition if used at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[n]})}catch(e_){e=e_}assert(e instanceof gpf.Error.MemberAttributeOnly)}),it("accepts definition if used at member level",function(){var e;try{gpf.define({$class:"Test","[test]":[n],test:function(){}})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/attributeforinstanceof",function(){describe("gpf.attributes.AttributeForInstanceOf",function(){var s,n;before(function(){s=gpf.define({$class:"A",$abstract:!0}),n=new gpf.attributes.AttributeForInstanceOf(s)}),it("requires a base class (no parameter)",function(){var e;try{var t=new gpf.attributes.AttributeForInstanceOf;throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)}),it("requires a base class (not a function)",function(){var e;try{var t=new gpf.attributes.AttributeForInstanceOf(0);throw new Error(t.toString())}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)}),it("can't be used on a non-attribute class",function(){var e;try{gpf.define({$class:"B",$attributes:[n]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an attribute class",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,"[test]":[n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),it("can't be used twice",function(){var e;try{gpf.define({$class:"Attribute",$extend:gpf.attributes.Attribute,$attributes:[n,n],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),describe("When used properly",function(){var e,r;before(function(){e=gpf.define({$class:"AttributeForA",$extend:gpf.attributes.Attribute,$attributes:[n]}),r=new e}),it("fails definition if used on the wrong class",function(){var e;try{gpf.define({$class:"NotAChildOfA",$attributes:[r]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("accepts definition if used on direct child class",function(){var e;try{gpf.define({$class:"DirectChildOfA",$extend:s,$attributes:[r]})}catch(e_){e=e_}assert(!e)}),it("accepts definition if used on child class",function(){var e;try{var t=gpf.define({$class:"DirectChildOfA",$extend:s,$attributes:[r]});gpf.define({$class:"SubChildOfA",$extend:t,$attributes:[r]})}catch(e_){e=e_}assert(!e)})})})}),describe("attributes/uniqueattribute",function(){describe("gpf.attributes.UniqueAttribute",function(){it("can't be used on a non-unique class",function(){var e;try{gpf.define({$class:"Any",$attributes:[new gpf.attributes.UniqueAttribute]})}catch(e_){e=e_}assert(e instanceof gpf.Error.RestrictedBaseClassAttribute)}),it("can't be used on a member of an unique class",function(){var e;try{gpf.define({$class:"UniqueAttribute",$extend:gpf.attributes.UniqueAttribute,"[test]":[new gpf.attributes.UniqueAttribute],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.ClassAttributeOnly)}),describe("When used properly",function(){var r,s;before(function(){var e=gpf.define({$class:"AttributeThatShouldBeUnique",$extend:gpf.attributes.Attribute,$attributes:[new gpf.attributes.UniqueAttribute]}),t=gpf.define({$class:"AnyAttribute",$extend:gpf.attributes.Attribute});r=new e,s=new t}),it("fails definition if used twice at class level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r,r]})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("fails definition if used twice at member level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,"[test]":[s,r,r],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("accepts definition if used once at any level",function(){var e;try{gpf.define({$class:"TestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r],"[test]":[s,r],test:function(){}})}catch(e_){e=e_}assert(!e)}),describe("using inheritance",function(){var n;before(function(){n=gpf.define({$class:"BaseTestAttribute",$extend:gpf.attributes.Attribute,$attributes:[s,r],"[test]":[s,r],test:function(){}})}),it("fails definition if used twice at class level",function(){var e;try{gpf.define({$class:"Test",$attributes:[r],$extend:n})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)}),it("fails definition if used twice at member level",function(){var e;try{gpf.define({$class:"Test",$extend:n,"[test]":[r],test:function(){}})}catch(e_){e=e_}assert(e instanceof gpf.Error.UniqueAttributeUsedTwice)})})})})}),describe("attributes/serializable",function(){var r;before(function(){r=gpf.define({$class:"A","[_member1]":[new gpf.attributes.Serializable({type:gpf.serial.types.string,required:!0})],_member1:"0","[member2]":[new gpf.attributes.Serializable],member2:""})}),describe("gpf.attributes.Serializable",function(){it("provides serialization information on members",function(){var e=gpf.attributes.get(r,gpf.attributes.Serializable),t=e._member1[0].getProperty(),n=e.member2[0].getProperty();assert("member1"===t.name),assert(t.type===gpf.serial.types.string),assert(t.required),assert("member2"===n.name),assert(n.type===gpf.serial.types.string),assert(!n.required)})})}),describe("serial/get",function(){describe("gpf.serial.getProperties",function(){var e;function t(e){assert(2===Object.keys(e).length),assert("id"===e._id.name),assert("name"===e._name.name)}before(function(){e=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:""})}),it("lists serializable properties (on class)",function(){t(gpf.serial.get(e))}),it("lists serializable properties (on instance)",function(){t(gpf.serial.get(new e))}),it("returns an empty object if no serializable attributes",function(){var e=gpf.serial.get(new Date);assert(0===Object.keys(e).length)})})}),describe("serial/raw/to",function(){describe("gpf.serial.toRaw",function(){var n;before(function(){n=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0,readOnly:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:"","[_created]":[new gpf.attributes.Serializable({name:"created",type:gpf.serial.datetime,readOnly:!0})],_created:null,"[_modified]":[new gpf.attributes.Serializable({name:"modified",type:gpf.serial.datetime})],_modified:null,constructor:function(e,t,n){this._id=e,this._name=t,this._created=new Date,this._modified=n||null}})}),[undefined,null,0,1,!1,!0,"","Hello World",function(){}].forEach(function(n){it("fails if the parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.serial.toRaw(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("generates an object containing only the serializable properties",function(){var e=new n("id","Test"),t=gpf.serial.toRaw(e);assert(2===Object.keys(t).length),assert("Test"===t.name)}),it("converts properties' value",function(){var r=new n("id","Test",new Date(Date.UTC(2018,8,19,12,50,12,0))),e=gpf.serial.toRaw(r,function(e,t,n){return assert(this===r),"_id"===n?(assert("id"===t.name),assert(!0===t.readOnly),assert("id"===e),"ID"):"_name"===n?(assert("name"===t.name),assert(!1===t.readOnly),assert("Test"===e),"TEST"):n.type===gpf.serial.datetime?(assert("_created"===n||"_modified"===n),e.toISOString()):void assert(!1)});assert(4===Object.keys(e).length),assert("ID"===e.id),assert("TEST"===e.name),assert("2018-09-19T12:50:12.000Z"===e.modified)})})}),config.features.propertydescriptor&&include("serial/raw/to.propertydescriptor"),describe("serial/raw/from",function(){describe("gpf.serial.fromRaw",function(){var n;before(function(){n=gpf.define({$class:"A","[_id]":[new gpf.attributes.Serializable({name:"id",required:!0,readOnly:!0})],_id:"","[_name]":[new gpf.attributes.Serializable({name:"name"})],_name:"","[_created]":[new gpf.attributes.Serializable({name:"created",type:gpf.serial.datetime,readOnly:!0})],_created:null,"[_modified]":[new gpf.attributes.Serializable({name:"modified",type:gpf.serial.datetime})],_modified:null})}),[undefined,null,0,1,!1,!0,"","Hello World",function(){}].forEach(function(n){it("fails if the first parameter is not correct ("+JSON.stringify(n)+")",function(){var e;try{gpf.serial.fromRaw(n,{})}catch(e_){e=e_}assert(e instanceof gpf.Error.InvalidParameter)})}),it("initializes the instance from the object containing the serializable properties",function(){var e=new n,t=gpf.serial.fromRaw(e,{id:"id",name:"Test"});assert(e===t),assert(""===e._id),assert("Test"===e._name)}),it("converts properties' value",function(){var r=new n;gpf.serial.fromRaw(r,{id:"ID",name:undefined,modified:"2018-09-19T12:50:12.000Z"},function(e,t,n){return assert(this===r),"_id"===n?(assert("id"===t.name),assert(!0===t.readOnly),assert("ID"===e),"id"):"_name"===n?(assert("name"===t.name),assert(!1===t.readOnly),assert(e===undefined),"Test"):n.type===gpf.serial.datetime?(assert("_modified"===n),new Date(e)):void assert(!1)}),assert("id"===r._id),assert("Test"===r._name),assert(2018===r._modified.getUTCFullYear()),assert(8===r._modified.getUTCMonth()),assert(19===r._modified.getUTCDate()),assert(12===r._modified.getUTCHours()),assert(50===r._modified.getUTCMinutes()),assert(12===r._modified.getUTCSeconds())})})}),config.features.propertydescriptor&&include("serial/raw/from.propertydescriptor"),describe("attributes/decorator",function(){describe("gpf.attributes.decorator",function(){function n(){}it("can't be used on a non-es6 class",function(){var e;try{gpf.attributes.decorator()(n)}catch(e_){e=e_}assert(e instanceof gpf.Error.Es6classOnly)})})}),config.features.es6class&&include("attributes/decorator.es6"); \ No newline at end of file diff --git a/doc/tutorials/LINTING.md b/doc/tutorials/LINTING.md index 3207e434..920ecd6a 100644 --- a/doc/tutorials/LINTING.md +++ b/doc/tutorials/LINTING.md @@ -13,11 +13,11 @@ Rule | Fixable | Level | Parameters | Comment **Possible Errors** | | | | [for-direction](https://eslint.org/docs/rules/for-direction) | | *error* | | [getter-return](https://eslint.org/docs/rules/getter-return) | | *error* | | -[no-async-promise-executor](https://eslint.org/docs/rules/no-async-promise-executor) | | **-** | | +[no-async-promise-executor](https://eslint.org/docs/rules/no-async-promise-executor) | | *error* | | [no-await-in-loop](https://eslint.org/docs/rules/no-await-in-loop) | | **-** | | [no-compare-neg-zero](https://eslint.org/docs/rules/no-compare-neg-zero) | | *error* | | [no-cond-assign](https://eslint.org/docs/rules/no-cond-assign) | | *error* | | -[no-console](https://eslint.org/docs/rules/no-console) | | **ignore** | | The library offers a [compatibility layer](https://arnaudbuchholz.github.io/gpf/doc/tutorial-COMPATIBILITY.html) that includes [console.log](https://developer.mozilla.org/en-US/docs/Web/API/Console/log), [console.warn](https://developer.mozilla.org/en-US/docs/Web/API/Console/warn) and [console.error](https://developer.mozilla.org/en-US/docs/Web/API/Console/error). +[no-console](https://eslint.org/docs/rules/no-console) | | **-** | | The library offers a [compatibility layer](https://arnaudbuchholz.github.io/gpf/doc/tutorial-COMPATIBILITY.html) that includes [console.log](https://developer.mozilla.org/en-US/docs/Web/API/Console/log), [console.warn](https://developer.mozilla.org/en-US/docs/Web/API/Console/warn) and [console.error](https://developer.mozilla.org/en-US/docs/Web/API/Console/error). [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition) | | *error* | | [no-control-regex](https://eslint.org/docs/rules/no-control-regex) | | *error* | | [no-debugger](https://eslint.org/docs/rules/no-debugger) | | *error* | | @@ -31,23 +31,24 @@ Rule | Fixable | Level | Parameters | Comment [no-extra-parens](https://eslint.org/docs/rules/no-extra-parens) | ✓ | **error** | | [no-extra-semi](https://eslint.org/docs/rules/no-extra-semi) | ✓ | *error* | | [no-func-assign](https://eslint.org/docs/rules/no-func-assign) | | *error* | | +[no-import-assign](https://eslint.org/docs/rules/no-import-assign) | | **-** | | [no-inner-declarations](https://eslint.org/docs/rules/no-inner-declarations) | | *error* | | [no-invalid-regexp](https://eslint.org/docs/rules/no-invalid-regexp) | | *error* | | [no-irregular-whitespace](https://eslint.org/docs/rules/no-irregular-whitespace) | | *error* | | -[no-misleading-character-class](https://eslint.org/docs/rules/no-misleading-character-class) | | **-** | | +[no-misleading-character-class](https://eslint.org/docs/rules/no-misleading-character-class) | | *error* | | [no-negated-in-lhs](https://eslint.org/docs/rules/no-negated-in-lhs) | | **-** | | [no-obj-calls](https://eslint.org/docs/rules/no-obj-calls) | | *error* | | -[no-prototype-builtins](https://eslint.org/docs/rules/no-prototype-builtins) | | **-** | | +[no-prototype-builtins](https://eslint.org/docs/rules/no-prototype-builtins) | | *error* | | [no-regex-spaces](https://eslint.org/docs/rules/no-regex-spaces) | ✓ | *error* | | [no-sparse-arrays](https://eslint.org/docs/rules/no-sparse-arrays) | | *error* | | [no-template-curly-in-string](https://eslint.org/docs/rules/no-template-curly-in-string) | | **-** | | [no-unexpected-multiline](https://eslint.org/docs/rules/no-unexpected-multiline) | | *error* | | [no-unreachable](https://eslint.org/docs/rules/no-unreachable) | | *error* | | [no-unsafe-finally](https://eslint.org/docs/rules/no-unsafe-finally) | | *error* | | -[no-unsafe-negation](https://eslint.org/docs/rules/no-unsafe-negation) | ✓ | *error* | | -[require-atomic-updates](https://eslint.org/docs/rules/require-atomic-updates) | | **-** | | +[no-unsafe-negation](https://eslint.org/docs/rules/no-unsafe-negation) | | *error* | | +[require-atomic-updates](https://eslint.org/docs/rules/require-atomic-updates) | | *error* | | [use-isnan](https://eslint.org/docs/rules/use-isnan) | | *error* | | -[valid-jsdoc](https://eslint.org/docs/rules/valid-jsdoc) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L7) | Rule parameters are used to normalize the [jsdoc](http://usejsdoc.org/) tags. Also, The rule was also [customized](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrules/valid-jsdoc.js) to match `@gpf` tags. +[valid-jsdoc](https://eslint.org/docs/rules/valid-jsdoc) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L6) | Rule parameters are used to normalize the [jsdoc](https://jsdoc.app/) tags. Also, The rule was also [customized](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrules/valid-jsdoc.js) to match `@gpf` tags. [valid-typeof](https://eslint.org/docs/rules/valid-typeof) | | *error* | | **Best Practices** | | | | [accessor-pairs](https://eslint.org/docs/rules/accessor-pairs) | | **error** | | @@ -58,15 +59,16 @@ Rule | Fixable | Level | Parameters | Comment [consistent-return](https://eslint.org/docs/rules/consistent-return) | | **-** | | The API extensively uses the [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) value to represent no value. Since a method with no [`return`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return) statement returns [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined), many functions are not consistent. [curly](https://eslint.org/docs/rules/curly) | ✓ | **error** | "all" | [default-case](https://eslint.org/docs/rules/default-case) | | **error** | | +[default-param-last](https://eslint.org/docs/rules/default-param-last) | | **-** | | [dot-location](https://eslint.org/docs/rules/dot-location) | ✓ | **error** | "property" | -[dot-notation](https://eslint.org/docs/rules/dot-notation) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L31) | +[dot-notation](https://eslint.org/docs/rules/dot-notation) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L30) | [eqeqeq](https://eslint.org/docs/rules/eqeqeq) | ✓ | **error** | | [guard-for-in](https://eslint.org/docs/rules/guard-for-in) | | **error** | | [max-classes-per-file](https://eslint.org/docs/rules/max-classes-per-file) | | **-** | | [no-alert](https://eslint.org/docs/rules/no-alert) | | **error** | | [no-caller](https://eslint.org/docs/rules/no-caller) | | **error** | | [no-case-declarations](https://eslint.org/docs/rules/no-case-declarations) | | *error* | | -[no-div-regex](https://eslint.org/docs/rules/no-div-regex) | | **error** | | +[no-div-regex](https://eslint.org/docs/rules/no-div-regex) | ✓ | **error** | | [no-else-return](https://eslint.org/docs/rules/no-else-return) | ✓ | **error** | | [no-empty-function](https://eslint.org/docs/rules/no-empty-function) | | **-** | | [no-empty-pattern](https://eslint.org/docs/rules/no-empty-pattern) | | *error* | | @@ -97,7 +99,7 @@ Rule | Fixable | Level | Parameters | Comment [no-octal-escape](https://eslint.org/docs/rules/no-octal-escape) | | **error** | | [no-param-reassign](https://eslint.org/docs/rules/no-param-reassign) | | **error** | | [no-proto](https://eslint.org/docs/rules/no-proto) | | **error** | | -[no-redeclare](https://eslint.org/docs/rules/no-redeclare) | | *error* | | +[no-redeclare](https://eslint.org/docs/rules/no-redeclare) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L132) | [no-restricted-properties](https://eslint.org/docs/rules/no-restricted-properties) | | **-** | | [no-return-assign](https://eslint.org/docs/rules/no-return-assign) | | **error** | | [no-return-await](https://eslint.org/docs/rules/no-return-await) | | **-** | | @@ -110,14 +112,16 @@ Rule | Fixable | Level | Parameters | Comment [no-unused-expressions](https://eslint.org/docs/rules/no-unused-expressions) | | **error** | | [no-unused-labels](https://eslint.org/docs/rules/no-unused-labels) | ✓ | *error* | | [no-useless-call](https://eslint.org/docs/rules/no-useless-call) | | **error** | | -[no-useless-catch](https://eslint.org/docs/rules/no-useless-catch) | | **-** | | +[no-useless-catch](https://eslint.org/docs/rules/no-useless-catch) | | *error* | | [no-useless-concat](https://eslint.org/docs/rules/no-useless-concat) | | **error** | | [no-useless-escape](https://eslint.org/docs/rules/no-useless-escape) | | *error* | | [no-useless-return](https://eslint.org/docs/rules/no-useless-return) | ✓ | **-** | | [no-void](https://eslint.org/docs/rules/no-void) | | **error** | | [no-warning-comments](https://eslint.org/docs/rules/no-warning-comments) | | **-** | | [no-with](https://eslint.org/docs/rules/no-with) | | **error** | | Extracted from the [MDN description](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with): Use of the with statement is not recommended, as it may be the source of confusing bugs and compatibility issues. +[prefer-named-capture-group](https://eslint.org/docs/rules/prefer-named-capture-group) | | **-** | | [prefer-promise-reject-errors](https://eslint.org/docs/rules/prefer-promise-reject-errors) | | **-** | | +[prefer-regex-literals](https://eslint.org/docs/rules/prefer-regex-literals) | | **-** | | [radix](https://eslint.org/docs/rules/radix) | | **error** | | [require-await](https://eslint.org/docs/rules/require-await) | | **-** | | [require-unicode-regexp](https://eslint.org/docs/rules/require-unicode-regexp) | | **-** | | @@ -137,8 +141,8 @@ Rule | Fixable | Level | Parameters | Comment [no-undef](https://eslint.org/docs/rules/no-undef) | | *error* | | [no-undef-init](https://eslint.org/docs/rules/no-undef-init) | ✓ | **error** | | [no-undefined](https://eslint.org/docs/rules/no-undefined) | | **-** | | [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) is a value. -[no-unused-vars](https://eslint.org/docs/rules/no-unused-vars) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L79) | -[no-use-before-define](https://eslint.org/docs/rules/no-use-before-define) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L80) | +[no-unused-vars](https://eslint.org/docs/rules/no-unused-vars) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L78) | +[no-use-before-define](https://eslint.org/docs/rules/no-use-before-define) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L79) | **Node.js and CommonJS** | | | | [callback-return](https://eslint.org/docs/rules/callback-return) | | **-** | | [global-require](https://eslint.org/docs/rules/global-require) | | **-** | | @@ -160,7 +164,7 @@ Rule | Fixable | Level | Parameters | Comment [camelcase](https://eslint.org/docs/rules/camelcase) | | **error** | | [capitalized-comments](https://eslint.org/docs/rules/capitalized-comments) | ✓ | **-** | | [comma-dangle](https://eslint.org/docs/rules/comma-dangle) | ✓ | **error** | "never" | -[comma-spacing](https://eslint.org/docs/rules/comma-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L90) | +[comma-spacing](https://eslint.org/docs/rules/comma-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L89) | [comma-style](https://eslint.org/docs/rules/comma-style) | ✓ | **error** | "last" | [computed-property-spacing](https://eslint.org/docs/rules/computed-property-spacing) | ✓ | **-** | | [consistent-this](https://eslint.org/docs/rules/consistent-this) | | **error** | "me" | @@ -169,6 +173,7 @@ Rule | Fixable | Level | Parameters | Comment [func-name-matching](https://eslint.org/docs/rules/func-name-matching) | | **-** | | [func-names](https://eslint.org/docs/rules/func-names) | | **-** | | [func-style](https://eslint.org/docs/rules/func-style) | | **error** | "declaration" | Enforced on purpose. +[function-call-argument-newline](https://eslint.org/docs/rules/function-call-argument-newline) | ✓ | **-** | | [function-paren-newline](https://eslint.org/docs/rules/function-paren-newline) | ✓ | **-** | | [id-blacklist](https://eslint.org/docs/rules/id-blacklist) | | **-** | | [id-length](https://eslint.org/docs/rules/id-length) | | **-** | | @@ -177,8 +182,8 @@ Rule | Fixable | Level | Parameters | Comment [indent](https://eslint.org/docs/rules/indent) | ✓ | **error** | 4 | [indent-legacy](https://eslint.org/docs/rules/indent-legacy) | ✓ | **-** | | [jsx-quotes](https://eslint.org/docs/rules/jsx-quotes) | ✓ | **-** | | -[key-spacing](https://eslint.org/docs/rules/key-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L97) | -[keyword-spacing](https://eslint.org/docs/rules/keyword-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L121) | +[key-spacing](https://eslint.org/docs/rules/key-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L96) | +[keyword-spacing](https://eslint.org/docs/rules/keyword-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L120) | [line-comment-position](https://eslint.org/docs/rules/line-comment-position) | | **-** | | [linebreak-style](https://eslint.org/docs/rules/linebreak-style) | ✓ | **warning** | "unix" | [lines-around-comment](https://eslint.org/docs/rules/lines-around-comment) | ✓ | **-** | | @@ -212,7 +217,7 @@ Rule | Fixable | Level | Parameters | Comment [no-nested-ternary](https://eslint.org/docs/rules/no-nested-ternary) | | **error** | | [no-new-object](https://eslint.org/docs/rules/no-new-object) | | **error** | | [no-plusplus](https://eslint.org/docs/rules/no-plusplus) | | **-** | | -[no-restricted-syntax](https://eslint.org/docs/rules/no-restricted-syntax) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L108) | Forbids the use of [switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch) and [with](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with) +[no-restricted-syntax](https://eslint.org/docs/rules/no-restricted-syntax) | | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L107) | Forbids the use of [switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch) and [with](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with) [no-spaced-func](https://eslint.org/docs/rules/no-spaced-func) | ✓ | **-** | | [no-tabs](https://eslint.org/docs/rules/no-tabs) | | **-** | | [no-ternary](https://eslint.org/docs/rules/no-ternary) | | **error** | | @@ -231,18 +236,18 @@ Rule | Fixable | Level | Parameters | Comment [padded-blocks](https://eslint.org/docs/rules/padded-blocks) | ✓ | **-** | | [padding-line-between-statements](https://eslint.org/docs/rules/padding-line-between-statements) | ✓ | **-** | | [prefer-object-spread](https://eslint.org/docs/rules/prefer-object-spread) | ✓ | **-** | | -[quote-props](https://eslint.org/docs/rules/quote-props) | ✓ | **warning** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L115) | +[quote-props](https://eslint.org/docs/rules/quote-props) | ✓ | **warning** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L114) | [quotes](https://eslint.org/docs/rules/quotes) | ✓ | **error** | "double" | [require-jsdoc](https://eslint.org/docs/rules/require-jsdoc) | | **-** | | [semi](https://eslint.org/docs/rules/semi) | ✓ | **error** | "always" | -[semi-spacing](https://eslint.org/docs/rules/semi-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L117) | +[semi-spacing](https://eslint.org/docs/rules/semi-spacing) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L116) | [semi-style](https://eslint.org/docs/rules/semi-style) | ✓ | **-** | | [sort-keys](https://eslint.org/docs/rules/sort-keys) | | **-** | | [sort-vars](https://eslint.org/docs/rules/sort-vars) | ✓ | **-** | | -[space-before-blocks](https://eslint.org/docs/rules/space-before-blocks) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L119) | +[space-before-blocks](https://eslint.org/docs/rules/space-before-blocks) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L118) | [space-before-function-paren](https://eslint.org/docs/rules/space-before-function-paren) | ✓ | **error** | "always" | [space-in-parens](https://eslint.org/docs/rules/space-in-parens) | ✓ | **error** | "never" | -[space-infix-ops](https://eslint.org/docs/rules/space-infix-ops) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L123) | +[space-infix-ops](https://eslint.org/docs/rules/space-infix-ops) | ✓ | **error** | [*.eslintrc*](https://github.com/ArnaudBuchholz/gpf-js/blob/master/.eslintrc#L122) | [space-unary-ops](https://eslint.org/docs/rules/space-unary-ops) | ✓ | **error** | | [spaced-comment](https://eslint.org/docs/rules/spaced-comment) | ✓ | **-** | | [switch-colon-spacing](https://eslint.org/docs/rules/switch-colon-spacing) | ✓ | **-** | | @@ -270,11 +275,11 @@ Rule | Fixable | Level | Parameters | Comment [object-shorthand](https://eslint.org/docs/rules/object-shorthand) | ✓ | **-** | | [prefer-arrow-callback](https://eslint.org/docs/rules/prefer-arrow-callback) | ✓ | **-** | | [prefer-const](https://eslint.org/docs/rules/prefer-const) | ✓ | **-** | | -[prefer-destructuring](https://eslint.org/docs/rules/prefer-destructuring) | | **-** | | +[prefer-destructuring](https://eslint.org/docs/rules/prefer-destructuring) | ✓ | **-** | | [prefer-numeric-literals](https://eslint.org/docs/rules/prefer-numeric-literals) | ✓ | **-** | | [prefer-reflect](https://eslint.org/docs/rules/prefer-reflect) | | **-** | | [prefer-rest-params](https://eslint.org/docs/rules/prefer-rest-params) | | **-** | | -[prefer-spread](https://eslint.org/docs/rules/prefer-spread) | ✓ | **-** | | +[prefer-spread](https://eslint.org/docs/rules/prefer-spread) | | **-** | | [prefer-template](https://eslint.org/docs/rules/prefer-template) | ✓ | **-** | | [require-yield](https://eslint.org/docs/rules/require-yield) | | *error* | | [rest-spread-spacing](https://eslint.org/docs/rules/rest-spread-spacing) | ✓ | **-** | | diff --git a/package.json b/package.json index 9806080d..9c919591 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gpf-js", - "version": "1.0.0-beta", + "version": "1.0.0", "description": "A multi-purpose JavaScript library", "main": "build/gpf-node.js", "directories": { diff --git a/src/boot.js b/src/boot.js index 53b6d43a..cfed6215 100644 --- a/src/boot.js +++ b/src/boot.js @@ -35,7 +35,7 @@ var * GPF Version * @since 0.1.5 */ - _gpfVersion = "1.0.0-beta", + _gpfVersion = "1.0.0", _GPF_NOT_FOUND = -1, _GPF_START = 0,