From e92871e71bffd5de177a8771c68dc5786f187058 Mon Sep 17 00:00:00 2001 From: Haydn Ewers Date: Thu, 8 Oct 2015 09:38:50 +1030 Subject: [PATCH] Release v0.7.0. --- dist/ajax-adapter.js | 328 +- dist/ajax.js | 241 + dist/store.dev.js | 11121 +++- dist/store.dev.js.map | 12 +- dist/store.js | 176 +- dist/store.prod.js | 10907 +++- docs/v0.7.0/ast/source/ajax-adapter.js.json | 10144 ++++ docs/v0.7.0/ast/source/ajax.js.json | 13257 +++++ .../ast/source/src/ajax-adapter.js.json | 15669 ++++++ docs/v0.7.0/ast/source/src/store.js.json | 44996 +++++++++++++++ docs/v0.7.0/ast/source/store.js.json | 45520 ++++++++++++++++ docs/v0.7.0/badge.svg | 17 + .../src/ajax-adapter.js~AjaxAdapter.html | 660 + docs/v0.7.0/class/src/store.js~Store.html | 2133 + docs/v0.7.0/coverage.json | 32 + docs/v0.7.0/css/prettify-tomorrow.css | 132 + docs/v0.7.0/css/style.css | 822 + docs/v0.7.0/dump.json | 2243 + docs/v0.7.0/file/src/ajax-adapter.js.html | 217 + docs/v0.7.0/file/src/ajax.js.html | 298 + docs/v0.7.0/file/src/store.js.html | 776 + docs/v0.7.0/function/index.html | 194 + docs/v0.7.0/identifiers.html | 163 + docs/v0.7.0/image/badge.svg | 17 + docs/v0.7.0/image/github.png | Bin 0 -> 4268 bytes docs/v0.7.0/image/search.png | Bin 0 -> 12704 bytes docs/v0.7.0/index.html | 171 + docs/v0.7.0/package.json | 35 + docs/v0.7.0/script/inherited-summary.js | 28 + docs/v0.7.0/script/inner-link.js | 21 + docs/v0.7.0/script/patch-for-local.js | 8 + .../script/prettify/Apache-License-2.0.txt | 202 + docs/v0.7.0/script/prettify/prettify.js | 28 + docs/v0.7.0/script/pretty-print.js | 23 + docs/v0.7.0/script/search.js | 117 + docs/v0.7.0/script/search_index.js | 506 + docs/v0.7.0/script/test-summary.js | 54 + docs/v0.7.0/source.html | 111 + index.html | 6 +- releases/v0.7.0/ajax-adapter.js | 171 + releases/v0.7.0/ajax.js | 241 + releases/v0.7.0/store.dev.js | 13381 +++++ releases/v0.7.0/store.dev.js.map | 25 + releases/v0.7.0/store.js | 823 + releases/v0.7.0/store.prod.js | 12147 +++++ 45 files changed, 182680 insertions(+), 5493 deletions(-) create mode 100644 dist/ajax.js create mode 100644 docs/v0.7.0/ast/source/ajax-adapter.js.json create mode 100644 docs/v0.7.0/ast/source/ajax.js.json create mode 100644 docs/v0.7.0/ast/source/src/ajax-adapter.js.json create mode 100644 docs/v0.7.0/ast/source/src/store.js.json create mode 100644 docs/v0.7.0/ast/source/store.js.json create mode 100644 docs/v0.7.0/badge.svg create mode 100644 docs/v0.7.0/class/src/ajax-adapter.js~AjaxAdapter.html create mode 100644 docs/v0.7.0/class/src/store.js~Store.html create mode 100644 docs/v0.7.0/coverage.json create mode 100644 docs/v0.7.0/css/prettify-tomorrow.css create mode 100644 docs/v0.7.0/css/style.css create mode 100644 docs/v0.7.0/dump.json create mode 100644 docs/v0.7.0/file/src/ajax-adapter.js.html create mode 100644 docs/v0.7.0/file/src/ajax.js.html create mode 100644 docs/v0.7.0/file/src/store.js.html create mode 100644 docs/v0.7.0/function/index.html create mode 100644 docs/v0.7.0/identifiers.html create mode 100644 docs/v0.7.0/image/badge.svg create mode 100644 docs/v0.7.0/image/github.png create mode 100644 docs/v0.7.0/image/search.png create mode 100644 docs/v0.7.0/index.html create mode 100644 docs/v0.7.0/package.json create mode 100644 docs/v0.7.0/script/inherited-summary.js create mode 100644 docs/v0.7.0/script/inner-link.js create mode 100644 docs/v0.7.0/script/patch-for-local.js create mode 100644 docs/v0.7.0/script/prettify/Apache-License-2.0.txt create mode 100644 docs/v0.7.0/script/prettify/prettify.js create mode 100644 docs/v0.7.0/script/pretty-print.js create mode 100644 docs/v0.7.0/script/search.js create mode 100644 docs/v0.7.0/script/search_index.js create mode 100644 docs/v0.7.0/script/test-summary.js create mode 100644 docs/v0.7.0/source.html create mode 100644 releases/v0.7.0/ajax-adapter.js create mode 100644 releases/v0.7.0/ajax.js create mode 100644 releases/v0.7.0/store.dev.js create mode 100644 releases/v0.7.0/store.dev.js.map create mode 100644 releases/v0.7.0/store.js create mode 100644 releases/v0.7.0/store.prod.js diff --git a/dist/ajax-adapter.js b/dist/ajax-adapter.js index 1bf8b9f..91a6f54 100644 --- a/dist/ajax-adapter.js +++ b/dist/ajax-adapter.js @@ -1,12 +1,18 @@ -'use strict'; +"use strict"; -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ajax = require("./ajax"); + +var _ajax2 = _interopRequireDefault(_ajax); var AjaxAdapter = (function () { function AjaxAdapter(options) { @@ -16,202 +22,150 @@ var AjaxAdapter = (function () { } _createClass(AjaxAdapter, [{ - key: 'create', - value: function create(store, type, partial, success, error, context) { - var _this = this; - - if (error && ({}).toString.call(error) !== '[object Function]') { - - this.create(store, type, partial, success, null, error); - } else if (store._types[type]) { - (function () { - - var request = new XMLHttpRequest(); - - request.open('POST', _this._base + '/' + type, true); - - request.setRequestHeader("Content-Type", "application/vnd.api+json"); - - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - var response = JSON.parse(request.responseText); - try { - store.push(response); - if (success) { - success.call(context, store.find(response.data.type, response.data.id)); - } - } catch (e) { - if (error) { - error.call(context, e); - } - } - } else { - if (error) { - error.call(context); - } - } - }; - - request.send(JSON.stringify({ - data: store.convert(type, partial) - })); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + key: "create", + value: function create(store, type, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); } + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: store.convert(type, partial) + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "POST", + responseType: "auto", + url: this._getUrl(type, null, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function (e) { + return store.find(e.response.data.type, e.response.data.id); + }).publish(); + + source.connect(); + + return source; } }, { - key: 'destroy', - value: function destroy(store, type, id, success, error, context) { - var _this2 = this; - - if (error && ({}).toString.call(error) !== '[object Function]') { - - this.destroy(store, type, id, success, null, error); - } else if (store._types[type]) { - (function () { - - var request = new XMLHttpRequest(); - - request.open('DELETE', _this2._base + '/' + type + '/' + id, true); - - request.setRequestHeader("Content-Type", "application/vnd.api+json"); - - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.remove(type, id); - if (success) { - success.call(context); - } - } catch (e) { - error.call(context, e); - } - } else if (error) { - error.call(context); - } - }; - - request.send(); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + key: "destroy", + value: function destroy(store, type, id, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "DELETE", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.remove(type, id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "load", + value: function load(store, type, id, options) { + + if (id && typeof id === "object") { + return this.load(store, type, null, id); } + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "GET", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function () { + return id ? store.find(type, id) : store.findAll(type); + }).publish(); + + source.connect(); + + return source; } }, { - key: 'load', - value: function load(store, type, id, options, success, error, context) { - var _this3 = this; - - if (id && ({}).toString.call(id) === '[object Function]') { - this.load(store, type, null, null, id, options, success); - } else if (id && typeof id === "object") { - this.load(store, type, null, id, options, success, error); - } else if (options && ({}).toString.call(options) === '[object Function]') { - this.load(store, type, id, {}, options, success, error); - } else if (error && ({}).toString.call(error) !== '[object Function]') { - this.load(store, type, id, options, success, null, error); - } else if (store._types[type]) { - (function () { - - var request = new XMLHttpRequest(); - var url = undefined; - - options = options || {}; - url = id ? _this3._base + '/' + type + '/' + id : _this3._base + '/' + type; - - if (options) { - - var params = []; - - if (options.fields) { - Object.keys(options.fields).forEach(function (field) { - options['fields[' + field + ']'] = options.fields[field]; - }); - delete options.fields; - } - - params = Object.keys(options).map(function (key) { - return key + "=" + encodeURIComponent(options[key]); - }).sort(); - - if (params.length) { - url = url + '?' + params.join("&"); - } - } - - request.open('GET', url, true); - - request.setRequestHeader("Content-Type", "application/vnd.api+json"); - - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.push(JSON.parse(request.responseText)); - if (success) { - success.call(context, id ? store.find(type, id) : store.find(type)); - } - } catch (e) { - error.call({}, e); - } - } else if (error) { - error.call(context); - } - }; - - request.send(); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + key: "update", + value: function update(store, type, id, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); } + + var data = store.convert(type, id, partial); + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: data + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "PATCH", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.add(data); + }).map(function () { + return store.find(type, id); + }).publish(); + + source.connect(); + + return source; } }, { - key: 'update', - value: function update(store, type, id, partial, success, error, context) { - var _this4 = this; - - if (error && ({}).toString.call(error) !== '[object Function]') { - - this.update(store, type, id, partial, success, null, error); - } else if (store._types[type]) { - (function () { - - var request = new XMLHttpRequest(); - var data = store.convert(type, id, partial); - - request.open('PATCH', _this4._base + '/' + type + '/' + id, true); - - request.setRequestHeader("Content-Type", "application/vnd.api+json"); - - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.add(data); - if (success) { - success.call(context, store.find(data.type, data.id)); - } - } catch (e) { - if (error) { - error.call(context, e); - } - } - } else if (error) { - error.call(context); - } - }; - - request.send(JSON.stringify({ - data: data - })); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + key: "_getUrl", + value: function _getUrl(type, id, options) { + + var params = []; + var url = id ? this._base + "/" + type + "/" + id : this._base + "/" + type; + + if (options) { + + if (options.fields) { + Object.keys(options.fields).forEach(function (field) { + options["fields[" + field + "]"] = options.fields[field]; + }); + delete options.fields; + } + + params = Object.keys(options).map(function (key) { + return key + "=" + encodeURIComponent(options[key]); + }).sort(); + + if (params.length) { + url = url + "?" + params.join("&"); + } } + + return url; } }]); return AjaxAdapter; })(); -exports['default'] = AjaxAdapter; -module.exports = exports['default']; +exports["default"] = AjaxAdapter; +module.exports = exports["default"]; diff --git a/dist/ajax.js b/dist/ajax.js new file mode 100644 index 0000000..6fee9a4 --- /dev/null +++ b/dist/ajax.js @@ -0,0 +1,241 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +var _rx = require("rx"); + +var _rx2 = _interopRequireDefault(_rx); + +/** + * + * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc: + * + * https://github.com/Reactive-Extensions/RxJS-DOM + * + * The original source file can be viewed here: + * + * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js + * + * Licensed under the Apache License, Version 2.0: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Modifications from original: + * + * - extracted from "Rx.DOM" namespace + * - minor eslinter cleanup ("var" to "let" etc) + * - addition of "auto" responseType + * + */ + +var root = typeof window !== "undefined" && window || undefined; + +// Gets the proper XMLHttpRequest for support for older IE +function getXMLHttpRequest() { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else { + var progId = undefined; + try { + var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (var i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root.ActiveXObject(progId)) { + break; + } + } catch (e) {} + } + return new root.ActiveXObject(progId); + } catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} + +// Get CORS support even for older IE +function getCORSRequest() { + var xhr = new root.XMLHttpRequest(); + if ('withCredentials' in xhr) { + return xhr; + } else if (!!root.XDomainRequest) { + return new XDomainRequest(); + } else { + throw new Error('CORS is not supported by your browser'); + } +} + +function normalizeAjaxSuccessEvent(e, xhr, settings) { + var response = 'response' in xhr ? xhr.response : xhr.responseText; + if (settings.responseType === 'auto') { + try { + response = JSON.parse(response); + } catch (e) {} + } else { + response = settings.responseType === 'json' ? JSON.parse(response) : response; + } + return { + response: response, + status: xhr.status, + responseType: xhr.responseType, + xhr: xhr, + originalEvent: e + }; +} + +function normalizeAjaxErrorEvent(e, xhr, type) { + return { + type: type, + status: xhr.status, + xhr: xhr, + originalEvent: e + }; +} + +/** + * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL. + * + * @example + * source = ajax('/products'); + * source = ajax({ url: 'products', method: 'GET' }); + * + * @param {Object} settings Can be one of the following: + * + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - responseType: "text" (default), "json" or "auto" + * + * @returns {Observable} An observable sequence containing the XMLHttpRequest. +*/ + +exports["default"] = function (options) { + var settings = { + method: 'GET', + crossDomain: false, + async: true, + headers: {}, + responseType: 'text', + createXHR: function createXHR() { + return this.crossDomain ? getCORSRequest() : getXMLHttpRequest(); + }, + normalizeError: normalizeAjaxErrorEvent, + normalizeSuccess: normalizeAjaxSuccessEvent + }; + + if (typeof options === 'string') { + settings.url = options; + } else { + for (var prop in options) { + if (hasOwnProperty.call(options, prop)) { + settings[prop] = options[prop]; + } + } + } + + var normalizeError = settings.normalizeError; + var normalizeSuccess = settings.normalizeSuccess; + + if (!settings.crossDomain && !settings.headers['X-Requested-With']) { + settings.headers['X-Requested-With'] = 'XMLHttpRequest'; + } + settings.hasContent = settings.body !== undefined; + + return new _rx2["default"].AnonymousObservable(function (observer) { + var isDone = false; + var xhr; + + var processResponse = function processResponse(xhr, e) { + var status = xhr.status === 1223 ? 204 : xhr.status; + if (status >= 200 && status <= 300 || status === 0 || status === '') { + observer.onNext(normalizeSuccess(e, xhr, settings)); + observer.onCompleted(); + } else { + observer.onError(normalizeError(e, xhr, 'error')); + } + isDone = true; + }; + + try { + xhr = settings.createXHR();; + } catch (err) { + observer.onError(err); + } + + try { + if (settings.user) { + xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password); + } else { + xhr.open(settings.method, settings.url, settings.async); + } + + var headers = settings.headers; + for (var header in headers) { + if (hasOwnProperty.call(headers, header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + if (!!xhr.upload || !('withCredentials' in xhr) && !!root.XDomainRequest) { + xhr.onload = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onNext(e); + settings.progressObserver.onCompleted(); + } + processResponse(xhr, e); + }; + + if (settings.progressObserver) { + xhr.onprogress = function (e) { + settings.progressObserver.onNext(e); + }; + } + + xhr.onerror = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'error')); + isDone = true; + }; + + xhr.onabort = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'abort')); + isDone = true; + }; + } else { + + xhr.onreadystatechange = function (e) { + if (xhr.readyState === 4) { + processResponse(xhr, e); + } + }; + } + + xhr.send(settings.hasContent && settings.body || null); + } catch (e) { + observer.onError(e); + } + + return function () { + if (!isDone && xhr.readyState !== 4) { + xhr.abort(); + } + }; + }); +}; + +; +module.exports = exports["default"]; diff --git a/dist/store.dev.js b/dist/store.dev.js index d57c6ff..68f773c 100644 --- a/dist/store.dev.js +++ b/dist/store.dev.js @@ -129,7 +129,7 @@ process.umask = function() { return 0; }; },{}],3:[function(require,module,exports){ (function (process,global){ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - + ;(function (undefined) { var objectTypes = { @@ -154,7 +154,7 @@ process.umask = function() { return 0; }; }, helpers: { } }; - + // Defaults var noop = Rx.helpers.noop = function () { }, identity = Rx.helpers.identity = function (x) { return x; }, @@ -180,13 +180,10 @@ process.umask = function() { return 0; }; return isFn; }()); - function cloneArray(arr) { - var len = arr.length, a = new Array(len); - for(var i = 0; i < len; i++) { a[i] = arr[i]; } - return a; - } - + function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;} + var errorObj = {e: {}}; + function tryCatcherGen(tryCatchTarget) { return function tryCatcher() { try { @@ -195,23 +192,25 @@ process.umask = function() { return 0; }; errorObj.e = e; return errorObj; } - } + }; } + var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } return tryCatcherGen(fn); - } + }; + function thrower(e) { throw e; } - + Rx.config.longStackSupport = false; var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })(); hasStacks = !!stacks.e && !!stacks.e.stack; // All code after this point will be filtered from stack traces reported by RxJS var rStartingLine = captureLine(), rFileName; - + var STACK_JUMP_SEPARATOR = 'From previous event:'; function makeStackTraceLong(error, observable) { @@ -295,7 +294,7 @@ process.umask = function() { return 0; }; var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine); if (attempt3) { return [attempt3[1], Number(attempt3[2])]; } } - + var EmptyError = Rx.EmptyError = function() { this.message = 'Sequence contains no elements.'; this.name = 'EmptyError'; @@ -338,7 +337,7 @@ process.umask = function() { return 0; }; var notSupported = Rx.helpers.notSupported = function () { throw new NotSupportedError(); }; - + // Shim in iterator support var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || '_es6shim_iterator_'; @@ -358,7 +357,7 @@ process.umask = function() { return 0; }; } Rx.helpers.iterator = $iterator$; - + var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) { if (typeof thisArg === 'undefined') { return func; } switch(argCount) { @@ -384,7 +383,7 @@ process.umask = function() { return 0; }; return func.apply(thisArg, arguments); }; }; - + /** Used to determine if values are of the language type Object */ var dontEnums = ['toString', 'toLocaleString', @@ -394,7 +393,7 @@ process.umask = function() { return 0; }; 'propertyIsEnumerable', 'constructor'], dontEnumsLength = dontEnums.length; - + /** `Object#toString` result shortcuts */ var argsClass = '[object Arguments]', arrayClass = '[object Array]', @@ -669,7 +668,7 @@ process.umask = function() { return 0; }; return result; } - + var hasProp = {}.hasOwnProperty, slice = Array.prototype.slice; @@ -692,7 +691,7 @@ process.umask = function() { return 0; }; // Rx Utils var addRef = Rx.internals.addRef = function (xs, r) { return new AnonymousObservable(function (observer) { - return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer)); + return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer)); }); }; @@ -703,7 +702,91 @@ process.umask = function() { return 0; }; } return a; } - + + function IndexedItem(id, value) { + this.id = id; + this.value = value; + } + + IndexedItem.prototype.compareTo = function (other) { + var c = this.value.compareTo(other.value); + c === 0 && (c = this.id - other.id); + return c; + }; + + var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) { + this.items = new Array(capacity); + this.length = 0; + }; + + var priorityProto = PriorityQueue.prototype; + priorityProto.isHigherPriority = function (left, right) { + return this.items[left].compareTo(this.items[right]) < 0; + }; + + priorityProto.percolate = function (index) { + if (index >= this.length || index < 0) { return; } + var parent = index - 1 >> 1; + if (parent < 0 || parent === index) { return; } + if (this.isHigherPriority(index, parent)) { + var temp = this.items[index]; + this.items[index] = this.items[parent]; + this.items[parent] = temp; + this.percolate(parent); + } + }; + + priorityProto.heapify = function (index) { + +index || (index = 0); + if (index >= this.length || index < 0) { return; } + var left = 2 * index + 1, + right = 2 * index + 2, + first = index; + if (left < this.length && this.isHigherPriority(left, first)) { + first = left; + } + if (right < this.length && this.isHigherPriority(right, first)) { + first = right; + } + if (first !== index) { + var temp = this.items[index]; + this.items[index] = this.items[first]; + this.items[first] = temp; + this.heapify(first); + } + }; + + priorityProto.peek = function () { return this.items[0].value; }; + + priorityProto.removeAt = function (index) { + this.items[index] = this.items[--this.length]; + this.items[this.length] = undefined; + this.heapify(); + }; + + priorityProto.dequeue = function () { + var result = this.peek(); + this.removeAt(0); + return result; + }; + + priorityProto.enqueue = function (item) { + var index = this.length++; + this.items[index] = new IndexedItem(PriorityQueue.count++, item); + this.percolate(index); + }; + + priorityProto.remove = function (item) { + for (var i = 0; i < this.length; i++) { + if (this.items[i].value === item) { + this.removeAt(i); + return true; + } + } + return false; + }; + PriorityQueue.count = 0; + /** * Represents a group of disposable resources that are disposed together. * @constructor @@ -718,9 +801,6 @@ process.umask = function() { return 0; }; args = new Array(len); for(i = 0; i < len; i++) { args[i] = arguments[i]; } } - for(i = 0; i < len; i++) { - if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); } - } this.disposables = args; this.isDisposed = false; this.length = args.length; @@ -776,7 +856,7 @@ process.umask = function() { return 0; }; } } }; - + /** * Provides a set of static methods for creating Disposables. * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. @@ -818,7 +898,11 @@ process.umask = function() { return 0; }; var checkDisposed = Disposable.checkDisposed = function (disposable) { if (disposable.isDisposed) { throw new ObjectDisposedError(); } }; - + + var disposableFixup = Disposable._fixup = function (result) { + return isDisposable(result) ? result : disposableEmpty; + }; + // Single assignment var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () { this.isDisposed = false; @@ -838,8 +922,8 @@ process.umask = function() { return 0; }; this.isDisposed = true; var old = this.current; this.current = null; + old && old.dispose(); } - old && old.dispose(); }; // Multiple assignment disposable @@ -867,7 +951,40 @@ process.umask = function() { return 0; }; } old && old.dispose(); }; - + + var BinaryDisposable = Rx.BinaryDisposable = function (first, second) { + this._first = first; + this._second = second; + this.isDisposed = false; + }; + + BinaryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old1 = this._first; + this._first = null; + old1 && old1.dispose(); + var old2 = this._second; + this._second = null; + old2 && old2.dispose(); + } + }; + + var NAryDisposable = Rx.NAryDisposable = function (disposables) { + this._disposables = disposables; + this.isDisposed = false; + }; + + NAryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + for (var i = 0, len = this._disposables.length; i < len; i++) { + this._disposables[i].dispose(); + } + this._disposables.length = 0; + } + }; + /** * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. */ @@ -925,7 +1042,24 @@ process.umask = function() { return 0; }; return RefCountDisposable; })(); - + + function ScheduledDisposable(scheduler, disposable) { + this.scheduler = scheduler; + this.disposable = disposable; + this.isDisposed = false; + } + + function scheduleItem(s, self) { + if (!self.isDisposed) { + self.isDisposed = true; + self.disposable.dispose(); + } + } + + ScheduledDisposable.prototype.dispose = function () { + this.scheduler.schedule(this, scheduleItem); + }; + var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) { this.scheduler = scheduler; this.state = state; @@ -948,95 +1082,58 @@ process.umask = function() { return 0; }; }; ScheduledItem.prototype.invokeCore = function () { - return this.action(this.scheduler, this.state); + return disposableFixup(this.action(this.scheduler, this.state)); }; - + /** Provides a set of static properties to access commonly used schedulers. */ var Scheduler = Rx.Scheduler = (function () { - function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute) { - this.now = now; - this._schedule = schedule; - this._scheduleRelative = scheduleRelative; - this._scheduleAbsolute = scheduleAbsolute; - } + function Scheduler() { } /** Determines whether the given object is a scheduler */ Scheduler.isScheduler = function (s) { return s instanceof Scheduler; - } - - function invokeAction(scheduler, action) { - action(); - return disposableEmpty; - } + }; var schedulerProto = Scheduler.prototype; /** - * Schedules an action to be executed. - * @param {Function} action Action to execute. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.schedule = function (action) { - return this._schedule(action, invokeAction); - }; - - /** - * Schedules an action to be executed. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithState = function (state, action) { - return this._schedule(state, action); + * Schedules an action to be executed. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.schedule = function (state, action) { + throw new NotImplementedError(); }; - /** - * Schedules an action to be executed after the specified relative due time. - * @param {Function} action Action to execute. - * @param {Number} dueTime Relative time after which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithRelative = function (dueTime, action) { - return this._scheduleRelative(action, dueTime, invokeAction); - }; + /** + * Schedules an action to be executed after dueTime. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime; + dt instanceof Date && (dt = dt - this.now()); + dt = Scheduler.normalize(dt); - /** - * Schedules an action to be executed after dueTime. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @param {Number} dueTime Relative time after which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithRelativeAndState = function (state, dueTime, action) { - return this._scheduleRelative(state, dueTime, action); - }; + if (dt === 0) { return this.schedule(state, action); } - /** - * Schedules an action to be executed at the specified absolute due time. - * @param {Function} action Action to execute. - * @param {Number} dueTime Absolute time at which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithAbsolute = function (dueTime, action) { - return this._scheduleAbsolute(action, dueTime, invokeAction); + return this._scheduleFuture(state, dt, action); }; - /** - * Schedules an action to be executed at dueTime. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @param {Number}dueTime Absolute time at which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithAbsoluteAndState = function (state, dueTime, action) { - return this._scheduleAbsolute(state, dueTime, action); + schedulerProto._scheduleFuture = function (state, dueTime, action) { + throw new NotImplementedError(); }; /** Gets the current time according to the local machine's system clock. */ Scheduler.now = defaultNow; + /** Gets the current time according to the local machine's system clock. */ + Scheduler.prototype.now = defaultNow; + /** * Normalizes the specified TimeSpan value to a positive value. * @param {Number} timeSpan The time span value to normalize. @@ -1051,7 +1148,7 @@ process.umask = function() { return 0; }; }()); var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler; - + (function (schedulerProto) { function invokeRecImmediate(scheduler, pair) { @@ -1062,7 +1159,7 @@ process.umask = function() { return 0; }; function innerAction(state2) { var isAdded = false, isDone = false; - var d = scheduler.scheduleWithState(state2, scheduleWork); + var d = scheduler.schedule(state2, scheduleWork); if (!isDone) { group.add(d); isAdded = true; @@ -1080,7 +1177,7 @@ process.umask = function() { return 0; }; } } - function invokeRecDate(scheduler, pair, method) { + function invokeRecDate(scheduler, pair) { var state = pair[0], action = pair[1], group = new CompositeDisposable(); action(state, innerAction); return group; @@ -1088,7 +1185,7 @@ process.umask = function() { return 0; }; function innerAction(state2, dueTime1) { var isAdded = false, isDone = false; - var d = scheduler[method](state2, dueTime1, scheduleWork); + var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork); if (!isDone) { group.add(d); isAdded = true; @@ -1106,91 +1203,30 @@ process.umask = function() { return 0; }; } } - function invokeRecDateRelative(s, p) { - return invokeRecDate(s, p, 'scheduleWithRelativeAndState'); - } - - function invokeRecDateAbsolute(s, p) { - return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState'); - } - - function scheduleInnerRecursive(action, self) { - action(function(dt) { self(action, dt); }); - } - - /** - * Schedules an action to be executed recursively. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursive = function (action) { - return this.scheduleRecursiveWithState(action, scheduleInnerRecursive); - }; - /** * Schedules an action to be executed recursively. * @param {Mixed} state State passed to the action to be executed. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ - schedulerProto.scheduleRecursiveWithState = function (state, action) { - return this.scheduleWithState([state, action], invokeRecImmediate); - }; - - /** - * Schedules an action to be executed recursively after a specified relative due time. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time. - * @param {Number}dueTime Relative time after which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithRelative = function (dueTime, action) { - return this.scheduleRecursiveWithRelativeAndState(action, dueTime, scheduleInnerRecursive); + schedulerProto.scheduleRecursive = function (state, action) { + return this.schedule([state, action], invokeRecImmediate); }; /** - * Schedules an action to be executed recursively after a specified relative due time. + * Schedules an action to be executed recursively after a specified relative or absolute due time. * @param {Mixed} state State passed to the action to be executed. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. - * @param {Number}dueTime Relative time after which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) { - return this._scheduleRelative([state, action], dueTime, invokeRecDateRelative); - }; - - /** - * Schedules an action to be executed recursively at a specified absolute due time. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time. - * @param {Number}dueTime Absolute time at which to execute the action for the first time. + * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ - schedulerProto.scheduleRecursiveWithAbsolute = function (dueTime, action) { - return this.scheduleRecursiveWithAbsoluteAndState(action, dueTime, scheduleInnerRecursive); + schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) { + return this.scheduleFuture([state, action], dueTime, invokeRecDate); }; - /** - * Schedules an action to be executed recursively at a specified absolute due time. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. - * @param {Number}dueTime Absolute time at which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) { - return this._scheduleAbsolute([state, action], dueTime, invokeRecDateAbsolute); - }; }(Scheduler.prototype)); - - (function (schedulerProto) { - /** - * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. - * @param {Number} period Period for running the work periodically. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). - */ - Scheduler.prototype.schedulePeriodic = function (period, action) { - return this.schedulePeriodicWithState(null, period, action); - }; + (function (schedulerProto) { /** * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. @@ -1199,7 +1235,7 @@ process.umask = function() { return 0; }; * @param {Function} action Action to be executed, potentially updating the state. * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). */ - Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) { + Scheduler.prototype.schedulePeriodic = function(state, period, action) { if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); } period = normalizeTime(period); var s = state, id = root.setInterval(function () { s = action(s); }, period); @@ -1207,47 +1243,18 @@ process.umask = function() { return 0; }; }; }(Scheduler.prototype)); - - /** Gets a scheduler that schedules work immediately on the current thread. */ - var immediateScheduler = Scheduler.immediate = (function () { - function scheduleNow(state, action) { return action(this, state); } - return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported); - }()); - - /** - * Gets a scheduler that schedules work as soon as possible on the current thread. - */ - var currentThreadScheduler = Scheduler.currentThread = (function () { - var queue; - - function runTrampoline () { - while (queue.length > 0) { - var item = queue.shift(); - !item.isCancelled() && item.invoke(); - } - } - - function scheduleNow(state, action) { - var si = new ScheduledItem(this, state, action, this.now()); - - if (!queue) { - queue = [si]; - - var result = tryCatch(runTrampoline)(); - queue = null; - if (result === errorObj) { return thrower(result.e); } - } else { - queue.push(si); - } - return si.disposable; - } - var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported); - currentScheduler.scheduleRequired = function () { return !queue; }; + (function (schedulerProto) { + /** + * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions. + * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false. + * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling. + */ + schedulerProto.catchError = schedulerProto['catch'] = function (handler) { + return new CatchScheduler(this, handler); + }; + }(Scheduler.prototype)); - return currentScheduler; - }()); - var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () { function tick(command, recurse) { recurse(0, this._period); @@ -1269,14 +1276,71 @@ process.umask = function() { return 0; }; SchedulePeriodicRecursive.prototype.start = function () { var d = new SingleAssignmentDisposable(); this._cancel = d; - d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this))); + d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this))); return d; }; return SchedulePeriodicRecursive; }()); - + + /** Gets a scheduler that schedules work immediately on the current thread. */ + var ImmediateScheduler = (function (__super__) { + inherits(ImmediateScheduler, __super__); + function ImmediateScheduler() { + __super__.call(this); + } + + ImmediateScheduler.prototype.schedule = function (state, action) { + return disposableFixup(action(this, state)); + }; + + return ImmediateScheduler; + }(Scheduler)); + + var immediateScheduler = Scheduler.immediate = new ImmediateScheduler(); + + /** + * Gets a scheduler that schedules work as soon as possible on the current thread. + */ + var CurrentThreadScheduler = (function (__super__) { + var queue; + + function runTrampoline () { + while (queue.length > 0) { + var item = queue.dequeue(); + !item.isCancelled() && item.invoke(); + } + } + + inherits(CurrentThreadScheduler, __super__); + function CurrentThreadScheduler() { + __super__.call(this); + } + + CurrentThreadScheduler.prototype.schedule = function (state, action) { + var si = new ScheduledItem(this, state, action, this.now()); + + if (!queue) { + queue = new PriorityQueue(4); + queue.enqueue(si); + + var result = tryCatch(runTrampoline)(); + queue = null; + if (result === errorObj) { thrower(result.e); } + } else { + queue.enqueue(si); + } + return si.disposable; + }; + + CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; }; + + return CurrentThreadScheduler; + }(Scheduler)); + + var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler(); + var scheduleMethod, clearMethod; var localTimer = (function () { @@ -1311,7 +1375,7 @@ process.umask = function() { return 0; }; function runTask(handle) { if (currentlyRunning) { - localSetTimeout(function () { runTask(handle) }, 0); + localSetTimeout(function () { runTask(handle); }, 0); } else { var task = tasksByHandle[handle]; if (task) { @@ -1319,12 +1383,12 @@ process.umask = function() { return 0; }; var result = tryCatch(task)(); clearMethod(handle); currentlyRunning = false; - if (result === errorObj) { return thrower(result.e); } + if (result === errorObj) { thrower(result.e); } } } } - var reNative = RegExp('^' + + var reNative = new RegExp('^' + String(toString) .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/toString| for [^\]]+/g, '.*?') + '$' @@ -1430,56 +1494,138 @@ process.umask = function() { return 0; }; /** * Gets a scheduler that schedules work via a timed callback based upon platform. */ - var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () { - - function scheduleNow(state, action) { + var DefaultScheduler = (function (__super__) { + inherits(DefaultScheduler, __super__); + function DefaultScheduler() { + __super__.call(this); + } + + function DefaultSchedulerDisposable(id) { + this._id = id; + this.isDisposed = false; + } + + DefaultSchedulerDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + localClearTimeout(this._id); + } + }; + + DefaultScheduler.prototype.schedule = function (state, action) { var scheduler = this, disposable = new SingleAssignmentDisposable(); var id = scheduleMethod(function () { - !disposable.isDisposed && disposable.setDisposable(action(scheduler, state)); + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); }); - return new CompositeDisposable(disposable, disposableCreate(function () { - clearMethod(id); - })); - } + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; - function scheduleRelative(state, dueTime, action) { + DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) { var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable(); - if (dt === 0) { return scheduler.scheduleWithState(state, action); } + if (dt === 0) { return scheduler.schedule(state, action); } var id = localSetTimeout(function () { - !disposable.isDisposed && disposable.setDisposable(action(scheduler, state)); + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); }, dt); - return new CompositeDisposable(disposable, disposableCreate(function () { - localClearTimeout(id); - })); - } + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; - function scheduleAbsolute(state, dueTime, action) { - return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action); - } + return DefaultScheduler; + }(Scheduler)); - return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute); - })(); - - /** - * Represents a notification to an observer. - */ - var Notification = Rx.Notification = (function () { - function Notification(kind, value, exception, accept, acceptObservable, toString) { - this.kind = kind; - this.value = value; - this.exception = exception; - this._accept = accept; - this._acceptObservable = acceptObservable; - this.toString = toString; + var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler(); + + var CatchScheduler = (function (__super__) { + inherits(CatchScheduler, __super__); + + function CatchScheduler(scheduler, handler) { + this._scheduler = scheduler; + this._handler = handler; + this._recursiveOriginal = null; + this._recursiveWrapper = null; + __super__.call(this); } - /** - * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. - * - * @memberOf Notification - * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. - * @param {Function} onError Delegate to invoke for an OnError notification. - * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. + CatchScheduler.prototype.schedule = function (state, action) { + return this._scheduler.schedule(state, this._wrap(action)); + }; + + CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + return this._scheduler.schedule(state, dueTime, this._wrap(action)); + }; + + CatchScheduler.prototype.now = function () { return this._scheduler.now(); }; + + CatchScheduler.prototype._clone = function (scheduler) { + return new CatchScheduler(scheduler, this._handler); + }; + + CatchScheduler.prototype._wrap = function (action) { + var parent = this; + return function (self, state) { + var res = tryCatch(action)(parent._getRecursiveWrapper(self), state); + if (res === errorObj) { + if (!parent._handler(res.e)) { thrower(res.e); } + return disposableEmpty; + } + return disposableFixup(ret); + }; + }; + + CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { + if (this._recursiveOriginal !== scheduler) { + this._recursiveOriginal = scheduler; + var wrapper = this._clone(scheduler); + wrapper._recursiveOriginal = scheduler; + wrapper._recursiveWrapper = wrapper; + this._recursiveWrapper = wrapper; + } + return this._recursiveWrapper; + }; + + CatchScheduler.prototype.schedulePeriodic = function (state, period, action) { + var self = this, failed = false, d = new SingleAssignmentDisposable(); + + d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) { + if (failed) { return null; } + var res = tryCatch(action)(state1); + if (res === errorObj) { + failed = true; + if (!self._handler(res.e)) { thrower(res.e); } + d.dispose(); + return null; + } + return ret; + })); + + return d; + }; + + return CatchScheduler; + }(Scheduler)); + + /** + * Represents a notification to an observer. + */ + var Notification = Rx.Notification = (function () { + function Notification() { + + } + + Notification.prototype._accept = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + /** + * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. + * + * @memberOf Notification + * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. + * @param {Function} onError Delegate to invoke for an OnError notification. + * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. * @returns {Any} Result produced by the observation. */ Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) { @@ -1498,10 +1644,10 @@ process.umask = function() { return 0; }; Notification.prototype.toObservable = function (scheduler) { var self = this; isScheduler(scheduler) || (scheduler = immediateScheduler); - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithState(self, function (_, notification) { - notification._acceptObservable(observer); - notification.kind === 'N' && observer.onCompleted(); + return new AnonymousObservable(function (o) { + return scheduler.schedule(self, function (_, notification) { + notification._acceptObservable(o); + notification.kind === 'N' && o.onCompleted(); }); }); }; @@ -1509,55 +1655,130 @@ process.umask = function() { return 0; }; return Notification; })(); + var OnNextNotification = (function (__super__) { + inherits(OnNextNotification, __super__); + function OnNextNotification(value) { + this.value = value; + this.kind = 'N'; + } + + OnNextNotification.prototype._accept = function (onNext) { + return onNext(this.value); + }; + + OnNextNotification.prototype._acceptObservable = function (o) { + return o.onNext(this.value); + }; + + OnNextNotification.prototype.toString = function () { + return 'OnNext(' + this.value + ')'; + }; + + return OnNextNotification; + }(Notification)); + + var OnErrorNotification = (function (__super__) { + inherits(OnErrorNotification, __super__); + function OnErrorNotification(error) { + this.error = error; + this.kind = 'E'; + } + + OnErrorNotification.prototype._accept = function (onNext, onError) { + return onError(this.error); + }; + + OnErrorNotification.prototype._acceptObservable = function (o) { + return o.onError(this.error); + }; + + OnErrorNotification.prototype.toString = function () { + return 'OnError(' + this.error + ')'; + }; + + return OnErrorNotification; + }(Notification)); + + var OnCompletedNotification = (function (__super__) { + inherits(OnCompletedNotification, __super__); + function OnCompletedNotification() { + this.kind = 'C'; + } + + OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) { + return onCompleted(); + }; + + OnCompletedNotification.prototype._acceptObservable = function (o) { + return o.onCompleted(); + }; + + OnCompletedNotification.prototype.toString = function () { + return 'OnCompleted()'; + }; + + return OnCompletedNotification; + }(Notification)); + /** * Creates an object that represents an OnNext notification to an observer. * @param {Any} value The value contained in the notification. * @returns {Notification} The OnNext notification containing the value. */ - var notificationCreateOnNext = Notification.createOnNext = (function () { - function _accept(onNext) { return onNext(this.value); } - function _acceptObservable(observer) { return observer.onNext(this.value); } - function toString() { return 'OnNext(' + this.value + ')'; } - - return function (value) { - return new Notification('N', value, null, _accept, _acceptObservable, toString); - }; - }()); + var notificationCreateOnNext = Notification.createOnNext = function (value) { + return new OnNextNotification(value); + }; /** * Creates an object that represents an OnError notification to an observer. * @param {Any} error The exception contained in the notification. * @returns {Notification} The OnError notification containing the exception. */ - var notificationCreateOnError = Notification.createOnError = (function () { - function _accept (onNext, onError) { return onError(this.exception); } - function _acceptObservable(observer) { return observer.onError(this.exception); } - function toString () { return 'OnError(' + this.exception + ')'; } - - return function (e) { - return new Notification('E', null, e, _accept, _acceptObservable, toString); - }; - }()); + var notificationCreateOnError = Notification.createOnError = function (error) { + return new OnErrorNotification(error); + }; /** * Creates an object that represents an OnCompleted notification to an observer. * @returns {Notification} The OnCompleted notification. */ - var notificationCreateOnCompleted = Notification.createOnCompleted = (function () { - function _accept (onNext, onError, onCompleted) { return onCompleted(); } - function _acceptObservable(observer) { return observer.onCompleted(); } - function toString () { return 'OnCompleted()'; } + var notificationCreateOnCompleted = Notification.createOnCompleted = function () { + return new OnCompletedNotification(); + }; - return function () { - return new Notification('C', null, null, _accept, _acceptObservable, toString); - }; - }()); - /** * Supports push-style iteration over an observable sequence. */ var Observer = Rx.Observer = function () { }; + /** + * Creates a notification callback from an observer. + * @returns The action that forwards its input notification to the underlying observer. + */ + Observer.prototype.toNotifier = function () { + var observer = this; + return function (n) { return n.accept(observer); }; + }; + + /** + * Hides the identity of an observer. + * @returns An observer that hides the identity of the specified observer. + */ + Observer.prototype.asObserver = function () { + var self = this; + return new AnonymousObserver( + function (x) { self.onNext(x); }, + function (err) { self.onError(err); }, + function () { self.onCompleted(); }); + }; + + /** + * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods. + * If a violation is detected, an Error is thrown from the offending observer method call. + * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer. + */ + Observer.prototype.checked = function () { return new CheckedObserver(this); }; + /** * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions. * @param {Function} [onNext] Observer's OnNext action implementation. @@ -1571,7 +1792,36 @@ process.umask = function() { return 0; }; onCompleted || (onCompleted = noop); return new AnonymousObserver(onNext, onError, onCompleted); }; - + + /** + * Creates an observer from a notification callback. + * @param {Function} handler Action that handles a notification. + * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives. + */ + Observer.fromNotifier = function (handler, thisArg) { + var cb = bindCallback(handler, thisArg, 1); + return new AnonymousObserver(function (x) { + return cb(notificationCreateOnNext(x)); + }, function (e) { + return cb(notificationCreateOnError(e)); + }, function () { + return cb(notificationCreateOnCompleted()); + }); + }; + + /** + * Schedules the invocation of observer methods on the given scheduler. + * @param {Scheduler} scheduler Scheduler to schedule observer messages on. + * @returns {Observer} Observer whose messages are scheduled on the given scheduler. + */ + Observer.prototype.notifyOn = function (scheduler) { + return new ObserveOnObserver(scheduler, this); + }; + + Observer.prototype.makeSafe = function(disposable) { + return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable); + }; + /** * Abstract base class for implementations of the Observer class. * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages. @@ -1637,7 +1887,7 @@ process.umask = function() { return 0; }; return AbstractObserver; }(Observer)); - + /** * Class to create an Observer instance from delegate-based implementations of the on* methods. */ @@ -1682,93 +1932,48 @@ process.umask = function() { return 0; }; return AnonymousObserver; }(AbstractObserver)); - - var observableProto; - - /** - * Represents a push-style collection. - */ - var Observable = Rx.Observable = (function () { - - function makeSubscribe(self, subscribe) { - return function (o) { - var oldOnError = o.onError; - o.onError = function (e) { - makeStackTraceLong(e, self); - oldOnError.call(o, e); - }; - return subscribe.call(self, o); - }; - } + var CheckedObserver = (function (__super__) { + inherits(CheckedObserver, __super__); - function Observable(subscribe) { - if (Rx.config.longStackSupport && hasStacks) { - var e = tryCatch(thrower)(new Error()).e; - this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); - this._subscribe = makeSubscribe(this, subscribe); - } else { - this._subscribe = subscribe; - } + function CheckedObserver(observer) { + __super__.call(this); + this._observer = observer; + this._state = 0; // 0 - idle, 1 - busy, 2 - done } - observableProto = Observable.prototype; - - /** - * Determines whether the given object is an Observable - * @param {Any} An object to determine whether it is an Observable - * @returns {Boolean} true if an Observable, else false. - */ - Observable.isObservable = function (o) { - return o && isFunction(o.subscribe); - } + var CheckedObserverPrototype = CheckedObserver.prototype; - /** - * Subscribes an o to the observable sequence. - * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. - * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. - * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. - * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { - return this._subscribe(typeof oOrOnNext === 'object' ? - oOrOnNext : - observerCreate(oOrOnNext, onError, onCompleted)); + CheckedObserverPrototype.onNext = function (value) { + this.checkAccess(); + var res = tryCatch(this._observer.onNext).call(this._observer, value); + this._state = 0; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onNext The function to invoke on each element in the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnNext = function (onNext, thisArg) { - return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + CheckedObserverPrototype.onError = function (err) { + this.checkAccess(); + var res = tryCatch(this._observer.onError).call(this._observer, err); + this._state = 2; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to an exceptional condition in the sequence with an optional "this" argument. - * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnError = function (onError, thisArg) { - return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + CheckedObserverPrototype.onCompleted = function () { + this.checkAccess(); + var res = tryCatch(this._observer.onCompleted).call(this._observer); + this._state = 2; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { - return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + CheckedObserverPrototype.checkAccess = function () { + if (this._state === 1) { throw new Error('Re-entrancy detected'); } + if (this._state === 2) { throw new Error('Observer completed'); } + if (this._state === 0) { this._state = 1; } }; - return Observable; - })(); - + return CheckedObserver; + }(Observer)); + var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) { inherits(ScheduledObserver, __super__); @@ -1804,7 +2009,7 @@ process.umask = function() { return 0; }; this.isAcquired = true; } if (isOwner) { - this.disposable.setDisposable(this.scheduler.scheduleRecursiveWithState(this, function (parent, self) { + this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) { var work; if (parent.queue.length > 0) { work = parent.queue.shift(); @@ -1830,122 +2035,233 @@ process.umask = function() { return 0; }; return ScheduledObserver; }(AbstractObserver)); - - var ObservableBase = Rx.ObservableBase = (function (__super__) { - inherits(ObservableBase, __super__); - - function fixSubscriber(subscriber) { - return subscriber && isFunction(subscriber.dispose) ? subscriber : - isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; - } - - function setDisposable(s, state) { - var ado = state[0], self = state[1]; - var sub = tryCatch(self.subscribeCore).call(self, ado); - - if (sub === errorObj) { - if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); } - } - ado.setDisposable(fixSubscriber(sub)); - } - - function subscribe(observer) { - var ado = new AutoDetachObserver(observer), state = [ado, this]; - - if (currentThreadScheduler.scheduleRequired()) { - currentThreadScheduler.scheduleWithState(state, setDisposable); - } else { - setDisposable(null, state); - } - return ado; - } - - function ObservableBase() { - __super__.call(this, subscribe); - } - - ObservableBase.prototype.subscribeCore = notImplemented; - - return ObservableBase; - }(Observable)); - -var FlatMapObservable = (function(__super__){ - - inherits(FlatMapObservable, __super__); - function FlatMapObservable(source, selector, resultSelector, thisArg) { - this.resultSelector = Rx.helpers.isFunction(resultSelector) ? - resultSelector : null; - - this.selector = Rx.internals.bindCallback(Rx.helpers.isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); - this.source = source; - - __super__.call(this); + var ObserveOnObserver = (function (__super__) { + inherits(ObserveOnObserver, __super__); + function ObserveOnObserver(scheduler, observer, cancel) { + __super__.call(this, scheduler, observer); + this._cancel = cancel; } - FlatMapObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + ObserveOnObserver.prototype.next = function (value) { + __super__.prototype.next.call(this, value); + this.ensureActive(); }; - function InnerObserver(observer, selector, resultSelector, source) { - this.i = 0; - this.selector = selector; - this.resultSelector = resultSelector; - this.source = source; - this.isStopped = false; - this.o = observer; - } + ObserveOnObserver.prototype.error = function (e) { + __super__.prototype.error.call(this, e); + this.ensureActive(); + }; - InnerObserver.prototype._wrapResult = function(result, x, i) { - return this.resultSelector ? - result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : - result; + ObserveOnObserver.prototype.completed = function () { + __super__.prototype.completed.call(this); + this.ensureActive(); }; - InnerObserver.prototype.onNext = function(x) { + ObserveOnObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this._cancel && this._cancel.dispose(); + this._cancel = null; + }; - if (this.isStopped) return; + return ObserveOnObserver; + })(ScheduledObserver); - var i = this.i++; - var result = tryCatch(this.selector)(x, i, this.source); + var observableProto; - if (result === errorObj) { - return this.o.onError(result.e); - } + /** + * Represents a push-style collection. + */ + var Observable = Rx.Observable = (function () { - Rx.helpers.isPromise(result) && (result = Rx.Observable.fromPromise(result)); - (Rx.helpers.isArrayLike(result) || Rx.helpers.isIterable(result)) && (result = Rx.Observable.from(result)); + function makeSubscribe(self, subscribe) { + return function (o) { + var oldOnError = o.onError; + o.onError = function (e) { + makeStackTraceLong(e, self); + oldOnError.call(o, e); + }; - this.o.onNext(this._wrapResult(result, x, i)); + return subscribe.call(self, o); + }; + } - }; + function Observable() { + if (Rx.config.longStackSupport && hasStacks) { + var oldSubscribe = this._subscribe; + var e = tryCatch(thrower)(new Error()).e; + this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); + this._subscribe = makeSubscribe(this, oldSubscribe); + } + } - InnerObserver.prototype.onError = function(e) { - if(!this.isStopped) { this.isStopped = true; this.o.onError(e); } - }; + observableProto = Observable.prototype; - InnerObserver.prototype.onCompleted = function() { - if (!this.isStopped) {this.isStopped = true; this.o.onCompleted(); } + /** + * Determines whether the given object is an Observable + * @param {Any} An object to determine whether it is an Observable + * @returns {Boolean} true if an Observable, else false. + */ + Observable.isObservable = function (o) { + return o && isFunction(o.subscribe); }; + /** + * Subscribes an o to the observable sequence. + * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. + * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { + return this._subscribe(typeof oOrOnNext === 'object' ? + oOrOnNext : + observerCreate(oOrOnNext, onError, onCompleted)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onNext The function to invoke on each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnNext = function (onNext, thisArg) { + return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + }; + + /** + * Subscribes to an exceptional condition in the sequence with an optional "this" argument. + * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnError = function (onError, thisArg) { + return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { + return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + }; + + return Observable; + })(); + + var ObservableBase = Rx.ObservableBase = (function (__super__) { + inherits(ObservableBase, __super__); + + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.subscribeCore).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function ObservableBase() { + __super__.call(this); + } + + ObservableBase.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + ObservableBase.prototype.subscribeCore = notImplemented; + + return ObservableBase; + }(Observable)); + +var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) { + + inherits(FlatMapObservable, __super__); + + function FlatMapObservable(source, selector, resultSelector, thisArg) { + this.resultSelector = isFunction(resultSelector) ? resultSelector : null; + this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); + this.source = source; + __super__.call(this); + } + + FlatMapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(observer, selector, resultSelector, source) { + this.i = 0; + this.selector = selector; + this.resultSelector = resultSelector; + this.source = source; + this.o = observer; + AbstractObserver.call(this); + } + + InnerObserver.prototype._wrapResult = function(result, x, i) { + return this.resultSelector ? + result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : + result; + }; + + InnerObserver.prototype.next = function(x) { + var i = this.i++; + var result = tryCatch(this.selector)(x, i, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result)); + this.o.onNext(this._wrapResult(result, x, i)); + }; + + InnerObserver.prototype.error = function(e) { this.o.onError(e); }; + + InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); }; + return FlatMapObservable; }(ObservableBase)); - + var Enumerable = Rx.internals.Enumerable = function () { }; + function IsDisposedDisposable(state) { + this._s = state; + this.isDisposed = false; + } + + IsDisposedDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.isDisposed = true; + } + }; + var ConcatEnumerableObservable = (function(__super__) { inherits(ConcatEnumerableObservable, __super__); function ConcatEnumerableObservable(sources) { this.sources = sources; __super__.call(this); } - + ConcatEnumerableObservable.prototype.subscribeCore = function (o) { - var isDisposed, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) { - if (isDisposed) { return; } + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -1962,60 +2278,40 @@ var FlatMapObservable = (function(__super__){ d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e))); }); - return new CompositeDisposable(subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); }; - + + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, s, e) { - this.o = o; - this.s = s; - this.e = e; - this.isStopped = false; + this._o = o; + this._s = s; + this._e = e; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } }; - InnerObserver.prototype.onError = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.s(this.e); - } - }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; }; - InnerObserver.prototype.fail = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - return true; - } - return false; - }; - + InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.onError = function (e) { this._o.onError(e); }; + InnerObserver.prototype.onCompleted = function () { this._s(this._e); }; + return ConcatEnumerableObservable; }(ObservableBase)); Enumerable.prototype.concat = function () { return new ConcatEnumerableObservable(this); }; - + var CatchErrorObservable = (function(__super__) { inherits(CatchErrorObservable, __super__); function CatchErrorObservable(sources) { this.sources = sources; __super__.call(this); } - + CatchErrorObservable.prototype.subscribeCore = function (o) { var e = this.sources[$iterator$](); - var isDisposed, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) { - if (isDisposed) { return; } + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -2029,16 +2325,22 @@ var FlatMapObservable = (function(__super__){ var d = new SingleAssignmentDisposable(); subscription.setDisposable(d); - d.setDisposable(currentValue.subscribe( - function(x) { o.onNext(x); }, - self, - function() { o.onCompleted(); })); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self))); }); - return new CompositeDisposable(subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); }; - + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, recurse) { + this._o = o; + this._recurse = recurse; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.error = function (e) { this._recurse(e); }; + InnerObserver.prototype.completed = function () { this._o.onCompleted(); }; + return CatchErrorObservable; }(ObservableBase)); @@ -2056,11 +2358,11 @@ var FlatMapObservable = (function(__super__){ var e = sources[$iterator$](); - var isDisposed, + var state = { isDisposed: false }, lastException, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursive(function (self) { - if (isDisposed) { return; } + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -2079,7 +2381,7 @@ var FlatMapObservable = (function(__super__){ var outer = new SingleAssignmentDisposable(); var inner = new SingleAssignmentDisposable(); - subscription.setDisposable(new CompositeDisposable(inner, outer)); + subscription.setDisposable(new BinaryDisposable(inner, outer)); outer.setDisposable(currentValue.subscribe( function(x) { o.onNext(x); }, function (exn) { @@ -2094,23 +2396,21 @@ var FlatMapObservable = (function(__super__){ function() { o.onCompleted(); })); }); - return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]); }); }; - + var RepeatEnumerable = (function (__super__) { inherits(RepeatEnumerable, __super__); - + function RepeatEnumerable(v, c) { this.v = v; this.c = c == null ? -1 : c; } RepeatEnumerable.prototype[$iterator$] = function () { - return new RepeatEnumerator(this); + return new RepeatEnumerator(this); }; - + function RepeatEnumerator(p) { this.v = p.v; this.l = p.c; @@ -2118,16 +2418,16 @@ var FlatMapObservable = (function(__super__){ RepeatEnumerator.prototype.next = function () { if (this.l === 0) { return doneEnumerator; } if (this.l > 0) { this.l--; } - return { done: false, value: this.v }; + return { done: false, value: this.v }; }; - + return RepeatEnumerable; }(Enumerable)); var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) { return new RepeatEnumerable(value, repeatCount); }; - + var OfEnumerable = (function(__super__) { inherits(OfEnumerable, __super__); function OfEnumerable(s, fn, thisArg) { @@ -2137,7 +2437,7 @@ var FlatMapObservable = (function(__super__){ OfEnumerable.prototype[$iterator$] = function () { return new OfEnumerator(this); }; - + function OfEnumerator(p) { this.i = -1; this.s = p.s; @@ -2147,71 +2447,173 @@ var FlatMapObservable = (function(__super__){ OfEnumerator.prototype.next = function () { return ++this.i < this.l ? { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } : - doneEnumerator; + doneEnumerator; }; - + return OfEnumerable; }(Enumerable)); var enumerableOf = Enumerable.of = function (source, selector, thisArg) { return new OfEnumerable(source, selector, thisArg); }; - - var ToArrayObservable = (function(__super__) { - inherits(ToArrayObservable, __super__); - function ToArrayObservable(source) { + +var ObserveOnObservable = (function (__super__) { + inherits(ObserveOnObservable, __super__); + function ObserveOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + ObserveOnObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ObserveOnObserver(this._s, o)); + }; + + return ObserveOnObservable; +}(ObservableBase)); + + /** + * Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + * + * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects + * that require to be run on a scheduler, use subscribeOn. + * + * @param {Scheduler} scheduler Scheduler to notify observers on. + * @returns {Observable} The source sequence whose observations happen on the specified scheduler. + */ + observableProto.observeOn = function (scheduler) { + return new ObserveOnObservable(this, scheduler); + }; + + var SubscribeOnObservable = (function (__super__) { + inherits(SubscribeOnObservable, __super__); + function SubscribeOnObservable(source, s) { this.source = source; + this._s = s; __super__.call(this); } - ToArrayObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o)); + function scheduleMethod(scheduler, state) { + var source = state[0], d = state[1], o = state[2]; + d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o))); + } + + SubscribeOnObservable.prototype.subscribeCore = function (o) { + var m = new SingleAssignmentDisposable(), d = new SerialDisposable(); + d.setDisposable(m); + m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod)); + return d; }; - function InnerObserver(o) { - this.o = o; - this.a = []; - this.isStopped = false; + return SubscribeOnObservable; + }(ObservableBase)); + + /** + * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used; + * see the remarks section for more information on the distinction between subscribeOn and observeOn. + + * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer + * callbacks on a scheduler, use observeOn. + + * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on. + * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + observableProto.subscribeOn = function (scheduler) { + return new SubscribeOnObservable(this, scheduler); + }; + + var FromPromiseObservable = (function(__super__) { + inherits(FromPromiseObservable, __super__); + function FromPromiseObservable(p) { + this.p = p; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } }; - InnerObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.o.onNext(this.a); - this.o.onCompleted(); - } - }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; } - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - - return false; + + FromPromiseObservable.prototype.subscribeCore = function(o) { + this.p + .then(function (data) { + o.onNext(data); + o.onCompleted(); + }, function (err) { + o.onError(err); + }); + return disposableEmpty; }; - return ToArrayObservable; + return FromPromiseObservable; }(ObservableBase)); /** - * Creates an array from an observable sequence. - * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + * Converts a Promise to an Observable sequence + * @param {Promise} An ES6 Compliant promise. + * @returns {Observable} An Observable sequence which wraps the existing promise success and failure. */ - observableProto.toArray = function () { - return new ToArrayObservable(this); + var observableFromPromise = Observable.fromPromise = function (promise) { + return new FromPromiseObservable(promise); }; - - /** - * Creates an observable sequence from a specified subscribe method implementation. - * @example + + /* + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence. + */ + observableProto.toPromise = function (promiseCtor) { + promiseCtor || (promiseCtor = Rx.config.Promise); + if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); } + var source = this; + return new promiseCtor(function (resolve, reject) { + // No cancellation can be done + var value; + source.subscribe(function (v) { + value = v; + }, reject, function () { + resolve(value); + }); + }); + }; + + var ToArrayObservable = (function(__super__) { + inherits(ToArrayObservable, __super__); + function ToArrayObservable(source) { + this.source = source; + __super__.call(this); + } + + ToArrayObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o) { + this.o = o; + this.a = []; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this.a.push(x); }; + InnerObserver.prototype.error = function (e) { this.o.onError(e); }; + InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); }; + + return ToArrayObservable; + }(ObservableBase)); + + /** + * Creates an array from an observable sequence. + * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + */ + observableProto.toArray = function () { + return new ToArrayObservable(this); + }; + + /** + * Creates an observable sequence from a specified subscribe method implementation. + * @example * var res = Rx.Observable.create(function (observer) { return function () { } ); * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } ); * var res = Rx.Observable.create(function (observer) { } ); @@ -2221,7 +2623,24 @@ var FlatMapObservable = (function(__super__){ Observable.create = function (subscribe, parent) { return new AnonymousObservable(subscribe, parent); }; - + + var Defer = (function(__super__) { + inherits(Defer, __super__); + function Defer(factory) { + this._f = factory; + __super__.call(this); + } + + Defer.prototype.subscribeCore = function (o) { + var result = tryCatch(this._f)(); + if (result === errorObj) { return observableThrow(result.e).subscribe(o);} + isPromise(result) && (result = observableFromPromise(result)); + return result.subscribe(o); + }; + + return Defer; + }(ObservableBase)); + /** * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. * @@ -2231,18 +2650,9 @@ var FlatMapObservable = (function(__super__){ * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function. */ var observableDefer = Observable.defer = function (observableFactory) { - return new AnonymousObservable(function (observer) { - var result; - try { - result = observableFactory(); - } catch (e) { - return observableThrow(e).subscribe(observer); - } - isPromise(result) && (result = observableFromPromise(result)); - return result.subscribe(observer); - }); + return new Defer(observableFactory); }; - + var EmptyObservable = (function(__super__) { inherits(EmptyObservable, __super__); function EmptyObservable(scheduler) { @@ -2266,7 +2676,10 @@ var FlatMapObservable = (function(__super__){ } EmptySink.prototype.run = function () { - return this.scheduler.scheduleWithState(this.observer, scheduleItem); + var state = this.observer; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); }; return EmptyObservable; @@ -2287,7 +2700,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler); }; - + var FromObservable = (function(__super__) { inherits(FromObservable, __super__); function FromObservable(iterable, mapper, scheduler) { @@ -2333,7 +2746,7 @@ var FlatMapObservable = (function(__super__){ recurse(i + 1); } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; return FromSink; @@ -2444,7 +2857,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromObservable(iterable, mapper, scheduler); } - + var FromArrayObservable = (function(__super__) { inherits(FromArrayObservable, __super__); function FromArrayObservable(args, scheduler) { @@ -2477,9 +2890,9 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; - + /** * Converts an array to an observable sequence, using an optional scheduler to enumerate the array. * @deprecated use Observable.from or Observable.of @@ -2490,30 +2903,64 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromArrayObservable(array, scheduler) }; - - var NeverObservable = (function(__super__) { - inherits(NeverObservable, __super__); - function NeverObservable() { + + var GenerateObservable = (function (__super__) { + inherits(GenerateObservable, __super__); + function GenerateObservable(state, cndFn, itrFn, resFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._s = s; + this._first = true; __super__.call(this); } - NeverObservable.prototype.subscribeCore = function (observer) { - return disposableEmpty; + function scheduleRecursive(self, recurse) { + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + var hasResult = tryCatch(self._cndFn)(self._state); + if (hasResult === errorObj) { return self._o.onError(hasResult.e); } + if (hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + self._o.onNext(result); + recurse(self); + } else { + self._o.onCompleted(); + } + } + + GenerateObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursive(this, scheduleRecursive); }; - return NeverObservable; + return GenerateObservable; }(ObservableBase)); - var NEVER_OBSERVABLE = new NeverObservable(); - /** - * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). - * @returns {Observable} An observable sequence whose observers will never get called. + * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. + * + * @example + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }); + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout); + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread. + * @returns {Observable} The generated sequence. */ - var observableNever = Observable.never = function () { - return NEVER_OBSERVABLE; + Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler); }; - + function observableOf (scheduler, array) { isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromArrayObservable(array, scheduler); @@ -2539,7 +2986,76 @@ var FlatMapObservable = (function(__super__){ for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; } return new FromArrayObservable(args, scheduler); }; - + + /** + * Creates an Observable sequence from changes to an array using Array.observe. + * @param {Array} array An array to observe changes. + * @returns {Observable} An observable sequence containing changes to an array from Array.observe. + */ + Observable.ofArrayChanges = function(array) { + if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); } + if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Array.observe(array, observerFn); + + return function () { + Array.unobserve(array, observerFn); + }; + }); + }; + + /** + * Creates an Observable sequence from changes to an object using Object.observe. + * @param {Object} obj An object to observe changes. + * @returns {Observable} An observable sequence containing changes to an object from Object.observe. + */ + Observable.ofObjectChanges = function(obj) { + if (obj == null) { throw new TypeError('object must not be null or undefined.'); } + if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Object.observe(obj, observerFn); + + return function () { + Object.unobserve(obj, observerFn); + }; + }); + }; + + var NeverObservable = (function(__super__) { + inherits(NeverObservable, __super__); + function NeverObservable() { + __super__.call(this); + } + + NeverObservable.prototype.subscribeCore = function (observer) { + return disposableEmpty; + }; + + return NeverObservable; + }(ObservableBase)); + + var NEVER_OBSERVABLE = new NeverObservable(); + + /** + * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). + * @returns {Observable} An observable sequence whose observers will never get called. + */ + var observableNever = Observable.never = function () { + return NEVER_OBSERVABLE; + }; + var PairsObservable = (function(__super__) { inherits(PairsObservable, __super__); function PairsObservable(obj, scheduler) { @@ -2574,7 +3090,7 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; /** @@ -2587,7 +3103,7 @@ var FlatMapObservable = (function(__super__){ scheduler || (scheduler = currentThreadScheduler); return new PairsObservable(obj, scheduler); }; - + var RangeObservable = (function(__super__) { inherits(RangeObservable, __super__); function RangeObservable(start, count, scheduler) { @@ -2622,7 +3138,7 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; return RangeSink; @@ -2639,7 +3155,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new RangeObservable(start, count, scheduler); }; - + var RepeatObservable = (function(__super__) { inherits(RepeatObservable, __super__); function RepeatObservable(value, repeatCount, scheduler) { @@ -2673,7 +3189,7 @@ var FlatMapObservable = (function(__super__){ recurse(i); } - return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive); + return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive); }; /** @@ -2687,7 +3203,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new RepeatObservable(value, repeatCount, scheduler); }; - + var JustObservable = (function(__super__) { inherits(JustObservable, __super__); function JustObservable(value, scheduler) { @@ -2718,7 +3234,7 @@ var FlatMapObservable = (function(__super__){ var state = [this.value, this.observer]; return this.scheduler === immediateScheduler ? scheduleItem(null, state) : - this.scheduler.scheduleWithState(state, scheduleItem); + this.scheduler.schedule(state, scheduleItem); }; return JustObservable; @@ -2735,7 +3251,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return new JustObservable(value, scheduler); }; - + var ThrowObservable = (function(__super__) { inherits(ThrowObservable, __super__); function ThrowObservable(error, scheduler) { @@ -2760,7 +3276,7 @@ var FlatMapObservable = (function(__super__){ } ThrowSink.prototype.run = function () { - return this.p.scheduler.scheduleWithState([this.p.error, this.o], scheduleItem); + return this.p.scheduler.schedule([this.p.error, this.o], scheduleItem); }; return ThrowObservable; @@ -2777,7 +3293,146 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return new ThrowObservable(error, scheduler); }; - + + var UsingObservable = (function (__super__) { + inherits(UsingObservable, __super__); + function UsingObservable(resFn, obsFn) { + this._resFn = resFn; + this._obsFn = obsFn; + __super__.call(this); + } + + UsingObservable.prototype.subscribeCore = function (o) { + var disposable = disposableEmpty; + var resource = tryCatch(this._resFn)(); + if (resource === errorObj) { + return new BinaryDisposable(observableThrow(resource.e).subscribe(o), disposable); + } + resource && (disposable = resource); + var source = tryCatch(this._obsFn)(resource); + if (source === errorObj) { + return new BinaryDisposable(observableThrow(source.e).subscribe(o), disposable); + } + return new BinaryDisposable(source.subscribe(o), disposable); + }; + + return UsingObservable; + }(ObservableBase)); + + /** + * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. + * @param {Function} resourceFactory Factory function to obtain a resource object. + * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource. + * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object. + */ + Observable.using = function (resourceFactory, observableFactory) { + return new UsingObservable(resourceFactory, observableFactory); + }; + + /** + * Propagates the observable sequence or Promise that reacts first. + * @param {Observable} rightSource Second observable sequence or Promise. + * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first. + */ + observableProto.amb = function (rightSource) { + var leftSource = this; + return new AnonymousObservable(function (observer) { + var choice, + leftChoice = 'L', rightChoice = 'R', + leftSubscription = new SingleAssignmentDisposable(), + rightSubscription = new SingleAssignmentDisposable(); + + isPromise(rightSource) && (rightSource = observableFromPromise(rightSource)); + + function choiceL() { + if (!choice) { + choice = leftChoice; + rightSubscription.dispose(); + } + } + + function choiceR() { + if (!choice) { + choice = rightChoice; + leftSubscription.dispose(); + } + } + + var leftSubscribe = observerCreate( + function (left) { + choiceL(); + choice === leftChoice && observer.onNext(left); + }, + function (e) { + choiceL(); + choice === leftChoice && observer.onError(e); + }, + function () { + choiceL(); + choice === leftChoice && observer.onCompleted(); + } + ); + var rightSubscribe = observerCreate( + function (right) { + choiceR(); + choice === rightChoice && observer.onNext(right); + }, + function (e) { + choiceR(); + choice === rightChoice && observer.onError(e); + }, + function () { + choiceR(); + choice === rightChoice && observer.onCompleted(); + } + ); + + leftSubscription.setDisposable(leftSource.subscribe(leftSubscribe)); + rightSubscription.setDisposable(rightSource.subscribe(rightSubscribe)); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }); + }; + + function amb(p, c) { return p.amb(c); } + + /** + * Propagates the observable sequence or Promise that reacts first. + * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first. + */ + Observable.amb = function () { + var acc = observableNever(), items; + if (Array.isArray(arguments[0])) { + items = arguments[0]; + } else { + var len = arguments.length; + items = new Array(items); + for(var i = 0; i < len; i++) { items[i] = arguments[i]; } + } + for (var i = 0, len = items.length; i < len; i++) { + acc = amb(acc, items[i]); + } + return acc; + }; + + var CatchObservable = (function (__super__) { + inherits(CatchObservable, __super__); + function CatchObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + CatchObservable.prototype.subscribeCore = function (o) { + var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable(); + subscription.setDisposable(d1); + d1.setDisposable(this.source.subscribe(new CatchObserver(o, subscription, this._fn))); + return subscription; + }; + + return CatchObservable; + }(ObservableBase)); + var CatchObserver = (function(__super__) { inherits(CatchObserver, __super__); function CatchObserver(o, s, fn) { @@ -2802,24 +3457,15 @@ var FlatMapObservable = (function(__super__){ return CatchObserver; }(AbstractObserver)); - function observableCatchHandler(source, handler) { - return new AnonymousObservable(function (o) { - var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable(); - subscription.setDisposable(d1); - d1.setDisposable(source.subscribe(new CatchObserver(o, subscription, handler))); - return subscription; - }, source); - } - /** * Continues an observable sequence that is terminated by an exception with the next observable sequence. * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence. * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred. */ observableProto['catch'] = function (handlerOrSecond) { - return isFunction(handlerOrSecond) ? observableCatchHandler(this, handlerOrSecond) : observableCatch([this, handlerOrSecond]); + return isFunction(handlerOrSecond) ? new CatchObservable(this, handlerOrSecond) : observableCatch([this, handlerOrSecond]); }; - + /** * Continues an observable sequence that is terminated by an exception with the next observable sequence. * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs. @@ -2836,7 +3482,7 @@ var FlatMapObservable = (function(__super__){ } return enumerableOf(items).catchError(); }; - + /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. * This can be in the form of an argument list of observables or an array. @@ -2856,7 +3502,7 @@ var FlatMapObservable = (function(__super__){ } return combineLatest.apply(this, args); }; - + function falseFactory() { return false; } function argumentsToArray() { var len = arguments.length, args = new Array(len); @@ -2864,66 +3510,84 @@ var FlatMapObservable = (function(__super__){ return args; } - /** - * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. - * - * @example - * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; }); - * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; }); - * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - var combineLatest = Observable.combineLatest = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - Array.isArray(args[0]) && (args = args[0]); + var CombineLatestObservable = (function(__super__) { + inherits(CombineLatestObservable, __super__); + function CombineLatestObservable(params, cb) { + var len = params.length; + this._params = params; + this._cb = cb; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._done = arrayInitialize(len, falseFactory); + this._v = new Array(len); + __super__.call(this); + } - return new AnonymousObservable(function (o) { - var n = args.length, - hasValue = arrayInitialize(n, falseFactory), - hasValueAll = false, - isDone = arrayInitialize(n, falseFactory), - values = new Array(n); + CombineLatestObservable.prototype.subscribeCore = function(observer) { + var len = this._params.length, subscriptions = new Array(len); - function next(i) { - hasValue[i] = true; - if (hasValueAll || (hasValueAll = hasValue.every(identity))) { - try { - var res = resultSelector.apply(null, values); - } catch (e) { - return o.onError(e); - } - o.onNext(res); - } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { - o.onCompleted(); - } + for (var i = 0; i < len; i++) { + var source = this._params[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new CombineLatestObserver(observer, i, this))); } - function done (i) { - isDone[i] = true; - isDone.every(identity) && o.onCompleted(); - } + return new NAryDisposable(subscriptions); + }; - var subscriptions = new Array(n); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var source = args[i], sad = new SingleAssignmentDisposable(); - isPromise(source) && (source = observableFromPromise(source)); - sad.setDisposable(source.subscribe(function (x) { - values[i] = x; - next(i); - }, - function(e) { o.onError(e); }, - function () { done(i); } - )); - subscriptions[i] = sad; - }(idx)); + return CombineLatestObservable; + }(ObservableBase)); + + var CombineLatestObserver = (function (__super__) { + inherits(CombineLatestObserver, __super__); + function CombineLatestObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + CombineLatestObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + if (this._p._hvAll || (this._p._hvAll = this._p._hv.every(identity))) { + var res = tryCatch(this._p._cb).apply(null, this._p._v); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); } + }; - return new CompositeDisposable(subscriptions); - }, this); + CombineLatestObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + CombineLatestObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return CombineLatestObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. + * + * @example + * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; }); + * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; }); + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + var combineLatest = Observable.combineLatest = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + return new CombineLatestObservable(args, resultSelector); }; - + /** * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate. * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order. @@ -2933,7 +3597,7 @@ var FlatMapObservable = (function(__super__){ args.unshift(this); return observableConcat.apply(null, args); }; - + var ConcatObservable = (function(__super__) { inherits(ConcatObservable, __super__); function ConcatObservable(sources) { @@ -2952,7 +3616,7 @@ var FlatMapObservable = (function(__super__){ } ConcatSink.prototype.run = function () { var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o; - var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) { + var cancelable = immediateScheduler.scheduleRecursive(0, function (i, self) { if (isDisposed) { return; } if (i === length) { return o.onCompleted(); @@ -2995,7 +3659,7 @@ var FlatMapObservable = (function(__super__){ } return new ConcatObservable(args); }; - + /** * Concatenates an observable sequence of observable sequences. * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order. @@ -3003,7 +3667,7 @@ var FlatMapObservable = (function(__super__){ observableProto.concatAll = function () { return this.merge(1); }; - + var MergeObservable = (function (__super__) { inherits(MergeObservable, __super__); @@ -3130,7 +3794,7 @@ var FlatMapObservable = (function(__super__){ observableMerge(this, maxConcurrentOrOther) : new MergeObservable(this, maxConcurrentOrOther); }; - + /** * Merges all the observable sequences into a single observable sequence. * The scheduler is optional and if not specified, the immediate scheduler is used. @@ -3153,7 +3817,103 @@ var FlatMapObservable = (function(__super__){ } return observableOf(scheduler, sources).mergeAll(); }; - + + var MergeAllObservable = (function (__super__) { + inherits(MergeAllObservable, __super__); + + function MergeAllObservable(source) { + this.source = source; + __super__.call(this); + } + + MergeAllObservable.prototype.subscribeCore = function (observer) { + var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); + g.add(m); + m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); + return g; + }; + + function MergeAllObserver(o, g) { + this.o = o; + this.g = g; + this.isStopped = false; + this.done = false; + } + MergeAllObserver.prototype.onNext = function(innerSource) { + if(this.isStopped) { return; } + var sad = new SingleAssignmentDisposable(); + this.g.add(sad); + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + }; + MergeAllObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + } + }; + MergeAllObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.done = true; + this.g.length === 1 && this.o.onCompleted(); + } + }; + MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; + MergeAllObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + + return false; + }; + + function InnerObserver(parent, sad) { + this.parent = parent; + this.sad = sad; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; + InnerObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + var parent = this.parent; + this.isStopped = true; + parent.g.remove(this.sad); + parent.done && parent.g.length === 1 && parent.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeAllObservable; + }(ObservableBase)); + + /** + * Merges an observable sequence of observable sequences into an observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.mergeAll = function () { + return new MergeAllObservable(this); + }; + var CompositeError = Rx.CompositeError = function(errors) { this.name = "NotImplementedError"; this.innerErrors = errors; @@ -3234,133 +3994,132 @@ var FlatMapObservable = (function(__super__){ return group; }); }; - - var MergeAllObservable = (function (__super__) { - inherits(MergeAllObservable, __super__); - function MergeAllObservable(source) { - this.source = source; - __super__.call(this); + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates. + * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally. + */ + observableProto.onErrorResumeNext = function (second) { + if (!second) { throw new Error('Second observable is required'); } + return onErrorResumeNext([this, second]); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * + * @example + * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs); + * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]); + * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. + */ + var onErrorResumeNext = Observable.onErrorResumeNext = function () { + var sources = []; + if (Array.isArray(arguments[0])) { + sources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } } + return new AnonymousObservable(function (observer) { + var pos = 0, subscription = new SerialDisposable(), + cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) { + var current, d; + if (pos < sources.length) { + current = sources[pos++]; + isPromise(current) && (current = observableFromPromise(current)); + d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self)); + } else { + observer.onCompleted(); + } + }); + return new BinaryDisposable(subscription, cancelable); + }); + }; - MergeAllObservable.prototype.subscribeCore = function (observer) { - var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); - g.add(m); - m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); - return g; - }; + var SkipUntilObservable = (function(__super__) { + inherits(SkipUntilObservable, __super__); - function MergeAllObserver(o, g) { - this.o = o; - this.g = g; - this.isStopped = false; - this.done = false; + function SkipUntilObservable(source, other) { + this._s = source; + this._o = isPromise(other) ? observableFromPromise(other) : other; + this._open = false; + __super__.call(this); } - MergeAllObserver.prototype.onNext = function(innerSource) { - if(this.isStopped) { return; } - var sad = new SingleAssignmentDisposable(); - this.g.add(sad); - isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + SkipUntilObservable.prototype.subscribeCore = function(o) { + var leftSubscription = new SingleAssignmentDisposable(); + leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this))); - sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + isPromise(this._o) && (this._o = observableFromPromise(this._o)); + + var rightSubscription = new SingleAssignmentDisposable(); + rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription))); + + return new BinaryDisposable(leftSubscription, rightSubscription); }; - MergeAllObserver.prototype.onError = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } + + return SkipUntilObservable; + }(ObservableBase)); + + var SkipUntilSourceObserver = (function(__super__) { + inherits(SkipUntilSourceObserver, __super__); + function SkipUntilSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilSourceObserver.prototype.next = function (x) { + this._p._open && this._o.onNext(x); }; - MergeAllObserver.prototype.onCompleted = function () { - if(!this.isStopped) { - this.isStopped = true; - this.done = true; - this.g.length === 1 && this.o.onCompleted(); - } + + SkipUntilSourceObserver.prototype.error = function (err) { + this._o.onError(err); }; - MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; - MergeAllObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + SkipUntilSourceObserver.prototype.onCompleted = function () { + this._p._open && this._o.onCompleted(); }; - function InnerObserver(parent, sad) { - this.parent = parent; - this.sad = sad; - this.isStopped = false; + return SkipUntilSourceObserver; + }(AbstractObserver)); + + var SkipUntilOtherObserver = (function(__super__) { + inherits(SkipUntilOtherObserver, __super__); + function SkipUntilOtherObserver(o, p, r) { + this._o = o; + this._p = p; + this._r = r; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; - InnerObserver.prototype.onError = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - } + + SkipUntilOtherObserver.prototype.next = function () { + this._p._open = true; + this._r.dispose(); }; - InnerObserver.prototype.onCompleted = function () { - if(!this.isStopped) { - var parent = this.parent; - this.isStopped = true; - parent.g.remove(this.sad); - parent.done && parent.g.length === 1 && parent.o.onCompleted(); - } + + SkipUntilOtherObserver.prototype.error = function (err) { + this._o.onError(err); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - return true; - } - return false; + SkipUntilOtherObserver.prototype.onCompleted = function () { + this._r.dispose(); }; - return MergeAllObservable; - }(ObservableBase)); + return SkipUntilOtherObserver; + }(AbstractObserver)); - /** - * Merges an observable sequence of observable sequences into an observable sequence. - * @returns {Observable} The observable sequence that merges the elements of the inner sequences. - */ - observableProto.mergeAll = function () { - return new MergeAllObservable(this); - }; - /** * Returns the values from the source observable sequence only after the other observable sequence produces a value. * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence. * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation. */ observableProto.skipUntil = function (other) { - var source = this; - return new AnonymousObservable(function (o) { - var isOpen = false; - var disposables = new CompositeDisposable(source.subscribe(function (left) { - isOpen && o.onNext(left); - }, function (e) { o.onError(e); }, function () { - isOpen && o.onCompleted(); - })); - - isPromise(other) && (other = observableFromPromise(other)); - - var rightSubscription = new SingleAssignmentDisposable(); - disposables.add(rightSubscription); - rightSubscription.setDisposable(other.subscribe(function () { - isOpen = true; - rightSubscription.dispose(); - }, function (e) { o.onError(e); }, function () { - rightSubscription.dispose(); - })); - - return disposables; - }, source); + return new SkipUntilObservable(this, other); }; - + var SwitchObservable = (function(__super__) { inherits(SwitchObservable, __super__); function SwitchObservable(source) { @@ -3370,80 +4129,55 @@ var FlatMapObservable = (function(__super__){ SwitchObservable.prototype.subscribeCore = function (o) { var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner)); - return new CompositeDisposable(s, inner); + return new BinaryDisposable(s, inner); }; + inherits(SwitchObserver, AbstractObserver); function SwitchObserver(o, inner) { this.o = o; this.inner = inner; this.stopped = false; this.latest = 0; this.hasLatest = false; - this.isStopped = false; + AbstractObserver.call(this); } - SwitchObserver.prototype.onNext = function (innerSource) { - if (this.isStopped) { return; } + + SwitchObserver.prototype.next = function (innerSource) { var d = new SingleAssignmentDisposable(), id = ++this.latest; this.hasLatest = true; this.inner.setDisposable(d); isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); d.setDisposable(innerSource.subscribe(new InnerObserver(this, id))); }; - SwitchObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }; - SwitchObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.stopped = true; - !this.hasLatest && this.o.onCompleted(); - } + + SwitchObserver.prototype.error = function (e) { + this.o.onError(e); }; - SwitchObserver.prototype.dispose = function () { this.isStopped = true; }; - SwitchObserver.prototype.fail = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + + SwitchObserver.prototype.completed = function () { + this.stopped = true; + !this.hasLatest && this.o.onCompleted(); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(parent, id) { this.parent = parent; this.id = id; - this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function (x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function (x) { this.parent.latest === this.id && this.parent.o.onNext(x); }; - InnerObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.parent.latest === this.id && this.parent.o.onError(e); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - if (this.parent.latest === this.id) { - this.parent.hasLatest = false; - this.parent.isStopped && this.parent.o.onCompleted(); - } - } + + InnerObserver.prototype.error = function (e) { + this.parent.latest === this.id && this.parent.o.onError(e); }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; } - InnerObserver.prototype.fail = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - return true; + + InnerObserver.prototype.completed = function () { + if (this.parent.latest === this.id) { + this.parent.hasLatest = false; + this.parent.isStopped && this.parent.o.onCompleted(); } - return false; }; return SwitchObservable; @@ -3456,7 +4190,7 @@ var FlatMapObservable = (function(__super__){ observableProto['switch'] = observableProto.switchLatest = function () { return new SwitchObservable(this); }; - + var TakeUntilObservable = (function(__super__) { inherits(TakeUntilObservable, __super__); @@ -3467,41 +4201,34 @@ var FlatMapObservable = (function(__super__){ } TakeUntilObservable.prototype.subscribeCore = function(o) { - return new CompositeDisposable( + return new BinaryDisposable( this.source.subscribe(o), - this.other.subscribe(new InnerObserver(o)) + this.other.subscribe(new TakeUntilObserver(o)) ); }; - function InnerObserver(o) { - this.o = o; - this.isStopped = false; + return TakeUntilObservable; + }(ObservableBase)); + + var TakeUntilObserver = (function(__super__) { + inherits(TakeUntilObserver, __super__); + function TakeUntilObserver(o) { + this._o = o; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { - if (this.isStopped) { return; } - this.o.onCompleted(); - }; - InnerObserver.prototype.onError = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function () { - !this.isStopped && (this.isStopped = true); + + TakeUntilObserver.prototype.next = function () { + this._o.onCompleted(); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + + TakeUntilObserver.prototype.error = function (err) { + this._o.onError(err); }; - return TakeUntilObservable; - }(ObservableBase)); + TakeUntilObserver.prototype.onCompleted = noop; + + return TakeUntilObserver; + }(AbstractObserver)); /** * Returns the values from the source observable sequence until the other observable sequence produces a value. @@ -3511,62 +4238,174 @@ var FlatMapObservable = (function(__super__){ observableProto.takeUntil = function (other) { return new TakeUntilObservable(this, other); }; - + function falseFactory() { return false; } + function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; + } + + var WithLatestFromObservable = (function(__super__) { + inherits(WithLatestFromObservable, __super__); + function WithLatestFromObservable(source, sources, resultSelector) { + var len = sources.length; + this._s = source; + this._ss = sources; + this._cb = resultSelector; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._v = new Array(len); + __super__.call(this); + } + + WithLatestFromObservable.prototype.subscribeCore = function (o) { + var n = this._ss.length, subscriptions = new Array(n + 1); + for (var i = 0; i < n; i++) { + var other = this._ss[i], sad = new SingleAssignmentDisposable(); + isPromise(other) && (other = observableFromPromise(other)); + sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this))); + subscriptions[i] = sad; + } + + var sad = new SingleAssignmentDisposable(); + sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this))); + subscriptions[n] = sad; + + return new NAryDisposable(subscriptions); + }; + + return WithLatestFromObservable; + }(ObservableBase)); + + var WithLatestFromOtherObserver = (function (__super__) { + inherits(WithLatestFromOtherObserver, __super__); + function WithLatestFromOtherObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + WithLatestFromOtherObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + this._p._hvAll = this._p._hv.every(identity); + }; + + WithLatestFromOtherObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromOtherObserver.prototype.completed = noop; + + return WithLatestFromOtherObserver; + }(AbstractObserver)); + + var WithLatestFromSourceObserver = (function (__super__) { + inherits(WithLatestFromSourceObserver, __super__); + function WithLatestFromSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + WithLatestFromSourceObserver.prototype.next = function (x) { + var allValues = [x].concat(this._p._v); + if (!this._p._hvAll) { return; } + var res = tryCatch(this._p._cb).apply(null, allValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + }; + + WithLatestFromSourceObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromSourceObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return WithLatestFromSourceObserver; + }(AbstractObserver)); /** * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. */ observableProto.withLatestFrom = function () { - var len = arguments.length, args = new Array(len) + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = args.pop(), source = this; + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; Array.isArray(args[0]) && (args = args[0]); - return new AnonymousObservable(function (observer) { - var n = args.length, - hasValue = arrayInitialize(n, falseFactory), - hasValueAll = false, - values = new Array(n); + return new WithLatestFromObservable(this, args, resultSelector); + }; - var subscriptions = new Array(n + 1); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var other = args[i], sad = new SingleAssignmentDisposable(); - isPromise(other) && (other = observableFromPromise(other)); - sad.setDisposable(other.subscribe(function (x) { - values[i] = x; - hasValue[i] = true; - hasValueAll = hasValue.every(identity); - }, function (e) { observer.onError(e); }, noop)); - subscriptions[i] = sad; - }(idx)); + function falseFactory() { return false; } + function emptyArrayFactory() { return []; } + + var ZipObservable = (function(__super__) { + inherits(ZipObservable, __super__); + function ZipObservable(sources, resultSelector) { + var len = sources.length; + this._s = sources; + this._cb = resultSelector; + this._done = arrayInitialize(len, falseFactory); + this._q = arrayInitialize(len, emptyArrayFactory); + __super__.call(this); + } + + ZipObservable.prototype.subscribeCore = function(observer) { + var n = this._s.length, subscriptions = new Array(n); + + for (var i = 0; i < n; i++) { + var source = this._s[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this))); } - var sad = new SingleAssignmentDisposable(); - sad.setDisposable(source.subscribe(function (x) { - var allValues = [x].concat(values); - if (!hasValueAll) { return; } - var res = tryCatch(resultSelector).apply(null, allValues); - if (res === errorObj) { return observer.onError(res.e); } - observer.onNext(res); - }, function (e) { observer.onError(e); }, function () { - observer.onCompleted(); - })); - subscriptions[n] = sad; + return new NAryDisposable(subscriptions); + }; - return new CompositeDisposable(subscriptions); - }, this); - }; - - function falseFactory() { return false; } - function emptyArrayFactory() { return []; } - function argumentsToArray() { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return args; - } + return ZipObservable; + }(ObservableBase)); + + var ZipObserver = (function (__super__) { + inherits(ZipObserver, __super__); + function ZipObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + ZipObserver.prototype.next = function (x) { + this._p._q[this._i].push(x); + if (this._p._q.every(function (x) { return x.length > 0; })) { + var queuedValues = this._p._q.map(function (x) { return x.shift(); }); + var res = tryCatch(this._p._cb).apply(null, queuedValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); + } + }; + + ZipObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ZipObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return ZipObserver; + }(AbstractObserver)); /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. @@ -3583,40 +4422,10 @@ var FlatMapObservable = (function(__super__){ var parent = this; args.unshift(parent); - return new AnonymousObservable(function (o) { - var n = args.length, - queues = arrayInitialize(n, emptyArrayFactory), - isDone = arrayInitialize(n, falseFactory); - - var subscriptions = new Array(n); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var source = args[i], sad = new SingleAssignmentDisposable(); - - isPromise(source) && (source = observableFromPromise(source)); - sad.setDisposable(source.subscribe(function (x) { - queues[i].push(x); - if (queues.every(function (x) { return x.length > 0; })) { - var queuedValues = queues.map(function (x) { return x.shift(); }), - res = tryCatch(resultSelector).apply(parent, queuedValues); - if (res === errorObj) { return o.onError(res.e); } - o.onNext(res); - } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { - o.onCompleted(); - } - }, function (e) { o.onError(e); }, function () { - isDone[i] = true; - isDone.every(identity) && o.onCompleted(); - })); - subscriptions[i] = sad; - })(idx); - } - - return new CompositeDisposable(subscriptions); - }, parent); + return new ZipObservable(args, resultSelector); }; - + /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. * @param arguments Observable sources. @@ -3632,7 +4441,7 @@ var FlatMapObservable = (function(__super__){ var first = args.shift(); return first.zip.apply(first, args); }; - + function falseFactory() { return false; } function emptyArrayFactory() { return []; } function argumentsToArray() { @@ -3688,7 +4497,7 @@ observableProto.zipIterable = function () { return new CompositeDisposable(subscriptions); }, parent); }; - + function asObservable(source) { return function subscribe(o) { return source.subscribe(o); }; } @@ -3700,18 +4509,60 @@ observableProto.zipIterable = function () { observableProto.asObservable = function () { return new AnonymousObservable(asObservable(this), this); }; - + + function toArray(x) { return x.toArray(); } + function notEmpty(x) { return x.length > 0; } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information. + * @param {Number} count Length of each buffer. + * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithCount = function (count, skip) { + typeof skip !== 'number' && (skip = count); + return this.windowWithCount(count, skip) + .flatMap(toArray) + .filter(notEmpty); + }; + + var DematerializeObservable = (function (__super__) { + inherits(DematerializeObservable, __super__); + function DematerializeObservable(source) { + this.source = source; + __super__.call(this); + } + + DematerializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DematerializeObserver(o)); + }; + + return DematerializeObservable; + }(ObservableBase)); + + var DematerializeObserver = (function (__super__) { + inherits(DematerializeObserver, __super__); + + function DematerializeObserver(o) { + this._o = o; + __super__.call(this); + } + + DematerializeObserver.prototype.next = function (x) { x.accept(this._o); }; + DematerializeObserver.prototype.error = function (e) { this._o.onError(e); }; + DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DematerializeObserver; + }(AbstractObserver)); + /** * Dematerializes the explicit notification values of an observable sequence as implicit notifications. * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. */ observableProto.dematerialize = function () { - var source = this; - return new AnonymousObservable(function (o) { - return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); }); - }, this); + return new DematerializeObservable(this); }; - + var DistinctUntilChangedObservable = (function(__super__) { inherits(DistinctUntilChangedObservable, __super__); function DistinctUntilChangedObservable(source, keyFn, comparer) { @@ -3775,7 +4626,7 @@ observableProto.zipIterable = function () { comparer || (comparer = defaultComparer); return new DistinctUntilChangedObservable(this, keyFn, comparer); }; - + var TapObservable = (function(__super__) { inherits(TapObservable,__super__); function TapObservable(source, observerOrOnNext, onError, onCompleted) { @@ -3790,43 +4641,29 @@ observableProto.zipIterable = function () { return this.source.subscribe(new InnerObserver(o, this)); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, p) { this.o = o; this.t = !p._oN || isFunction(p._oN) ? observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) : p._oN; this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function(x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function(x) { var res = tryCatch(this.t.onNext).call(this.t, x); if (res === errorObj) { this.o.onError(res.e); } this.o.onNext(x); }; - InnerObserver.prototype.onError = function(err) { - if (!this.isStopped) { - this.isStopped = true; - var res = tryCatch(this.t.onError).call(this.t, err); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function() { - if (!this.isStopped) { - this.isStopped = true; - var res = tryCatch(this.t.onCompleted).call(this.t); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onCompleted(); - } + InnerObserver.prototype.error = function(err) { + var res = tryCatch(this.t.onError).call(this.t, err); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onError(err); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + InnerObserver.prototype.completed = function() { + var res = tryCatch(this.t.onCompleted).call(this.t); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onCompleted(); }; return TapObservable; @@ -3876,7 +4713,7 @@ observableProto.zipIterable = function () { observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) { return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted); }; - + /** * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. * @param {Function} finallyAction Action to invoke after the source observable sequence terminates. @@ -3897,7 +4734,7 @@ observableProto.zipIterable = function () { }); }, this); }; - + var IgnoreElementsObservable = (function(__super__) { inherits(IgnoreElementsObservable, __super__); @@ -3948,26 +4785,44 @@ observableProto.zipIterable = function () { observableProto.ignoreElements = function () { return new IgnoreElementsObservable(this); }; - + + var MaterializeObservable = (function (__super__) { + inherits(MaterializeObservable, __super__); + function MaterializeObservable(source, fn) { + this.source = source; + __super__.call(this); + } + + MaterializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new MaterializeObserver(o)); + }; + + return MaterializeObservable; + }(ObservableBase)); + + var MaterializeObserver = (function (__super__) { + inherits(MaterializeObserver, __super__); + + function MaterializeObserver(o) { + this._o = o; + __super__.call(this); + } + + MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) }; + MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); }; + MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); }; + + return MaterializeObserver; + }(AbstractObserver)); + /** * Materializes the implicit notifications of an observable sequence as explicit notification values. * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence. */ observableProto.materialize = function () { - var source = this; - return new AnonymousObservable(function (observer) { - return source.subscribe(function (value) { - observer.onNext(notificationCreateOnNext(value)); - }, function (e) { - observer.onNext(notificationCreateOnError(e)); - observer.onCompleted(); - }, function () { - observer.onNext(notificationCreateOnCompleted()); - observer.onCompleted(); - }); - }, source); + return new MaterializeObservable(this); }; - + /** * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely. * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely. @@ -3976,7 +4831,7 @@ observableProto.zipIterable = function () { observableProto.repeat = function (repeatCount) { return enumerableRepeat(this, repeatCount).concat(); }; - + /** * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely. * Note if you encounter an error and want it to retry once, then you must use .retry(2); @@ -3990,7 +4845,7 @@ observableProto.zipIterable = function () { observableProto.retry = function (retryCount) { return enumerableRepeat(this, retryCount).catchError(); }; - + /** * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. * if the notifier completes, the observable sequence completes. @@ -4003,7 +4858,7 @@ observableProto.zipIterable = function () { */ observableProto.retryWhen = function (notifier) { return enumerableRepeat(this).catchErrorWhen(notifier); - }; + }; var ScanObservable = (function(__super__) { inherits(ScanObservable, __super__); function ScanObservable(source, accumulator, hasSeed, seed) { @@ -4015,58 +4870,51 @@ observableProto.zipIterable = function () { } ScanObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o,this)); + return this.source.subscribe(new ScanObserver(o,this)); }; return ScanObservable; }(ObservableBase)); - function InnerObserver(o, parent) { - this.o = o; - this.accumulator = parent.accumulator; - this.hasSeed = parent.hasSeed; - this.seed = parent.seed; - this.hasAccumulation = false; - this.accumulation = null; - this.hasValue = false; - this.isStopped = false; - } - InnerObserver.prototype = { - onNext: function (x) { - if (this.isStopped) { return; } - !this.hasValue && (this.hasValue = true); - if (this.hasAccumulation) { - this.accumulation = tryCatch(this.accumulator)(this.accumulation, x); + var ScanObserver = (function (__super__) { + inherits(ScanObserver, __super__); + function ScanObserver(o, parent) { + this._o = o; + this._p = parent; + this._fn = parent.accumulator; + this._hs = parent.hasSeed; + this._s = parent.seed; + this._ha = false; + this._a = null; + this._hv = false; + this._i = 0; + __super__.call(this); + } + + ScanObserver.prototype.next = function (x) { + !this._hv && (this._hv = true); + if (this._ha) { + this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); } else { - this.accumulation = this.hasSeed ? tryCatch(this.accumulator)(this.seed, x) : x; - this.hasAccumulation = true; + this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; + this._ha = true; } - if (this.accumulation === errorObj) { return this.o.onError(this.accumulation.e); } - this.o.onNext(this.accumulation); - }, - onError: function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }, - onCompleted: function () { - if (!this.isStopped) { - this.isStopped = true; - !this.hasValue && this.hasSeed && this.o.onNext(this.seed); - this.o.onCompleted(); - } - }, - dispose: function() { this.isStopped = true; }, - fail: function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; - } - }; + if (this._a === errorObj) { return this._o.onError(this._a.e); } + this._o.onNext(this._a); + this._i++; + }; + + ScanObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ScanObserver.prototype.completed = function () { + !this._hv && this._hs && this._o.onNext(this._s); + this._o.onCompleted(); + }; + + return ScanObserver; + }(AbstractObserver)); /** * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. @@ -4083,7 +4931,47 @@ observableProto.zipIterable = function () { } return new ScanObservable(this, accumulator, hasSeed, seed); }; - + + var SkipLastObservable = (function (__super__) { + inherits(SkipLastObservable, __super__); + function SkipLastObservable(source, c) { + this.source = source; + this._c = c; + __super__.call(this); + } + + SkipLastObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastObserver(o, this._c)); + }; + + return SkipLastObservable; + }(ObservableBase)); + + var SkipLastObserver = (function (__super__) { + inherits(SkipLastObserver, __super__); + function SkipLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + SkipLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._o.onNext(this._q.shift()); + }; + + SkipLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + SkipLastObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return SkipLastObserver; + }(AbstractObserver)); + /** * Bypasses a specified number of elements at the end of an observable sequence. * @description @@ -4094,16 +4982,9 @@ observableProto.zipIterable = function () { */ observableProto.skipLast = function (count) { if (count < 0) { throw new ArgumentOutOfRangeError(); } - var source = this; - return new AnonymousObservable(function (o) { - var q = []; - return source.subscribe(function (x) { - q.push(x); - q.length > count && o.onNext(q.shift()); - }, function (e) { o.onError(e); }, function () { o.onCompleted(); }); - }, source); + return new SkipLastObservable(this, count); }; - + /** * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend. * @example @@ -4123,7 +5004,33 @@ observableProto.zipIterable = function () { for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); } return enumerableOf([observableFromArray(args, scheduler), this]).concat(); }; - + + var TakeLastObserver = (function (__super__) { + inherits(TakeLastObserver, __super__); + function TakeLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastObserver.prototype.completed = function () { + while (this._q.length > 0) { this._o.onNext(this._q.shift()); } + this._o.onCompleted(); + }; + + return TakeLastObserver; + }(AbstractObserver)); + /** * Returns a specified number of contiguous elements from the end of an observable sequence. * @description @@ -4136,20 +5043,424 @@ observableProto.zipIterable = function () { if (count < 0) { throw new ArgumentOutOfRangeError(); } var source = this; return new AnonymousObservable(function (o) { - var q = []; - return source.subscribe(function (x) { - q.push(x); - q.length > count && q.shift(); - }, function (e) { o.onError(e); }, function () { - while (q.length > 0) { o.onNext(q.shift()); } - o.onCompleted(); + return source.subscribe(new TakeLastObserver(o, count)); + }, source); + }; + + var TakeLastBufferObserver = (function (__super__) { + inherits(TakeLastBufferObserver, __super__); + function TakeLastBufferObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastBufferObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastBufferObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastBufferObserver.prototype.completed = function () { + this._o.onNext(this._q); + this._o.onCompleted(); + }; + + return TakeLastBufferObserver; + }(AbstractObserver)); + + /** + * Returns an array with the specified number of contiguous elements from the end of an observable sequence. + * + * @description + * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the + * source sequence, this buffer is produced on the result sequence. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence. + */ + observableProto.takeLastBuffer = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastBufferObserver(o, count)); + }, source); + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on element count information. + * @param {Number} count Length of each window. + * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithCount = function (count, skip) { + var source = this; + +count || (count = 0); + Math.abs(count) === Infinity && (count = 0); + if (count <= 0) { throw new ArgumentOutOfRangeError(); } + skip == null && (skip = count); + +skip || (skip = 0); + Math.abs(skip) === Infinity && (skip = 0); + + if (skip <= 0) { throw new ArgumentOutOfRangeError(); } + return new AnonymousObservable(function (observer) { + var m = new SingleAssignmentDisposable(), + refCountDisposable = new RefCountDisposable(m), + n = 0, + q = []; + + function createWindow () { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + + createWindow(); + + m.setDisposable(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + var c = n - count + 1; + c >= 0 && c % skip === 0 && q.shift().onCompleted(); + ++n % skip === 0 && createWindow(); + }, + function (e) { + while (q.length > 0) { q.shift().onError(e); } + observer.onError(e); + }, + function () { + while (q.length > 0) { q.shift().onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function concatMap(source, selector, thisArg) { + var selectorFunc = bindCallback(selector, thisArg, 3); + return source.map(function (x, i) { + var result = selectorFunc(x, i, source); + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result)); + return result; + }).concatAll(); + } + + /** + * One of the Following: + * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * + * @example + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }); + * Or: + * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence. + * + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; }); + * Or: + * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence. + * + * var res = source.concatMap(Rx.Observable.fromArray([1,2,3])); + * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the + * source sequence onto which could be either an observable or Promise. + * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element. + */ + observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) { + if (isFunction(selector) && isFunction(resultSelector)) { + return this.concatMap(function (x, i) { + var selectorResult = selector(x, i); + isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult)); + (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult)); + + return selectorResult.map(function (y, i2) { + return resultSelector(x, y, i, i2); + }); }); + } + return isFunction(selector) ? + concatMap(this, selector, thisArg) : + concatMap(this, function () { return selector; }); + }; + + /** + * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) { + var source = this, + onNextFunc = bindCallback(onNext, thisArg, 2), + onErrorFunc = bindCallback(onError, thisArg, 1), + onCompletedFunc = bindCallback(onCompleted, thisArg, 0); + return new AnonymousObservable(function (observer) { + var index = 0; + return source.subscribe( + function (x) { + var result; + try { + result = onNextFunc(x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onErrorFunc(err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompletedFunc(); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, this).concatAll(); + }; + + var DefaultIfEmptyObserver = (function (__super__) { + inherits(DefaultIfEmptyObserver, __super__); + function DefaultIfEmptyObserver(o, d) { + this._o = o; + this._d = d; + this._f = false; + __super__.call(this); + } + + DefaultIfEmptyObserver.prototype.next = function (x) { + this._f = true; + this._o.onNext(x); + }; + + DefaultIfEmptyObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + DefaultIfEmptyObserver.prototype.completed = function () { + !this._f && this._o.onNext(defaultValue); + this._o.onCompleted(); + }; + + return DefaultIfEmptyObserver; + }(AbstractObserver)); + + /** + * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty. + * + * var res = obs = xs.defaultIfEmpty(); + * 2 - obs = xs.defaultIfEmpty(false); + * + * @memberOf Observable# + * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null. + * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. + */ + observableProto.defaultIfEmpty = function (defaultValue) { + var source = this; + defaultValue === undefined && (defaultValue = null); + return new AnonymousObservable(function (o) { + return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue)); + }, source); + }; + + // Swap out for Array.findIndex + function arrayIndexOfComparer(array, item, comparer) { + for (var i = 0, len = array.length; i < len; i++) { + if (comparer(array[i], item)) { return i; } + } + return -1; + } + + function HashSet(comparer) { + this.comparer = comparer; + this.set = []; + } + HashSet.prototype.push = function(value) { + var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1; + retValue && this.set.push(value); + return retValue; + }; + + var DistinctObservable = (function (__super__) { + inherits(DistinctObservable, __super__); + function DistinctObservable(source, keyFn, cmpFn) { + this.source = source; + this._keyFn = keyFn; + this._cmpFn = cmpFn; + __super__.call(this); + } + + DistinctObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn)); + }; + + return DistinctObservable; + }(ObservableBase)); + + var DistinctObserver = (function (__super__) { + inherits(DistinctObserver, __super__); + function DistinctObserver(o, keyFn, cmpFn) { + this._o = o; + this._keyFn = keyFn; + this._h = new HashSet(cmpFn); + __super__.call(this); + } + + DistinctObserver.prototype.next = function (x) { + var key = x; + if (isFunction(this._keyFn)) { + key = tryCatch(this._keyFn)(x); + if (key === errorObj) { return this._o.onError(key.e); } + } + this._h.push(key) && this._o.onNext(x); + }; + + DistinctObserver.prototype.error = function (e) { this._o.onError(e); }; + DistinctObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DistinctObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. + * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. + * + * @example + * var res = obs = xs.distinct(); + * 2 - obs = xs.distinct(function (x) { return x.id; }); + * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; }); + * @param {Function} [keySelector] A function to compute the comparison key for each element. + * @param {Function} [comparer] Used to compare items in the collection. + * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. + */ + observableProto.distinct = function (keySelector, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctObservable(this, keySelector, comparer); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. + * + * @example + * var res = observable.groupBy(function (x) { return x.id; }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} [elementSelector] A function to map each source element to an element in an observable group. + * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + */ + observableProto.groupBy = function (keySelector, elementSelector) { + return this.groupByUntil(keySelector, elementSelector, observableNever); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function. + * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same + * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request. + * + * @example + * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} durationSelector A function to signal the expiration of a group. + * @returns {Observable} + * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered. + * + */ + observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) { + var source = this; + return new AnonymousObservable(function (o) { + var map = new Map(), + groupDisposable = new CompositeDisposable(), + refCountDisposable = new RefCountDisposable(groupDisposable), + handleError = function (e) { return function (item) { item.onError(e); }; }; + + groupDisposable.add( + source.subscribe(function (x) { + var key = tryCatch(keySelector)(x); + if (key === errorObj) { + map.forEach(handleError(key.e)); + return o.onError(key.e); + } + + var fireNewMapEntry = false, writer = map.get(key); + if (writer === undefined) { + writer = new Subject(); + map.set(key, writer); + fireNewMapEntry = true; + } + + if (fireNewMapEntry) { + var group = new GroupedObservable(key, writer, refCountDisposable), + durationGroup = new GroupedObservable(key, writer); + var duration = tryCatch(durationSelector)(durationGroup); + if (duration === errorObj) { + map.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + o.onNext(group); + + var md = new SingleAssignmentDisposable(); + groupDisposable.add(md); + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, + function () { + if (map['delete'](key)) { writer.onCompleted(); } + groupDisposable.remove(md); + })); + } + + var element = x; + if (isFunction(elementSelector)) { + element = tryCatch(elementSelector)(x); + if (element === errorObj) { + map.forEach(handleError(element.e)); + return o.onError(element.e); + } + } + + writer.onNext(element); + }, function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, function () { + map.forEach(function (item) { item.onCompleted(); }); + o.onCompleted(); + })); + + return refCountDisposable; }, source); }; - -observableProto.flatMapConcat = observableProto.concatMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(1); -}; + var MapObservable = (function (__super__) { inherits(MapObservable, __super__); @@ -4171,35 +5482,27 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r return this.source.subscribe(new InnerObserver(o, this.selector, this)); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, selector, source) { this.o = o; this.selector = selector; this.source = source; this.i = 0; - this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function(x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function(x) { var result = tryCatch(this.selector)(x, this.i++, this.source); if (result === errorObj) { return this.o.onError(result.e); } this.o.onNext(result); }; - InnerObserver.prototype.onError = function (e) { - if(!this.isStopped) { this.isStopped = true; this.o.onError(e); } - }; - InnerObserver.prototype.onCompleted = function () { - if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); } + + InnerObserver.prototype.error = function (e) { + this.o.onError(e); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + InnerObserver.prototype.completed = function () { + this.o.onCompleted(); }; return MapObservable; @@ -4218,7 +5521,7 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r this.internalMap(selectorFn, thisArg) : new MapObservable(this, selectorFn, thisArg); }; - + function plucker(args, len) { return function mapper(x) { var currentProp = x; @@ -4246,7 +5549,7 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r for(var i = 0; i < len; i++) { args[i] = arguments[i]; } return this.map(plucker(args, len)); }; - + observableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) { return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll(); }; @@ -4257,14 +5560,66 @@ observableProto.flatMap = observableProto.selectMany = function(selector, result // return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); //}; // - -Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); -}; - var SkipObservable = (function(__super__) { - inherits(SkipObservable, __super__); - function SkipObservable(source, count) { - this.source = source; + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) { + var source = this; + return new AnonymousObservable(function (observer) { + var index = 0; + + return source.subscribe( + function (x) { + var result; + try { + result = onNext.call(thisArg, x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onError.call(thisArg, err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompleted.call(thisArg); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, source).mergeAll(); + }; + +Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); +}; + var SkipObservable = (function(__super__) { + inherits(SkipObservable, __super__); + function SkipObservable(source, count) { + this.source = source; this.skipCount = count; __super__.call(this); } @@ -4314,7 +5669,47 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA observableProto.skip = function (count) { if (count < 0) { throw new ArgumentOutOfRangeError(); } return new SkipObservable(this, count); - }; + }; + var SkipWhileObservable = (function (__super__) { + inherits(SkipWhileObservable, __super__); + function SkipWhileObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + SkipWhileObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipWhileObserver(o, this)); + }; + + return SkipWhileObservable; + }(ObservableBase)); + + var SkipWhileObserver = (function (__super__) { + inherits(SkipWhileObserver, __super__); + + function SkipWhileObserver(o, p) { + this._o = o; + this._p = p; + this._i = 0; + this._r = false; + __super__.call(this); + } + + SkipWhileObserver.prototype.next = function (x) { + if (!this._r) { + var res = tryCatch(this._p._fn)(x, this._i++, this._p); + if (res === errorObj) { return this._o.onError(res.e); } + this._r = !res; + } + this._r && this._o.onNext(x); + }; + SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWhileObserver; + }(AbstractObserver)); + /** * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. * The element's index is used in the logic of the predicate function. @@ -4326,29 +5721,65 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. */ observableProto.skipWhile = function (predicate, thisArg) { - var source = this, - callback = bindCallback(predicate, thisArg, 3); - return new AnonymousObservable(function (o) { - var i = 0, running = false; - return source.subscribe(function (x) { - if (!running) { - try { - running = !callback(x, i++, source); - } catch (e) { - o.onError(e); - return; - } - } - running && o.onNext(x); - }, function (e) { o.onError(e); }, function () { o.onCompleted(); }); - }, source); + var fn = bindCallback(predicate, thisArg, 3); + return new SkipWhileObservable(this, fn); }; - + + var TakeObservable = (function(__super__) { + inherits(TakeObservable, __super__); + + function TakeObservable(source, count) { + this.source = source; + this.takeCount = count; + __super__.call(this); + } + + TakeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.takeCount)); + }; + + function InnerObserver(o, c) { + this.o = o; + this.c = c; + this.r = c; + this.isStopped = false; + } + InnerObserver.prototype = { + onNext: function (x) { + if (this.isStopped) { return; } + if (this.r-- > 0) { + this.o.onNext(x); + this.r <= 0 && this.o.onCompleted(); + } + }, + onError: function (err) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }, + onCompleted: function () { + if (!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }, + dispose: function () { this.isStopped = true; }, + fail: function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + } + }; + + return TakeObservable; + }(ObservableBase)); + /** * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0). - * - * var res = source.take(5); - * var res = source.take(0, Rx.Scheduler.timeout); * @param {Number} count The number of elements to return. * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.value = null; + this.error = null; + } + }); + + return BehaviorSubject; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. + */ + var ReplaySubject = Rx.ReplaySubject = (function (__super__) { + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function createRemovableDisposable(subject, observer) { + return disposableCreate(function () { + observer.dispose(); + !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); + }); + } + + inherits(ReplaySubject, __super__); + + /** + * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. + * @param {Number} [bufferSize] Maximum element count of the replay buffer. + * @param {Number} [windowSize] Maximum time length of the replay buffer. + * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. + */ + function ReplaySubject(bufferSize, windowSize, scheduler) { + this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; + this.windowSize = windowSize == null ? maxSafeInteger : windowSize; + this.scheduler = scheduler || currentThreadScheduler; + this.q = []; + this.observers = []; + this.isStopped = false; + this.isDisposed = false; + this.hasError = false; + this.error = null; + __super__.call(this); + } + + addProperties(ReplaySubject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so); + + this._trim(this.scheduler.now()); + this.observers.push(so); + + for (var i = 0, len = this.q.length; i < len; i++) { + so.onNext(this.q[i].value); + } + + if (this.hasError) { + so.onError(this.error); + } else if (this.isStopped) { + so.onCompleted(); + } + + so.ensureActive(); + return subscription; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + return this.observers.length > 0; + }, + _trim: function (now) { + while (this.q.length > this.bufferSize) { + this.q.shift(); + } + while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { + this.q.shift(); + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + var now = this.scheduler.now(); + this.q.push({ interval: now, value: value }); + this._trim(now); + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onNext(value); + observer.ensureActive(); + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.error = error; + this.hasError = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onError(error); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onCompleted(); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + return ReplaySubject; + }(Observable)); + + var RefCountObservable = (function (__super__) { + inherits(RefCountObservable, __super__); + function RefCountObservable(source) { + this.source = source; + this._count = 0; + this._connectableSubscription = null; + __super__.call(this); + } + + RefCountObservable.prototype.subscribeCore = function (o) { + var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o); + shouldConnect && (this._connectableSubscription = this.source.connect()); + return new RefCountDisposable(this, subscription); + }; + + function RefCountDisposable(p, s) { + this._p = p; + this._s = s; + this.isDisposed = false; + } + + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.dispose(); + --this._p._count === 0 && this._p._connectableSubscription.dispose(); + } + }; + + return RefCountObservable; + }(ObservableBase)); + + var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { + inherits(ConnectableObservable, __super__); + function ConnectableObservable(source, subject) { + this.source = source; + this._hasSubscription = false; + this._subscription = null; + this._sourceObservable = source.asObservable(); + this._subject = subject; + __super__.call(this); + } + + function ConnectDisposable(parent) { + this._p = parent; + this.isDisposed = false; + } + + ConnectDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._p._hasSubscription = false; + } + }; + + ConnectableObservable.prototype.connect = function () { + if (!this._hasSubscription) { + this._hasSubscription = true; + this._subscription = new BinaryDisposable( + this._sourceObservable.subscribe(this._subject), + new ConnectDisposable(this) + ); + } + return this._subscription; + }; + + ConnectableObservable.prototype._subscribe = function (o) { + return this._subject.subscribe(o); + }; + + ConnectableObservable.prototype.refCount = function () { + return new RefCountObservable(this); + }; + + return ConnectableObservable; + }(Observable)); + + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence + * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`) + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source. + */ + observableProto.singleInstance = function() { + var source = this, hasObservable = false, observable; + + function getObservable() { + if (!hasObservable) { + hasObservable = true; + observable = source.finally(function() { hasObservable = false; }).publish().refCount(); + } + return observable; + } + + return new AnonymousObservable(function(o) { + return getObservable().subscribe(o); + }); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var leftDone = false, rightDone = false; + var leftId = 0, rightId = 0; + var leftMap = new Map(), rightMap = new Map(); + var handleError = function (e) { o.onError(e); }; + + group.add(left.subscribe( + function (value) { + var id = leftId++, md = new SingleAssignmentDisposable(); + + leftMap.set(id, value); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted(); + group.remove(md); + })); + + rightMap.forEach(function (v) { + var result = tryCatch(resultSelector)(value, v); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + leftDone = true; + (rightDone || leftMap.size === 0) && o.onCompleted(); + }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++, md = new SingleAssignmentDisposable(); + + rightMap.set(id, value); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted(); + group.remove(md); + })); + + leftMap.forEach(function (v) { + var result = tryCatch(resultSelector)(v, value); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + rightDone = true; + (leftDone || rightMap.size === 0) && o.onCompleted(); + }) + ); + return group; + }, left); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations, and groups the results. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var r = new RefCountDisposable(group); + var leftMap = new Map(), rightMap = new Map(); + var leftId = 0, rightId = 0; + var handleError = function (e) { return function (v) { v.onError(e); }; }; + + function handleError(e) { }; + + group.add(left.subscribe( + function (value) { + var s = new Subject(); + var id = leftId++; + leftMap.set(id, s); + + var result = tryCatch(resultSelector)(value, addRef(s, r)); + if (result === errorObj) { + leftMap.forEach(handleError(result.e)); + return o.onError(result.e); + } + o.onNext(result); + + rightMap.forEach(function (v) { s.onNext(v); }); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + leftMap['delete'](id) && s.onCompleted(); + group.remove(md); + })); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { o.onCompleted(); }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++; + rightMap.set(id, value); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + rightMap['delete'](id); + group.remove(md); + })); + + leftMap.forEach(function (v) { v.onNext(value); }); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }) + ); + + return r; + }, left); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers. + * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.buffer = function () { + return this.window.apply(this, arguments) + .flatMap(toArray); + }; + + /** + * Projects each element of an observable sequence into zero or more windows. + * + * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { + if (arguments.length === 1 && typeof arguments[0] !== 'function') { + return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector); + } + return typeof windowOpeningsOrClosingSelector === 'function' ? + observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) : + observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector); + }; + + function observableWindowWithOpenings(windowOpenings, windowClosingSelector) { + return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) { + return win; + }); + } + + function observableWindowWithBoundaries(windowBoundaries) { + var source = this; + return new AnonymousObservable(function (observer) { + var win = new Subject(), + d = new CompositeDisposable(), + r = new RefCountDisposable(d); + + observer.onNext(addRef(win, r)); + + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries)); + + d.add(windowBoundaries.subscribe(function (w) { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + return r; + }, source); + } + + function observableWindowWithClosingSelector(windowClosingSelector) { + var source = this; + return new AnonymousObservable(function (observer) { + var m = new SerialDisposable(), + d = new CompositeDisposable(m), + r = new RefCountDisposable(d), + win = new Subject(); + observer.onNext(addRef(win, r)); + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + function createWindowClose () { + var windowClose; + try { + windowClose = windowClosingSelector(); + } catch (e) { + observer.onError(e); + return; + } + + isPromise(windowClose) && (windowClose = observableFromPromise(windowClose)); + + var m1 = new SingleAssignmentDisposable(); + m.setDisposable(m1); + m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + createWindowClose(); + })); + } + + createWindowClose(); + return r; + }, source); } - + + /** + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. + * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array. + */ + observableProto.pairwise = function () { + var source = this; + return new AnonymousObservable(function (observer) { + var previous, hasPrevious = false; + return source.subscribe( + function (x) { + if (hasPrevious) { + observer.onNext([previous, x]); + } else { + hasPrevious = true; + } + previous = x; + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer)); + }, source); + }; + /** - * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each - * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's - * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay. + * Returns two observables which partition the observations of the source by the given function. + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes + * when the source completes. + * @param {Function} predicate + * The function to determine which output Observable will trigger a particular observation. + * @returns {Array} + * An array of observables. The first triggers when the predicate returns true, + * and the second triggers when the predicate returns false. + */ + observableProto.partition = function(predicate, thisArg) { + return [ + this.filter(predicate, thisArg), + this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); }) + ]; + }; + + var WhileEnumerable = (function(__super__) { + inherits(WhileEnumerable, __super__); + function WhileEnumerable(c, s) { + this.c = c; + this.s = s; + } + WhileEnumerable.prototype[$iterator$] = function () { + var self = this; + return { + next: function () { + return self.c() ? + { done: false, value: self.s } : + { done: true, value: void 0 }; + } + }; + }; + return WhileEnumerable; + }(Enumerable)); + + function enumerableWhile(condition, source) { + return new WhileEnumerable(condition, source); + } + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + observableProto.letBind = observableProto['let'] = function (func) { + return func(this); + }; + + /** + * Determines whether an observable collection contains values. * * @example - * 1 - res = source.multicast(observable); - * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; }); + * 1 - res = Rx.Observable.if(condition, obs1); + * 2 - res = Rx.Observable.if(condition, obs1, obs2); + * 3 - res = Rx.Observable.if(condition, obs1, scheduler); + * @param {Function} condition The condition which determines if the thenSource or elseSource will be run. + * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true. + * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. + * @returns {Observable} An observable sequence which is either the thenSource or elseSource. + */ + Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) { + return observableDefer(function () { + elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty()); + + isPromise(thenSource) && (thenSource = observableFromPromise(thenSource)); + isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler)); + + // Assume a scheduler for empty only + typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler)); + return condition() ? thenSource : elseSourceOrScheduler; + }); + }; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers 0) { + isOwner = !isAcquired; + isAcquired = true; + } + if (isOwner) { + m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) { + var work; + if (q.length > 0) { + work = q.shift(); + } else { + isAcquired = false; + return; + } + var m1 = new SingleAssignmentDisposable(); + d.add(m1); + m1.setDisposable(work.subscribe(function (x) { + o.onNext(x); + var result = null; + try { + result = selector(x); + } catch (e) { + o.onError(e); + } + q.push(result); + activeCount++; + ensureActive(); + }, function (e) { o.onError(e); }, function () { + d.remove(m1); + activeCount--; + if (activeCount === 0) { + o.onCompleted(); + } + })); + self(); + })); + } + }; + + q.push(source); + activeCount++; + ensureActive(); + return d; + }, this); }; - - /** - * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence. - * This operator is a specialization of Multicast using a regular Subject. + + /** + * Runs all observable sequences in parallel and collect their last elements. * * @example - * var resres = source.publish(); - * var res = source.publish(function (x) { return x; }); - * - * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + * 1 - res = Rx.Observable.forkJoin([obs1, obs2]); + * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences. */ - observableProto.publish = function (selector) { - return selector && isFunction(selector) ? - this.multicast(function () { return new Subject(); }, selector) : - this.multicast(new Subject()); + Observable.forkJoin = function () { + var allSources = []; + if (Array.isArray(arguments[0])) { + allSources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); } + } + return new AnonymousObservable(function (subscriber) { + var count = allSources.length; + if (count === 0) { + subscriber.onCompleted(); + return disposableEmpty; + } + var group = new CompositeDisposable(), + finished = false, + hasResults = new Array(count), + hasCompleted = new Array(count), + results = new Array(count); + + for (var idx = 0; idx < count; idx++) { + (function (i) { + var source = allSources[i]; + isPromise(source) && (source = observableFromPromise(source)); + group.add( + source.subscribe( + function (value) { + if (!finished) { + hasResults[i] = true; + results[i] = value; + } + }, + function (e) { + finished = true; + subscriber.onError(e); + group.dispose(); + }, + function () { + if (!finished) { + if (!hasResults[i]) { + subscriber.onCompleted(); + return; + } + hasCompleted[i] = true; + for (var ix = 0; ix < count; ix++) { + if (!hasCompleted[ix]) { return; } + } + finished = true; + subscriber.onNext(results); + subscriber.onCompleted(); + } + })); + })(idx); + } + + return group; + }); + }; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * @param {Observable} second Second observable sequence. + * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + observableProto.forkJoin = function (second, resultSelector) { + var first = this; + return new AnonymousObservable(function (observer) { + var leftStopped = false, rightStopped = false, + hasLeft = false, hasRight = false, + lastLeft, lastRight, + leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable(); + + isPromise(second) && (second = observableFromPromise(second)); + + leftSubscription.setDisposable( + first.subscribe(function (left) { + hasLeft = true; + lastLeft = left; + }, function (err) { + rightSubscription.dispose(); + observer.onError(err); + }, function () { + leftStopped = true; + if (rightStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + rightSubscription.setDisposable( + second.subscribe(function (right) { + hasRight = true; + lastRight = right; + }, function (err) { + leftSubscription.dispose(); + observer.onError(err); + }, function () { + rightStopped = true; + if (leftStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(result.e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }, first); }; - + /** - * Returns an observable sequence that shares a single subscription to the underlying sequence. - * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + * Comonadic bind operator. + * @param {Function} selector A transform function to apply to each element. + * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns {Observable} An observable sequence which results from the comonadic bind operation. */ - observableProto.share = function () { - return this.publish().refCount(); + observableProto.manySelect = observableProto.extend = function (selector, scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + var source = this; + return observableDefer(function () { + var chain; + + return source + .map(function (x) { + var curr = new ChainObservable(x); + + chain && chain.onNext(x); + chain = curr; + + return curr; + }) + .tap( + noop, + function (e) { chain && chain.onError(e); }, + function () { chain && chain.onCompleted(); } + ) + .observeOn(scheduler) + .map(selector); + }, source); }; - + + var ChainObservable = (function (__super__) { + inherits(ChainObservable, __super__); + function ChainObservable(head) { + __super__.call(this); + this.head = head; + this.tail = new AsyncSubject(); + } + + addProperties(ChainObservable.prototype, Observer, { + _subscribe: function (o) { + var g = new CompositeDisposable(); + g.add(currentThreadScheduler.schedule(this, function (_, self) { + o.onNext(self.head); + g.add(self.tail.mergeAll().subscribe(o)); + })); + + return g; + }, + onCompleted: function () { + this.onNext(Observable.empty()); + }, + onError: function (e) { + this.onNext(Observable['throw'](e)); + }, + onNext: function (v) { + this.tail.onNext(v); + this.tail.onCompleted(); + } + }); + + return ChainObservable; + + }(Observable)); + + var Map = root.Map || (function () { + function Map() { + this.size = 0; + this._values = []; + this._keys = []; + } + + Map.prototype['delete'] = function (key) { + var i = this._keys.indexOf(key); + if (i === -1) { return false; } + this._values.splice(i, 1); + this._keys.splice(i, 1); + this.size--; + return true; + }; + + Map.prototype.get = function (key) { + var i = this._keys.indexOf(key); + return i === -1 ? undefined : this._values[i]; + }; + + Map.prototype.set = function (key, value) { + var i = this._keys.indexOf(key); + if (i === -1) { + this._keys.push(key); + this._values.push(value); + this.size++; + } else { + this._values[i] = value; + } + return this; + }; + + Map.prototype.forEach = function (cb, thisArg) { + for (var i = 0; i < this.size; i++) { + cb.call(thisArg, this._values[i], this._keys[i]); + } + }; + + return Map; + }()); + /** - * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification. - * This operator is a specialization of Multicast using a AsyncSubject. - * - * @example - * var res = source.publishLast(); - * var res = source.publishLast(function (x) { return x; }); - * - * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + * @constructor + * Represents a join pattern over observable sequences. */ - observableProto.publishLast = function (selector) { - return selector && isFunction(selector) ? - this.multicast(function () { return new AsyncSubject(); }, selector) : - this.multicast(new AsyncSubject()); + function Pattern(patterns) { + this.patterns = patterns; + } + + /** + * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. + * @param other Observable sequence to match in addition to the current pattern. + * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value. + */ + Pattern.prototype.and = function (other) { + return new Pattern(this.patterns.concat(other)); }; - + /** - * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue. - * This operator is a specialization of Multicast using a BehaviorSubject. - * - * @example - * var res = source.publishValue(42); - * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42); - * - * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on. - * @param {Mixed} initialValue Initial value received by observers upon subscription. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. + * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. + * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. */ - observableProto.publishValue = function (initialValueOrSelector, initialValue) { - return arguments.length === 2 ? - this.multicast(function () { - return new BehaviorSubject(initialValue); - }, initialValueOrSelector) : - this.multicast(new BehaviorSubject(initialValueOrSelector)); + Pattern.prototype.thenDo = function (selector) { + return new Plan(this, selector); + }; + + function Plan(expression, selector) { + this.expression = expression; + this.selector = selector; + } + + Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) { + var self = this; + var joinObservers = []; + for (var i = 0, len = this.expression.patterns.length; i < len; i++) { + joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer))); + } + var activePlan = new ActivePlan(joinObservers, function () { + var result; + try { + result = self.selector.apply(self, arguments); + } catch (e) { + observer.onError(e); + return; + } + observer.onNext(result); + }, function () { + for (var j = 0, jlen = joinObservers.length; j < jlen; j++) { + joinObservers[j].removeActivePlan(activePlan); + } + deactivate(activePlan); + }); + for (i = 0, len = joinObservers.length; i < len; i++) { + joinObservers[i].addActivePlan(activePlan); + } + return activePlan; + }; + + function planCreateObserver(externalSubscriptions, observable, onError) { + var entry = externalSubscriptions.get(observable); + if (!entry) { + var observer = new JoinObserver(observable, onError); + externalSubscriptions.set(observable, observer); + return observer; + } + return entry; + } + + function ActivePlan(joinObserverArray, onNext, onCompleted) { + this.joinObserverArray = joinObserverArray; + this.onNext = onNext; + this.onCompleted = onCompleted; + this.joinObservers = new Map(); + for (var i = 0, len = this.joinObserverArray.length; i < len; i++) { + var joinObserver = this.joinObserverArray[i]; + this.joinObservers.set(joinObserver, joinObserver); + } + } + + ActivePlan.prototype.dequeue = function () { + this.joinObservers.forEach(function (v) { v.queue.shift(); }); + }; + + ActivePlan.prototype.match = function () { + var i, len, hasValues = true; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + if (this.joinObserverArray[i].queue.length === 0) { + hasValues = false; + break; + } + } + if (hasValues) { + var firstValues = [], + isCompleted = false; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + firstValues.push(this.joinObserverArray[i].queue[0]); + this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true); + } + if (isCompleted) { + this.onCompleted(); + } else { + this.dequeue(); + var values = []; + for (i = 0, len = firstValues.length; i < firstValues.length; i++) { + values.push(firstValues[i].value); + } + this.onNext.apply(this, values); + } + } }; - + + var JoinObserver = (function (__super__) { + inherits(JoinObserver, __super__); + + function JoinObserver(source, onError) { + __super__.call(this); + this.source = source; + this.onError = onError; + this.queue = []; + this.activePlans = []; + this.subscription = new SingleAssignmentDisposable(); + this.isDisposed = false; + } + + var JoinObserverPrototype = JoinObserver.prototype; + + JoinObserverPrototype.next = function (notification) { + if (!this.isDisposed) { + if (notification.kind === 'E') { + return this.onError(notification.error); + } + this.queue.push(notification); + var activePlans = this.activePlans.slice(0); + for (var i = 0, len = activePlans.length; i < len; i++) { + activePlans[i].match(); + } + } + }; + + JoinObserverPrototype.error = noop; + JoinObserverPrototype.completed = noop; + + JoinObserverPrototype.addActivePlan = function (activePlan) { + this.activePlans.push(activePlan); + }; + + JoinObserverPrototype.subscribe = function () { + this.subscription.setDisposable(this.source.materialize().subscribe(this)); + }; + + JoinObserverPrototype.removeActivePlan = function (activePlan) { + this.activePlans.splice(this.activePlans.indexOf(activePlan), 1); + this.activePlans.length === 0 && this.dispose(); + }; + + JoinObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + if (!this.isDisposed) { + this.isDisposed = true; + this.subscription.dispose(); + } + }; + + return JoinObserver; + } (AbstractObserver)); + /** - * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue. - * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * @param {Mixed} initialValue Initial value received by observers upon subscription. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + * Creates a pattern that matches when both observable sequences have an available value. + * + * @param right Observable sequence to match with the current sequence. + * @return {Pattern} Pattern object that matches when both observable sequences have an available value. */ - observableProto.shareValue = function (initialValue) { - return this.publishValue(initialValue).refCount(); + observableProto.and = function (right) { + return new Pattern([this, right]); }; - + /** - * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer. - * This operator is a specialization of Multicast using a ReplaySubject. - * - * @example - * var res = source.replay(null, 3); - * var res = source.replay(null, 3, 500); - * var res = source.replay(null, 3, 500, scheduler); - * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler); + * Matches when the observable sequence has an available value and projects the value. * - * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy. - * @param bufferSize [Optional] Maximum element count of the replay buffer. - * @param windowSize [Optional] Maximum time length of the replay buffer. - * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + * @param {Function} selector Selector that will be invoked for values in the source sequence. + * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. */ - observableProto.replay = function (selector, bufferSize, windowSize, scheduler) { - return selector && isFunction(selector) ? - this.multicast(function () { return new ReplaySubject(bufferSize, windowSize, scheduler); }, selector) : - this.multicast(new ReplaySubject(bufferSize, windowSize, scheduler)); + observableProto.thenDo = function (selector) { + return new Pattern([this]).thenDo(selector); }; - + /** - * Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer. - * This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + * Joins together the results from several patterns. * - * @example - * var res = source.shareReplay(3); - * var res = source.shareReplay(3, 500); - * var res = source.shareReplay(3, 500, scheduler); - * - - * @param bufferSize [Optional] Maximum element count of the replay buffer. - * @param window [Optional] Maximum time length of the replay buffer. - * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns. + * @returns {Observable} Observable sequence with the results form matching several patterns. */ - observableProto.shareReplay = function (bufferSize, windowSize, scheduler) { - return this.replay(null, bufferSize, windowSize, scheduler).refCount(); - }; - - var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { - inherits(ConnectableObservable, __super__); - - function ConnectableObservable(source, subject) { - var hasSubscription = false, - subscription, - sourceObservable = source.asObservable(); - - this.connect = function () { - if (!hasSubscription) { - hasSubscription = true; - subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () { - hasSubscription = false; + Observable.when = function () { + var len = arguments.length, plans; + if (Array.isArray(arguments[0])) { + plans = arguments[0]; + } else { + plans = new Array(len); + for(var i = 0; i < len; i++) { plans[i] = arguments[i]; } + } + return new AnonymousObservable(function (o) { + var activePlans = [], + externalSubscriptions = new Map(); + var outObserver = observerCreate( + function (x) { o.onNext(x); }, + function (err) { + externalSubscriptions.forEach(function (v) { v.onError(err); }); + o.onError(err); + }, + function (x) { o.onCompleted(); } + ); + try { + for (var i = 0, len = plans.length; i < len; i++) { + activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) { + var idx = activePlans.indexOf(activePlan); + activePlans.splice(idx, 1); + activePlans.length === 0 && o.onCompleted(); })); } - return subscription; - }; + } catch (e) { + observableThrow(e).subscribe(o); + } + var group = new CompositeDisposable(); + externalSubscriptions.forEach(function (joinObserver) { + joinObserver.subscribe(); + group.add(joinObserver); + }); + + return group; + }); + }; - __super__.call(this, function (o) { return subject.subscribe(o); }); + var TimerObservable = (function(__super__) { + inherits(TimerObservable, __super__); + function TimerObservable(dt, s) { + this._dt = dt; + this._s = s; + __super__.call(this); } - ConnectableObservable.prototype.refCount = function () { - var connectableSubscription, count = 0, source = this; - return new AnonymousObservable(function (observer) { - var shouldConnect = ++count === 1, - subscription = source.subscribe(observer); - shouldConnect && (connectableSubscription = source.connect()); - return function () { - subscription.dispose(); - --count === 0 && connectableSubscription.dispose(); - }; - }); + TimerObservable.prototype.subscribeCore = function (o) { + return this._s.scheduleFuture(o, this._dt, scheduleMethod); }; - return ConnectableObservable; - }(Observable)); - - function observableTimerDate(dueTime, scheduler) { - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithAbsolute(dueTime, function () { - observer.onNext(0); - observer.onCompleted(); - }); - }); + function scheduleMethod(s, o) { + o.onNext(0); + o.onCompleted(); + } + + return TimerObservable; + }(ObservableBase)); + + function _observableTimer(dueTime, scheduler) { + return new TimerObservable(dueTime, scheduler); } - + function observableTimerDateAndPeriod(dueTime, period, scheduler) { return new AnonymousObservable(function (observer) { var d = dueTime, p = normalizeTime(period); - return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) { + return scheduler.scheduleRecursiveFuture(0, d, function (count, self) { if (p > 0) { var now = scheduler.now(); d = d + p; d <= now && (d = now + p); } observer.onNext(count); - self(count + 1, d); - }); - }); - } - - function observableTimerTimeSpan(dueTime, scheduler) { - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithRelative(normalizeTime(dueTime), function () { - observer.onNext(0); - observer.onCompleted(); + self(count + 1, new Date(d)); }); }); } - + function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { return dueTime === period ? new AnonymousObservable(function (observer) { - return scheduler.schedulePeriodicWithState(0, period, function (count) { + return scheduler.schedulePeriodic(0, period, function (count) { observer.onNext(count); return count + 1; }); }) : observableDefer(function () { - return observableTimerDateAndPeriod(scheduler.now() + dueTime, period, scheduler); + return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler); }); } - + /** * Returns an observable sequence that produces a value after each period. * @@ -4975,9 +9662,9 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { * @returns {Observable} An observable sequence that produces a value after each period. */ var observableinterval = Observable.interval = function (period, scheduler) { - return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : timeoutScheduler); + return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler); }; - + /** * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. @@ -4987,23 +9674,21 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { */ var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { var period; - isScheduler(scheduler) || (scheduler = timeoutScheduler); + isScheduler(scheduler) || (scheduler = defaultScheduler); if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { period = periodOrScheduler; } else if (isScheduler(periodOrScheduler)) { scheduler = periodOrScheduler; } - if (dueTime instanceof Date && period === undefined) { - return observableTimerDate(dueTime.getTime(), scheduler); + if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) { + return _observableTimer(dueTime, scheduler); } if (dueTime instanceof Date && period !== undefined) { return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler); } - return period === undefined ? - observableTimerTimeSpan(dueTime, scheduler) : - observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); + return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); }; - + function observableDelayRelative(source, dueTime, scheduler) { return new AnonymousObservable(function (o) { var active = false, @@ -5017,7 +9702,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { if (notification.value.kind === 'E') { q = []; q.push(notification); - exception = notification.value.exception; + exception = notification.value.error; shouldRun = !running; } else { q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); @@ -5030,7 +9715,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { } else { d = new SingleAssignmentDisposable(); cancelable.setDisposable(d); - d.setDisposable(scheduler.scheduleRecursiveWithRelative(dueTime, function (self) { + d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) { var e, recurseDueTime, result, shouldRecurse; if (exception !== null) { return; @@ -5058,13 +9743,13 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { if (e !== null) { o.onError(e); } else if (shouldRecurse) { - self(recurseDueTime); + self(null, recurseDueTime); } })); } } }); - return new CompositeDisposable(subscription, cancelable); + return new BinaryDisposable(subscription, cancelable); }, source); } @@ -5125,7 +9810,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); } - return new CompositeDisposable(subscription, delays); + return new BinaryDisposable(subscription, delays); }, this); } @@ -5138,52 +9823,82 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { * @returns {Observable} Time-shifted sequence. */ observableProto.delay = function () { - if (typeof arguments[0] === 'number' || arguments[0] instanceof Date) { - var dueTime = arguments[0], scheduler = arguments[1]; - isScheduler(scheduler) || (scheduler = timeoutScheduler); + var firstArg = arguments[0]; + if (typeof firstArg === 'number' || firstArg instanceof Date) { + var dueTime = firstArg, scheduler = arguments[1]; + isScheduler(scheduler) || (scheduler = defaultScheduler); return dueTime instanceof Date ? observableDelayAbsolute(this, dueTime, scheduler) : observableDelayRelative(this, dueTime, scheduler); - } else if (isFunction(arguments[0])) { - return delayWithSelector(this, arguments[0], arguments[1]); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return delayWithSelector(this, firstArg, arguments[1]); } else { throw new Error('Invalid arguments'); } }; - - function debounce(source, dueTime, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return new AnonymousObservable(function (observer) { - var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0; - var subscription = source.subscribe( - function (x) { - hasvalue = true; - value = x; - id++; - var currentId = id, - d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () { - hasvalue && id === currentId && observer.onNext(value); - hasvalue = false; - })); - }, - function (e) { - cancelable.dispose(); - observer.onError(e); - hasvalue = false; - id++; - }, - function () { - cancelable.dispose(); - hasvalue && observer.onNext(value); - observer.onCompleted(); - hasvalue = false; - id++; - }); - return new CompositeDisposable(subscription, cancelable); - }, this); - } + + var DebounceObservable = (function (__super__) { + inherits(DebounceObservable, __super__); + function DebounceObservable(source, dt, s) { + isScheduler(s) || (s = defaultScheduler); + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DebounceObservable.prototype.subscribeCore = function (o) { + var cancelable = new SerialDisposable(); + return new BinaryDisposable( + this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)), + cancelable); + }; + + return DebounceObservable; + }(ObservableBase)); + + var DebounceObserver = (function (__super__) { + inherits(DebounceObserver, __super__); + function DebounceObserver(observer, source, dueTime, scheduler, cancelable) { + this._o = observer; + this._s = source; + this._d = dueTime; + this._scheduler = scheduler; + this._c = cancelable; + this._v = null; + this._hv = false; + this._id = 0; + __super__.call(this); + } + + DebounceObserver.prototype.next = function (x) { + this._hv = true; + this._v = x; + var currentId = ++this._id, d = new SingleAssignmentDisposable(); + this._c.setDisposable(d); + d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) { + self._hv && self._id === currentId && self._o.onNext(x); + self._hv = false; + })); + }; + + DebounceObserver.prototype.error = function (e) { + this._c.dispose(); + this._o.onError(e); + this._hv = false; + this._id++; + }; + + DebounceObserver.prototype.completed = function () { + this._c.dispose(); + this._hv && this._o.onNext(this._v); + this._o.onCompleted(); + this._hv = false; + this._id++; + }; + + return DebounceObserver; + }(AbstractObserver)); function debounceWithSelector(source, durationSelector) { return new AnonymousObservable(function (o) { @@ -5228,20 +9943,276 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { id++; } ); - return new CompositeDisposable(subscription, cancelable); + return new BinaryDisposable(subscription, cancelable); }, source); } - observableProto.debounce = function () { - if (isFunction (arguments[0])) { - return debounceWithSelector(this, arguments[0]); - } else if (typeof arguments[0] === 'number') { - return debounce(this, arguments[0], arguments[1]); - } else { - throw new Error('Invalid arguments'); - } - }; - + observableProto.debounce = function () { + if (isFunction (arguments[0])) { + return debounceWithSelector(this, arguments[0]); + } else if (typeof arguments[0] === 'number') { + return new DebounceObservable(this, arguments[0], arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on timing information. + * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + var source = this, timeShift; + timeShiftOrScheduler == null && (timeShift = timeSpan); + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (typeof timeShiftOrScheduler === 'number') { + timeShift = timeShiftOrScheduler; + } else if (isScheduler(timeShiftOrScheduler)) { + timeShift = timeSpan; + scheduler = timeShiftOrScheduler; + } + return new AnonymousObservable(function (observer) { + var groupDisposable, + nextShift = timeShift, + nextSpan = timeSpan, + q = [], + refCountDisposable, + timerD = new SerialDisposable(), + totalTime = 0; + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable); + + function createTimer () { + var m = new SingleAssignmentDisposable(), + isSpan = false, + isShift = false; + timerD.setDisposable(m); + if (nextSpan === nextShift) { + isSpan = true; + isShift = true; + } else if (nextSpan < nextShift) { + isSpan = true; + } else { + isShift = true; + } + var newTotalTime = isSpan ? nextSpan : nextShift, + ts = newTotalTime - totalTime; + totalTime = newTotalTime; + if (isSpan) { + nextSpan += timeShift; + } + if (isShift) { + nextShift += timeShift; + } + m.setDisposable(scheduler.scheduleFuture(null, ts, function () { + if (isShift) { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + isSpan && q.shift().onCompleted(); + createTimer(); + })); + }; + q.push(new Subject()); + observer.onNext(addRef(q[0], refCountDisposable)); + createTimer(); + groupDisposable.add(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + }, + function (e) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); } + observer.onError(e); + }, + function () { + for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + /** + * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a window. + * @param {Number} count Maximum element count of a window. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (observer) { + var timerD = new SerialDisposable(), + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable), + n = 0, + windowId = 0, + s = new Subject(); + + function createTimer(id) { + var m = new SingleAssignmentDisposable(); + timerD.setDisposable(m); + m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () { + if (id !== windowId) { return; } + n = 0; + var newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + createTimer(newId); + })); + } + + observer.onNext(addRef(s, refCountDisposable)); + createTimer(0); + + groupDisposable.add(source.subscribe( + function (x) { + var newId = 0, newWindow = false; + s.onNext(x); + if (++n === count) { + newWindow = true; + n = 0; + newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + } + newWindow && createTimer(newId); + }, + function (e) { + s.onError(e); + observer.onError(e); + }, function () { + s.onCompleted(); + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. + * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. + * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a buffer. + * @param {Number} count Maximum element count of a buffer. + * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) { + return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray); + }; + + var TimeIntervalObservable = (function (__super__) { + inherits(TimeIntervalObservable, __super__); + function TimeIntervalObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimeIntervalObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimeIntervalObserver(o, this._s)); + }; + + return TimeIntervalObservable; + }(ObservableBase)); + + var TimeIntervalObserver = (function (__super__) { + inherits(TimeIntervalObserver, __super__); + + function TimeIntervalObserver(o, s) { + this._o = o; + this._s = s; + this._l = s.now(); + __super__.call(this); + } + + TimeIntervalObserver.prototype.next = function (x) { + var now = this._s.now(), span = now - this._l; + this._l = now; + this._o.onNext({ value: x, interval: span }); + }; + TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); }; + TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return TimeIntervalObserver; + }(AbstractObserver)); + + /** + * Records the time interval between consecutive values in an observable sequence. + * + * @example + * 1 - res = source.timeInterval(); + * 2 - res = source.timeInterval(Rx.Scheduler.timeout); + * + * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence with time interval information on values. + */ + observableProto.timeInterval = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimeIntervalObservable(this, scheduler); + }; + + var TimestampObservable = (function (__super__) { + inherits(TimestampObservable, __super__); + function TimestampObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimestampObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimestampObserver(o, this._s)); + }; + + return TimestampObservable; + }(ObservableBase)); + + var TimestampObserver = (function (__super__) { + inherits(TimestampObserver, __super__); + function TimestampObserver(o, s) { + this._o = o; + this._s = s; + __super__.call(this); + } + + TimestampObserver.prototype.next = function (x) { + this._o.onNext({ value: x, timestamp: this._s.now() }); + }; + + TimestampObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TimestampObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return TimestampObserver; + }(AbstractObserver)); + /** * Records the timestamp for each value in an observable sequence. * @@ -5253,12 +10224,10 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { * @returns {Observable} An observable sequence with timestamp information on values. */ observableProto.timestamp = function (scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return this.map(function (x) { - return { value: x, timestamp: scheduler.now() }; - }); + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimestampObservable(this, scheduler); }; - + function sampleObservable(source, sampler) { return new AnonymousObservable(function (o) { var atEnd = false, value, hasValue = false; @@ -5280,11 +10249,11 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { function (e) { o.onError(e); }, function () { atEnd = true; - sourceSubscription.dispose(); + sourceSubscription.dispose(); } )); - return new CompositeDisposable( + return new BinaryDisposable( sourceSubscription, sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe) ); @@ -5304,12 +10273,12 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { * @returns {Observable} Sampled observable sequence. */ observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); + isScheduler(scheduler) || (scheduler = defaultScheduler); return typeof intervalOrSampler === 'number' ? sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : sampleObservable(this, intervalOrSampler); }; - + var TimeoutError = Rx.TimeoutError = function(message) { this.message = message || 'Timeout has occurred'; this.name = 'TimeoutError'; @@ -5325,7 +10294,9 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { } other || (other = observableThrow(new TimeoutError())); return new AnonymousObservable(function (o) { - var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable(); + var subscription = new SerialDisposable(), + timer = new SerialDisposable(), + original = new SingleAssignmentDisposable(); subscription.setDisposable(original); @@ -5333,14 +10304,20 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { function setTimer(timeout) { var myId = id, d = new SingleAssignmentDisposable(); + + function timerWins() { + switched = (myId === id); + return switched; + } + timer.setDisposable(d); d.setDisposable(timeout.subscribe(function () { - id === myId && subscription.setDisposable(other.subscribe(o)); + timerWins() && subscription.setDisposable(other.subscribe(o)); d.dispose(); }, function (e) { - id === myId && o.onError(e); + timerWins() && o.onError(e); }, function () { - id === myId && subscription.setDisposable(other.subscribe(o)); + timerWins() && subscription.setDisposable(other.subscribe(o)); })); }; @@ -5364,22 +10341,17 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { }, function () { oWins() && o.onCompleted(); })); - return new CompositeDisposable(subscription, timer); + return new BinaryDisposable(subscription, timer); }, source); } function timeout(source, dueTime, other, scheduler) { - if (other == null) { throw new Error('other or scheduler must be specified'); } if (isScheduler(other)) { scheduler = other; other = observableThrow(new TimeoutError()); } if (other instanceof Error) { other = observableThrow(other); } - isScheduler(scheduler) || (scheduler = timeoutScheduler); - - var schedulerMethod = dueTime instanceof Date ? - 'scheduleWithAbsolute' : - 'scheduleWithRelative'; + isScheduler(scheduler) || (scheduler = defaultScheduler); return new AnonymousObservable(function (o) { var id = 0, @@ -5390,50 +10362,555 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { subscription.setDisposable(original); - function createTimer() { - var myId = id; - timer.setDisposable(scheduler[schedulerMethod](dueTime, function () { - if (id === myId) { - isPromise(other) && (other = observableFromPromise(other)); - subscription.setDisposable(other.subscribe(o)); - } - })); - } + function createTimer() { + var myId = id; + timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () { + switched = id === myId; + if (switched) { + isPromise(other) && (other = observableFromPromise(other)); + subscription.setDisposable(other.subscribe(o)); + } + })); + } + + createTimer(); + + original.setDisposable(source.subscribe(function (x) { + if (!switched) { + id++; + o.onNext(x); + createTimer(); + } + }, function (e) { + if (!switched) { + id++; + o.onError(e); + } + }, function () { + if (!switched) { + id++; + o.onCompleted(); + } + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + observableProto.timeout = function () { + var firstArg = arguments[0]; + if (firstArg instanceof Date || typeof firstArg === 'number') { + return timeout(this, firstArg, arguments[1], arguments[2]); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var GenerateAbsoluteObservable = (function (__super__) { + inherits(GenerateAbsoluteObservable, __super__); + function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateAbsoluteObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive); + }; + + return GenerateAbsoluteObservable; + }(ObservableBase)); + + /** + * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithAbsoluteTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return new Date(); } + * }); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var GenerateRelativeObservable = (function (__super__) { + inherits(GenerateRelativeObservable, __super__); + function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateRelativeObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive); + }; + + return GenerateRelativeObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithRelativeTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return 500; } + * ); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var DelaySubscription = (function(__super__) { + inherits(DelaySubscription, __super__); + function DelaySubscription(source, dt, s) { + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DelaySubscription.prototype.subscribeCore = function (o) { + var d = new SerialDisposable(); + + d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod)); + + return d; + }; + + function scheduleMethod(s, state) { + var source = state[0], o = state[1], d = state[2]; + d.setDisposable(source.subscribe(o)); + } + + return DelaySubscription; + }(ObservableBase)); + + /** + * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.delaySubscription(5000); // 5s + * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds + * + * @param {Number} dueTime Relative or absolute time shift of the subscription. + * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delaySubscription = function (dueTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new DelaySubscription(this, dueTime, scheduler); + }; + + var SkipLastWithTimeObservable = (function (__super__) { + inherits(SkipLastWithTimeObservable, __super__); + function SkipLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + SkipLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastWithTimeObserver(o, this)); + }; + + return SkipLastWithTimeObservable; + }(ObservableBase)); + + var SkipLastWithTimeObserver = (function (__super__) { + inherits(SkipLastWithTimeObserver, __super__); + + function SkipLastWithTimeObserver(o, p) { + this._o = o; + this._s = p._s; + this._d = p._d; + this._q = []; + __super__.call(this); + } + + SkipLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + }; + SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + this._o.onCompleted(); + }; + + return SkipLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for skipping elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence. + */ + observableProto.skipLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipLastWithTimeObservable(this, duration, scheduler); + }; + + var TakeLastWithTimeObservable = (function (__super__) { + inherits(TakeLastWithTimeObservable, __super__); + function TakeLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + TakeLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s)); + }; + + return TakeLastWithTimeObservable; + }(ObservableBase)); + + var TakeLastWithTimeObserver = (function (__super__) { + inherits(TakeLastWithTimeObserver, __super__); + + function TakeLastWithTimeObserver(o, d, s) { + this._o = o; + this._d = d; + this._s = s; + this._q = []; + __super__.call(this); + } + + TakeLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._q.shift(); + } + }; + TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + TakeLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0) { + var next = this._q.shift(); + if (now - next.interval <= this._d) { this._o.onNext(next.value); } + } + this._o.onCompleted(); + }; + + return TakeLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeLastWithTimeObservable(this, duration, scheduler); + }; + + /** + * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastBufferWithTime = function (duration, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (o) { + var q = []; + return source.subscribe(function (x) { + var now = scheduler.now(); + q.push({ interval: now, value: x }); + while (q.length > 0 && now - q[0].interval >= duration) { + q.shift(); + } + }, function (e) { o.onError(e); }, function () { + var now = scheduler.now(), res = []; + while (q.length > 0) { + var next = q.shift(); + now - next.interval <= duration && res.push(next.value); + } + o.onNext(res); + o.onCompleted(); + }); + }, source); + }; + + var TakeWithTimeObservable = (function (__super__) { + inherits(TakeWithTimeObservable, __super__); + function TakeWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + function scheduleMethod(s, o) { + o.onCompleted(); + } + + TakeWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(o, this._d, scheduleMethod), + this.source.subscribe(o) + ); + }; + + return TakeWithTimeObservable; + }(ObservableBase)); + + /** + * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.takeWithTime(5000, [optional scheduler]); + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence. + */ + observableProto.takeWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeWithTimeObservable(this, duration, scheduler); + }; + + var SkipWithTimeObservable = (function (__super__) { + inherits(SkipWithTimeObservable, __super__); + function SkipWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + this._open = false; + __super__.call(this); + } + + function scheduleMethod(s, self) { + self._open = true; + } + + SkipWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(this, this._d, scheduleMethod), + this.source.subscribe(new SkipWithTimeObserver(o, this)) + ); + }; + + return SkipWithTimeObservable; + }(ObservableBase)); + + var SkipWithTimeObserver = (function (__super__) { + inherits(SkipWithTimeObserver, __super__); + + function SkipWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * @description + * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. + * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded + * may not execute immediately, despite the zero due time. + * + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. + * @param {Number} duration Duration for skipping elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence. + */ + observableProto.skipWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipWithTimeObservable(this, duration, scheduler); + }; + + var SkipUntilWithTimeObservable = (function (__super__) { + inherits(SkipUntilWithTimeObservable, __super__); + function SkipUntilWithTimeObservable(source, startTime, scheduler) { + this.source = source; + this._st = startTime; + this._s = scheduler; + __super__.call(this); + } + + function scheduleMethod(s, state) { + state._open = true; + } + + SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) { + this._open = false; + return new BinaryDisposable( + this._s.scheduleFuture(this, this._st, scheduleMethod), + this.source.subscribe(new SkipUntilWithTimeObserver(o, this)) + ); + }; + + return SkipUntilWithTimeObservable; + }(ObservableBase)); + + var SkipUntilWithTimeObserver = (function (__super__) { + inherits(SkipUntilWithTimeObserver, __super__); + + function SkipUntilWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipUntilWithTimeObserver; + }(AbstractObserver)); + - createTimer(); + /** + * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time. + * + * @examples + * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]); + * 2 - res = source.skipUntilWithTime(5000, [scheduler]); + * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped until the specified start time. + */ + observableProto.skipUntilWithTime = function (startTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipUntilWithTimeObservable(this, startTime, scheduler); + }; - original.setDisposable(source.subscribe(function (x) { - if (!switched) { - id++; - o.onNext(x); - createTimer(); - } - }, function (e) { - if (!switched) { - id++; - o.onError(e); - } - }, function () { - if (!switched) { - id++; - o.onCompleted(); - } - })); - return new CompositeDisposable(subscription, timer); + /** + * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. + * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. + * @returns {Observable} An observable sequence with the elements taken until the specified end time. + */ + observableProto.takeUntilWithTime = function (endTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var source = this; + return new AnonymousObservable(function (o) { + return new BinaryDisposable( + scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }), + source.subscribe(o)); }, source); - } - - observableProto.timeout = function () { - var firstArg = arguments[0]; - if (firstArg instanceof Date || typeof firstArg === 'number') { - return timeout(this, firstArg, arguments[1], arguments[2]); - } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { - return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); - } else { - throw new Error('Invalid arguments'); - } }; - + /** * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. * @param {Number} windowDuration time to wait before emitting another item after emitting the last item @@ -5441,7 +10918,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { * @returns {Observable} An Observable that performs the throttle operation. */ observableProto.throttle = function (windowDuration, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); + isScheduler(scheduler) || (scheduler = defaultScheduler); var duration = +windowDuration || 0; if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } var source = this; @@ -5458,405 +10935,809 @@ Observable.fromNodeCallback = function (fn, ctx, selector) { ); }, source); }; - - var PausableObservable = (function (__super__) { - inherits(PausableObservable, __super__); + var TransduceObserver = (function (__super__) { + inherits(TransduceObserver, __super__); + function TransduceObserver(o, xform) { + this._o = o; + this._xform = xform; + __super__.call(this); + } - function subscribe(observer) { - var conn = this.source.publish(), - subscription = conn.subscribe(observer), - connection = disposableEmpty; + TransduceObserver.prototype.next = function (x) { + var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x); + if (res === errorObj) { this._o.onError(res.e); } + }; - var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) { - if (b) { - connection = conn.connect(); - } else { - connection.dispose(); - connection = disposableEmpty; - } - }); + TransduceObserver.prototype.error = function (e) { this._o.onError(e); }; - return new CompositeDisposable(subscription, connection, pausable); - } + TransduceObserver.prototype.completed = function () { + this._xform['@@transducer/result'](this._o); + }; - function PausableObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); + return TransduceObserver; + }(AbstractObserver)); - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; + function transformForObserver(o) { + return { + '@@transducer/init': function() { + return o; + }, + '@@transducer/step': function(obs, input) { + return obs.onNext(input); + }, + '@@transducer/result': function(obs) { + return obs.onCompleted(); } + }; + } + + /** + * Executes a transducer to transform the observable sequence + * @param {Transducer} transducer A transducer to execute + * @returns {Observable} An Observable sequence containing the results from the transducer. + */ + observableProto.transduce = function(transducer) { + var source = this; + return new AnonymousObservable(function(o) { + var xform = transducer(transformForObserver(o)); + return source.subscribe(new TransduceObserver(o, xform)); + }, source); + }; + + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * @returns {Observable} A exclusive observable with only the results that happen when subscribed. + */ + observableProto.switchFirst = function () { + var sources = this; + return new AnonymousObservable(function (o) { + var hasCurrent = false, + isStopped = false, + m = new SingleAssignmentDisposable(), + g = new CompositeDisposable(); - __super__.call(this, subscribe, source); + g.add(m); + + m.setDisposable(sources.subscribe( + function (innerSource) { + if (!hasCurrent) { + hasCurrent = true; + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + var innerSubscription = new SingleAssignmentDisposable(); + g.add(innerSubscription); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { o.onError(e); }, + function () { + g.remove(innerSubscription); + hasCurrent = false; + isStopped && g.length === 1 && o.onCompleted(); + })); + } + }, + function (e) { o.onError(e); }, + function () { + isStopped = true; + !hasCurrent && g.length === 1 && o.onCompleted(); + })); + + return g; + }, this); + }; + +observableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst(); +}; + +Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +}; + /** Provides a set of extension methods for virtual time scheduling. */ + var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) { + inherits(VirtualTimeScheduler, __super__); + + /** + * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer. + * + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function VirtualTimeScheduler(initialClock, comparer) { + this.clock = initialClock; + this.comparer = comparer; + this.isEnabled = false; + this.queue = new PriorityQueue(1024); + __super__.call(this); } - PausableObservable.prototype.pause = function () { - this.controller.onNext(false); + var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype; + + VirtualTimeSchedulerPrototype.now = function () { + return this.toAbsoluteTime(this.clock); }; - PausableObservable.prototype.resume = function () { - this.controller.onNext(true); + VirtualTimeSchedulerPrototype.schedule = function (state, action) { + return this.scheduleAbsolute(state, this.clock, action); }; - return PausableObservable; + VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime instanceof Date ? + this.toRelativeTime(dueTime - this.now()) : + this.toRelativeTime(dueTime); - }(Observable)); + return this.scheduleRelative(state, dt, action); + }; - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausable(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. - */ - observableProto.pausable = function (pauser) { - return new PausableObservable(this, pauser); - }; - - function combineLatestSource(source, subject, resultSelector) { - return new AnonymousObservable(function (o) { - var hasValue = [false, false], - hasValueAll = false, - isDone = false, - values = new Array(2), - err; + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + VirtualTimeSchedulerPrototype.add = notImplemented; - function next(x, i) { - values[i] = x; - hasValue[i] = true; - if (hasValueAll || (hasValueAll = hasValue.every(identity))) { - if (err) { return o.onError(err); } - var res = tryCatch(resultSelector).apply(null, values); - if (res === errorObj) { return o.onError(res.e); } - o.onNext(res); + /** + * Converts an absolute time to a number + * @param {Any} The absolute time. + * @returns {Number} The absolute time in ms + */ + VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented; + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) { + var s = new SchedulePeriodicRecursive(this, state, period, action); + return s.start(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) { + var runAt = this.add(this.clock, dueTime); + return this.scheduleAbsolute(state, runAt, action); + }; + + /** + * Starts the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.start = function () { + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + } + }; + + /** + * Stops the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.stop = function () { + this.isEnabled = false; + }; + + /** + * Advances the scheduler's clock to the specified time, running all work till that point. + * @param {Number} time Absolute time to advance the scheduler's clock to. + */ + VirtualTimeSchedulerPrototype.advanceTo = function (time) { + var dueToClock = this.comparer(this.clock, time); + if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null && this.comparer(next.dueTime, time) <= 0) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + this.clock = time; + } + }; + + /** + * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.advanceBy = function (time) { + var dt = this.add(this.clock, time), + dueToClock = this.comparer(this.clock, dt); + if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + + this.advanceTo(dt); + }; + + /** + * Advances the scheduler's clock by the specified relative time. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.sleep = function (time) { + var dt = this.add(this.clock, time); + if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); } + + this.clock = dt; + }; + + /** + * Gets the next scheduled item to be executed. + * @returns {ScheduledItem} The next scheduled item. + */ + VirtualTimeSchedulerPrototype.getNext = function () { + while (this.queue.length > 0) { + var next = this.queue.peek(); + if (next.isCancelled()) { + this.queue.dequeue(); + } else { + return next; } - isDone && values[1] && o.onCompleted(); } + return null; + }; - return new CompositeDisposable( - source.subscribe( - function (x) { - next(x, 0); - }, - function (e) { - if (values[1]) { - o.onError(e); - } else { - err = e; - } - }, - function () { - isDone = true; - values[1] && o.onCompleted(); - }), - subject.subscribe( - function (x) { - next(x, 1); - }, - function (e) { o.onError(e); }, - function () { - isDone = true; - next(true, 1); - }) - ); - }, source); - } + /** + * Schedules an action to be executed at dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Absolute time at which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) { + var self = this; - var PausableBufferedObservable = (function (__super__) { + function run(scheduler, state1) { + self.queue.remove(si); + return action(scheduler, state1); + } + + var si = new ScheduledItem(this, state, run, dueTime, this.comparer); + this.queue.enqueue(si); - inherits(PausableBufferedObservable, __super__); + return si.disposable; + }; - function subscribe(o) { - var q = [], previousShouldFire; + return VirtualTimeScheduler; + }(Scheduler)); - function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } } + /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */ + Rx.HistoricalScheduler = (function (__super__) { + inherits(HistoricalScheduler, __super__); - var subscription = - combineLatestSource( - this.source, - this.pauser.startWith(false).distinctUntilChanged(), - function (data, shouldFire) { - return { data: data, shouldFire: shouldFire }; - }) - .subscribe( - function (results) { - if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) { - previousShouldFire = results.shouldFire; - // change in shouldFire - if (results.shouldFire) { drainQueue(); } - } else { - previousShouldFire = results.shouldFire; - // new data - if (results.shouldFire) { - o.onNext(results.data); - } else { - q.push(results.data); - } - } - }, - function (err) { - drainQueue(); - o.onError(err); - }, - function () { - drainQueue(); - o.onCompleted(); - } - ); - return subscription; + /** + * Creates a new historical scheduler with the specified initial clock value. + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function HistoricalScheduler(initialClock, comparer) { + var clock = initialClock == null ? 0 : initialClock; + var cmp = comparer || defaultSubComparer; + __super__.call(this, clock, cmp); } - function PausableBufferedObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); - - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; - } + var HistoricalSchedulerProto = HistoricalScheduler.prototype; - __super__.call(this, subscribe, source); - } + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + HistoricalSchedulerProto.add = function (absolute, relative) { + return absolute + relative; + }; - PausableBufferedObservable.prototype.pause = function () { - this.controller.onNext(false); + HistoricalSchedulerProto.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); }; - PausableBufferedObservable.prototype.resume = function () { - this.controller.onNext(true); + /** + * Converts the TimeSpan value to a relative virtual time value. + * @memberOf HistoricalScheduler + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + HistoricalSchedulerProto.toRelativeTime = function (timeSpan) { + return timeSpan; }; - return PausableBufferedObservable; + return HistoricalScheduler; + }(Rx.VirtualTimeScheduler)); - }(Observable)); +function OnNextPredicate(predicate) { + this.predicate = predicate; +} + +OnNextPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'N') { return false; } + return this.predicate(other.value); +}; + +function OnErrorPredicate(predicate) { + this.predicate = predicate; +} + +OnErrorPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'E') { return false; } + return this.predicate(other.error); +}; + +var ReactiveTest = Rx.ReactiveTest = { + /** Default virtual time used for creation of observable sequences in unit tests. */ + created: 100, + /** Default virtual time used to subscribe to observable sequences in unit tests. */ + subscribed: 200, + /** Default virtual time used to dispose subscriptions in unit tests. */ + disposed: 1000, /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, - * and yields the values that were buffered while paused. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausableBuffered(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. + * Factory method for an OnNext notification record at a given time with a given value or a predicate function. + * + * 1 - ReactiveTest.onNext(200, 42); + * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); + * + * @param ticks Recorded virtual time the OnNext notification occurs. + * @param value Recorded value stored in the OnNext notification or a predicate. + * @return Recorded OnNext notification. */ - observableProto.pausableBuffered = function (subject) { - return new PausableBufferedObservable(this, subject); + onNext: function (ticks, value) { + return typeof value === 'function' ? + new Recorded(ticks, new OnNextPredicate(value)) : + new Recorded(ticks, Notification.createOnNext(value)); + }, + /** + * Factory method for an OnError notification record at a given time with a given error. + * + * 1 - ReactiveTest.onNext(200, new Error('error')); + * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); + * + * @param ticks Recorded virtual time the OnError notification occurs. + * @param exception Recorded exception stored in the OnError notification. + * @return Recorded OnError notification. + */ + onError: function (ticks, error) { + return typeof error === 'function' ? + new Recorded(ticks, new OnErrorPredicate(error)) : + new Recorded(ticks, Notification.createOnError(error)); + }, + /** + * Factory method for an OnCompleted notification record at a given time. + * + * @param ticks Recorded virtual time the OnCompleted notification occurs. + * @return Recorded OnCompleted notification. + */ + onCompleted: function (ticks) { + return new Recorded(ticks, Notification.createOnCompleted()); + }, + /** + * Factory method for a subscription record based on a given subscription and disposal time. + * + * @param start Virtual time indicating when the subscription was created. + * @param end Virtual time indicating when the subscription was disposed. + * @return Subscription object. + */ + subscribe: function (start, end) { + return new Subscription(start, end); + } +}; + + /** + * Creates a new object recording the production of the specified value at the given virtual time. + * + * @constructor + * @param {Number} time Virtual time the value was produced on. + * @param {Mixed} value Value that was produced. + * @param {Function} comparer An optional comparer. + */ + var Recorded = Rx.Recorded = function (time, value, comparer) { + this.time = time; + this.value = value; + this.comparer = comparer || defaultComparer; }; - -var ControlledObservable = (function (__super__) { - inherits(ControlledObservable, __super__); + /** + * Checks whether the given recorded object is equal to the current instance. + * + * @param {Recorded} other Recorded object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Recorded.prototype.equals = function (other) { + return this.time === other.time && this.comparer(this.value, other.value); + }; - function subscribe (observer) { - return this.source.subscribe(observer); - } + /** + * Returns a string representation of the current Recorded value. + * + * @returns {String} String representation of the current Recorded value. + */ + Recorded.prototype.toString = function () { + return this.value.toString() + '@' + this.time; + }; - function ControlledObservable (source, enableQueue, scheduler) { - __super__.call(this, subscribe, source); - this.subject = new ControlledSubject(enableQueue, scheduler); - this.source = source.multicast(this.subject).refCount(); - } + /** + * Creates a new subscription object with the given virtual subscription and unsubscription time. + * + * @constructor + * @param {Number} subscribe Virtual time at which the subscription occurred. + * @param {Number} unsubscribe Virtual time at which the unsubscription occurred. + */ + var Subscription = Rx.Subscription = function (start, end) { + this.subscribe = start; + this.unsubscribe = end || Number.MAX_VALUE; + }; - ControlledObservable.prototype.request = function (numberOfItems) { - return this.subject.request(numberOfItems == null ? -1 : numberOfItems); + /** + * Checks whether the given subscription is equal to the current instance. + * @param other Subscription object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Subscription.prototype.equals = function (other) { + return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; }; - return ControlledObservable; + /** + * Returns a string representation of the current Subscription value. + * @returns {String} String representation of the current Subscription value. + */ + Subscription.prototype.toString = function () { + return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')'; + }; -}(Observable)); + var MockDisposable = Rx.MockDisposable = function (scheduler) { + this.scheduler = scheduler; + this.disposes = []; + this.disposes.push(this.scheduler.clock); + }; -var ControlledSubject = (function (__super__) { + MockDisposable.prototype.dispose = function () { + this.disposes.push(this.scheduler.clock); + }; - function subscribe (observer) { - return this.subject.subscribe(observer); - } + var MockObserver = (function (__super__) { + inherits(MockObserver, __super__); - inherits(ControlledSubject, __super__); - - function ControlledSubject(enableQueue, scheduler) { - enableQueue == null && (enableQueue = true); - - __super__.call(this, subscribe); - this.subject = new Subject(); - this.enableQueue = enableQueue; - this.queue = enableQueue ? [] : null; - this.requestedCount = 0; - this.requestedDisposable = null; - this.error = null; - this.hasFailed = false; - this.hasCompleted = false; - this.scheduler = scheduler || currentThreadScheduler; - } + function MockObserver(scheduler) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = []; + } - addProperties(ControlledSubject.prototype, Observer, { - onCompleted: function () { - this.hasCompleted = true; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onCompleted(); - this.disposeCurrentRequest() - } else { - this.queue.push(Notification.createOnCompleted()); - } - }, - onError: function (error) { - this.hasFailed = true; - this.error = error; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onError(error); - this.disposeCurrentRequest() - } else { - this.queue.push(Notification.createOnError(error)); - } - }, - onNext: function (value) { - if (this.requestedCount <= 0) { - this.enableQueue && this.queue.push(Notification.createOnNext(value)); - } else { - (this.requestedCount-- === 0) && this.disposeCurrentRequest(); - this.subject.onNext(value); - } - }, - _processRequest: function (numberOfItems) { - if (this.enableQueue) { - while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) { - var first = this.queue.shift(); - first.accept(this.subject); - if (first.kind === 'N') { - numberOfItems--; - } else { - this.disposeCurrentRequest(); - this.queue = []; + var MockObserverPrototype = MockObserver.prototype; + + MockObserverPrototype.onNext = function (value) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value))); + }; + + MockObserverPrototype.onError = function (e) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e))); + }; + + MockObserverPrototype.onCompleted = function () { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted())); + }; + + return MockObserver; + })(Observer); + + function MockPromise(scheduler, messages) { + var self = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + var message = this.messages[i], + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = self.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); } + return disposableEmpty; + }); + })(notification); + } + } + + MockPromise.prototype.then = function (onResolved, onRejected) { + var self = this; + + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + + var newPromise; + + var observer = Rx.Observer.create( + function (x) { + var retValue = onResolved(x); + if (retValue && typeof retValue.then === 'function') { + newPromise = retValue; + } else { + var ticks = self.scheduler.clock; + newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]); } + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + }, + function (err) { + onRejected(err); + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); } + ); + this.observers.push(observer); - return numberOfItems; - }, - request: function (number) { - this.disposeCurrentRequest(); - var self = this; + return newPromise || new MockPromise(this.scheduler, this.messages); + }; - this.requestedDisposable = this.scheduler.scheduleWithState(number, - function(s, i) { - var remaining = self._processRequest(i); - var stopped = self.hasCompleted || self.hasFailed - if (!stopped && remaining > 0) { - self.requestedCount = remaining; + var HotObservable = (function (__super__) { + inherits(HotObservable, __super__); - return disposableCreate(function () { - self.requestedCount = 0; + function HotObservable(scheduler, messages) { + __super__.call(this); + var message, notification, observable = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = observable.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; }); - // Scheduled item is still in progress. Return a new - // disposable to allow the request to be interrupted - // via dispose. - } - }); - - return this.requestedDisposable; - }, - disposeCurrentRequest: function () { - if (this.requestedDisposable) { - this.requestedDisposable.dispose(); - this.requestedDisposable = null; + })(notification); } } - }); - return ControlledSubject; -}(Observable)); + HotObservable.prototype._subscribe = function (o) { + var observable = this; + this.observers.push(o); + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + return disposableCreate(function () { + var idx = observable.observers.indexOf(o); + observable.observers.splice(idx, 1); + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + }); + }; -/** - * Attaches a controller to the observable sequence with the ability to queue. - * @example - * var source = Rx.Observable.interval(100).controlled(); - * source.request(3); // Reads 3 values - * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request - * @param {Scheduler} scheduler determines how the requests will be scheduled - * @returns {Observable} The observable sequence which only propagates values on request. - */ -observableProto.controlled = function (enableQueue, scheduler) { + return HotObservable; + })(Observable); - if (enableQueue && isScheduler(enableQueue)) { - scheduler = enableQueue; - enableQueue = true; - } + var ColdObservable = (function (__super__) { + inherits(ColdObservable, __super__); - if (enableQueue == null) { enableQueue = true; } - return new ControlledObservable(this, enableQueue, scheduler); -}; - - /** - * Pipes the existing Observable sequence into a Node.js Stream. - * @param {Stream} dest The destination Node.js stream. - * @returns {Stream} The destination stream. - */ - observableProto.pipe = function (dest) { - var source = this.pausableBuffered(); + function ColdObservable(scheduler, messages) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + } + + ColdObservable.prototype._subscribe = function (o) { + var message, notification, observable = this; + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + var d = new CompositeDisposable(); + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + d.add(observable.scheduler.scheduleRelative(null, message.time, function () { + innerNotification.accept(o); + return disposableEmpty; + })); + })(notification); + } + return disposableCreate(function () { + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + d.dispose(); + }); + }; - function onDrain() { - source.resume(); + return ColdObservable; + })(Observable); + + /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ + Rx.TestScheduler = (function (__super__) { + inherits(TestScheduler, __super__); + + function baseComparer(x, y) { + return x > y ? 1 : (x < y ? -1 : 0); } - dest.addListener('drain', onDrain); + function TestScheduler() { + __super__.call(this, 0, baseComparer); + } - source.subscribe( - function (x) { - !dest.write(String(x)) && source.pause(); - }, - function (err) { - dest.emit('error', err); - }, - function () { - // Hack check because STDIO is not closable - !dest._isStdio && dest.end(); - dest.removeListener('drain', onDrain); + /** + * Schedules an action to be executed at the specified virtual time. + * + * @param state State passed to the action to be executed. + * @param dueTime Absolute virtual time at which to execute the action. + * @param action Action to be executed. + * @return Disposable object used to cancel the scheduled action (best effort). + */ + TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) { + dueTime <= this.clock && (dueTime = this.clock + 1); + return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action); + }; + /** + * Adds a relative virtual time to an absolute virtual time value. + * + * @param absolute Absolute virtual time value. + * @param relative Relative virtual time value to add. + * @return Resulting absolute virtual time sum value. + */ + TestScheduler.prototype.add = function (absolute, relative) { + return absolute + relative; + }; + /** + * Converts the absolute virtual time value to a DateTimeOffset value. + * + * @param absolute Absolute virtual time value to convert. + * @return Corresponding DateTimeOffset value. + */ + TestScheduler.prototype.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + /** + * Converts the TimeSpan value to a relative virtual time value. + * + * @param timeSpan TimeSpan value to convert. + * @return Corresponding relative virtual time value. + */ + TestScheduler.prototype.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + /** + * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. + * + * @param create Factory method to create an observable sequence. + * @param created Virtual time at which to invoke the factory to create an observable sequence. + * @param subscribed Virtual time at which to subscribe to the created observable sequence. + * @param disposed Virtual time at which to dispose the subscription. + * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. + */ + TestScheduler.prototype.startScheduler = function (createFn, settings) { + settings || (settings = {}); + settings.created == null && (settings.created = ReactiveTest.created); + settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed); + settings.disposed == null && (settings.disposed = ReactiveTest.disposed); + + var observer = this.createObserver(), source, subscription; + + this.scheduleAbsolute(null, settings.created, function () { + source = createFn(); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.subscribed, function () { + subscription = source.subscribe(observer); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.disposed, function () { + subscription.dispose(); + return disposableEmpty; }); - source.resume(); + this.start(); + + return observer; + }; + + /** + * Creates a hot observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified absolute virtual times. + * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createHotObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new HotObservable(this, args); + }; + + /** + * Creates a cold observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. + * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createColdObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new ColdObservable(this, args); + }; + + /** + * Creates a resolved promise with the given value and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} value The value to yield at the given tick. + * @returns {MockPromise} A mock Promise which fulfills with the given value. + */ + TestScheduler.prototype.createResolvedPromise = function (ticks, value) { + return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]); + }; - return dest; - }; - - /** - * Executes a transducer to transform the observable sequence - * @param {Transducer} transducer A transducer to execute - * @returns {Observable} An Observable sequence containing the results from the transducer. - */ - observableProto.transduce = function(transducer) { - var source = this; + /** + * Creates a rejected promise with the given reason and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} reason The reason for rejection to yield at the given tick. + * @returns {MockPromise} A mock Promise which rejects with the given reason. + */ + TestScheduler.prototype.createRejectedPromise = function (ticks, reason) { + return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]); + }; - function transformForObserver(o) { - return { - '@@transducer/init': function() { - return o; - }, - '@@transducer/step': function(obs, input) { - return obs.onNext(input); - }, - '@@transducer/result': function(obs) { - return obs.onCompleted(); - } - }; - } + /** + * Creates an observer that records received notification messages and timestamps those. + * @return Observer that can be used to assert the timing of received notifications. + */ + TestScheduler.prototype.createObserver = function () { + return new MockObserver(this); + }; + + return TestScheduler; + })(VirtualTimeScheduler); - return new AnonymousObservable(function(o) { - var xform = transducer(transformForObserver(o)); - return source.subscribe( - function(v) { - var res = tryCatch(xform['@@transducer/step']).call(xform, o, v); - if (res === errorObj) { o.onError(res.e); } - }, - function (e) { o.onError(e); }, - function() { xform['@@transducer/result'](o); } - ); - }, source); - }; - var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) { inherits(AnonymousObservable, __super__); @@ -5869,34 +11750,31 @@ observableProto.controlled = function (enableQueue, scheduler) { function setDisposable(s, state) { var ado = state[0], self = state[1]; var sub = tryCatch(self.__subscribe).call(self, ado); - - if (sub === errorObj) { - if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); } - } + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } ado.setDisposable(fixSubscriber(sub)); } - function innerSubscribe(observer) { - var ado = new AutoDetachObserver(observer), state = [ado, this]; + function AnonymousObservable(subscribe, parent) { + this.source = parent; + this.__subscribe = subscribe; + __super__.call(this); + } + + AnonymousObservable.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; if (currentThreadScheduler.scheduleRequired()) { - currentThreadScheduler.scheduleWithState(state, setDisposable); + currentThreadScheduler.schedule(state, setDisposable); } else { setDisposable(null, state); } return ado; - } - - function AnonymousObservable(subscribe, parent) { - this.source = parent; - this.__subscribe = subscribe; - __super__.call(this, innerSubscribe); - } + }; return AnonymousObservable; }(Observable)); - + var AutoDetachObserver = (function (__super__) { inherits(AutoDetachObserver, __super__); @@ -5938,318 +11816,66 @@ observableProto.controlled = function (enableQueue, scheduler) { return AutoDetachObserver; }(AbstractObserver)); - - var InnerSubscription = function (subject, observer) { - this.subject = subject; - this.observer = observer; - }; - - InnerSubscription.prototype.dispose = function () { - if (!this.subject.isDisposed && this.observer !== null) { - var idx = this.subject.observers.indexOf(this.observer); - this.subject.observers.splice(idx, 1); - this.observer = null; - } - }; - - /** - * Represents an object that is both an observable sequence as well as an observer. - * Each notification is broadcasted to all subscribed observers. - */ - var Subject = Rx.Subject = (function (__super__) { - function subscribe(observer) { - checkDisposed(this); - if (!this.isStopped) { - this.observers.push(observer); - return new InnerSubscription(this, observer); - } - if (this.hasError) { - observer.onError(this.error); - return disposableEmpty; - } - observer.onCompleted(); - return disposableEmpty; - } - - inherits(Subject, __super__); - /** - * Creates a subject. - */ - function Subject() { - __super__.call(this, subscribe); - this.isDisposed = false, - this.isStopped = false, - this.observers = []; - this.hasError = false; + var UnderlyingObservable = (function (__super__) { + inherits(UnderlyingObservable, __super__); + function UnderlyingObservable(m, u) { + this._m = m; + this._u = u; + __super__.call(this); } - addProperties(Subject.prototype, Observer.prototype, { - /** - * Indicates whether the subject has observers subscribed to it. - * @returns {Boolean} Indicates whether the subject has observers subscribed to it. - */ - hasObservers: function () { return this.observers.length > 0; }, - /** - * Notifies all subscribed observers about the end of the sequence. - */ - onCompleted: function () { - checkDisposed(this); - if (!this.isStopped) { - this.isStopped = true; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onCompleted(); - } - - this.observers.length = 0; - } - }, - /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (!this.isStopped) { - this.isStopped = true; - this.error = error; - this.hasError = true; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onError(error); - } - - this.observers.length = 0; - } - }, - /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. - */ - onNext: function (value) { - checkDisposed(this); - if (!this.isStopped) { - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onNext(value); - } - } - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - } - }); - - /** - * Creates a subject from the specified observer and observable. - * @param {Observer} observer The observer used to send messages to the subject. - * @param {Observable} observable The observable used to subscribe to messages sent from the subject. - * @returns {Subject} Subject implemented using the given observer and observable. - */ - Subject.create = function (observer, observable) { - return new AnonymousSubject(observer, observable); + UnderlyingObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o)); }; - return Subject; - }(Observable)); - - /** - * Represents the result of an asynchronous operation. - * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers. - */ - var AsyncSubject = Rx.AsyncSubject = (function (__super__) { - - function subscribe(observer) { - checkDisposed(this); - - if (!this.isStopped) { - this.observers.push(observer); - return new InnerSubscription(this, observer); - } - - if (this.hasError) { - observer.onError(this.error); - } else if (this.hasValue) { - observer.onNext(this.value); - observer.onCompleted(); - } else { - observer.onCompleted(); - } - - return disposableEmpty; - } - - inherits(AsyncSubject, __super__); - - /** - * Creates a subject that can only receive one value and that value is cached for all future observations. - * @constructor - */ - function AsyncSubject() { - __super__.call(this, subscribe); - - this.isDisposed = false; - this.isStopped = false; - this.hasValue = false; - this.observers = []; - this.hasError = false; - } - - addProperties(AsyncSubject.prototype, Observer, { - /** - * Indicates whether the subject has observers subscribed to it. - * @returns {Boolean} Indicates whether the subject has observers subscribed to it. - */ - hasObservers: function () { - checkDisposed(this); - return this.observers.length > 0; - }, - /** - * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any). - */ - onCompleted: function () { - var i, len; - checkDisposed(this); - if (!this.isStopped) { - this.isStopped = true; - var os = cloneArray(this.observers), len = os.length; - - if (this.hasValue) { - for (i = 0; i < len; i++) { - var o = os[i]; - o.onNext(this.value); - o.onCompleted(); - } - } else { - for (i = 0; i < len; i++) { - os[i].onCompleted(); - } - } - - this.observers.length = 0; - } - }, - /** - * Notifies all subscribed observers about the error. - * @param {Mixed} error The Error to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (!this.isStopped) { - this.isStopped = true; - this.hasError = true; - this.error = error; - - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onError(error); - } - - this.observers.length = 0; - } - }, - /** - * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers. - * @param {Mixed} value The value to store in the subject. - */ - onNext: function (value) { - checkDisposed(this); - if (this.isStopped) { return; } - this.value = value; - this.hasValue = true; - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - this.exception = null; - this.value = null; - } - }); - - return AsyncSubject; - }(Observable)); - - var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) { - inherits(AnonymousSubject, __super__); - - function subscribe(observer) { - return this.observable.subscribe(observer); - } + return UnderlyingObservable; + }(ObservableBase)); - function AnonymousSubject(observer, observable) { - this.observer = observer; - this.observable = observable; - __super__.call(this, subscribe); + var GroupedObservable = (function (__super__) { + inherits(GroupedObservable, __super__); + function GroupedObservable(key, underlyingObservable, mergedDisposable) { + __super__.call(this); + this.key = key; + this.underlyingObservable = !mergedDisposable ? + underlyingObservable : + new UnderlyingObservable(mergedDisposable, underlyingObservable); } - addProperties(AnonymousSubject.prototype, Observer.prototype, { - onCompleted: function () { - this.observer.onCompleted(); - }, - onError: function (error) { - this.observer.onError(error); - }, - onNext: function (value) { - this.observer.onNext(value); - } - }); + GroupedObservable.prototype._subscribe = function (o) { + return this.underlyingObservable.subscribe(o); + }; - return AnonymousSubject; + return GroupedObservable; }(Observable)); - + /** - * Represents a value that changes over time. - * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications. + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed observers. */ - var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) { - function subscribe(observer) { - checkDisposed(this); - if (!this.isStopped) { - this.observers.push(observer); - observer.onNext(this.value); - return new InnerSubscription(this, observer); - } - if (this.hasError) { - observer.onError(this.error); - } else { - observer.onCompleted(); - } - return disposableEmpty; - } - - inherits(BehaviorSubject, __super__); - - /** - * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value. - * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet. - */ - function BehaviorSubject(value) { - __super__.call(this, subscribe); - this.value = value, - this.observers = [], - this.isDisposed = false, - this.isStopped = false, + var Subject = Rx.Subject = (function (__super__) { + inherits(Subject, __super__); + function Subject() { + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; + this.observers = []; this.hasError = false; } - addProperties(BehaviorSubject.prototype, Observer, { - /** - * Gets the current value or throws an exception. - * Value is frozen after onCompleted is called. - * After onError is called always throws the specified exception. - * An exception is always thrown after dispose is called. - * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext. - */ - getValue: function () { - checkDisposed(this); - if (this.hasError) { - throw this.error; - } - return this.value; + addProperties(Subject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + if (this.hasError) { + o.onError(this.error); + return disposableEmpty; + } + o.onCompleted(); + return disposableEmpty; }, /** * Indicates whether the subject has observers subscribed to it. @@ -6261,13 +11887,14 @@ observableProto.controlled = function (enableQueue, scheduler) { */ onCompleted: function () { checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onCompleted(); - } + if (!this.isStopped) { + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } - this.observers.length = 0; + this.observers.length = 0; + } }, /** * Notifies all subscribed observers about the exception. @@ -6275,16 +11902,16 @@ observableProto.controlled = function (enableQueue, scheduler) { */ onError: function (error) { checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.hasError = true; - this.error = error; + if (!this.isStopped) { + this.isStopped = true; + this.error = error; + this.hasError = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onError(error); + this.observers.length = 0; } - - this.observers.length = 0; }, /** * Notifies all subscribed observers about the arrival of the specified element in the sequence. @@ -6292,10 +11919,10 @@ observableProto.controlled = function (enableQueue, scheduler) { */ onNext: function (value) { checkDisposed(this); - if (this.isStopped) { return; } - this.value = value; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onNext(value); + if (!this.isStopped) { + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } } }, /** @@ -6304,138 +11931,122 @@ observableProto.controlled = function (enableQueue, scheduler) { dispose: function () { this.isDisposed = true; this.observers = null; - this.value = null; - this.exception = null; } }); - return BehaviorSubject; + /** + * Creates a subject from the specified observer and observable. + * @param {Observer} observer The observer used to send messages to the subject. + * @param {Observable} observable The observable used to subscribe to messages sent from the subject. + * @returns {Subject} Subject implemented using the given observer and observable. + */ + Subject.create = function (observer, observable) { + return new AnonymousSubject(observer, observable); + }; + + return Subject; }(Observable)); - + /** - * Represents an object that is both an observable sequence as well as an observer. - * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. + * Represents the result of an asynchronous operation. + * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers. */ - var ReplaySubject = Rx.ReplaySubject = (function (__super__) { - - var maxSafeInteger = Math.pow(2, 53) - 1; - - function createRemovableDisposable(subject, observer) { - return disposableCreate(function () { - observer.dispose(); - !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); - }); - } - - function subscribe(observer) { - var so = new ScheduledObserver(this.scheduler, observer), - subscription = createRemovableDisposable(this, so); - checkDisposed(this); - this._trim(this.scheduler.now()); - this.observers.push(so); - - for (var i = 0, len = this.q.length; i < len; i++) { - so.onNext(this.q[i].value); - } - - if (this.hasError) { - so.onError(this.error); - } else if (this.isStopped) { - so.onCompleted(); - } - - so.ensureActive(); - return subscription; - } - - inherits(ReplaySubject, __super__); + var AsyncSubject = Rx.AsyncSubject = (function (__super__) { + inherits(AsyncSubject, __super__); /** - * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. - * @param {Number} [bufferSize] Maximum element count of the replay buffer. - * @param {Number} [windowSize] Maximum time length of the replay buffer. - * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. + * Creates a subject that can only receive one value and that value is cached for all future observations. + * @constructor */ - function ReplaySubject(bufferSize, windowSize, scheduler) { - this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; - this.windowSize = windowSize == null ? maxSafeInteger : windowSize; - this.scheduler = scheduler || currentThreadScheduler; - this.q = []; - this.observers = []; - this.isStopped = false; + function AsyncSubject() { + __super__.call(this); this.isDisposed = false; + this.isStopped = false; + this.hasValue = false; + this.observers = []; this.hasError = false; - this.error = null; - __super__.call(this, subscribe); } - addProperties(ReplaySubject.prototype, Observer.prototype, { + addProperties(AsyncSubject.prototype, Observer, { + _subscribe: function (o) { + checkDisposed(this); + + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + + if (this.hasError) { + o.onError(this.error); + } else if (this.hasValue) { + o.onNext(this.value); + o.onCompleted(); + } else { + o.onCompleted(); + } + + return disposableEmpty; + }, /** * Indicates whether the subject has observers subscribed to it. * @returns {Boolean} Indicates whether the subject has observers subscribed to it. */ hasObservers: function () { + checkDisposed(this); return this.observers.length > 0; }, - _trim: function (now) { - while (this.q.length > this.bufferSize) { - this.q.shift(); - } - while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { - this.q.shift(); - } - }, /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. + * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any). */ - onNext: function (value) { + onCompleted: function () { + var i, len; checkDisposed(this); - if (this.isStopped) { return; } - var now = this.scheduler.now(); - this.q.push({ interval: now, value: value }); - this._trim(now); + if (!this.isStopped) { + this.isStopped = true; + var os = cloneArray(this.observers), len = os.length; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onNext(value); - observer.ensureActive(); + if (this.hasValue) { + for (i = 0; i < len; i++) { + var o = os[i]; + o.onNext(this.value); + o.onCompleted(); + } + } else { + for (i = 0; i < len; i++) { + os[i].onCompleted(); + } + } + + this.observers.length = 0; } }, /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. + * Notifies all subscribed observers about the error. + * @param {Mixed} error The Error to send to all observers. */ onError: function (error) { checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.error = error; - this.hasError = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onError(error); - observer.ensureActive(); + if (!this.isStopped) { + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; } - this.observers.length = 0; }, /** - * Notifies all subscribed observers about the end of the sequence. + * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers. + * @param {Mixed} value The value to store in the subject. */ - onCompleted: function () { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onCompleted(); - observer.ensureActive(); - } - this.observers.length = 0; + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + this.hasValue = true; }, /** * Unsubscribe all observers and release resources. @@ -6443,18 +12054,45 @@ observableProto.controlled = function (enableQueue, scheduler) { dispose: function () { this.isDisposed = true; this.observers = null; + this.error = null; + this.value = null; } }); - return ReplaySubject; + return AsyncSubject; + }(Observable)); + + var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) { + inherits(AnonymousSubject, __super__); + function AnonymousSubject(observer, observable) { + this.observer = observer; + this.observable = observable; + __super__.call(this); + } + + addProperties(AnonymousSubject.prototype, Observer.prototype, { + _subscribe: function (o) { + return this.observable.subscribe(o); + }, + onCompleted: function () { + this.observer.onCompleted(); + }, + onError: function (error) { + this.observer.onError(error); + }, + onNext: function (value) { + this.observer.onNext(value); + } + }); + + return AnonymousSubject; }(Observable)); - + /** * Used to pause and resume streams. */ Rx.Pauser = (function (__super__) { inherits(Pauser, __super__); - function Pauser() { __super__.call(this); } @@ -6471,7 +12109,7 @@ observableProto.controlled = function (enableQueue, scheduler) { return Pauser; }(Subject)); - + if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { root.Rx = Rx; @@ -6489,24 +12127,30 @@ observableProto.controlled = function (enableQueue, scheduler) { // in a browser or Rhino root.Rx = Rx; } - + // All code before this point will be filtered from stack traces. var rEndingLine = captureLine(); - + }.call(this)); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":2}],4:[function(require,module,exports){ -'use strict'; +"use strict"; -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ajax = require("./ajax"); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } +var _ajax2 = _interopRequireDefault(_ajax); var AjaxAdapter = (function () { function AjaxAdapter(options) { @@ -6516,207 +12160,398 @@ var AjaxAdapter = (function () { } _createClass(AjaxAdapter, [{ - key: 'create', - value: function create(store, type, partial, success, error, context) { - var _this = this; + key: "create", + value: function create(store, type, partial, options) { - if (error && ({}).toString.call(error) !== '[object Function]') { + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } - this.create(store, type, partial, success, null, error); - } else if (store._types[type]) { - (function () { + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: store.convert(type, partial) + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "POST", + responseType: "auto", + url: this._getUrl(type, null, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function (e) { + return store.find(e.response.data.type, e.response.data.id); + }).publish(); - var request = new XMLHttpRequest(); + source.connect(); - request.open('POST', _this._base + '/' + type, true); + return source; + } + }, { + key: "destroy", + value: function destroy(store, type, id, options) { - request.setRequestHeader("Content-Type", "application/vnd.api+json"); + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - var response = JSON.parse(request.responseText); - try { - store.push(response); - if (success) { - success.call(context, store.find(response.data.type, response.data.id)); - } - } catch (e) { - if (error) { - error.call(context, e); - } - } - } else { - if (error) { - error.call(context); - } - } - }; + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "DELETE", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.remove(type, id); + }).publish(); - request.send(JSON.stringify({ - data: store.convert(type, partial) - })); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + source.connect(); + + return source; + } + }, { + key: "load", + value: function load(store, type, id, options) { + + if (id && typeof id === "object") { + return this.load(store, type, null, id); + } + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "GET", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function () { + return id ? store.find(type, id) : store.findAll(type); + }).publish(); + + source.connect(); + + return source; } }, { - key: 'destroy', - value: function destroy(store, type, id, success, error, context) { - var _this2 = this; + key: "update", + value: function update(store, type, id, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var data = store.convert(type, id, partial); - if (error && ({}).toString.call(error) !== '[object Function]') { + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: data + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "PATCH", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.add(data); + }).map(function () { + return store.find(type, id); + }).publish(); - this.destroy(store, type, id, success, null, error); - } else if (store._types[type]) { - (function () { + source.connect(); - var request = new XMLHttpRequest(); + return source; + } + }, { + key: "_getUrl", + value: function _getUrl(type, id, options) { - request.open('DELETE', _this2._base + '/' + type + '/' + id, true); + var params = []; + var url = id ? this._base + "/" + type + "/" + id : this._base + "/" + type; - request.setRequestHeader("Content-Type", "application/vnd.api+json"); + if (options) { - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.remove(type, id); - if (success) { - success.call(context); - } - } catch (e) { - error.call(context, e); - } - } else if (error) { - error.call(context); - } - }; + if (options.fields) { + Object.keys(options.fields).forEach(function (field) { + options["fields[" + field + "]"] = options.fields[field]; + }); + delete options.fields; + } - request.send(); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); + params = Object.keys(options).map(function (key) { + return key + "=" + encodeURIComponent(options[key]); + }).sort(); + + if (params.length) { + url = url + "?" + params.join("&"); + } } + + return url; } - }, { - key: 'load', - value: function load(store, type, id, options, success, error, context) { - var _this3 = this; + }]); - if (id && ({}).toString.call(id) === '[object Function]') { - this.load(store, type, null, null, id, options, success); - } else if (id && typeof id === "object") { - this.load(store, type, null, id, options, success, error); - } else if (options && ({}).toString.call(options) === '[object Function]') { - this.load(store, type, id, {}, options, success, error); - } else if (error && ({}).toString.call(error) !== '[object Function]') { - this.load(store, type, id, options, success, null, error); - } else if (store._types[type]) { - (function () { + return AjaxAdapter; +})(); - var request = new XMLHttpRequest(); - var url = undefined; +exports["default"] = AjaxAdapter; +module.exports = exports["default"]; - options = options || {}; - url = id ? _this3._base + '/' + type + '/' + id : _this3._base + '/' + type; +},{"./ajax":5}],5:[function(require,module,exports){ +"use strict"; - if (options) { +Object.defineProperty(exports, "__esModule", { + value: true +}); - var params = []; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - if (options.fields) { - Object.keys(options.fields).forEach(function (field) { - options['fields[' + field + ']'] = options.fields[field]; - }); - delete options.fields; - } +var _rx = require("rx"); - params = Object.keys(options).map(function (key) { - return key + "=" + encodeURIComponent(options[key]); - }).sort(); +var _rx2 = _interopRequireDefault(_rx); - if (params.length) { - url = url + '?' + params.join("&"); - } +/** + * + * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc: + * + * https://github.com/Reactive-Extensions/RxJS-DOM + * + * The original source file can be viewed here: + * + * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js + * + * Licensed under the Apache License, Version 2.0: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Modifications from original: + * + * - extracted from "Rx.DOM" namespace + * - minor eslinter cleanup ("var" to "let" etc) + * - addition of "auto" responseType + * + */ + +var root = typeof window !== "undefined" && window || undefined; + +// Gets the proper XMLHttpRequest for support for older IE +function getXMLHttpRequest() { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else { + var progId = undefined; + try { + var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (var i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root.ActiveXObject(progId)) { + break; } + } catch (e) {} + } + return new root.ActiveXObject(progId); + } catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} - request.open('GET', url, true); +// Get CORS support even for older IE +function getCORSRequest() { + var xhr = new root.XMLHttpRequest(); + if ('withCredentials' in xhr) { + return xhr; + } else if (!!root.XDomainRequest) { + return new XDomainRequest(); + } else { + throw new Error('CORS is not supported by your browser'); + } +} - request.setRequestHeader("Content-Type", "application/vnd.api+json"); +function normalizeAjaxSuccessEvent(e, xhr, settings) { + var response = 'response' in xhr ? xhr.response : xhr.responseText; + if (settings.responseType === 'auto') { + try { + response = JSON.parse(response); + } catch (e) {} + } else { + response = settings.responseType === 'json' ? JSON.parse(response) : response; + } + return { + response: response, + status: xhr.status, + responseType: xhr.responseType, + xhr: xhr, + originalEvent: e + }; +} - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.push(JSON.parse(request.responseText)); - if (success) { - success.call(context, id ? store.find(type, id) : store.find(type)); - } - } catch (e) { - error.call({}, e); - } - } else if (error) { - error.call(context); - } - }; +function normalizeAjaxErrorEvent(e, xhr, type) { + return { + type: type, + status: xhr.status, + xhr: xhr, + originalEvent: e + }; +} - request.send(); - })(); - } else { - throw new Error('Unknown type \'' + type + '\''); +/** + * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL. + * + * @example + * source = ajax('/products'); + * source = ajax({ url: 'products', method: 'GET' }); + * + * @param {Object} settings Can be one of the following: + * + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - responseType: "text" (default), "json" or "auto" + * + * @returns {Observable} An observable sequence containing the XMLHttpRequest. +*/ + +exports["default"] = function (options) { + var settings = { + method: 'GET', + crossDomain: false, + async: true, + headers: {}, + responseType: 'text', + createXHR: function createXHR() { + return this.crossDomain ? getCORSRequest() : getXMLHttpRequest(); + }, + normalizeError: normalizeAjaxErrorEvent, + normalizeSuccess: normalizeAjaxSuccessEvent + }; + + if (typeof options === 'string') { + settings.url = options; + } else { + for (var prop in options) { + if (hasOwnProperty.call(options, prop)) { + settings[prop] = options[prop]; } } - }, { - key: 'update', - value: function update(store, type, id, partial, success, error, context) { - var _this4 = this; + } - if (error && ({}).toString.call(error) !== '[object Function]') { + var normalizeError = settings.normalizeError; + var normalizeSuccess = settings.normalizeSuccess; - this.update(store, type, id, partial, success, null, error); - } else if (store._types[type]) { - (function () { + if (!settings.crossDomain && !settings.headers['X-Requested-With']) { + settings.headers['X-Requested-With'] = 'XMLHttpRequest'; + } + settings.hasContent = settings.body !== undefined; - var request = new XMLHttpRequest(); - var data = store.convert(type, id, partial); + return new _rx2["default"].AnonymousObservable(function (observer) { + var isDone = false; + var xhr; - request.open('PATCH', _this4._base + '/' + type + '/' + id, true); + var processResponse = function processResponse(xhr, e) { + var status = xhr.status === 1223 ? 204 : xhr.status; + if (status >= 200 && status <= 300 || status === 0 || status === '') { + observer.onNext(normalizeSuccess(e, xhr, settings)); + observer.onCompleted(); + } else { + observer.onError(normalizeError(e, xhr, 'error')); + } + isDone = true; + }; - request.setRequestHeader("Content-Type", "application/vnd.api+json"); + try { + xhr = settings.createXHR();; + } catch (err) { + observer.onError(err); + } - request.onload = function () { - if (request.status >= 200 && request.status < 300) { - try { - store.add(data); - if (success) { - success.call(context, store.find(data.type, data.id)); - } - } catch (e) { - if (error) { - error.call(context, e); - } - } - } else if (error) { - error.call(context); - } + try { + if (settings.user) { + xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password); + } else { + xhr.open(settings.method, settings.url, settings.async); + } + + var headers = settings.headers; + for (var header in headers) { + if (hasOwnProperty.call(headers, header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + if (!!xhr.upload || !('withCredentials' in xhr) && !!root.XDomainRequest) { + xhr.onload = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onNext(e); + settings.progressObserver.onCompleted(); + } + processResponse(xhr, e); + }; + + if (settings.progressObserver) { + xhr.onprogress = function (e) { + settings.progressObserver.onNext(e); }; + } - request.send(JSON.stringify({ - data: data - })); - })(); + xhr.onerror = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'error')); + isDone = true; + }; + + xhr.onabort = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'abort')); + isDone = true; + }; } else { - throw new Error('Unknown type \'' + type + '\''); + + xhr.onreadystatechange = function (e) { + if (xhr.readyState === 4) { + processResponse(xhr, e); + } + }; } + + xhr.send(settings.hasContent && settings.body || null); + } catch (e) { + observer.onError(e); } - }]); - return AjaxAdapter; -})(); + return function () { + if (!isDone && xhr.readyState !== 4) { + xhr.abort(); + } + }; + }); +}; -exports['default'] = AjaxAdapter; -module.exports = exports['default']; +; +module.exports = exports["default"]; -},{}],5:[function(require,module,exports){ +},{"rx":3}],6:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6731,9 +12566,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons require("array.prototype.find"); -var _rxLite = require("rx-lite"); +var _rx = require("rx"); -var _rxLite2 = _interopRequireDefault(_rxLite); +var _rx2 = _interopRequireDefault(_rx); var _ajaxAdapter = require("./ajax-adapter"); @@ -6865,7 +12700,7 @@ var Store = (function () { this._adapter = adapter; this._data = {}; - this._subject = new _rxLite2["default"].Subject(); + this._subject = new _rx2["default"].Subject(); this._subscriptions = {}; this._types = {}; @@ -7000,22 +12835,21 @@ var Store = (function () { * @since 0.5.0 * @param {!string} type - Type of resource. * @param {!Object} partial - Data to create the resource with. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.create("product", { title: "A Book" }, (product) => { + * store.create("product", { title: "A Book" }).subscribe((product) => { * console.log(product.title); * }); */ }, { key: "create", - value: function create(type, partial, success, error, context) { + value: function create(type, partial, options) { if (this._adapter) { - this._adapter.create(this, type, partial, success, error, context); + return this._adapter.create(this, type, partial, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -7055,38 +12889,36 @@ var Store = (function () { * @since 0.5.0 * @param {!string} type - Type of resource. * @param {!string} id - ID of resource. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.destroy("product", "1", () => { + * store.destroy("product", "1").subscribe(() => { * console.log("Destroyed!"); * }); */ }, { key: "destroy", - value: function destroy(type, id, success, error, context) { + value: function destroy(type, id, options) { if (this._adapter) { - this._adapter.destroy(this, type, id, success, error, context); + return this._adapter.destroy(this, type, id, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } } /** - * Find a resource or entire collection of resources. + * Finds a resource by type and id. * * NOTE: If the resource hasn't been loaded via an add() or push() call it * will be automatically created when find is called. * * @since 0.1.0 - * @param {!string} type - Type of the resource(s) to find. - * @param {string} [id] - The id of the resource to find. If omitted all - * resources of the type will be returned. - * @return {Object|Object[]} - Either the resource or an array of resources. + * @param {!string} type - Type of the resource to find. + * @param {!string} id - The id of the resource to find. + * @return {Object} - The resource. */ }, { key: "find", @@ -7122,10 +12954,12 @@ var Store = (function () { v: _this5._data[type][id] }; } else { + // throw new TypeError(`You must provide an id`); + /*eslint-disable*/ + console.warn(["Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ return { - v: Object.keys(_this5._data[type]).map(function (x) { - return _this5._data[type][x]; - }) + v: _this5.findAll(type) }; } } else { @@ -7140,29 +12974,92 @@ var Store = (function () { } /** - * Attempts to load the resource(s) through the adapter and adds it/them to - * the store if successful. + * Finds all the resources of a given type. + * + * @since 0.7.0 + * @param {!string} type - Type of the resource to find. + * @return {Object[]} - An array of resources. + */ + }, { + key: "findAll", + value: function findAll(type) { + var _this6 = this; + + if (type) { + var definition = this._types[type]; + if (definition) { + if (!this._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this6._data[t] = collection; + }); + })(); + } + return Object.keys(this._data[type]).map(function (x) { + return _this6._data[type][x]; + }); + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Attempts to load the given resource through the adapter and adds it to the + * store if successful. * * @since 0.5.0 * @param {!string} type - Type of resource. - * @param {!string} [id] - ID of resource. - * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options) - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.load("product", "1", (product) => { + * store.load("products", "1").subscribe((product) => { * console.log(product.title); * }); */ }, { key: "load", - value: function load(type, id, options, success, error, context) { + value: function load(type, id, options) { + if (!id || typeof id === "object") { + /*eslint-disable*/ + console.warn(["Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + } + if (this._adapter) { + return this._adapter.load(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Attempts to load all the resources of the given type through the adapter + * and adds them to the store if successful. + * + * @since 0.7.0 + * @param {!string} type - Type of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.loadAll("products").subscribe((products) => { + * console.log(products); + * }); + */ + }, { + key: "loadAll", + value: function loadAll(type, options) { if (this._adapter) { - this._adapter.load(this, type, id, options, success, error, context); + return this._adapter.load(this, type, null, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -7181,7 +13078,9 @@ var Store = (function () { }, { key: "off", value: function off(event, type, id, callback) { + /*eslint-disable*/ console.warn(["The `store.off()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ if (event === "added" || event === "updated" || event === "removed") { if (this._types[type]) { if (id && ({}).toString.call(id) === '[object Function]') { @@ -7212,9 +13111,11 @@ var Store = (function () { }, { key: "on", value: function on(event, type, id, callback, context) { - var _this6 = this; + var _this7 = this; + /*eslint-disable*/ console.warn(["The `store.on()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ if (event === "added" || event === "updated" || event === "removed") { if (this._types[type]) { if (id && ({}).toString.call(id) === '[object Function]') { @@ -7224,7 +13125,7 @@ var Store = (function () { return e.name === event; }); subscription = subscription.filter(function (e) { - return _this6._types[type]._names.indexOf(e.type) !== -1; + return _this7._types[type]._names.indexOf(e.type) !== -1; }); if (id) { subscription = subscription.filter(function (e) { @@ -7232,14 +13133,14 @@ var Store = (function () { }); } subscription = subscription.map(function (e) { - return _this6.find(e.type, e.id); + return _this7.find(e.type, e.id); }); this._subscriptions[event] = this._subscriptions[event] || {}; if (!this._subscriptions[event][type]) { (function () { var obj = {}; - _this6._types[type]._names.forEach(function (type) { - _this6._subscriptions[event][type] = obj; + _this7._types[type]._names.forEach(function (type) { + _this7._subscriptions[event][type] = obj; }); })(); } @@ -7264,18 +13165,18 @@ var Store = (function () { }, { key: "push", value: function push(root) { - var _this7 = this; + var _this8 = this; if (root.data.constructor === Array) { root.data.forEach(function (x) { - return _this7.add(x); + return _this8.add(x); }); } else { this.add(root.data); } if (root.included) { root.included.forEach(function (x) { - return _this7.add(x); + return _this8.add(x); }); } } @@ -7291,7 +13192,7 @@ var Store = (function () { }, { key: "remove", value: function remove(type, id) { - var _this8 = this; + var _this9 = this; if (type) { if (this._types[type]) { @@ -7308,7 +13209,7 @@ var Store = (function () { } } else { Object.keys(this._data[type]).forEach(function (id) { - return _this8.remove(type, id); + return _this9.remove(type, id); }); } } else { @@ -7327,22 +13228,21 @@ var Store = (function () { * @param {!string} type - Type of resource. * @param {!string} id - ID of resource. * @param {!Object} partial - Data to update the resource with. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.update("product", "1", { title: "foo" }, (product) => { + * store.update("product", "1", { title: "foo" }).subscribe((product) => { * console.log(product.title); * }); */ }, { key: "update", - value: function update(type, id, partial, success, error, context) { + value: function update(type, id, partial, options) { if (this._adapter) { - this._adapter.update(this, type, id, partial, success, error, context); + return this._adapter.update(this, type, id, partial, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -7350,7 +13250,7 @@ var Store = (function () { }, { key: "_addField", value: function _addField(object, resource, definition, fieldName) { - var _this9 = this; + var _this10 = this; var field = definition[fieldName]; var newValue = field.deserialize.call(this, object, fieldName); @@ -7365,11 +13265,11 @@ var Store = (function () { } else if (field.type === "has-many") { resource[fieldName].forEach(function (r) { if (resource[fieldName].indexOf(r) !== -1) { - _this9._removeInverseRelationship(resource, fieldName, r, field); + _this10._removeInverseRelationship(resource, fieldName, r, field); } }); newValue.forEach(function (r) { - _this9._addInverseRelationship(resource, fieldName, r, field); + _this10._addInverseRelationship(resource, fieldName, r, field); }); } resource[fieldName] = newValue; @@ -7406,11 +13306,11 @@ var Store = (function () { }, { key: "_remove", value: function _remove(resource) { - var _this10 = this; + var _this11 = this; resource._dependents.forEach(function (dependent) { - var dependentResource = _this10._data[dependent.type][dependent.id]; - switch (_this10._types[dependent.type][dependent.fieldName].type) { + var dependentResource = _this11._data[dependent.type][dependent.id]; + switch (_this11._types[dependent.type][dependent.fieldName].type) { case "has-one": { dependentResource[dependent.fieldName] = null; @@ -7472,9 +13372,10 @@ var Store = (function () { exports["default"] = Store; +Store.Rx = _rx2["default"]; Store.AjaxAdapter = _ajaxAdapter2["default"]; module.exports = exports["default"]; -},{"./ajax-adapter":4,"array.prototype.find":1,"rx-lite":3}]},{},[5])(5) +},{"./ajax-adapter":4,"array.prototype.find":1,"rx":3}]},{},[6])(6) }); //# sourceMappingURL=store.dev.js.map diff --git a/dist/store.dev.js.map b/dist/store.dev.js.map index 21ecceb..eb4e609 100644 --- a/dist/store.dev.js.map +++ b/dist/store.dev.js.map @@ -4,20 +4,22 @@ "../node_modules/browserify/node_modules/browser-pack/_prelude.js", "../node_modules/array.prototype.find/index.js", "../node_modules/browserify/node_modules/process/browser.js", - "../node_modules/rx-lite/rx.lite.js", + "../node_modules/rx/dist/rx.all.js", "../src/ajax-adapter.js", + "../src/ajax.js", "../src/store.js" ], "names": [], - "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;IC9tMqB,WAAW;AAEnB,WAFQ,WAAW,CAElB,OAAO,EAAE;0BAFF,WAAW;;AAG5B,QAAI,CAAC,KAAK,GAAG,AAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAK,EAAE,CAAC;GAC9C;;eAJkB,WAAW;;WAMxB,gBAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;;;AAEpD,UAAI,KAAK,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,mBAAmB,EAAE;;AAE5D,YAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;OAEzD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;;;AAE7B,cAAI,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;;AAEnC,iBAAO,CAAC,IAAI,CAAC,MAAM,EAAK,MAAK,KAAK,SAAI,IAAI,EAAI,IAAI,CAAC,CAAC;;AAEpD,iBAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;;AAErE,iBAAO,CAAC,MAAM,GAAG,YAAY;AAC3B,gBAAI,OAAO,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;AACjD,kBAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAChD,kBAAI;AACF,qBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrB,oBAAI,OAAO,EAAE;AACX,yBAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;iBACzE;eACF,CAAC,OAAO,CAAC,EAAE;AACV,oBAAI,KAAK,EAAE;AACT,uBAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;iBACxB;eACF;aACF,MAAM;AACL,kBAAI,KAAK,EAAE;AACT,qBAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;eACrB;aACF;WACF,CAAC;;AAEF,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;AAC1B,gBAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;WACnC,CAAC,CAAC,CAAC;;OAEL,MAAM;AACL,cAAM,IAAI,KAAK,qBAAkB,IAAI,QAAI,CAAC;OAC3C;KAEF;;;WAEM,iBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;;;AAEhD,UAAI,KAAK,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,mBAAmB,EAAE;;AAE5D,YAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;OAErD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;;;AAE7B,cAAI,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;;AAEnC,iBAAO,CAAC,IAAI,CAAC,QAAQ,EAAK,OAAK,KAAK,SAAI,IAAI,SAAI,EAAE,EAAI,IAAI,CAAC,CAAC;;AAE5D,iBAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;;AAErE,iBAAO,CAAC,MAAM,GAAG,YAAY;AAC3B,gBAAI,OAAO,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;AACjD,kBAAI;AACF,qBAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACvB,oBAAI,OAAO,EAAE;AACX,yBAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACvB;eACF,CAAC,OAAO,CAAC,EAAE;AACV,qBAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;eACxB;aACF,MAAM,IAAI,KAAK,EAAE;AAChB,mBAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACrB;WACF,CAAC;;AAEF,iBAAO,CAAC,IAAI,EAAE,CAAC;;OAEhB,MAAM;AACL,cAAM,IAAI,KAAK,qBAAkB,IAAI,QAAI,CAAC;OAC3C;KAEF;;;WAEG,cAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;;;AAEtD,UAAI,EAAE,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACtD,YAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;OAC1D,MAAM,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AACvC,YAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;OAC3D,MAAM,IAAI,OAAO,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,mBAAmB,EAAE;AACvE,YAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;OACzD,MAAM,IAAI,KAAK,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,mBAAmB,EAAE;AACnE,YAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;OAC3D,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;;;AAE7B,cAAI,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;AACnC,cAAI,GAAG,YAAA,CAAC;;AAER,iBAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AACxB,aAAG,GAAG,EAAE,GAAM,OAAK,KAAK,SAAI,IAAI,SAAI,EAAE,GAAQ,OAAK,KAAK,SAAI,IAAI,AAAE,CAAC;;AAEnE,cAAI,OAAO,EAAE;;AAEX,gBAAI,MAAM,GAAG,EAAE,CAAC;;AAEhB,gBAAI,OAAO,CAAC,MAAM,EAAE;AAClB,oBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK,EAAI;AAC3C,uBAAO,aAAW,KAAK,OAAI,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;eACrD,CAAC,CAAC;AACH,qBAAO,OAAO,CAAC,MAAM,CAAC;aACvB;;AAED,kBAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAA,GAAG,EAAI;AACvC,qBAAO,GAAG,GAAG,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;aACrD,CAAC,CAAC,IAAI,EAAE,CAAC;;AAEV,gBAAI,MAAM,CAAC,MAAM,EAAE;AACjB,iBAAG,GAAM,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,AAAE,CAAC;aACpC;WAEF;;AAED,iBAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;;AAE/B,iBAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;;AAErE,iBAAO,CAAC,MAAM,GAAG,YAAY;AAC3B,gBAAI,OAAO,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;AACjD,kBAAI;AACF,qBAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;AAC7C,oBAAI,OAAO,EAAE;AACX,yBAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;iBACrE;eACF,CAAC,OAAO,CAAC,EAAE;AACV,qBAAK,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;eACnB;aACF,MAAM,IAAI,KAAK,EAAE;AAChB,mBAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACrB;WACF,CAAC;;AAEF,iBAAO,CAAC,IAAI,EAAE,CAAC;;OAEhB,MAAM;AACL,cAAM,IAAI,KAAK,qBAAkB,IAAI,QAAI,CAAC;OAC3C;KAEF;;;WAEK,gBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;;;AAExD,UAAI,KAAK,IAAI,CAAA,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,mBAAmB,EAAE;;AAE5D,YAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;OAE7D,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;;;AAE7B,cAAI,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;AACnC,cAAI,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;;AAE5C,iBAAO,CAAC,IAAI,CAAC,OAAO,EAAK,OAAK,KAAK,SAAI,IAAI,SAAI,EAAE,EAAI,IAAI,CAAC,CAAC;;AAE3D,iBAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;;AAErE,iBAAO,CAAC,MAAM,GAAG,YAAY;AAC3B,gBAAI,OAAO,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;AACjD,kBAAI;AACF,qBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,oBAAI,OAAO,EAAE;AACX,yBAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;iBACvD;eACF,CAAC,OAAO,CAAC,EAAE;AACV,oBAAI,KAAK,EAAE;AACT,uBAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;iBACxB;eACF;aACF,MAAM,IAAI,KAAK,EAAE;AAChB,mBAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACrB;WACF,CAAC;;AAEF,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;AAC1B,gBAAI,EAAE,IAAI;WACX,CAAC,CAAC,CAAC;;OAEL,MAAM;AACL,cAAM,IAAI,KAAK,qBAAkB,IAAI,QAAI,CAAC;OAC3C;KAEF;;;SAjMkB,WAAW;;;qBAAX,WAAW;;;;;;;;;;;;;;;;QCAzB,sBAAsB;;sBACd,SAAS;;;;2BACA,gBAAgB;;;;IAEnB,KAAK;eAAL,KAAK;;;;;;;;;;;;WAWb,cAAC,IAAI,EAAE,OAAO,EAAE;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAC/B,MAAM;AACL,eAAO;AACL,cAAI,EAAE,MAAM;AACZ,qBAAS,OAAO,IAAI,OAAO,WAAQ;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,mBAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;WACxD;AACD,mBAAS,EAAE,mBAAU,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACxC,gBAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;WAC9C;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWY,gBAAC,IAAI,EAAE,OAAO,EAAE;AAC3B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OACjC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,SAAS;AACf,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,IAAI,CAAC;eACb,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;eACxF;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AAC1B,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;aACxC,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE;AACJ,sBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI;AACxB,oBAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;iBACrB;eACF,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWa,iBAAC,IAAI,EAAE,OAAO,EAAE;AAC5B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAClC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,UAAU;AAChB,qBAAS,EAAE;AACX,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;;;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,EAAE,CAAC;eACX,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,EAAK;AAC9C,yBAAO,MAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBAChC,CAAC,CAAC;eACJ;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACjB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,EAAI;AAC3B,yBAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;iBACnC,CAAC;eACH,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;AAEU,WAhHQ,KAAK,CAgHZ,OAAO,EAAE;0BAhHF,KAAK;;AAkHtB,QAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,QAAI,CAAC,KAAK,GAAG,EAAE,CAAC;AAChB,QAAI,CAAC,QAAQ,GAAG,IAAI,oBAAG,OAAO,EAAE,CAAC;AACjC,QAAI,CAAC,cAAc,GAAG,EAAE,CAAC;AACzB,QAAI,CAAC,MAAM,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,QAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;GAEhD;;;;;;;;;;;eAhKkB,KAAK;;WA0KrB,aAAC,MAAM,EAAE;;;AACV,UAAI,MAAM,EAAE;AACV,YAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,EAAE;;AAC5B,gBAAI,IAAI,GAAG,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC;AAC/F,gBAAI,QAAQ,GAAG,OAAK,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AACjD,gBAAI,UAAU,GAAG,OAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1C,kBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,kBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,uBAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;eACzD;aACF,CAAC,CAAC;AACH,mBAAK,QAAQ,CAAC,MAAM,CAAC;AACnB,kBAAI,EAAE,IAAI;AACV,kBAAI,EAAE,MAAM,CAAC,IAAI;AACjB,gBAAE,EAAE,MAAM,CAAC,EAAE;AACb,sBAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;;SACJ,MAAM;AACL,gBAAM,IAAI,SAAS,oCAAoC,CAAC;SACzD;OACF,MAAM;AACL,cAAM,IAAI,SAAS,gCAAgC,CAAC;OACrD;KACF;;;;;;;;;;;;;WAWM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;OAC/C,MAAM,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AACvC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;OACtC,MAAM;;AACL,cAAI,IAAI,GAAG;AACT,gBAAI,EAAE,IAAI;AACV,sBAAU,EAAE,EAAE;AACd,yBAAa,EAAE,EAAE;WAClB,CAAC;AACF,cAAI,EAAE,EAAE;AACN,gBAAI,CAAC,EAAE,GAAG,EAAE,CAAC;WACd;AACD,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,gBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,wBAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;aAC3D;WACF,CAAC,CAAC;AACH;eAAO,IAAI;YAAC;;;;OACb;KACF;;;;;;;;;;;;;;;;;;;;;;WAoBK,gBAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AAC7C,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;OACpE,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;WASK,gBAAC,KAAK,EAAE,UAAU,EAAE;;;AACxB,WAAK,GAAG,AAAC,KAAK,CAAC,WAAW,KAAK,KAAK,GAAI,KAAK,GAAG,CAAE,KAAK,CAAE,CAAC;AAC1D,UAAI,UAAU,EAAE;AACd,kBAAU,CAAC,MAAM,GAAG,KAAK,CAAC;AAC1B,aAAK,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACpB,cAAI,CAAC,OAAK,MAAM,CAAC,IAAI,CAAC,EAAE;AACtB,mBAAK,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;WAChC,MAAM;AACL,kBAAM,IAAI,KAAK,gBAAc,IAAI,iCAA8B,CAAC;WACjE;SACF,CAAC,CAAC;OACJ,MAAM;AACL,cAAM,IAAI,KAAK,kDAAgD,KAAK,CAAC,CAAC,CAAC,QAAK,CAAC;OAC9E;KACF;;;;;;;;;;;;;;;;;;;;;;WAoBM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AACzC,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;OAChE,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;;;WAcG,cAAC,IAAI,EAAE,EAAE,EAAE;;;AACb,UAAI,IAAI,EAAE;;AACR,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,cAAI,UAAU,EAAE;AACd,gBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,EAAE;;AACrB,oBAAI,UAAU,GAAG,EAAE,CAAC;AACpB,0BAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;yBAAI,OAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU;iBAAA,CAAC,CAAC;;aAC5D;AACD,gBAAI,EAAE,EAAE;AACN,kBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE;AACzB,uBAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG;AACrB,6BAAW,EAAE,EAAE;AACf,sBAAI,EAAE,IAAI;AACV,oBAAE,EAAE,EAAE;iBACP,CAAC;AACF,sBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG,EAAI;AACrC,sBAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAClB,2BAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,WAAQ,CAAC;mBACrD;iBACF,CAAC,CAAC;eACJ;AACD;mBAAO,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAAC;aAC7B,MAAM;AACL;mBAAO,MAAM,CAAC,IAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC;yBAAI,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBAAA,CAAC;gBAAC;aACpE;WACF,MAAM;AACL,kBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;WAC/C;;;;OACF,MAAM;AACL,cAAM,IAAI,SAAS,2BAA2B,CAAC;OAChD;KACF;;;;;;;;;;;;;;;;;;;;;;;WAqBG,cAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AAC/C,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;OACtE,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;WAYE,aAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE;AAC7B,aAAO,CAAC,IAAI,CAAC,CACX,+EAA+E,EAC/E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACtD,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AACxH,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AACtD,mBAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;WACpD;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;;;;WAaC,YAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE;;;AACrC,aAAO,CAAC,IAAI,CAAC,CACX,8EAA8E,EAC9E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACrD,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AAC3H,gBAAI,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,CAAC,CAAC,IAAI,KAAK,KAAK;aAAA,CAAC,CAAC;AAC/D,wBAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAAA,CAAC,CAAC;AACzF,gBAAI,EAAE,EAAE;AACN,0BAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;uBAAI,CAAC,CAAC,EAAE,KAAK,EAAE;eAAA,CAAC,CAAC;aACtD;AACD,wBAAY,GAAG,YAAY,CAAC,GAAG,CAAC,UAAA,CAAC;qBAAI,OAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAAA,CAAC,CAAC;AAC9D,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAC9D,gBAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE;;AACrC,oBAAI,GAAG,GAAG,EAAE,CAAC;AACb,uBAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACvC,yBAAK,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;iBACxC,CAAC,CAAC;;aACJ;AACD,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;WAC9F;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;WAUG,cAAC,IAAI,EAAE;;;AACT,UAAI,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;AACnC,YAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACrC,MAAM;AACL,YAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;OACrB;AACD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACzC;KACF;;;;;;;;;;;;WAUK,gBAAC,IAAI,EAAE,EAAE,EAAE;;;AACf,UAAI,IAAI,EAAE;AACR,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,EAAE;AACN,gBAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AACxD,gBAAI,QAAQ,EAAE;AACZ,kBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvB,kBAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACnB,oBAAI,EAAE,SAAS;AACf,oBAAI,EAAE,IAAI;AACV,kBAAE,EAAE,EAAE;AACN,wBAAQ,EAAE,IAAI;eACf,CAAC,CAAC;aACJ;WACF,MAAM;AACL,kBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAA,EAAE;qBAAI,OAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;aAAA,CAAC,CAAC;WACpE;SACF,MAAM;AACL,gBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;SAC/C;OACF,MAAM;AACL,cAAM,IAAI,SAAS,qCAAqC,CAAC;OAC1D;KACF;;;;;;;;;;;;;;;;;;;;;;;WAqBK,gBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AACjD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;OACxE,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;WAEQ,mBAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE;;;AACjD,UAAI,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAClC,UAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/D,UAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,YAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;AAC5B,cAAI,QAAQ,CAAC,SAAS,CAAC,EAAE;AACvB,gBAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;WAClF;AACD,cAAI,QAAQ,EAAE;AACZ,gBAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;WACpE;SACF,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;AACpC,kBAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AAC/B,gBAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;AACzC,qBAAK,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aAChE;WACF,CAAC,CAAC;AACH,kBAAQ,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AACpB,mBAAK,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;WAC7D,CAAC,CAAC;SACJ;AACD,gBAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;OAChC;KACF;;;WAEsB,iCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACpF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,EAAE;AACpB,YAAI,eAAe,GAAG,CAAE,WAAW,CAAC,OAAO,CAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC;iBAAI,gBAAgB,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;AAC7G,YAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,sBAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,YAAI,WAAW,EAAE;AACf,cAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,0BAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC;WAClD,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,gBAAI,cAAc,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;AAClE,4BAAc,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aACtD;WACF,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,kBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;WACjH;SACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,gBAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;SAChH;OACF;KACF;;;WAEM,iBAAC,QAAQ,EAAE;;;AAChB,cAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AACxC,YAAI,iBAAiB,GAAG,QAAK,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACjE,gBAAQ,QAAK,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI;AAC3D,eAAK,SAAS;AAAE;AACd,+BAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;AAC9C,oBAAM;aACP;AAAA,AACD,eAAK,UAAU;AAAE;AACf,kBAAI,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrE,kBAAI,KAAK,KAAK,CAAC,CAAC,EAAE;AAChB,iCAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;eACzD;AACD,oBAAM;aACP;AAAA,AACD;AAAS;AACP,oBAAM;aACP;AAAA,SACF;;AAED,yBAAiB,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AACxE,iBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAA,AAAC,CAAC;SAC5D,CAAC,CAAC;OACJ,CAAC,CAAC;AACH,aAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;KAC/C;;;WAEyB,oCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACvF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,eAAe,GAAG,WAAW,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC;AACjE,UAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,oBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,eAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;OAC3G,CAAC,CAAC;AACH,UAAI,WAAW,EAAE;AACf,YAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;SACxC,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAC5E,mBAAO,CAAC,KAAK,cAAc,CAAC;WAC7B,CAAC,CAAC;SACJ,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,gBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;SACjH;OACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,cAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;OAChH;KACF;;;SAxnBkB,KAAK;;;qBAAL,KAAK;;AA4nB1B,KAAK,CAAC,WAAW,2BAAc,CAAC", + "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;oBCpuXiB,QAAQ;;;;IAEJ,WAAW;AAEnB,WAFQ,WAAW,CAElB,OAAO,EAAE;0BAFF,WAAW;;AAG5B,QAAI,CAAC,KAAK,GAAG,AAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAK,EAAE,CAAC;GAC9C;;eAJkB,WAAW;;WAMxB,gBAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;;AAEpC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,YAAI,EAAE,IAAI,CAAC,SAAS,CAAC;AACnB,cAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACnC,CAAC;AACF,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,MAAM;AACd,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;OACvC,CAAC,MAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;OAAA,CAAC,CAC/B,GAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;OAAA,CAAC,CAC9D,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEM,iBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAEhC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,QAAQ;AAChB,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC;eAAM,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;OAAA,CAAC,CAChC,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEG,cAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAE7B,UAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AAChC,eAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;OACzC;;AAED,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,KAAK;AACb,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;OAAA,CAAC,CAC/B,GAAG,CAAC;eAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;OAAA,CAAC,CAC1D,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEK,gBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;;AAExC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;;AAE5C,UAAI,MAAM,GAAG,uBAAK;AAChB,YAAI,EAAE,IAAI,CAAC,SAAS,CAAC;AACnB,cAAI,EAAE,IAAI;SACX,CAAC;AACF,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,OAAO;AACf,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC;eAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;OAAA,CAAC,CACzB,GAAG,CAAC;eAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;OAAA,CAAC,CAC/B,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAEzB,UAAI,MAAM,GAAG,EAAE,CAAC;AAChB,UAAI,GAAG,GAAG,EAAE,GAAM,IAAI,CAAC,KAAK,SAAI,IAAI,SAAI,EAAE,GAAQ,IAAI,CAAC,KAAK,SAAI,IAAI,AAAE,CAAC;;AAEvE,UAAI,OAAO,EAAE;;AAEX,YAAI,OAAO,CAAC,MAAM,EAAE;AAClB,gBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK,EAAI;AAC3C,mBAAO,aAAW,KAAK,OAAI,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;WACrD,CAAC,CAAC;AACH,iBAAO,OAAO,CAAC,MAAM,CAAC;SACvB;;AAED,cAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAA,GAAG,EAAI;AACvC,iBAAO,GAAG,GAAG,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;SACrD,CAAC,CAAC,IAAI,EAAE,CAAC;;AAEV,YAAI,MAAM,CAAC,MAAM,EAAE;AACjB,aAAG,GAAM,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,AAAE,CAAC;SACpC;OAEF;;AAED,aAAO,GAAG,CAAC;KAEZ;;;SA3IkB,WAAW;;;qBAAX,WAAW;;;;;;;;;;;;kBCFjB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBnB,IAAI,IAAI,GAAG,AAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,aAAS,CAAC;;;AAG7D,SAAS,iBAAiB,GAAG;AAC3B,MAAI,IAAI,CAAC,cAAc,EAAE;AACvB,WAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;GAClC,MAAM;AACL,QAAI,MAAM,YAAA,CAAC;AACX,QAAI;AACF,UAAI,OAAO,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;AAC5E,WAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACzB,YAAI;AACF,gBAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,cAAI,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;AAClC,kBAAM;WACP;SACF,CAAC,OAAM,CAAC,EAAE,EAAG;OACf;AACD,aAAO,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;KACvC,CAAC,OAAO,CAAC,EAAE;AACV,YAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;GACF;CACF;;;AAGD,SAAS,cAAc,GAAG;AACxB,MAAI,GAAG,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;AACpC,MAAI,iBAAiB,IAAI,GAAG,EAAE;AAC5B,WAAO,GAAG,CAAC;GACZ,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE;AAChC,WAAO,IAAI,cAAc,EAAE,CAAC;GAC7B,MAAM;AACL,UAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;GAC1D;CACF;;AAED,SAAS,yBAAyB,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE;AACnD,MAAI,QAAQ,GAAG,AAAC,UAAU,IAAI,GAAG,GAAI,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC;AACrE,MAAI,QAAQ,CAAC,YAAY,KAAK,MAAM,EAAE;AACpC,QAAI;AACF,cAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KACjC,CAAC,OAAO,CAAC,EAAE,EAAE;GACf,MAAM;AACL,YAAQ,GAAG,QAAQ,CAAC,YAAY,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;GAC/E;AACD,SAAO;AACL,YAAQ,EAAE,QAAQ;AAClB,UAAM,EAAE,GAAG,CAAC,MAAM;AAClB,gBAAY,EAAE,GAAG,CAAC,YAAY;AAC9B,OAAG,EAAE,GAAG;AACR,iBAAa,EAAE,CAAC;GACjB,CAAC;CACH;;AAED,SAAS,uBAAuB,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE;AAC7C,SAAO;AACL,QAAI,EAAE,IAAI;AACV,UAAM,EAAE,GAAG,CAAC,MAAM;AAClB,OAAG,EAAE,GAAG;AACR,iBAAa,EAAE,CAAC;GACjB,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;qBAuBc,UAAU,OAAO,EAAE;AAChC,MAAI,QAAQ,GAAG;AACb,UAAM,EAAE,KAAK;AACb,eAAW,EAAE,KAAK;AAClB,SAAK,EAAE,IAAI;AACX,WAAO,EAAE,EAAE;AACX,gBAAY,EAAE,MAAM;AACpB,aAAS,EAAE,qBAAU;AACnB,aAAO,IAAI,CAAC,WAAW,GAAG,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;KAClE;AACD,kBAAc,EAAE,uBAAuB;AACvC,oBAAgB,EAAE,yBAAyB;GAC5C,CAAC;;AAEF,MAAG,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC9B,YAAQ,CAAC,GAAG,GAAG,OAAO,CAAC;GACxB,MAAM;AACL,SAAI,IAAI,IAAI,IAAI,OAAO,EAAE;AACvB,UAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AACrC,gBAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;OAChC;KACF;GACF;;AAED,MAAI,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;AAC7C,MAAI,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;;AAEjD,MAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AAClE,YAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,gBAAgB,CAAC;GACzD;AACD,UAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;;AAElD,SAAO,IAAI,gBAAG,mBAAmB,CAAC,UAAU,QAAQ,EAAE;AACpD,QAAI,MAAM,GAAG,KAAK,CAAC;AACnB,QAAI,GAAG,CAAC;;AAER,QAAI,eAAe,GAAG,SAAlB,eAAe,CAAY,GAAG,EAAE,CAAC,EAAC;AACpC,UAAI,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;AACpD,UAAI,AAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAK,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,EAAE,EAAE;AACrE,gBAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpD,gBAAQ,CAAC,WAAW,EAAE,CAAC;OACxB,MAAM;AACL,gBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;OACnD;AACD,YAAM,GAAG,IAAI,CAAC;KACf,CAAC;;AAEF,QAAI;AACF,SAAG,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;KAC7B,CAAC,OAAO,GAAG,EAAE;AACZ,cAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KACvB;;AAED,QAAI;AACF,UAAI,QAAQ,CAAC,IAAI,EAAE;AACjB,WAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;OAC3F,MAAM;AACL,WAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;OACzD;;AAED,UAAI,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAC/B,WAAK,IAAI,MAAM,IAAI,OAAO,EAAE;AAC1B,YAAI,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;AACxC,aAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;SAC/C;OACF;;AAED,UAAG,CAAC,CAAC,GAAG,CAAC,MAAM,IAAK,EAAE,iBAAiB,IAAI,GAAG,CAAA,AAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,AAAC,EAAE;AACzE,WAAG,CAAC,MAAM,GAAG,UAAS,CAAC,EAAE;AACvB,cAAG,QAAQ,CAAC,gBAAgB,EAAE;AAC5B,oBAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpC,oBAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC;WACzC;AACD,yBAAe,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;SACzB,CAAC;;AAEF,YAAG,QAAQ,CAAC,gBAAgB,EAAE;AAC5B,aAAG,CAAC,UAAU,GAAG,UAAS,CAAC,EAAE;AAC3B,oBAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;WACrC,CAAC;SACH;;AAED,WAAG,CAAC,OAAO,GAAG,UAAS,CAAC,EAAE;AACxB,cAAI,QAAQ,CAAC,gBAAgB,EAAE;AAC7B,oBAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;WACtC;AACD,kBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,gBAAM,GAAG,IAAI,CAAC;SACf,CAAC;;AAEF,WAAG,CAAC,OAAO,GAAG,UAAS,CAAC,EAAE;AACxB,cAAI,QAAQ,CAAC,gBAAgB,EAAE;AAC7B,oBAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;WACtC;AACD,kBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,gBAAM,GAAG,IAAI,CAAC;SACf,CAAC;OACH,MAAM;;AAEL,WAAG,CAAC,kBAAkB,GAAG,UAAU,CAAC,EAAE;AACpC,cAAI,GAAG,CAAC,UAAU,KAAK,CAAC,EAAE;AACxB,2BAAe,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;WACzB;SACF,CAAC;OACH;;AAED,SAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;KACxD,CAAC,OAAO,CAAC,EAAE;AACV,cAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACrB;;AAED,WAAO,YAAY;AACjB,UAAI,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,EAAE;AAAE,WAAG,CAAC,KAAK,EAAE,CAAC;OAAE;KACtD,CAAC;GACH,CAAC,CAAC;CACJ;;AAAA,CAAC;;;;;;;;;;;;;;;;QChOK,sBAAsB;;kBACd,IAAI;;;;2BACK,gBAAgB;;;;IAEnB,KAAK;eAAL,KAAK;;;;;;;;;;;;WAWb,cAAC,IAAI,EAAE,OAAO,EAAE;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAC/B,MAAM;AACL,eAAO;AACL,cAAI,EAAE,MAAM;AACZ,qBAAS,OAAO,IAAI,OAAO,WAAQ;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,mBAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;WACxD;AACD,mBAAS,EAAE,mBAAU,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACxC,gBAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;WAC9C;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWY,gBAAC,IAAI,EAAE,OAAO,EAAE;AAC3B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OACjC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,SAAS;AACf,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,IAAI,CAAC;eACb,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;eACxF;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AAC1B,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;aACxC,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE;AACJ,sBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI;AACxB,oBAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;iBACrB;eACF,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWa,iBAAC,IAAI,EAAE,OAAO,EAAE;AAC5B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAClC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,UAAU;AAChB,qBAAS,EAAE;AACX,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;;;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,EAAE,CAAC;eACX,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,EAAK;AAC9C,yBAAO,MAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBAChC,CAAC,CAAC;eACJ;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACjB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,EAAI;AAC3B,yBAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;iBACnC,CAAC;eACH,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;AAEU,WAhHQ,KAAK,CAgHZ,OAAO,EAAE;0BAhHF,KAAK;;AAkHtB,QAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,QAAI,CAAC,KAAK,GAAG,EAAE,CAAC;AAChB,QAAI,CAAC,QAAQ,GAAG,IAAI,gBAAG,OAAO,EAAE,CAAC;AACjC,QAAI,CAAC,cAAc,GAAG,EAAE,CAAC;AACzB,QAAI,CAAC,MAAM,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,QAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;GAEhD;;;;;;;;;;;eAhKkB,KAAK;;WA0KrB,aAAC,MAAM,EAAE;;;AACV,UAAI,MAAM,EAAE;AACV,YAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,EAAE;;AAC5B,gBAAI,IAAI,GAAG,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC;AAC/F,gBAAI,QAAQ,GAAG,OAAK,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AACjD,gBAAI,UAAU,GAAG,OAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1C,kBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,kBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,uBAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;eACzD;aACF,CAAC,CAAC;AACH,mBAAK,QAAQ,CAAC,MAAM,CAAC;AACnB,kBAAI,EAAE,IAAI;AACV,kBAAI,EAAE,MAAM,CAAC,IAAI;AACjB,gBAAE,EAAE,MAAM,CAAC,EAAE;AACb,sBAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;;SACJ,MAAM;AACL,gBAAM,IAAI,SAAS,oCAAoC,CAAC;SACzD;OACF,MAAM;AACL,cAAM,IAAI,SAAS,gCAAgC,CAAC;OACrD;KACF;;;;;;;;;;;;;WAWM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;OAC/C,MAAM,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AACvC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;OACtC,MAAM;;AACL,cAAI,IAAI,GAAG;AACT,gBAAI,EAAE,IAAI;AACV,sBAAU,EAAE,EAAE;AACd,yBAAa,EAAE,EAAE;WAClB,CAAC;AACF,cAAI,EAAE,EAAE;AACN,gBAAI,CAAC,EAAE,GAAG,EAAE,CAAC;WACd;AACD,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,gBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,wBAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;aAC3D;WACF,CAAC,CAAC;AACH;eAAO,IAAI;YAAC;;;;OACb;KACF;;;;;;;;;;;;;;;;;;;;;WAmBK,gBAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;AAC7B,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;OAC3D,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;WASK,gBAAC,KAAK,EAAE,UAAU,EAAE;;;AACxB,WAAK,GAAG,AAAC,KAAK,CAAC,WAAW,KAAK,KAAK,GAAI,KAAK,GAAG,CAAE,KAAK,CAAE,CAAC;AAC1D,UAAI,UAAU,EAAE;AACd,kBAAU,CAAC,MAAM,GAAG,KAAK,CAAC;AAC1B,aAAK,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACpB,cAAI,CAAC,OAAK,MAAM,CAAC,IAAI,CAAC,EAAE;AACtB,mBAAK,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;WAChC,MAAM;AACL,kBAAM,IAAI,KAAK,gBAAc,IAAI,iCAA8B,CAAC;WACjE;SACF,CAAC,CAAC;OACJ,MAAM;AACL,cAAM,IAAI,KAAK,kDAAgD,KAAK,CAAC,CAAC,CAAC,QAAK,CAAC;OAC9E;KACF;;;;;;;;;;;;;;;;;;;;;WAmBM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;AACzB,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;OACvD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;;WAaG,cAAC,IAAI,EAAE,EAAE,EAAE;;;AACb,UAAI,IAAI,EAAE;;AACR,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,cAAI,UAAU,EAAE;AACd,gBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,EAAE;;AACrB,oBAAI,UAAU,GAAG,EAAE,CAAC;AACpB,0BAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;yBAAI,OAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU;iBAAA,CAAC,CAAC;;aAC5D;AACD,gBAAI,EAAE,EAAE;AACN,kBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE;AACzB,uBAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG;AACrB,6BAAW,EAAE,EAAE;AACf,sBAAI,EAAE,IAAI;AACV,oBAAE,EAAE,EAAE;iBACP,CAAC;AACF,sBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG,EAAI;AACrC,sBAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAClB,2BAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,WAAQ,CAAC;mBACrD;iBACF,CAAC,CAAC;eACJ;AACD;mBAAO,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAAC;aAC7B,MAAM;;;AAGL,qBAAO,CAAC,IAAI,CAAC,CACX,kHAAkH,EAClH,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd;mBAAO,OAAK,OAAO,CAAC,IAAI,CAAC;gBAAC;aAC3B;WACF,MAAM;AACL,kBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;WAC/C;;;;OACF,MAAM;AACL,cAAM,IAAI,SAAS,2BAA2B,CAAC;OAChD;KACF;;;;;;;;;;;WASM,iBAAC,IAAI,EAAE;;;AACZ,UAAI,IAAI,EAAE;AACR,YAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,YAAI,UAAU,EAAE;AACd,cAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;;AACrB,kBAAI,UAAU,GAAG,EAAE,CAAC;AACpB,wBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;uBAAI,OAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU;eAAA,CAAC,CAAC;;WAC5D;AACD,iBAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC;mBAAI,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;WAAA,CAAC,CAAC;SACpE,MAAM;AACL,gBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;SAC/C;OACF,MAAM;AACL,cAAM,IAAI,SAAS,2BAA2B,CAAC;OAChD;KACF;;;;;;;;;;;;;;;;;;;;;WAmBG,cAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;AACtB,UAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;;AAEjC,eAAO,CAAC,IAAI,CAAC,CACX,kHAAkH,EAClH,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;OAEf;AACD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;OACpD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;;;;;;;WAkBM,iBAAC,IAAI,EAAE,OAAO,EAAE;AACrB,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;OACtD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;WAYE,aAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE;;AAE7B,aAAO,CAAC,IAAI,CAAC,CACX,+EAA+E,EAC/E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACtD,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AACxH,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AACtD,mBAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;WACpD;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;;;;WAaC,YAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE;;;;AAErC,aAAO,CAAC,IAAI,CAAC,CACX,8EAA8E,EAC9E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACrD,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AAC3H,gBAAI,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,CAAC,CAAC,IAAI,KAAK,KAAK;aAAA,CAAC,CAAC;AAC/D,wBAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAAA,CAAC,CAAC;AACzF,gBAAI,EAAE,EAAE;AACN,0BAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;uBAAI,CAAC,CAAC,EAAE,KAAK,EAAE;eAAA,CAAC,CAAC;aACtD;AACD,wBAAY,GAAG,YAAY,CAAC,GAAG,CAAC,UAAA,CAAC;qBAAI,OAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAAA,CAAC,CAAC;AAC9D,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAC9D,gBAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE;;AACrC,oBAAI,GAAG,GAAG,EAAE,CAAC;AACb,uBAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACvC,yBAAK,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;iBACxC,CAAC,CAAC;;aACJ;AACD,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;WAC9F;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;WAUG,cAAC,IAAI,EAAE;;;AACT,UAAI,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;AACnC,YAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACrC,MAAM;AACL,YAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;OACrB;AACD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACzC;KACF;;;;;;;;;;;;WAUK,gBAAC,IAAI,EAAE,EAAE,EAAE;;;AACf,UAAI,IAAI,EAAE;AACR,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,EAAE;AACN,gBAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AACxD,gBAAI,QAAQ,EAAE;AACZ,kBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvB,kBAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACnB,oBAAI,EAAE,SAAS;AACf,oBAAI,EAAE,IAAI;AACV,kBAAE,EAAE,EAAE;AACN,wBAAQ,EAAE,IAAI;eACf,CAAC,CAAC;aACJ;WACF,MAAM;AACL,kBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAA,EAAE;qBAAI,OAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;aAAA,CAAC,CAAC;WACpE;SACF,MAAM;AACL,gBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;SAC/C;OACF,MAAM;AACL,cAAM,IAAI,SAAS,qCAAqC,CAAC;OAC1D;KACF;;;;;;;;;;;;;;;;;;;;;;WAoBK,gBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;AACjC,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;OAC/D,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;WAEQ,mBAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE;;;AACjD,UAAI,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAClC,UAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/D,UAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,YAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;AAC5B,cAAI,QAAQ,CAAC,SAAS,CAAC,EAAE;AACvB,gBAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;WAClF;AACD,cAAI,QAAQ,EAAE;AACZ,gBAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;WACpE;SACF,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;AACpC,kBAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AAC/B,gBAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;AACzC,sBAAK,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aAChE;WACF,CAAC,CAAC;AACH,kBAAQ,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AACpB,oBAAK,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;WAC7D,CAAC,CAAC;SACJ;AACD,gBAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;OAChC;KACF;;;WAEsB,iCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACpF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,EAAE;AACpB,YAAI,eAAe,GAAG,CAAE,WAAW,CAAC,OAAO,CAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC;iBAAI,gBAAgB,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;AAC7G,YAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,sBAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,YAAI,WAAW,EAAE;AACf,cAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,0BAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC;WAClD,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,gBAAI,cAAc,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;AAClE,4BAAc,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aACtD;WACF,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,kBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;WACjH;SACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,gBAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;SAChH;OACF;KACF;;;WAEM,iBAAC,QAAQ,EAAE;;;AAChB,cAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AACxC,YAAI,iBAAiB,GAAG,QAAK,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACjE,gBAAQ,QAAK,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI;AAC3D,eAAK,SAAS;AAAE;AACd,+BAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;AAC9C,oBAAM;aACP;AAAA,AACD,eAAK,UAAU;AAAE;AACf,kBAAI,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrE,kBAAI,KAAK,KAAK,CAAC,CAAC,EAAE;AAChB,iCAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;eACzD;AACD,oBAAM;aACP;AAAA,AACD;AAAS;AACP,oBAAM;aACP;AAAA,SACF;;AAED,yBAAiB,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AACxE,iBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAA,AAAC,CAAC;SAC5D,CAAC,CAAC;OACJ,CAAC,CAAC;AACH,aAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;KAC/C;;;WAEyB,oCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACvF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,eAAe,GAAG,WAAW,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC;AACjE,UAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,oBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,eAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;OAC3G,CAAC,CAAC;AACH,UAAI,WAAW,EAAE;AACf,YAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;SACxC,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAC5E,mBAAO,CAAC,KAAK,cAAc,CAAC;WAC7B,CAAC,CAAC;SACJ,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,gBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;SACjH;OACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,cAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;OAChH;KACF;;;SArrBkB,KAAK;;;qBAAL,KAAK;;AAyrB1B,KAAK,CAAC,EAAE,kBAAK,CAAC;AACd,KAAK,CAAC,WAAW,2BAAc,CAAC", "file": "generated.js", "sourceRoot": "", "sourcesContent": [ "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o\n// For all details and docs: https://github.com/paulmillr/array.prototype.find\n// Fixes and tests supplied by Duncan Hall \n(function(globals){\n if (Array.prototype.find) return;\n\n var find = function(predicate) {\n var list = Object(this);\n var length = list.length < 0 ? 0 : list.length >>> 0; // ES.ToUint32;\n if (length === 0) return undefined;\n if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') {\n throw new TypeError('Array#find: predicate must be a function');\n }\n var thisArg = arguments[1];\n for (var i = 0, value; i < length; i++) {\n value = list[i];\n if (predicate.call(thisArg, value, i, list)) return value;\n }\n return undefined;\n };\n\n if (Object.defineProperty) {\n try {\n Object.defineProperty(Array.prototype, 'find', {\n value: find, configurable: true, enumerable: false, writable: true\n });\n } catch(e) {}\n }\n\n if (!Array.prototype.find) {\n Array.prototype.find = find;\n }\n})(this);\n", "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", - "// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\r\n;(function (undefined) {\n\n var objectTypes = {\n 'function': true,\n 'object': true\n };\n\n var\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeSelf = objectTypes[typeof self] && self.Object && self,\n freeWindow = objectTypes[typeof window] && window && window.Object && window,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;\n\n var root = root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;\n\n var Rx = {\n internals: {},\n config: {\n Promise: root.Promise\n },\n helpers: { }\n };\n\r\n // Defaults\n var noop = Rx.helpers.noop = function () { },\n identity = Rx.helpers.identity = function (x) { return x; },\n defaultNow = Rx.helpers.defaultNow = Date.now,\n defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },\n defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },\n defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },\n defaultError = Rx.helpers.defaultError = function (err) { throw err; },\n isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; },\n isFunction = Rx.helpers.isFunction = (function () {\n\n var isFn = function (value) {\n return typeof value == 'function' || false;\n }\n\n // fallback for older versions of Chrome and Safari\n if (isFn(/x/)) {\n isFn = function(value) {\n return typeof value == 'function' && toString.call(value) == '[object Function]';\n };\n }\n\n return isFn;\n }());\n\n function cloneArray(arr) {\n var len = arr.length, a = new Array(len);\n for(var i = 0; i < len; i++) { a[i] = arr[i]; }\n return a;\n }\n\r\n var errorObj = {e: {}};\n function tryCatcherGen(tryCatchTarget) {\n return function tryCatcher() {\n try {\n return tryCatchTarget.apply(this, arguments);\n } catch (e) {\n errorObj.e = e;\n return errorObj;\n }\n }\n }\n var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) {\n if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }\n return tryCatcherGen(fn);\n }\n function thrower(e) {\n throw e;\n }\n\r\n Rx.config.longStackSupport = false;\n var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })();\n hasStacks = !!stacks.e && !!stacks.e.stack;\n\n // All code after this point will be filtered from stack traces reported by RxJS\n var rStartingLine = captureLine(), rFileName;\n\r\n var STACK_JUMP_SEPARATOR = 'From previous event:';\n\n function makeStackTraceLong(error, observable) {\n // If possible, transform the error stack trace by removing Node and RxJS\n // cruft, then concatenating with the stack trace of `observable`.\n if (hasStacks &&\n observable.stack &&\n typeof error === 'object' &&\n error !== null &&\n error.stack &&\n error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1\n ) {\n var stacks = [];\n for (var o = observable; !!o; o = o.source) {\n if (o.stack) {\n stacks.unshift(o.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join('\\n' + STACK_JUMP_SEPARATOR + '\\n');\n error.stack = filterStackString(concatedStacks);\n }\n }\n\n function filterStackString(stackString) {\n var lines = stackString.split('\\n'), desiredLines = [];\n for (var i = 0, len = lines.length; i < len; i++) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join('\\n');\n }\n\n function isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n if (!fileNameAndLineNumber) {\n return false;\n }\n var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];\n\n return fileName === rFileName &&\n lineNumber >= rStartingLine &&\n lineNumber <= rEndingLine;\n }\n\n function isNodeFrame(stackLine) {\n return stackLine.indexOf('(module.js:') !== -1 ||\n stackLine.indexOf('(node.js:') !== -1;\n }\n\n function captureLine() {\n if (!hasStacks) { return; }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split('\\n');\n var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) { return; }\n\n rFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n }\n\n function getFileNameAndLineNumber(stackLine) {\n // Named functions: 'at functionName (filename:lineNumber:columnNumber)'\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }\n\n // Anonymous functions: 'at filename:lineNumber:columnNumber'\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }\n\n // Firefox style: 'function@filename:lineNumber or @filename:lineNumber'\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }\n }\n\r\n var EmptyError = Rx.EmptyError = function() {\n this.message = 'Sequence contains no elements.';\n this.name = 'EmptyError';\n Error.call(this);\n };\n EmptyError.prototype = Object.create(Error.prototype);\n\n var ObjectDisposedError = Rx.ObjectDisposedError = function() {\n this.message = 'Object has been disposed';\n this.name = 'ObjectDisposedError';\n Error.call(this);\n };\n ObjectDisposedError.prototype = Object.create(Error.prototype);\n\n var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {\n this.message = 'Argument out of range';\n this.name = 'ArgumentOutOfRangeError';\n Error.call(this);\n };\n ArgumentOutOfRangeError.prototype = Object.create(Error.prototype);\n\n var NotSupportedError = Rx.NotSupportedError = function (message) {\n this.message = message || 'This operation is not supported';\n this.name = 'NotSupportedError';\n Error.call(this);\n };\n NotSupportedError.prototype = Object.create(Error.prototype);\n\n var NotImplementedError = Rx.NotImplementedError = function (message) {\n this.message = message || 'This operation is not implemented';\n this.name = 'NotImplementedError';\n Error.call(this);\n };\n NotImplementedError.prototype = Object.create(Error.prototype);\n\n var notImplemented = Rx.helpers.notImplemented = function () {\n throw new NotImplementedError();\n };\n\n var notSupported = Rx.helpers.notSupported = function () {\n throw new NotSupportedError();\n };\n\r\n // Shim in iterator support\n var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||\n '_es6shim_iterator_';\n // Bug for mozilla version\n if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {\n $iterator$ = '@@iterator';\n }\n\n var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };\n\n var isIterable = Rx.helpers.isIterable = function (o) {\n return o[$iterator$] !== undefined;\n }\n\n var isArrayLike = Rx.helpers.isArrayLike = function (o) {\n return o && o.length !== undefined;\n }\n\n Rx.helpers.iterator = $iterator$;\n\r\n var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {\n if (typeof thisArg === 'undefined') { return func; }\n switch(argCount) {\n case 0:\n return function() {\n return func.call(thisArg)\n };\n case 1:\n return function(arg) {\n return func.call(thisArg, arg);\n }\n case 2:\n return function(value, index) {\n return func.call(thisArg, value, index);\n };\n case 3:\n return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n }\n\n return function() {\n return func.apply(thisArg, arguments);\n };\n };\n\r\n /** Used to determine if values are of the language type Object */\n var dontEnums = ['toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'],\n dontEnumsLength = dontEnums.length;\n\r\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n errorClass = '[object Error]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n var toString = Object.prototype.toString,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n supportsArgsClass = toString.call(arguments) == argsClass, // For less -1);\n }\n });\n }\n }\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\r\n var hasProp = {}.hasOwnProperty,\n slice = Array.prototype.slice;\n\n var inherits = Rx.internals.inherits = function (child, parent) {\n function __() { this.constructor = child; }\n __.prototype = parent.prototype;\n child.prototype = new __();\n };\n\n var addProperties = Rx.internals.addProperties = function (obj) {\n for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n for (var idx = 0, ln = sources.length; idx < ln; idx++) {\n var source = sources[idx];\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n };\n\n // Rx Utils\n var addRef = Rx.internals.addRef = function (xs, r) {\n return new AnonymousObservable(function (observer) {\n return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));\n });\n };\n\n function arrayInitialize(count, factory) {\n var a = new Array(count);\n for (var i = 0; i < count; i++) {\n a[i] = factory();\n }\n return a;\n }\n\r\n /**\n * Represents a group of disposable resources that are disposed together.\n * @constructor\n */\n var CompositeDisposable = Rx.CompositeDisposable = function () {\n var args = [], i, len;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n len = args.length;\n } else {\n len = arguments.length;\n args = new Array(len);\n for(i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n for(i = 0; i < len; i++) {\n if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); }\n }\n this.disposables = args;\n this.isDisposed = false;\n this.length = args.length;\n };\n\n var CompositeDisposablePrototype = CompositeDisposable.prototype;\n\n /**\n * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.\n * @param {Mixed} item Disposable to add.\n */\n CompositeDisposablePrototype.add = function (item) {\n if (this.isDisposed) {\n item.dispose();\n } else {\n this.disposables.push(item);\n this.length++;\n }\n };\n\n /**\n * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.\n * @param {Mixed} item Disposable to remove.\n * @returns {Boolean} true if found; false otherwise.\n */\n CompositeDisposablePrototype.remove = function (item) {\n var shouldDispose = false;\n if (!this.isDisposed) {\n var idx = this.disposables.indexOf(item);\n if (idx !== -1) {\n shouldDispose = true;\n this.disposables.splice(idx, 1);\n this.length--;\n item.dispose();\n }\n }\n return shouldDispose;\n };\n\n /**\n * Disposes all disposables in the group and removes them from the group.\n */\n CompositeDisposablePrototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var len = this.disposables.length, currentDisposables = new Array(len);\n for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }\n this.disposables = [];\n this.length = 0;\n\n for (i = 0; i < len; i++) {\n currentDisposables[i].dispose();\n }\n }\n };\n\r\n /**\n * Provides a set of static methods for creating Disposables.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n */\n var Disposable = Rx.Disposable = function (action) {\n this.isDisposed = false;\n this.action = action || noop;\n };\n\n /** Performs the task of cleaning up resources. */\n Disposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.action();\n this.isDisposed = true;\n }\n };\n\n /**\n * Creates a disposable object that invokes the specified action when disposed.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n * @return {Disposable} The disposable object that runs the given action upon disposal.\n */\n var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };\n\n /**\n * Gets the disposable that does nothing when disposed.\n */\n var disposableEmpty = Disposable.empty = { dispose: noop };\n\n /**\n * Validates whether the given object is a disposable\n * @param {Object} Object to test whether it has a dispose method\n * @returns {Boolean} true if a disposable object, else false.\n */\n var isDisposable = Disposable.isDisposable = function (d) {\n return d && isFunction(d.dispose);\n };\n\n var checkDisposed = Disposable.checkDisposed = function (disposable) {\n if (disposable.isDisposed) { throw new ObjectDisposedError(); }\n };\n\r\n // Single assignment\n var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SingleAssignmentDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SingleAssignmentDisposable.prototype.setDisposable = function (value) {\n if (this.current) { throw new Error('Disposable has already been assigned'); }\n var shouldDispose = this.isDisposed;\n !shouldDispose && (this.current = value);\n shouldDispose && value && value.dispose();\n };\n SingleAssignmentDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\n // Multiple assignment disposable\n var SerialDisposable = Rx.SerialDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SerialDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SerialDisposable.prototype.setDisposable = function (value) {\n var shouldDispose = this.isDisposed;\n if (!shouldDispose) {\n var old = this.current;\n this.current = value;\n }\n old && old.dispose();\n shouldDispose && value && value.dispose();\n };\n SerialDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\r\n /**\n * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.\n */\n var RefCountDisposable = Rx.RefCountDisposable = (function () {\n\n function InnerDisposable(disposable) {\n this.disposable = disposable;\n this.disposable.count++;\n this.isInnerDisposed = false;\n }\n\n InnerDisposable.prototype.dispose = function () {\n if (!this.disposable.isDisposed && !this.isInnerDisposed) {\n this.isInnerDisposed = true;\n this.disposable.count--;\n if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {\n this.disposable.isDisposed = true;\n this.disposable.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Initializes a new instance of the RefCountDisposable with the specified disposable.\n * @constructor\n * @param {Disposable} disposable Underlying disposable.\n */\n function RefCountDisposable(disposable) {\n this.underlyingDisposable = disposable;\n this.isDisposed = false;\n this.isPrimaryDisposed = false;\n this.count = 0;\n }\n\n /**\n * Disposes the underlying disposable only when all dependent disposables have been disposed\n */\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed && !this.isPrimaryDisposed) {\n this.isPrimaryDisposed = true;\n if (this.count === 0) {\n this.isDisposed = true;\n this.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.\n * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.\n */\n RefCountDisposable.prototype.getDisposable = function () {\n return this.isDisposed ? disposableEmpty : new InnerDisposable(this);\n };\n\n return RefCountDisposable;\n })();\n\r\n var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {\n this.scheduler = scheduler;\n this.state = state;\n this.action = action;\n this.dueTime = dueTime;\n this.comparer = comparer || defaultSubComparer;\n this.disposable = new SingleAssignmentDisposable();\n }\n\n ScheduledItem.prototype.invoke = function () {\n this.disposable.setDisposable(this.invokeCore());\n };\n\n ScheduledItem.prototype.compareTo = function (other) {\n return this.comparer(this.dueTime, other.dueTime);\n };\n\n ScheduledItem.prototype.isCancelled = function () {\n return this.disposable.isDisposed;\n };\n\n ScheduledItem.prototype.invokeCore = function () {\n return this.action(this.scheduler, this.state);\n };\n\r\n /** Provides a set of static properties to access commonly used schedulers. */\n var Scheduler = Rx.Scheduler = (function () {\n\n function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute) {\n this.now = now;\n this._schedule = schedule;\n this._scheduleRelative = scheduleRelative;\n this._scheduleAbsolute = scheduleAbsolute;\n }\n\n /** Determines whether the given object is a scheduler */\n Scheduler.isScheduler = function (s) {\n return s instanceof Scheduler;\n }\n\n function invokeAction(scheduler, action) {\n action();\n return disposableEmpty;\n }\n\n var schedulerProto = Scheduler.prototype;\n\n /**\n * Schedules an action to be executed.\n * @param {Function} action Action to execute.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.schedule = function (action) {\n return this._schedule(action, invokeAction);\n };\n\n /**\n * Schedules an action to be executed.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithState = function (state, action) {\n return this._schedule(state, action);\n };\n\n /**\n * Schedules an action to be executed after the specified relative due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelative = function (dueTime, action) {\n return this._scheduleRelative(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative(state, dueTime, action);\n };\n\n /**\n * Schedules an action to be executed at the specified absolute due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsolute = function (dueTime, action) {\n return this._scheduleAbsolute(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number}dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute(state, dueTime, action);\n };\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.now = defaultNow;\n\n /**\n * Normalizes the specified TimeSpan value to a positive value.\n * @param {Number} timeSpan The time span value to normalize.\n * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0\n */\n Scheduler.normalize = function (timeSpan) {\n timeSpan < 0 && (timeSpan = 0);\n return timeSpan;\n };\n\n return Scheduler;\n }());\n\n var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;\n\r\n (function (schedulerProto) {\n\n function invokeRecImmediate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2) {\n var isAdded = false, isDone = false;\n\n var d = scheduler.scheduleWithState(state2, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n function invokeRecDate(scheduler, pair, method) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2, dueTime1) {\n var isAdded = false, isDone = false;\n\n var d = scheduler[method](state2, dueTime1, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n function invokeRecDateRelative(s, p) {\n return invokeRecDate(s, p, 'scheduleWithRelativeAndState');\n }\n\n function invokeRecDateAbsolute(s, p) {\n return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');\n }\n\n function scheduleInnerRecursive(action, self) {\n action(function(dt) { self(action, dt); });\n }\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursive = function (action) {\n return this.scheduleRecursiveWithState(action, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithState = function (state, action) {\n return this.scheduleWithState([state, action], invokeRecImmediate);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelative = function (dueTime, action) {\n return this.scheduleRecursiveWithRelativeAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative([state, action], dueTime, invokeRecDateRelative);\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsolute = function (dueTime, action) {\n return this.scheduleRecursiveWithAbsoluteAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute([state, action], dueTime, invokeRecDateAbsolute);\n };\n }(Scheduler.prototype));\n\r\n (function (schedulerProto) {\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodic = function (period, action) {\n return this.schedulePeriodicWithState(null, period, action);\n };\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {\n if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }\n period = normalizeTime(period);\n var s = state, id = root.setInterval(function () { s = action(s); }, period);\n return disposableCreate(function () { root.clearInterval(id); });\n };\n\n }(Scheduler.prototype));\n\r\n /** Gets a scheduler that schedules work immediately on the current thread. */\n var immediateScheduler = Scheduler.immediate = (function () {\n function scheduleNow(state, action) { return action(this, state); }\n return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n }());\n\r\n /**\n * Gets a scheduler that schedules work as soon as possible on the current thread.\n */\n var currentThreadScheduler = Scheduler.currentThread = (function () {\n var queue;\n\n function runTrampoline () {\n while (queue.length > 0) {\n var item = queue.shift();\n !item.isCancelled() && item.invoke();\n }\n }\n\n function scheduleNow(state, action) {\n var si = new ScheduledItem(this, state, action, this.now());\n\n if (!queue) {\n queue = [si];\n\n var result = tryCatch(runTrampoline)();\n queue = null;\n if (result === errorObj) { return thrower(result.e); }\n } else {\n queue.push(si);\n }\n return si.disposable;\n }\n\n var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n currentScheduler.scheduleRequired = function () { return !queue; };\n\n return currentScheduler;\n }());\n\r\n var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {\n function tick(command, recurse) {\n recurse(0, this._period);\n try {\n this._state = this._action(this._state);\n } catch (e) {\n this._cancel.dispose();\n throw e;\n }\n }\n\n function SchedulePeriodicRecursive(scheduler, state, period, action) {\n this._scheduler = scheduler;\n this._state = state;\n this._period = period;\n this._action = action;\n }\n\n SchedulePeriodicRecursive.prototype.start = function () {\n var d = new SingleAssignmentDisposable();\n this._cancel = d;\n d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));\n\n return d;\n };\n\n return SchedulePeriodicRecursive;\n }());\n\r\n var scheduleMethod, clearMethod;\n\n var localTimer = (function () {\n var localSetTimeout, localClearTimeout = noop;\n if (!!root.setTimeout) {\n localSetTimeout = root.setTimeout;\n localClearTimeout = root.clearTimeout;\n } else if (!!root.WScript) {\n localSetTimeout = function (fn, time) {\n root.WScript.Sleep(time);\n fn();\n };\n } else {\n throw new NotSupportedError();\n }\n\n return {\n setTimeout: localSetTimeout,\n clearTimeout: localClearTimeout\n };\n }());\n var localSetTimeout = localTimer.setTimeout,\n localClearTimeout = localTimer.clearTimeout;\n\n (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;\n\n clearMethod = function (handle) {\n delete tasksByHandle[handle];\n };\n\n function runTask(handle) {\n if (currentlyRunning) {\n localSetTimeout(function () { runTask(handle) }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n var result = tryCatch(task)();\n clearMethod(handle);\n currentlyRunning = false;\n if (result === errorObj) { return thrower(result.e); }\n }\n }\n }\n\n var reNative = RegExp('^' +\n String(toString)\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/toString| for [^\\]]+/g, '.*?') + '$'\n );\n\n var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&\n !reNative.test(setImmediate) && setImmediate;\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n if (isFunction(setImmediate)) {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n setImmediate(function () { runTask(id); });\n\n return id;\n };\n } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n process.nextTick(function () { runTask(id); });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent) {\n root.attachEvent('onmessage', onGlobalPostMessage);\n } else {\n root.onmessage = onGlobalPostMessage;\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (e) { runTask(e.data); };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n localSetTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n }());\n\n /**\n * Gets a scheduler that schedules work via a timed callback based upon platform.\n */\n var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () {\n\n function scheduleNow(state, action) {\n var scheduler = this, disposable = new SingleAssignmentDisposable();\n var id = scheduleMethod(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n });\n return new CompositeDisposable(disposable, disposableCreate(function () {\n clearMethod(id);\n }));\n }\n\n function scheduleRelative(state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();\n if (dt === 0) { return scheduler.scheduleWithState(state, action); }\n var id = localSetTimeout(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n }, dt);\n return new CompositeDisposable(disposable, disposableCreate(function () {\n localClearTimeout(id);\n }));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);\n }\n\n return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n })();\n\r\n /**\n * Represents a notification to an observer.\n */\n var Notification = Rx.Notification = (function () {\n function Notification(kind, value, exception, accept, acceptObservable, toString) {\n this.kind = kind;\n this.value = value;\n this.exception = exception;\n this._accept = accept;\n this._acceptObservable = acceptObservable;\n this.toString = toString;\n }\n\n /**\n * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.\n *\n * @memberOf Notification\n * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..\n * @param {Function} onError Delegate to invoke for an OnError notification.\n * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.\n * @returns {Any} Result produced by the observation.\n */\n Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {\n return observerOrOnNext && typeof observerOrOnNext === 'object' ?\n this._acceptObservable(observerOrOnNext) :\n this._accept(observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Returns an observable sequence with a single notification.\n *\n * @memberOf Notifications\n * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.\n * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.\n */\n Notification.prototype.toObservable = function (scheduler) {\n var self = this;\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithState(self, function (_, notification) {\n notification._acceptObservable(observer);\n notification.kind === 'N' && observer.onCompleted();\n });\n });\n };\n\n return Notification;\n })();\n\n /**\n * Creates an object that represents an OnNext notification to an observer.\n * @param {Any} value The value contained in the notification.\n * @returns {Notification} The OnNext notification containing the value.\n */\n var notificationCreateOnNext = Notification.createOnNext = (function () {\n function _accept(onNext) { return onNext(this.value); }\n function _acceptObservable(observer) { return observer.onNext(this.value); }\n function toString() { return 'OnNext(' + this.value + ')'; }\n\n return function (value) {\n return new Notification('N', value, null, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnError notification to an observer.\n * @param {Any} error The exception contained in the notification.\n * @returns {Notification} The OnError notification containing the exception.\n */\n var notificationCreateOnError = Notification.createOnError = (function () {\n function _accept (onNext, onError) { return onError(this.exception); }\n function _acceptObservable(observer) { return observer.onError(this.exception); }\n function toString () { return 'OnError(' + this.exception + ')'; }\n\n return function (e) {\n return new Notification('E', null, e, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnCompleted notification to an observer.\n * @returns {Notification} The OnCompleted notification.\n */\n var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {\n function _accept (onNext, onError, onCompleted) { return onCompleted(); }\n function _acceptObservable(observer) { return observer.onCompleted(); }\n function toString () { return 'OnCompleted()'; }\n\n return function () {\n return new Notification('C', null, null, _accept, _acceptObservable, toString);\n };\n }());\n\r\n /**\n * Supports push-style iteration over an observable sequence.\n */\n var Observer = Rx.Observer = function () { };\n\n /**\n * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.\n * @param {Function} [onNext] Observer's OnNext action implementation.\n * @param {Function} [onError] Observer's OnError action implementation.\n * @param {Function} [onCompleted] Observer's OnCompleted action implementation.\n * @returns {Observer} The observer object implemented using the given actions.\n */\n var observerCreate = Observer.create = function (onNext, onError, onCompleted) {\n onNext || (onNext = noop);\n onError || (onError = defaultError);\n onCompleted || (onCompleted = noop);\n return new AnonymousObserver(onNext, onError, onCompleted);\n };\n\r\n /**\n * Abstract base class for implementations of the Observer class.\n * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.\n */\n var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {\n inherits(AbstractObserver, __super__);\n\n /**\n * Creates a new observer in a non-stopped state.\n */\n function AbstractObserver() {\n this.isStopped = false;\n }\n\n // Must be implemented by other observers\n AbstractObserver.prototype.next = notImplemented;\n AbstractObserver.prototype.error = notImplemented;\n AbstractObserver.prototype.completed = notImplemented;\n\n /**\n * Notifies the observer of a new element in the sequence.\n * @param {Any} value Next element in the sequence.\n */\n AbstractObserver.prototype.onNext = function (value) {\n !this.isStopped && this.next(value);\n };\n\n /**\n * Notifies the observer that an exception has occurred.\n * @param {Any} error The error that has occurred.\n */\n AbstractObserver.prototype.onError = function (error) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(error);\n }\n };\n\n /**\n * Notifies the observer of the end of the sequence.\n */\n AbstractObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.completed();\n }\n };\n\n /**\n * Disposes the observer, causing it to transition to the stopped state.\n */\n AbstractObserver.prototype.dispose = function () { this.isStopped = true; };\n\n AbstractObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(e);\n return true;\n }\n\n return false;\n };\n\n return AbstractObserver;\n }(Observer));\n\r\n /**\n * Class to create an Observer instance from delegate-based implementations of the on* methods.\n */\n var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {\n inherits(AnonymousObserver, __super__);\n\n /**\n * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.\n * @param {Any} onNext Observer's OnNext action implementation.\n * @param {Any} onError Observer's OnError action implementation.\n * @param {Any} onCompleted Observer's OnCompleted action implementation.\n */\n function AnonymousObserver(onNext, onError, onCompleted) {\n __super__.call(this);\n this._onNext = onNext;\n this._onError = onError;\n this._onCompleted = onCompleted;\n }\n\n /**\n * Calls the onNext action.\n * @param {Any} value Next element in the sequence.\n */\n AnonymousObserver.prototype.next = function (value) {\n this._onNext(value);\n };\n\n /**\n * Calls the onError action.\n * @param {Any} error The error that has occurred.\n */\n AnonymousObserver.prototype.error = function (error) {\n this._onError(error);\n };\n\n /**\n * Calls the onCompleted action.\n */\n AnonymousObserver.prototype.completed = function () {\n this._onCompleted();\n };\n\n return AnonymousObserver;\n }(AbstractObserver));\n\r\n var observableProto;\n\n /**\n * Represents a push-style collection.\n */\n var Observable = Rx.Observable = (function () {\n\n function makeSubscribe(self, subscribe) {\n return function (o) {\n var oldOnError = o.onError;\n o.onError = function (e) {\n makeStackTraceLong(e, self);\n oldOnError.call(o, e);\n };\n\n return subscribe.call(self, o);\n };\n }\n\n function Observable(subscribe) {\n if (Rx.config.longStackSupport && hasStacks) {\n var e = tryCatch(thrower)(new Error()).e;\n this.stack = e.stack.substring(e.stack.indexOf('\\n') + 1);\n this._subscribe = makeSubscribe(this, subscribe);\n } else {\n this._subscribe = subscribe;\n }\n }\n\n observableProto = Observable.prototype;\n\n /**\n * Determines whether the given object is an Observable\n * @param {Any} An object to determine whether it is an Observable\n * @returns {Boolean} true if an Observable, else false.\n */\n Observable.isObservable = function (o) {\n return o && isFunction(o.subscribe);\n }\n\n /**\n * Subscribes an o to the observable sequence.\n * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.\n * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) {\n return this._subscribe(typeof oOrOnNext === 'object' ?\n oOrOnNext :\n observerCreate(oOrOnNext, onError, onCompleted));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onNext The function to invoke on each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnNext = function (onNext, thisArg) {\n return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));\n };\n\n /**\n * Subscribes to an exceptional condition in the sequence with an optional \"this\" argument.\n * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnError = function (onError, thisArg) {\n return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {\n return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));\n };\n\n return Observable;\n })();\n\r\n var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {\n inherits(ScheduledObserver, __super__);\n\n function ScheduledObserver(scheduler, observer) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.observer = observer;\n this.isAcquired = false;\n this.hasFaulted = false;\n this.queue = [];\n this.disposable = new SerialDisposable();\n }\n\n ScheduledObserver.prototype.next = function (value) {\n var self = this;\n this.queue.push(function () { self.observer.onNext(value); });\n };\n\n ScheduledObserver.prototype.error = function (e) {\n var self = this;\n this.queue.push(function () { self.observer.onError(e); });\n };\n\n ScheduledObserver.prototype.completed = function () {\n var self = this;\n this.queue.push(function () { self.observer.onCompleted(); });\n };\n\n ScheduledObserver.prototype.ensureActive = function () {\n var isOwner = false;\n if (!this.hasFaulted && this.queue.length > 0) {\n isOwner = !this.isAcquired;\n this.isAcquired = true;\n }\n if (isOwner) {\n this.disposable.setDisposable(this.scheduler.scheduleRecursiveWithState(this, function (parent, self) {\n var work;\n if (parent.queue.length > 0) {\n work = parent.queue.shift();\n } else {\n parent.isAcquired = false;\n return;\n }\n var res = tryCatch(work)();\n if (res === errorObj) {\n parent.queue = [];\n parent.hasFaulted = true;\n return thrower(res.e);\n }\n self(parent);\n }));\n }\n };\n\n ScheduledObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.disposable.dispose();\n };\n\n return ScheduledObserver;\n }(AbstractObserver));\n\r\n var ObservableBase = Rx.ObservableBase = (function (__super__) {\n inherits(ObservableBase, __super__);\n\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.subscribeCore).call(self, ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function subscribe(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n function ObservableBase() {\n __super__.call(this, subscribe);\n }\n\n ObservableBase.prototype.subscribeCore = notImplemented;\n\n return ObservableBase;\n }(Observable));\n\r\nvar FlatMapObservable = (function(__super__){\n\n inherits(FlatMapObservable, __super__);\n\n function FlatMapObservable(source, selector, resultSelector, thisArg) {\n this.resultSelector = Rx.helpers.isFunction(resultSelector) ?\n resultSelector : null;\n\n this.selector = Rx.internals.bindCallback(Rx.helpers.isFunction(selector) ? selector : function() { return selector; }, thisArg, 3);\n this.source = source;\n\n __super__.call(this);\n\n }\n\n FlatMapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this));\n };\n\n function InnerObserver(observer, selector, resultSelector, source) {\n this.i = 0;\n this.selector = selector;\n this.resultSelector = resultSelector;\n this.source = source;\n this.isStopped = false;\n this.o = observer;\n }\n\n InnerObserver.prototype._wrapResult = function(result, x, i) {\n return this.resultSelector ?\n result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) :\n result;\n };\n\n InnerObserver.prototype.onNext = function(x) {\n\n if (this.isStopped) return;\n\n var i = this.i++;\n var result = tryCatch(this.selector)(x, i, this.source);\n\n if (result === errorObj) {\n return this.o.onError(result.e);\n }\n\n Rx.helpers.isPromise(result) && (result = Rx.Observable.fromPromise(result));\n (Rx.helpers.isArrayLike(result) || Rx.helpers.isIterable(result)) && (result = Rx.Observable.from(result));\n\n this.o.onNext(this._wrapResult(result, x, i));\n\n };\n\n InnerObserver.prototype.onError = function(e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) {this.isStopped = true; this.o.onCompleted(); }\n };\n\n return FlatMapObservable;\n\n}(ObservableBase));\n\r\n var Enumerable = Rx.internals.Enumerable = function () { };\n\n var ConcatEnumerableObservable = (function(__super__) {\n inherits(ConcatEnumerableObservable, __super__);\n function ConcatEnumerableObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n ConcatEnumerableObservable.prototype.subscribeCore = function (o) {\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e)));\n });\n\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n function InnerObserver(o, s, e) {\n this.o = o;\n this.s = s;\n this.e = e;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.s(this.e);\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; };\n InnerObserver.prototype.fail = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n return true;\n }\n return false;\n };\n \n return ConcatEnumerableObservable;\n }(ObservableBase));\n\n Enumerable.prototype.concat = function () {\n return new ConcatEnumerableObservable(this);\n };\n \n var CatchErrorObservable = (function(__super__) {\n inherits(CatchErrorObservable, __super__);\n function CatchErrorObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n CatchErrorObservable.prototype.subscribeCore = function (o) {\n var e = this.sources[$iterator$]();\n\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return lastException !== null ? o.onError(lastException) : o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n self,\n function() { o.onCompleted(); }));\n });\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n return CatchErrorObservable;\n }(ObservableBase));\n\n Enumerable.prototype.catchError = function () {\n return new CatchErrorObservable(this);\n };\n\n Enumerable.prototype.catchErrorWhen = function (notificationHandler) {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var exceptions = new Subject(),\n notifier = new Subject(),\n handled = notificationHandler(exceptions),\n notificationDisposable = handled.subscribe(notifier);\n\n var e = sources[$iterator$]();\n\n var isDisposed,\n lastException,\n subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursive(function (self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n if (lastException) {\n o.onError(lastException);\n } else {\n o.onCompleted();\n }\n return;\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var outer = new SingleAssignmentDisposable();\n var inner = new SingleAssignmentDisposable();\n subscription.setDisposable(new CompositeDisposable(inner, outer));\n outer.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n function (exn) {\n inner.setDisposable(notifier.subscribe(self, function(ex) {\n o.onError(ex);\n }, function() {\n o.onCompleted();\n }));\n\n exceptions.onNext(exn);\n },\n function() { o.onCompleted(); }));\n });\n\n return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n });\n };\n \n var RepeatEnumerable = (function (__super__) {\n inherits(RepeatEnumerable, __super__);\n \n function RepeatEnumerable(v, c) {\n this.v = v;\n this.c = c == null ? -1 : c;\n }\n RepeatEnumerable.prototype[$iterator$] = function () {\n return new RepeatEnumerator(this); \n };\n \n function RepeatEnumerator(p) {\n this.v = p.v;\n this.l = p.c;\n }\n RepeatEnumerator.prototype.next = function () {\n if (this.l === 0) { return doneEnumerator; }\n if (this.l > 0) { this.l--; }\n return { done: false, value: this.v }; \n };\n \n return RepeatEnumerable;\n }(Enumerable));\n\n var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {\n return new RepeatEnumerable(value, repeatCount);\n };\n \n var OfEnumerable = (function(__super__) {\n inherits(OfEnumerable, __super__);\n function OfEnumerable(s, fn, thisArg) {\n this.s = s;\n this.fn = fn ? bindCallback(fn, thisArg, 3) : null;\n }\n OfEnumerable.prototype[$iterator$] = function () {\n return new OfEnumerator(this);\n };\n \n function OfEnumerator(p) {\n this.i = -1;\n this.s = p.s;\n this.l = this.s.length;\n this.fn = p.fn;\n }\n OfEnumerator.prototype.next = function () {\n return ++this.i < this.l ?\n { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } :\n doneEnumerator; \n };\n \n return OfEnumerable;\n }(Enumerable));\n\n var enumerableOf = Enumerable.of = function (source, selector, thisArg) {\n return new OfEnumerable(source, selector, thisArg);\n };\n\r\n var ToArrayObservable = (function(__super__) {\n inherits(ToArrayObservable, __super__);\n function ToArrayObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToArrayObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.a = [];\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onNext(this.a);\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n \n return false;\n };\n\n return ToArrayObservable;\n }(ObservableBase));\n\n /**\n * Creates an array from an observable sequence.\n * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.\n */\n observableProto.toArray = function () {\n return new ToArrayObservable(this);\n };\n\r\n /**\n * Creates an observable sequence from a specified subscribe method implementation.\n * @example\n * var res = Rx.Observable.create(function (observer) { return function () { } );\n * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );\n * var res = Rx.Observable.create(function (observer) { } );\n * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.\n * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.\n */\n Observable.create = function (subscribe, parent) {\n return new AnonymousObservable(subscribe, parent);\n };\n\r\n /**\n * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.\n *\n * @example\n * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });\n * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.\n * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.\n */\n var observableDefer = Observable.defer = function (observableFactory) {\n return new AnonymousObservable(function (observer) {\n var result;\n try {\n result = observableFactory();\n } catch (e) {\n return observableThrow(e).subscribe(observer);\n }\n isPromise(result) && (result = observableFromPromise(result));\n return result.subscribe(observer);\n });\n };\n\r\n var EmptyObservable = (function(__super__) {\n inherits(EmptyObservable, __super__);\n function EmptyObservable(scheduler) {\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n EmptyObservable.prototype.subscribeCore = function (observer) {\n var sink = new EmptySink(observer, this.scheduler);\n return sink.run();\n };\n\n function EmptySink(observer, scheduler) {\n this.observer = observer;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n state.onCompleted();\n return disposableEmpty;\n }\n\n EmptySink.prototype.run = function () {\n return this.scheduler.scheduleWithState(this.observer, scheduleItem);\n };\n\n return EmptyObservable;\n }(ObservableBase));\n\n var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler);\n\n /**\n * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.\n *\n * @example\n * var res = Rx.Observable.empty();\n * var res = Rx.Observable.empty(Rx.Scheduler.timeout);\n * @param {Scheduler} [scheduler] Scheduler to send the termination call on.\n * @returns {Observable} An observable sequence with no elements.\n */\n var observableEmpty = Observable.empty = function (scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler);\n };\n\r\n var FromObservable = (function(__super__) {\n inherits(FromObservable, __super__);\n function FromObservable(iterable, mapper, scheduler) {\n this.iterable = iterable;\n this.mapper = mapper;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromObservable.prototype.subscribeCore = function (o) {\n var sink = new FromSink(o, this);\n return sink.run();\n };\n\n return FromObservable;\n }(ObservableBase));\n\n var FromSink = (function () {\n function FromSink(o, parent) {\n this.o = o;\n this.parent = parent;\n }\n\n FromSink.prototype.run = function () {\n var list = Object(this.parent.iterable),\n it = getIterable(list),\n o = this.o,\n mapper = this.parent.mapper;\n\n function loopRecursive(i, recurse) {\n var next = tryCatch(it.next).call(it);\n if (next === errorObj) { return o.onError(next.e); }\n if (next.done) { return o.onCompleted(); }\n\n var result = next.value;\n\n if (isFunction(mapper)) {\n result = tryCatch(mapper)(result, i);\n if (result === errorObj) { return o.onError(result.e); }\n }\n\n o.onNext(result);\n recurse(i + 1);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return FromSink;\n }());\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function StringIterable(s) {\n this._s = s;\n }\n\n StringIterable.prototype[$iterator$] = function () {\n return new StringIterator(this._s);\n };\n\n function StringIterator(s) {\n this._s = s;\n this._l = s.length;\n this._i = 0;\n }\n\n StringIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n StringIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;\n };\n\n function ArrayIterable(a) {\n this._a = a;\n }\n\n ArrayIterable.prototype[$iterator$] = function () {\n return new ArrayIterator(this._a);\n };\n\n function ArrayIterator(a) {\n this._a = a;\n this._l = toLength(a);\n this._i = 0;\n }\n\n ArrayIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n ArrayIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;\n };\n\n function numberIsFinite(value) {\n return typeof value === 'number' && root.isFinite(value);\n }\n\n function isNan(n) {\n return n !== n;\n }\n\n function getIterable(o) {\n var i = o[$iterator$], it;\n if (!i && typeof o === 'string') {\n it = new StringIterable(o);\n return it[$iterator$]();\n }\n if (!i && o.length !== undefined) {\n it = new ArrayIterable(o);\n return it[$iterator$]();\n }\n if (!i) { throw new TypeError('Object is not iterable'); }\n return o[$iterator$]();\n }\n\n function sign(value) {\n var number = +value;\n if (number === 0) { return number; }\n if (isNaN(number)) { return number; }\n return number < 0 ? -1 : 1;\n }\n\n function toLength(o) {\n var len = +o.length;\n if (isNaN(len)) { return 0; }\n if (len === 0 || !numberIsFinite(len)) { return len; }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) { return 0; }\n if (len > maxSafeInteger) { return maxSafeInteger; }\n return len;\n }\n\n /**\n * This method creates a new Observable sequence from an array-like or iterable object.\n * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.\n * @param {Function} [mapFn] Map function to call on every element of the array.\n * @param {Any} [thisArg] The context to use calling the mapFn if provided.\n * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.\n */\n var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {\n if (iterable == null) {\n throw new Error('iterable cannot be null.')\n }\n if (mapFn && !isFunction(mapFn)) {\n throw new Error('mapFn when provided must be a function');\n }\n if (mapFn) {\n var mapper = bindCallback(mapFn, thisArg, 2);\n }\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromObservable(iterable, mapper, scheduler);\n }\n\r\n var FromArrayObservable = (function(__super__) {\n inherits(FromArrayObservable, __super__);\n function FromArrayObservable(args, scheduler) {\n this.args = args;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromArrayObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromArraySink(observer, this);\n return sink.run();\n };\n\n return FromArrayObservable;\n }(ObservableBase));\n\n function FromArraySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromArraySink.prototype.run = function () {\n var observer = this.observer, args = this.parent.args, len = args.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n observer.onNext(args[i]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\r\n /**\n * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.\n * @deprecated use Observable.from or Observable.of\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.\n */\n var observableFromArray = Observable.fromArray = function (array, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler)\n };\n\r\n var NeverObservable = (function(__super__) {\n inherits(NeverObservable, __super__);\n function NeverObservable() {\n __super__.call(this);\n }\n\n NeverObservable.prototype.subscribeCore = function (observer) {\n return disposableEmpty;\n };\n\n return NeverObservable;\n }(ObservableBase));\n\n var NEVER_OBSERVABLE = new NeverObservable();\n\n /**\n * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).\n * @returns {Observable} An observable sequence whose observers will never get called.\n */\n var observableNever = Observable.never = function () {\n return NEVER_OBSERVABLE;\n };\n\r\n function observableOf (scheduler, array) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler);\n }\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.of = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return new FromArrayObservable(args, currentThreadScheduler);\n };\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.ofWithScheduler = function (scheduler) {\n var len = arguments.length, args = new Array(len - 1);\n for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }\n return new FromArrayObservable(args, scheduler);\n };\n\r\n var PairsObservable = (function(__super__) {\n inherits(PairsObservable, __super__);\n function PairsObservable(obj, scheduler) {\n this.obj = obj;\n this.keys = Object.keys(obj);\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n PairsObservable.prototype.subscribeCore = function (observer) {\n var sink = new PairsSink(observer, this);\n return sink.run();\n };\n\n return PairsObservable;\n }(ObservableBase));\n\n function PairsSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n PairsSink.prototype.run = function () {\n var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n var key = keys[i];\n observer.onNext([key, obj[key]]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n /**\n * Convert an object into an observable sequence of [key, value] pairs.\n * @param {Object} obj The object to inspect.\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} An observable sequence of [key, value] pairs from the object.\n */\n Observable.pairs = function (obj, scheduler) {\n scheduler || (scheduler = currentThreadScheduler);\n return new PairsObservable(obj, scheduler);\n };\n\r\n var RangeObservable = (function(__super__) {\n inherits(RangeObservable, __super__);\n function RangeObservable(start, count, scheduler) {\n this.start = start;\n this.rangeCount = count;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RangeObservable.prototype.subscribeCore = function (observer) {\n var sink = new RangeSink(observer, this);\n return sink.run();\n };\n\n return RangeObservable;\n }(ObservableBase));\n\n var RangeSink = (function () {\n function RangeSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RangeSink.prototype.run = function () {\n var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;\n function loopRecursive(i, recurse) {\n if (i < count) {\n observer.onNext(start + i);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return RangeSink;\n }());\n\n /**\n * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.\n * @param {Number} start The value of the first integer in the sequence.\n * @param {Number} count The number of sequential integers to generate.\n * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.\n * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.\n */\n Observable.range = function (start, count, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RangeObservable(start, count, scheduler);\n };\n\r\n var RepeatObservable = (function(__super__) {\n inherits(RepeatObservable, __super__);\n function RepeatObservable(value, repeatCount, scheduler) {\n this.value = value;\n this.repeatCount = repeatCount == null ? -1 : repeatCount;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RepeatObservable.prototype.subscribeCore = function (observer) {\n var sink = new RepeatSink(observer, this);\n return sink.run();\n };\n\n return RepeatObservable;\n }(ObservableBase));\n\n function RepeatSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RepeatSink.prototype.run = function () {\n var observer = this.observer, value = this.parent.value;\n function loopRecursive(i, recurse) {\n if (i === -1 || i > 0) {\n observer.onNext(value);\n i > 0 && i--;\n }\n if (i === 0) { return observer.onCompleted(); }\n recurse(i);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive);\n };\n\n /**\n * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.\n * @param {Mixed} value Element to repeat.\n * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.\n * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence that repeats the given element the specified number of times.\n */\n Observable.repeat = function (value, repeatCount, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RepeatObservable(value, repeatCount, scheduler);\n };\n\r\n var JustObservable = (function(__super__) {\n inherits(JustObservable, __super__);\n function JustObservable(value, scheduler) {\n this.value = value;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n JustObservable.prototype.subscribeCore = function (observer) {\n var sink = new JustSink(observer, this.value, this.scheduler);\n return sink.run();\n };\n\n function JustSink(observer, value, scheduler) {\n this.observer = observer;\n this.value = value;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n var value = state[0], observer = state[1];\n observer.onNext(value);\n observer.onCompleted();\n return disposableEmpty;\n }\n\n JustSink.prototype.run = function () {\n var state = [this.value, this.observer];\n return this.scheduler === immediateScheduler ?\n scheduleItem(null, state) :\n this.scheduler.scheduleWithState(state, scheduleItem);\n };\n\n return JustObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.\n * There is an alias called 'just' or browsers 0) {\n parent.handleSubscribe(parent.q.shift());\n } else {\n parent.activeCount--;\n parent.done && parent.activeCount === 0 && parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeObserver;\n }());\n\n\n\n\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.\n * Or merges two observable sequences into a single observable sequence.\n *\n * @example\n * 1 - merged = sources.merge(1);\n * 2 - merged = source.merge(otherSource);\n * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.merge = function (maxConcurrentOrOther) {\n return typeof maxConcurrentOrOther !== 'number' ?\n observableMerge(this, maxConcurrentOrOther) :\n new MergeObservable(this, maxConcurrentOrOther);\n };\n\r\n /**\n * Merges all the observable sequences into a single observable sequence.\n * The scheduler is optional and if not specified, the immediate scheduler is used.\n * @returns {Observable} The observable sequence that merges the elements of the observable sequences.\n */\n var observableMerge = Observable.merge = function () {\n var scheduler, sources = [], i, len = arguments.length;\n if (!arguments[0]) {\n scheduler = immediateScheduler;\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else if (isScheduler(arguments[0])) {\n scheduler = arguments[0];\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else {\n scheduler = immediateScheduler;\n for(i = 0; i < len; i++) { sources.push(arguments[i]); }\n }\n if (Array.isArray(sources[0])) {\n sources = sources[0];\n }\n return observableOf(scheduler, sources).mergeAll();\n };\n\r\n var CompositeError = Rx.CompositeError = function(errors) {\n this.name = \"NotImplementedError\";\n this.innerErrors = errors;\n this.message = 'This contains multiple errors. Check the innerErrors';\n Error.call(this);\n }\n CompositeError.prototype = Error.prototype;\n\n /**\n * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to\n * receive all successfully emitted items from all of the source Observables without being interrupted by\n * an error notification from one of them.\n *\n * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an\n * error via the Observer's onError, mergeDelayError will refrain from propagating that\n * error notification until all of the merged Observables have finished emitting items.\n * @param {Array | Arguments} args Arguments or an array to merge.\n * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable\n */\n Observable.mergeDelayError = function() {\n var args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n var len = arguments.length;\n args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n var source = observableOf(null, args);\n\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable(),\n m = new SingleAssignmentDisposable(),\n isStopped = false,\n errors = [];\n\n function setCompletion() {\n if (errors.length === 0) {\n o.onCompleted();\n } else if (errors.length === 1) {\n o.onError(errors[0]);\n } else {\n o.onError(new CompositeError(errors));\n }\n }\n\n group.add(m);\n\n m.setDisposable(source.subscribe(\n function (innerSource) {\n var innerSubscription = new SingleAssignmentDisposable();\n group.add(innerSubscription);\n\n // Check for promises support\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) {\n errors.push(e);\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n },\n function () {\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n }));\n },\n function (e) {\n errors.push(e);\n isStopped = true;\n group.length === 1 && setCompletion();\n },\n function () {\n isStopped = true;\n group.length === 1 && setCompletion();\n }));\n return group;\n });\n };\n\r\n var MergeAllObservable = (function (__super__) {\n inherits(MergeAllObservable, __super__);\n\n function MergeAllObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n MergeAllObservable.prototype.subscribeCore = function (observer) {\n var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();\n g.add(m);\n m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));\n return g;\n };\n\n function MergeAllObserver(o, g) {\n this.o = o;\n this.g = g;\n this.isStopped = false;\n this.done = false;\n }\n MergeAllObserver.prototype.onNext = function(innerSource) {\n if(this.isStopped) { return; }\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad)));\n };\n MergeAllObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeAllObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.g.length === 1 && this.o.onCompleted();\n }\n };\n MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeAllObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, sad) {\n this.parent = parent;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n var parent = this.parent;\n this.isStopped = true;\n parent.g.remove(this.sad);\n parent.done && parent.g.length === 1 && parent.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeAllObservable;\n }(ObservableBase));\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.mergeAll = function () {\n return new MergeAllObservable(this);\n };\n\r\n /**\n * Returns the values from the source observable sequence only after the other observable sequence produces a value.\n * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.\n */\n observableProto.skipUntil = function (other) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var isOpen = false;\n var disposables = new CompositeDisposable(source.subscribe(function (left) {\n isOpen && o.onNext(left);\n }, function (e) { o.onError(e); }, function () {\n isOpen && o.onCompleted();\n }));\n\n isPromise(other) && (other = observableFromPromise(other));\n\n var rightSubscription = new SingleAssignmentDisposable();\n disposables.add(rightSubscription);\n rightSubscription.setDisposable(other.subscribe(function () {\n isOpen = true;\n rightSubscription.dispose();\n }, function (e) { o.onError(e); }, function () {\n rightSubscription.dispose();\n }));\n\n return disposables;\n }, source);\n };\n\r\n var SwitchObservable = (function(__super__) {\n inherits(SwitchObservable, __super__);\n function SwitchObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n SwitchObservable.prototype.subscribeCore = function (o) {\n var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner));\n return new CompositeDisposable(s, inner);\n };\n\n function SwitchObserver(o, inner) {\n this.o = o;\n this.inner = inner;\n this.stopped = false;\n this.latest = 0;\n this.hasLatest = false;\n this.isStopped = false;\n }\n SwitchObserver.prototype.onNext = function (innerSource) {\n if (this.isStopped) { return; }\n var d = new SingleAssignmentDisposable(), id = ++this.latest;\n this.hasLatest = true;\n this.inner.setDisposable(d);\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n d.setDisposable(innerSource.subscribe(new InnerObserver(this, id)));\n };\n SwitchObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n SwitchObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.stopped = true;\n !this.hasLatest && this.o.onCompleted();\n }\n };\n SwitchObserver.prototype.dispose = function () { this.isStopped = true; };\n SwitchObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n function InnerObserver(parent, id) {\n this.parent = parent;\n this.id = id;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.parent.latest === this.id && this.parent.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.latest === this.id && this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n if (this.parent.latest === this.id) {\n this.parent.hasLatest = false;\n this.parent.isStopped && this.parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n return false;\n };\n\n return SwitchObservable;\n }(ObservableBase));\n\n /**\n * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto['switch'] = observableProto.switchLatest = function () {\n return new SwitchObservable(this);\n };\n\r\n var TakeUntilObservable = (function(__super__) {\n inherits(TakeUntilObservable, __super__);\n\n function TakeUntilObservable(source, other) {\n this.source = source;\n this.other = isPromise(other) ? observableFromPromise(other) : other;\n __super__.call(this);\n }\n\n TakeUntilObservable.prototype.subscribeCore = function(o) {\n return new CompositeDisposable(\n this.source.subscribe(o),\n this.other.subscribe(new InnerObserver(o))\n );\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.o.onCompleted();\n };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n !this.isStopped && (this.isStopped = true);\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TakeUntilObservable;\n }(ObservableBase));\n\n /**\n * Returns the values from the source observable sequence until the other observable sequence produces a value.\n * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.\n */\n observableProto.takeUntil = function (other) {\n return new TakeUntilObservable(this, other);\n };\n\r\n function falseFactory() { return false; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.withLatestFrom = function () {\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = args.pop(), source = this;\n Array.isArray(args[0]) && (args = args[0]);\n\n return new AnonymousObservable(function (observer) {\n var n = args.length,\n hasValue = arrayInitialize(n, falseFactory),\n hasValueAll = false,\n values = new Array(n);\n\n var subscriptions = new Array(n + 1);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var other = args[i], sad = new SingleAssignmentDisposable();\n isPromise(other) && (other = observableFromPromise(other));\n sad.setDisposable(other.subscribe(function (x) {\n values[i] = x;\n hasValue[i] = true;\n hasValueAll = hasValue.every(identity);\n }, function (e) { observer.onError(e); }, noop));\n subscriptions[i] = sad;\n }(idx));\n }\n\n var sad = new SingleAssignmentDisposable();\n sad.setDisposable(source.subscribe(function (x) {\n var allValues = [x].concat(values);\n if (!hasValueAll) { return; }\n var res = tryCatch(resultSelector).apply(null, allValues);\n if (res === errorObj) { return observer.onError(res.e); }\n observer.onNext(res);\n }, function (e) { observer.onError(e); }, function () {\n observer.onCompleted();\n }));\n subscriptions[n] = sad;\n\n return new CompositeDisposable(subscriptions);\n }, this);\n };\n\r\n function falseFactory() { return false; }\n function emptyArrayFactory() { return []; }\n function argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\n observableProto.zip = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n Array.isArray(args[0]) && (args = args[0]);\n\n var parent = this;\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n\n isPromise(source) && (source = observableFromPromise(source));\n\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n * @param arguments Observable sources.\n * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n Observable.zip = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n if (Array.isArray(args[0])) {\n args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];\n }\n var first = args.shift();\n return first.zip.apply(first, args);\n };\n\r\nfunction falseFactory() { return false; }\nfunction emptyArrayFactory() { return []; }\nfunction argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n}\n\n/**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\nobservableProto.zipIterable = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n\n var parent = this;\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n\n (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source));\n\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n};\n\r\n function asObservable(source) {\n return function subscribe(o) { return source.subscribe(o); };\n }\n\n /**\n * Hides the identity of an observable sequence.\n * @returns {Observable} An observable sequence that hides the identity of the source sequence.\n */\n observableProto.asObservable = function () {\n return new AnonymousObservable(asObservable(this), this);\n };\n\r\n /**\n * Dematerializes the explicit notification values of an observable sequence as implicit notifications.\n * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.\n */\n observableProto.dematerialize = function () {\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n var DistinctUntilChangedObservable = (function(__super__) {\n inherits(DistinctUntilChangedObservable, __super__);\n function DistinctUntilChangedObservable(source, keyFn, comparer) {\n this.source = source;\n this.keyFn = keyFn;\n this.comparer = comparer;\n __super__.call(this);\n }\n\n DistinctUntilChangedObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer));\n };\n\n return DistinctUntilChangedObservable;\n }(ObservableBase));\n\n var DistinctUntilChangedObserver = (function(__super__) {\n inherits(DistinctUntilChangedObserver, __super__);\n function DistinctUntilChangedObserver(o, keyFn, comparer) {\n this.o = o;\n this.keyFn = keyFn;\n this.comparer = comparer;\n this.hasCurrentKey = false;\n this.currentKey = null;\n __super__.call(this);\n }\n\n DistinctUntilChangedObserver.prototype.next = function (x) {\n var key = x, comparerEquals;\n if (isFunction(this.keyFn)) {\n key = tryCatch(this.keyFn)(x);\n if (key === errorObj) { return this.o.onError(key.e); }\n }\n if (this.hasCurrentKey) {\n comparerEquals = tryCatch(this.comparer)(this.currentKey, key);\n if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); }\n }\n if (!this.hasCurrentKey || !comparerEquals) {\n this.hasCurrentKey = true;\n this.currentKey = key;\n this.o.onNext(x);\n }\n };\n DistinctUntilChangedObserver.prototype.error = function(e) {\n this.o.onError(e);\n };\n DistinctUntilChangedObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return DistinctUntilChangedObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer.\n * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value.\n * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.\n * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinctUntilChanged = function (keyFn, comparer) {\n comparer || (comparer = defaultComparer);\n return new DistinctUntilChangedObservable(this, keyFn, comparer);\n };\n\r\n var TapObservable = (function(__super__) {\n inherits(TapObservable,__super__);\n function TapObservable(source, observerOrOnNext, onError, onCompleted) {\n this.source = source;\n this._oN = observerOrOnNext;\n this._oE = onError;\n this._oC = onCompleted;\n __super__.call(this);\n }\n\n TapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this));\n };\n\n function InnerObserver(o, p) {\n this.o = o;\n this.t = !p._oN || isFunction(p._oN) ?\n observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) :\n p._oN;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var res = tryCatch(this.t.onNext).call(this.t, x);\n if (res === errorObj) { this.o.onError(res.e); }\n this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function(err) {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onError).call(this.t, err);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onCompleted).call(this.t);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TapObservable;\n }(ObservableBase));\n\n /**\n * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {\n return new TapObservable(this, observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Invokes an action for each element in the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onNext Action to invoke for each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {\n return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);\n };\n\n /**\n * Invokes an action upon exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {\n return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);\n };\n\n /**\n * Invokes an action upon graceful termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {\n return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);\n };\n\r\n /**\n * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.\n * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.\n * @returns {Observable} Source sequence with the action-invoking termination behavior applied.\n */\n observableProto['finally'] = function (action) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription = tryCatch(source.subscribe).call(source, observer);\n if (subscription === errorObj) {\n action();\n return thrower(subscription.e);\n }\n return disposableCreate(function () {\n var r = tryCatch(subscription.dispose).call(subscription);\n action();\n r === errorObj && thrower(r.e);\n });\n }, this);\n };\n\r\n var IgnoreElementsObservable = (function(__super__) {\n inherits(IgnoreElementsObservable, __super__);\n\n function IgnoreElementsObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IgnoreElementsObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = noop;\n InnerObserver.prototype.onError = function (err) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n\n return false;\n };\n\n return IgnoreElementsObservable;\n }(ObservableBase));\n\n /**\n * Ignores all elements in an observable sequence leaving only the termination messages.\n * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.\n */\n observableProto.ignoreElements = function () {\n return new IgnoreElementsObservable(this);\n };\n\r\n /**\n * Materializes the implicit notifications of an observable sequence as explicit notification values.\n * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.\n */\n observableProto.materialize = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n return source.subscribe(function (value) {\n observer.onNext(notificationCreateOnNext(value));\n }, function (e) {\n observer.onNext(notificationCreateOnError(e));\n observer.onCompleted();\n }, function () {\n observer.onNext(notificationCreateOnCompleted());\n observer.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.\n * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.\n * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.\n */\n observableProto.repeat = function (repeatCount) {\n return enumerableRepeat(this, repeatCount).concat();\n };\n\r\n /**\n * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.\n * Note if you encounter an error and want it to retry once, then you must use .retry(2);\n *\n * @example\n * var res = retried = retry.repeat();\n * var res = retried = retry.repeat(2);\n * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retry = function (retryCount) {\n return enumerableRepeat(this, retryCount).catchError();\n };\n\r\n /**\n * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. \n * if the notifier completes, the observable sequence completes.\n *\n * @example\n * var timer = Observable.timer(500);\n * var source = observable.retryWhen(timer);\n * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retryWhen = function (notifier) {\n return enumerableRepeat(this).catchErrorWhen(notifier);\n };\r\n var ScanObservable = (function(__super__) {\n inherits(ScanObservable, __super__);\n function ScanObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ScanObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o,this));\n };\n\n return ScanObservable;\n }(ObservableBase));\n\n function InnerObserver(o, parent) {\n this.o = o;\n this.accumulator = parent.accumulator;\n this.hasSeed = parent.hasSeed;\n this.seed = parent.seed;\n this.hasAccumulation = false;\n this.accumulation = null;\n this.hasValue = false;\n this.isStopped = false;\n }\n InnerObserver.prototype = {\n onNext: function (x) {\n if (this.isStopped) { return; }\n !this.hasValue && (this.hasValue = true);\n if (this.hasAccumulation) {\n this.accumulation = tryCatch(this.accumulator)(this.accumulation, x);\n } else {\n this.accumulation = this.hasSeed ? tryCatch(this.accumulator)(this.seed, x) : x;\n this.hasAccumulation = true;\n }\n if (this.accumulation === errorObj) { return this.o.onError(this.accumulation.e); }\n this.o.onNext(this.accumulation);\n },\n onError: function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n },\n onCompleted: function () {\n if (!this.isStopped) {\n this.isStopped = true;\n !this.hasValue && this.hasSeed && this.o.onNext(this.seed);\n this.o.onCompleted();\n }\n },\n dispose: function() { this.isStopped = true; },\n fail: function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n }\n };\n\n /**\n * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.\n * For aggregation behavior with no intermediate results, see Observable.aggregate.\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing the accumulated values.\n */\n observableProto.scan = function () {\n var hasSeed = false, seed, accumulator = arguments[0];\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[1];\n }\n return new ScanObservable(this, accumulator, hasSeed, seed);\n };\n\r\n /**\n * Bypasses a specified number of elements at the end of an observable sequence.\n * @description\n * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are\n * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.\n * @param count Number of elements to bypass at the end of the source sequence.\n * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.\n */\n observableProto.skipLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && o.onNext(q.shift());\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.\n * @example\n * var res = source.startWith(1, 2, 3);\n * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);\n * @param {Arguments} args The specified values to prepend to the observable sequence\n * @returns {Observable} The source sequence prepended with the specified values.\n */\n observableProto.startWith = function () {\n var values, scheduler, start = 0;\n if (!!arguments.length && isScheduler(arguments[0])) {\n scheduler = arguments[0];\n start = 1;\n } else {\n scheduler = immediateScheduler;\n }\n for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n return enumerableOf([observableFromArray(args, scheduler), this]).concat();\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the end of an observable sequence.\n * @description\n * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of\n * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && q.shift();\n }, function (e) { o.onError(e); }, function () {\n while (q.length > 0) { o.onNext(q.shift()); }\n o.onCompleted();\n });\n }, source);\n };\n\r\nobservableProto.flatMapConcat = observableProto.concatMap = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(1);\n};\r\n var MapObservable = (function (__super__) {\n inherits(MapObservable, __super__);\n\n function MapObservable(source, selector, thisArg) {\n this.source = source;\n this.selector = bindCallback(selector, thisArg, 3);\n __super__.call(this);\n }\n\n function innerMap(selector, self) {\n return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }\n }\n\n MapObservable.prototype.internalMap = function (selector, thisArg) {\n return new MapObservable(this.source, innerMap(selector, this), thisArg);\n };\n\n MapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this));\n };\n\n function InnerObserver(o, selector, source) {\n this.o = o;\n this.selector = selector;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n\n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var result = tryCatch(this.selector)(x, this.i++, this.source);\n if (result === errorObj) { return this.o.onError(result.e); }\n this.o.onNext(result);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MapObservable;\n\n }(ObservableBase));\n\n /**\n * Projects each element of an observable sequence into a new form by incorporating the element's index.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.\n */\n observableProto.map = observableProto.select = function (selector, thisArg) {\n var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };\n return this instanceof MapObservable ?\n this.internalMap(selectorFn, thisArg) :\n new MapObservable(this, selectorFn, thisArg);\n };\n\r\n function plucker(args, len) {\n return function mapper(x) {\n var currentProp = x;\n for (var i = 0; i < len; i++) {\n var p = currentProp[args[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n }\n }\n\n /**\n * Retrieves the value of a specified nested property from all elements in\n * the Observable sequence.\n * @param {Arguments} arguments The nested properties to pluck.\n * @returns {Observable} Returns a new Observable sequence of property values.\n */\n observableProto.pluck = function () {\n var len = arguments.length, args = new Array(len);\n if (len === 0) { throw new Error('List of properties cannot be empty.'); }\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return this.map(plucker(args, len));\n };\n\r\nobservableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll();\n};\n\n\n//\n//Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) {\n// return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit);\n//};\n//\n\r\nRx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest();\n};\r\n var SkipObservable = (function(__super__) {\n inherits(SkipObservable, __super__);\n function SkipObservable(source, count) {\n this.source = source;\n this.skipCount = count;\n __super__.call(this);\n }\n \n SkipObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.skipCount));\n };\n \n function InnerObserver(o, c) {\n this.c = c;\n this.r = c;\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n if (this.r <= 0) { \n this.o.onNext(x);\n } else {\n this.r--;\n }\n };\n InnerObserver.prototype.onError = function(e) {\n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n \n return SkipObservable;\n }(ObservableBase)); \n \n /**\n * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.\n * @param {Number} count The number of elements to skip before returning the remaining elements.\n * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.\n */\n observableProto.skip = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipObservable(this, count);\n };\r\n /**\n * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.\n * The element's index is used in the logic of the predicate function.\n *\n * var res = source.skipWhile(function (value) { return value < 10; });\n * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\n observableProto.skipWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = false;\n return source.subscribe(function (x) {\n if (!running) {\n try {\n running = !callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n running && o.onNext(x);\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).\n *\n * var res = source.take(5);\n * var res = source.take(0, Rx.Scheduler.timeout);\n * @param {Number} count The number of elements to return.\n * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case is set to 0.\n * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.\n */\n observableProto.take = function (count, scheduler) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n if (count === 0) { return observableEmpty(scheduler); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var remaining = count;\n return source.subscribe(function (x) {\n if (remaining-- > 0) {\n o.onNext(x);\n remaining <= 0 && o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns elements from an observable sequence as long as a specified condition is true.\n * The element's index is used in the logic of the predicate function.\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.\n */\n observableProto.takeWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = true;\n return source.subscribe(function (x) {\n if (running) {\n try {\n running = callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (running) {\n o.onNext(x);\n } else {\n o.onCompleted();\n }\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n var FilterObservable = (function (__super__) {\n inherits(FilterObservable, __super__);\n\n function FilterObservable(source, predicate, thisArg) {\n this.source = source;\n this.predicate = bindCallback(predicate, thisArg, 3);\n __super__.call(this);\n }\n\n FilterObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.predicate, this));\n };\n \n function innerPredicate(predicate, self) {\n return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }\n }\n\n FilterObservable.prototype.internalFilter = function(predicate, thisArg) {\n return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);\n };\n \n function InnerObserver(o, predicate, source) {\n this.o = o;\n this.predicate = predicate;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n \n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var shouldYield = tryCatch(this.predicate)(x, this.i++, this.source);\n if (shouldYield === errorObj) {\n return this.o.onError(shouldYield.e);\n }\n shouldYield && this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return FilterObservable;\n\n }(ObservableBase));\n\n /**\n * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.\n * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.\n */\n observableProto.filter = observableProto.where = function (predicate, thisArg) {\n return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :\n new FilterObservable(this, predicate, thisArg);\n };\n\r\nfunction createCbObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createCbHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createCbHandler(o, ctx, selector) {\n return function handler () {\n var len = arguments.length, results = new Array(len);\n for(var i = 0; i < len; i++) { results[i] = arguments[i]; }\n\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a callback function to an observable sequence.\n *\n * @param {Function} fn Function with a callback as the last parameter to convert to an Observable sequence.\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.\n * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.\n */\nObservable.fromCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createCbObservable(fn, ctx, selector, args);\n };\n};\n\r\nfunction createNodeObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createNodeHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createNodeHandler(o, ctx, selector) {\n return function handler () {\n var err = arguments[0];\n if (err) { return o.onError(err); }\n\n var len = arguments.length, results = [];\n for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }\n\n if (isFunction(selector)) {\n var results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.\n * @param {Function} fn The function to call\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.\n * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.\n */\nObservable.fromNodeCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createNodeObservable(fn, ctx, selector, args);\n };\n};\n\r\n function ListenDisposable(e, n, fn) {\n this._e = e;\n this._n = n;\n this._fn = fn;\n this._e.addEventListener(this._n, this._fn, false);\n this.isDisposed = false;\n }\n ListenDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this._e.removeEventListener(this._n, this._fn, false);\n this.isDisposed = true;\n }\n };\n\n function createEventListener (el, eventName, handler) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var elemToString = Object.prototype.toString.call(el);\n if (elemToString === '[object NodeList]' || elemToString === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler));\n }\n } else if (el) {\n disposables.add(new ListenDisposable(el, eventName, handler));\n }\n\n return disposables;\n }\n\n /**\n * Configuration option to determine whether to use native events only\n */\n Rx.config.useNativeEvents = false;\n\n function eventHandler(o, selector) {\n return function handler () {\n var results = arguments[0];\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(null, arguments);\n if (results === errorObj) { return o.onError(results.e); }\n }\n o.onNext(results);\n };\n }\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n Observable.fromEvent = function (element, eventName, selector) {\n // Node.js specific\n if (element.addListener) {\n return fromEventPattern(\n function (h) { element.addListener(eventName, h); },\n function (h) { element.removeListener(eventName, h); },\n selector);\n }\n\n // Use only if non-native events are allowed\n if (!Rx.config.useNativeEvents) {\n // Handles jq, Angular.js, Zepto, Marionette, Ember.js\n if (typeof element.on === 'function' && typeof element.off === 'function') {\n return fromEventPattern(\n function (h) { element.on(eventName, h); },\n function (h) { element.off(eventName, h); },\n selector);\n }\n }\n\n return new AnonymousObservable(function (o) {\n return createEventListener(\n element,\n eventName,\n eventHandler(o, selector));\n }).publish().refCount();\n };\n\r\n /**\n * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.\n * @param {Function} addHandler The function to add a handler to the emitter.\n * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @param {Scheduler} [scheduler] A scheduler used to schedule the remove handler.\n * @returns {Observable} An observable sequence which wraps an event from an event emitter\n */\n var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (o) {\n function innerHandler () {\n var result = arguments[0];\n if (isFunction(selector)) {\n result = tryCatch(selector).apply(null, arguments);\n if (result === errorObj) { return o.onError(result.e); }\n }\n o.onNext(result);\n }\n\n var returnValue = addHandler(innerHandler);\n return disposableCreate(function () {\n isFunction(removeHandler) && removeHandler(innerHandler, returnValue);\n });\n }).publish().refCount();\n };\n\r\n var FromPromiseObservable = (function(__super__) {\n inherits(FromPromiseObservable, __super__);\n function FromPromiseObservable(p) {\n this.p = p;\n __super__.call(this);\n }\n\n FromPromiseObservable.prototype.subscribeCore = function(o) {\n this.p.then(function (data) {\n o.onNext(data);\n o.onCompleted();\n }, function (err) { o.onError(err); });\n return disposableEmpty;\n };\n\n return FromPromiseObservable;\n }(ObservableBase));\n\n /**\n * Converts a Promise to an Observable sequence\n * @param {Promise} An ES6 Compliant promise.\n * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.\n */\n var observableFromPromise = Observable.fromPromise = function (promise) {\n return new FromPromiseObservable(promise);\n };\r\n /*\n * Converts an existing observable sequence to an ES6 Compatible Promise\n * @example\n * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);\n *\n * // With config\n * Rx.config.Promise = RSVP.Promise;\n * var promise = Rx.Observable.return(42).toPromise();\n * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.\n * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.\n */\n observableProto.toPromise = function (promiseCtor) {\n promiseCtor || (promiseCtor = Rx.config.Promise);\n if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }\n var source = this;\n return new promiseCtor(function (resolve, reject) {\n // No cancellation can be done\n var value, hasValue = false;\n source.subscribe(function (v) {\n value = v;\n hasValue = true;\n }, reject, function () {\n hasValue && resolve(value);\n });\n });\n };\n\r\n /**\n * Invokes the asynchronous function, surfacing the result through an observable sequence.\n * @param {Function} functionAsync Asynchronous function which returns a Promise to run.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n */\n Observable.startAsync = function (functionAsync) {\n var promise;\n try {\n promise = functionAsync();\n } catch (e) {\n return observableThrow(e);\n }\n return observableFromPromise(promise);\n }\n\r\n /**\n * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each\n * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's\n * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.\n *\n * @example\n * 1 - res = source.multicast(observable);\n * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });\n *\n * @param {Function|Subject} subjectOrSubjectSelector\n * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.\n * Or:\n * Subject to push source elements into.\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if 0) {\n var now = scheduler.now();\n d = d + p;\n d <= now && (d = now + p);\n }\n observer.onNext(count);\n self(count + 1, d);\n });\n });\n }\n\r\n function observableTimerTimeSpan(dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithRelative(normalizeTime(dueTime), function () {\n observer.onNext(0);\n observer.onCompleted();\n });\n });\n }\n\r\n function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) {\n return dueTime === period ?\n new AnonymousObservable(function (observer) {\n return scheduler.schedulePeriodicWithState(0, period, function (count) {\n observer.onNext(count);\n return count + 1;\n });\n }) :\n observableDefer(function () {\n return observableTimerDateAndPeriod(scheduler.now() + dueTime, period, scheduler);\n });\n }\n\r\n /**\n * Returns an observable sequence that produces a value after each period.\n *\n * @example\n * 1 - res = Rx.Observable.interval(1000);\n * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);\n *\n * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.\n * @returns {Observable} An observable sequence that produces a value after each period.\n */\n var observableinterval = Observable.interval = function (period, scheduler) {\n return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : timeoutScheduler);\n };\n\r\n /**\n * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.\n * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.\n */\n var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) {\n var period;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n if (periodOrScheduler != null && typeof periodOrScheduler === 'number') {\n period = periodOrScheduler;\n } else if (isScheduler(periodOrScheduler)) {\n scheduler = periodOrScheduler;\n }\n if (dueTime instanceof Date && period === undefined) {\n return observableTimerDate(dueTime.getTime(), scheduler);\n }\n if (dueTime instanceof Date && period !== undefined) {\n return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler);\n }\n return period === undefined ?\n observableTimerTimeSpan(dueTime, scheduler) :\n observableTimerTimeSpanAndPeriod(dueTime, period, scheduler);\n };\n\r\n function observableDelayRelative(source, dueTime, scheduler) {\n return new AnonymousObservable(function (o) {\n var active = false,\n cancelable = new SerialDisposable(),\n exception = null,\n q = [],\n running = false,\n subscription;\n subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) {\n var d, shouldRun;\n if (notification.value.kind === 'E') {\n q = [];\n q.push(notification);\n exception = notification.value.exception;\n shouldRun = !running;\n } else {\n q.push({ value: notification.value, timestamp: notification.timestamp + dueTime });\n shouldRun = !active;\n active = true;\n }\n if (shouldRun) {\n if (exception !== null) {\n o.onError(exception);\n } else {\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleRecursiveWithRelative(dueTime, function (self) {\n var e, recurseDueTime, result, shouldRecurse;\n if (exception !== null) {\n return;\n }\n running = true;\n do {\n result = null;\n if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) {\n result = q.shift().value;\n }\n if (result !== null) {\n result.accept(o);\n }\n } while (result !== null);\n shouldRecurse = false;\n recurseDueTime = 0;\n if (q.length > 0) {\n shouldRecurse = true;\n recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now());\n } else {\n active = false;\n }\n e = exception;\n running = false;\n if (e !== null) {\n o.onError(e);\n } else if (shouldRecurse) {\n self(recurseDueTime);\n }\n }));\n }\n }\n });\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n }\n\n function observableDelayAbsolute(source, dueTime, scheduler) {\n return observableDefer(function () {\n return observableDelayRelative(source, dueTime - scheduler.now(), scheduler);\n });\n }\n\n function delayWithSelector(source, subscriptionDelay, delayDurationSelector) {\n var subDelay, selector;\n if (isFunction(subscriptionDelay)) {\n selector = subscriptionDelay;\n } else {\n subDelay = subscriptionDelay;\n selector = delayDurationSelector;\n }\n return new AnonymousObservable(function (o) {\n var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();\n\n function start() {\n subscription.setDisposable(source.subscribe(\n function (x) {\n var delay = tryCatch(selector)(x);\n if (delay === errorObj) { return o.onError(delay.e); }\n var d = new SingleAssignmentDisposable();\n delays.add(d);\n d.setDisposable(delay.subscribe(\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n }\n ));\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n subscription.dispose();\n done();\n }\n ));\n }\n\n function done () {\n atEnd && delays.length === 0 && o.onCompleted();\n }\n\n if (!subDelay) {\n start();\n } else {\n subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start));\n }\n\n return new CompositeDisposable(subscription, delays);\n }, this);\n }\n\n /**\n * Time shifts the observable sequence by dueTime.\n * The relative time intervals between the values are preserved.\n *\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delay = function () {\n if (typeof arguments[0] === 'number' || arguments[0] instanceof Date) {\n var dueTime = arguments[0], scheduler = arguments[1];\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return dueTime instanceof Date ?\n observableDelayAbsolute(this, dueTime, scheduler) :\n observableDelayRelative(this, dueTime, scheduler);\n } else if (isFunction(arguments[0])) {\n return delayWithSelector(this, arguments[0], arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\r\n function debounce(source, dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0;\n var subscription = source.subscribe(\n function (x) {\n hasvalue = true;\n value = x;\n id++;\n var currentId = id,\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () {\n hasvalue && id === currentId && observer.onNext(value);\n hasvalue = false;\n }));\n },\n function (e) {\n cancelable.dispose();\n observer.onError(e);\n hasvalue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasvalue && observer.onNext(value);\n observer.onCompleted();\n hasvalue = false;\n id++;\n });\n return new CompositeDisposable(subscription, cancelable);\n }, this);\n }\n\n function debounceWithSelector(source, durationSelector) {\n return new AnonymousObservable(function (o) {\n var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;\n var subscription = source.subscribe(\n function (x) {\n var throttle = tryCatch(durationSelector)(x);\n if (throttle === errorObj) { return o.onError(throttle.e); }\n\n isPromise(throttle) && (throttle = observableFromPromise(throttle));\n\n hasValue = true;\n value = x;\n id++;\n var currentid = id, d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(throttle.subscribe(\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n },\n function (e) { o.onError(e); },\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n }\n ));\n },\n function (e) {\n cancelable.dispose();\n o.onError(e);\n hasValue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasValue && o.onNext(value);\n o.onCompleted();\n hasValue = false;\n id++;\n }\n );\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n }\n\n observableProto.debounce = function () {\n if (isFunction (arguments[0])) {\n return debounceWithSelector(this, arguments[0]);\n } else if (typeof arguments[0] === 'number') {\n return debounce(this, arguments[0], arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\r\n /**\n * Records the timestamp for each value in an observable sequence.\n *\n * @example\n * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }\n * 2 - res = source.timestamp(Rx.Scheduler.default);\n *\n * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.\n * @returns {Observable} An observable sequence with timestamp information on values.\n */\n observableProto.timestamp = function (scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return this.map(function (x) {\n return { value: x, timestamp: scheduler.now() };\n });\n };\n\r\n function sampleObservable(source, sampler) {\n return new AnonymousObservable(function (o) {\n var atEnd = false, value, hasValue = false;\n\n function sampleSubscribe() {\n if (hasValue) {\n hasValue = false;\n o.onNext(value);\n }\n atEnd && o.onCompleted();\n }\n\n var sourceSubscription = new SingleAssignmentDisposable();\n sourceSubscription.setDisposable(source.subscribe(\n function (newValue) {\n hasValue = true;\n value = newValue;\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n sourceSubscription.dispose(); \n }\n ));\n\n return new CompositeDisposable(\n sourceSubscription,\n sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe)\n );\n }, source);\n }\n\n /**\n * Samples the observable sequence at each interval.\n *\n * @example\n * 1 - res = source.sample(sampleObservable); // Sampler tick sequence\n * 2 - res = source.sample(5000); // 5 seconds\n * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds\n *\n * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.\n * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Sampled observable sequence.\n */\n observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return typeof intervalOrSampler === 'number' ?\n sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :\n sampleObservable(this, intervalOrSampler);\n };\n\r\n var TimeoutError = Rx.TimeoutError = function(message) {\n this.message = message || 'Timeout has occurred';\n this.name = 'TimeoutError';\n Error.call(this);\n };\n TimeoutError.prototype = Object.create(Error.prototype);\n\n function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) {\n if (isFunction(firstTimeout)) {\n other = timeoutDurationSelector;\n timeoutDurationSelector = firstTimeout;\n firstTimeout = observableNever();\n }\n other || (other = observableThrow(new TimeoutError()));\n return new AnonymousObservable(function (o) {\n var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable();\n\n subscription.setDisposable(original);\n\n var id = 0, switched = false;\n\n function setTimer(timeout) {\n var myId = id, d = new SingleAssignmentDisposable();\n timer.setDisposable(d);\n d.setDisposable(timeout.subscribe(function () {\n id === myId && subscription.setDisposable(other.subscribe(o));\n d.dispose();\n }, function (e) {\n id === myId && o.onError(e);\n }, function () {\n id === myId && subscription.setDisposable(other.subscribe(o));\n }));\n };\n\n setTimer(firstTimeout);\n\n function oWins() {\n var res = !switched;\n if (res) { id++; }\n return res;\n }\n\n original.setDisposable(source.subscribe(function (x) {\n if (oWins()) {\n o.onNext(x);\n var timeout = tryCatch(timeoutDurationSelector)(x);\n if (timeout === errorObj) { return o.onError(timeout.e); }\n setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);\n }\n }, function (e) {\n oWins() && o.onError(e);\n }, function () {\n oWins() && o.onCompleted();\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n }\n\n function timeout(source, dueTime, other, scheduler) {\n if (other == null) { throw new Error('other or scheduler must be specified'); }\n if (isScheduler(other)) {\n scheduler = other;\n other = observableThrow(new TimeoutError());\n }\n if (other instanceof Error) { other = observableThrow(other); }\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n\n var schedulerMethod = dueTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n\n return new AnonymousObservable(function (o) {\n var id = 0,\n original = new SingleAssignmentDisposable(),\n subscription = new SerialDisposable(),\n switched = false,\n timer = new SerialDisposable();\n\n subscription.setDisposable(original);\n\n function createTimer() {\n var myId = id;\n timer.setDisposable(scheduler[schedulerMethod](dueTime, function () {\n if (id === myId) {\n isPromise(other) && (other = observableFromPromise(other));\n subscription.setDisposable(other.subscribe(o));\n }\n }));\n }\n\n createTimer();\n\n original.setDisposable(source.subscribe(function (x) {\n if (!switched) {\n id++;\n o.onNext(x);\n createTimer();\n }\n }, function (e) {\n if (!switched) {\n id++;\n o.onError(e);\n }\n }, function () {\n if (!switched) {\n id++;\n o.onCompleted();\n }\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n }\n\n observableProto.timeout = function () {\n var firstArg = arguments[0];\n if (firstArg instanceof Date || typeof firstArg === 'number') {\n return timeout(this, firstArg, arguments[1], arguments[2]);\n } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) {\n return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\r\n /**\n * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.\n * @param {Number} windowDuration time to wait before emitting another item after emitting the last item\n * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.\n * @returns {Observable} An Observable that performs the throttle operation.\n */\n observableProto.throttle = function (windowDuration, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var duration = +windowDuration || 0;\n if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var lastOnNext = 0;\n return source.subscribe(\n function (x) {\n var now = scheduler.now();\n if (lastOnNext === 0 || now - lastOnNext >= duration) {\n lastOnNext = now;\n o.onNext(x);\n }\n },function (e) { o.onError(e); }, function () { o.onCompleted(); }\n );\n }, source);\n };\n\r\n var PausableObservable = (function (__super__) {\n\n inherits(PausableObservable, __super__);\n\n function subscribe(observer) {\n var conn = this.source.publish(),\n subscription = conn.subscribe(observer),\n connection = disposableEmpty;\n\n var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {\n if (b) {\n connection = conn.connect();\n } else {\n connection.dispose();\n connection = disposableEmpty;\n }\n });\n\n return new CompositeDisposable(subscription, connection, pausable);\n }\n\n function PausableObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausable(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausable = function (pauser) {\n return new PausableObservable(this, pauser);\n };\n\r\n function combineLatestSource(source, subject, resultSelector) {\n return new AnonymousObservable(function (o) {\n var hasValue = [false, false],\n hasValueAll = false,\n isDone = false,\n values = new Array(2),\n err;\n\n function next(x, i) {\n values[i] = x;\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n if (err) { return o.onError(err); }\n var res = tryCatch(resultSelector).apply(null, values);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n }\n isDone && values[1] && o.onCompleted();\n }\n\n return new CompositeDisposable(\n source.subscribe(\n function (x) {\n next(x, 0);\n },\n function (e) {\n if (values[1]) {\n o.onError(e);\n } else {\n err = e;\n }\n },\n function () {\n isDone = true;\n values[1] && o.onCompleted();\n }),\n subject.subscribe(\n function (x) {\n next(x, 1);\n },\n function (e) { o.onError(e); },\n function () {\n isDone = true;\n next(true, 1);\n })\n );\n }, source);\n }\n\n var PausableBufferedObservable = (function (__super__) {\n\n inherits(PausableBufferedObservable, __super__);\n\n function subscribe(o) {\n var q = [], previousShouldFire;\n\n function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } }\n\n var subscription =\n combineLatestSource(\n this.source,\n this.pauser.startWith(false).distinctUntilChanged(),\n function (data, shouldFire) {\n return { data: data, shouldFire: shouldFire };\n })\n .subscribe(\n function (results) {\n if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) {\n previousShouldFire = results.shouldFire;\n // change in shouldFire\n if (results.shouldFire) { drainQueue(); }\n } else {\n previousShouldFire = results.shouldFire;\n // new data\n if (results.shouldFire) {\n o.onNext(results.data);\n } else {\n q.push(results.data);\n }\n }\n },\n function (err) {\n drainQueue();\n o.onError(err);\n },\n function () {\n drainQueue();\n o.onCompleted();\n }\n );\n return subscription;\n }\n\n function PausableBufferedObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableBufferedObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableBufferedObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableBufferedObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,\n * and yields the values that were buffered while paused.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausableBuffered(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausableBuffered = function (subject) {\n return new PausableBufferedObservable(this, subject);\n };\n\r\nvar ControlledObservable = (function (__super__) {\n\n inherits(ControlledObservable, __super__);\n\n function subscribe (observer) {\n return this.source.subscribe(observer);\n }\n\n function ControlledObservable (source, enableQueue, scheduler) {\n __super__.call(this, subscribe, source);\n this.subject = new ControlledSubject(enableQueue, scheduler);\n this.source = source.multicast(this.subject).refCount();\n }\n\n ControlledObservable.prototype.request = function (numberOfItems) {\n return this.subject.request(numberOfItems == null ? -1 : numberOfItems);\n };\n\n return ControlledObservable;\n\n}(Observable));\n\nvar ControlledSubject = (function (__super__) {\n\n function subscribe (observer) {\n return this.subject.subscribe(observer);\n }\n\n inherits(ControlledSubject, __super__);\n\n function ControlledSubject(enableQueue, scheduler) {\n enableQueue == null && (enableQueue = true);\n\n __super__.call(this, subscribe);\n this.subject = new Subject();\n this.enableQueue = enableQueue;\n this.queue = enableQueue ? [] : null;\n this.requestedCount = 0;\n this.requestedDisposable = null;\n this.error = null;\n this.hasFailed = false;\n this.hasCompleted = false;\n this.scheduler = scheduler || currentThreadScheduler;\n }\n\n addProperties(ControlledSubject.prototype, Observer, {\n onCompleted: function () {\n this.hasCompleted = true;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onCompleted();\n this.disposeCurrentRequest()\n } else {\n this.queue.push(Notification.createOnCompleted());\n }\n },\n onError: function (error) {\n this.hasFailed = true;\n this.error = error;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onError(error);\n this.disposeCurrentRequest()\n } else {\n this.queue.push(Notification.createOnError(error));\n }\n },\n onNext: function (value) {\n if (this.requestedCount <= 0) {\n this.enableQueue && this.queue.push(Notification.createOnNext(value));\n } else {\n (this.requestedCount-- === 0) && this.disposeCurrentRequest();\n this.subject.onNext(value);\n }\n },\n _processRequest: function (numberOfItems) {\n if (this.enableQueue) {\n while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) {\n var first = this.queue.shift();\n first.accept(this.subject);\n if (first.kind === 'N') {\n numberOfItems--;\n } else {\n this.disposeCurrentRequest();\n this.queue = [];\n }\n }\n }\n\n return numberOfItems;\n },\n request: function (number) {\n this.disposeCurrentRequest();\n var self = this;\n\n this.requestedDisposable = this.scheduler.scheduleWithState(number,\n function(s, i) {\n var remaining = self._processRequest(i);\n var stopped = self.hasCompleted || self.hasFailed\n if (!stopped && remaining > 0) {\n self.requestedCount = remaining;\n\n return disposableCreate(function () {\n self.requestedCount = 0;\n });\n // Scheduled item is still in progress. Return a new\n // disposable to allow the request to be interrupted\n // via dispose.\n }\n });\n\n return this.requestedDisposable;\n },\n disposeCurrentRequest: function () {\n if (this.requestedDisposable) {\n this.requestedDisposable.dispose();\n this.requestedDisposable = null;\n }\n }\n });\n\n return ControlledSubject;\n}(Observable));\n\n/**\n * Attaches a controller to the observable sequence with the ability to queue.\n * @example\n * var source = Rx.Observable.interval(100).controlled();\n * source.request(3); // Reads 3 values\n * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request\n * @param {Scheduler} scheduler determines how the requests will be scheduled\n * @returns {Observable} The observable sequence which only propagates values on request.\n */\nobservableProto.controlled = function (enableQueue, scheduler) {\n\n if (enableQueue && isScheduler(enableQueue)) {\n scheduler = enableQueue;\n enableQueue = true;\n }\n\n if (enableQueue == null) { enableQueue = true; }\n return new ControlledObservable(this, enableQueue, scheduler);\n};\n\r\n /**\n * Pipes the existing Observable sequence into a Node.js Stream.\n * @param {Stream} dest The destination Node.js stream.\n * @returns {Stream} The destination stream.\n */\n observableProto.pipe = function (dest) {\n var source = this.pausableBuffered();\n\n function onDrain() {\n source.resume();\n }\n\n dest.addListener('drain', onDrain);\n\n source.subscribe(\n function (x) {\n !dest.write(String(x)) && source.pause();\n },\n function (err) {\n dest.emit('error', err);\n },\n function () {\n // Hack check because STDIO is not closable\n !dest._isStdio && dest.end();\n dest.removeListener('drain', onDrain);\n });\n\n source.resume();\n\n return dest;\n };\n\r\n /**\n * Executes a transducer to transform the observable sequence\n * @param {Transducer} transducer A transducer to execute\n * @returns {Observable} An Observable sequence containing the results from the transducer.\n */\n observableProto.transduce = function(transducer) {\n var source = this;\n\n function transformForObserver(o) {\n return {\n '@@transducer/init': function() {\n return o;\n },\n '@@transducer/step': function(obs, input) {\n return obs.onNext(input);\n },\n '@@transducer/result': function(obs) {\n return obs.onCompleted();\n }\n };\n }\n\n return new AnonymousObservable(function(o) {\n var xform = transducer(transformForObserver(o));\n return source.subscribe(\n function(v) {\n var res = tryCatch(xform['@@transducer/step']).call(xform, o, v);\n if (res === errorObj) { o.onError(res.e); }\n },\n function (e) { o.onError(e); },\n function() { xform['@@transducer/result'](o); }\n );\n }, source);\n };\n\r\n var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {\n inherits(AnonymousObservable, __super__);\n\n // Fix subscriber to check for undefined or function returned to decorate as Disposable\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.__subscribe).call(self, ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function innerSubscribe(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n function AnonymousObservable(subscribe, parent) {\n this.source = parent;\n this.__subscribe = subscribe;\n __super__.call(this, innerSubscribe);\n }\n\n return AnonymousObservable;\n\n }(Observable));\n\r\n var AutoDetachObserver = (function (__super__) {\n inherits(AutoDetachObserver, __super__);\n\n function AutoDetachObserver(observer) {\n __super__.call(this);\n this.observer = observer;\n this.m = new SingleAssignmentDisposable();\n }\n\n var AutoDetachObserverPrototype = AutoDetachObserver.prototype;\n\n AutoDetachObserverPrototype.next = function (value) {\n var result = tryCatch(this.observer.onNext).call(this.observer, value);\n if (result === errorObj) {\n this.dispose();\n thrower(result.e);\n }\n };\n\n AutoDetachObserverPrototype.error = function (err) {\n var result = tryCatch(this.observer.onError).call(this.observer, err);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.completed = function () {\n var result = tryCatch(this.observer.onCompleted).call(this.observer);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };\n AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };\n\n AutoDetachObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.m.dispose();\n };\n\n return AutoDetachObserver;\n }(AbstractObserver));\n\r\n var InnerSubscription = function (subject, observer) {\n this.subject = subject;\n this.observer = observer;\n };\n\n InnerSubscription.prototype.dispose = function () {\n if (!this.subject.isDisposed && this.observer !== null) {\n var idx = this.subject.observers.indexOf(this.observer);\n this.subject.observers.splice(idx, 1);\n this.observer = null;\n }\n };\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed observers.\n */\n var Subject = Rx.Subject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n return disposableEmpty;\n }\n observer.onCompleted();\n return disposableEmpty;\n }\n\n inherits(Subject, __super__);\n\n /**\n * Creates a subject.\n */\n function Subject() {\n __super__.call(this, subscribe);\n this.isDisposed = false,\n this.isStopped = false,\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(Subject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (!this.isStopped) {\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n /**\n * Creates a subject from the specified observer and observable.\n * @param {Observer} observer The observer used to send messages to the subject.\n * @param {Observable} observable The observable used to subscribe to messages sent from the subject.\n * @returns {Subject} Subject implemented using the given observer and observable.\n */\n Subject.create = function (observer, observable) {\n return new AnonymousSubject(observer, observable);\n };\n\n return Subject;\n }(Observable));\n\r\n /**\n * Represents the result of an asynchronous operation.\n * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.\n */\n var AsyncSubject = Rx.AsyncSubject = (function (__super__) {\n\n function subscribe(observer) {\n checkDisposed(this);\n\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n\n if (this.hasError) {\n observer.onError(this.error);\n } else if (this.hasValue) {\n observer.onNext(this.value);\n observer.onCompleted();\n } else {\n observer.onCompleted();\n }\n\n return disposableEmpty;\n }\n\n inherits(AsyncSubject, __super__);\n\n /**\n * Creates a subject that can only receive one value and that value is cached for all future observations.\n * @constructor\n */\n function AsyncSubject() {\n __super__.call(this, subscribe);\n\n this.isDisposed = false;\n this.isStopped = false;\n this.hasValue = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(AsyncSubject.prototype, Observer, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n checkDisposed(this);\n return this.observers.length > 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).\n */\n onCompleted: function () {\n var i, len;\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n var os = cloneArray(this.observers), len = os.length;\n\n if (this.hasValue) {\n for (i = 0; i < len; i++) {\n var o = os[i];\n o.onNext(this.value);\n o.onCompleted();\n }\n } else {\n for (i = 0; i < len; i++) {\n os[i].onCompleted();\n }\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the error.\n * @param {Mixed} error The Error to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.\n * @param {Mixed} value The value to store in the subject.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n this.hasValue = true;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.exception = null;\n this.value = null;\n }\n });\n\n return AsyncSubject;\n }(Observable));\n\r\n var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {\n inherits(AnonymousSubject, __super__);\n\n function subscribe(observer) {\n return this.observable.subscribe(observer);\n }\n\n function AnonymousSubject(observer, observable) {\n this.observer = observer;\n this.observable = observable;\n __super__.call(this, subscribe);\n }\n\n addProperties(AnonymousSubject.prototype, Observer.prototype, {\n onCompleted: function () {\n this.observer.onCompleted();\n },\n onError: function (error) {\n this.observer.onError(error);\n },\n onNext: function (value) {\n this.observer.onNext(value);\n }\n });\n\n return AnonymousSubject;\n }(Observable));\n\r\n /**\n * Represents a value that changes over time.\n * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.\n */\n var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n observer.onNext(this.value);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n } else {\n observer.onCompleted();\n }\n return disposableEmpty;\n }\n\n inherits(BehaviorSubject, __super__);\n\n /**\n * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.\n * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.\n */\n function BehaviorSubject(value) {\n __super__.call(this, subscribe);\n this.value = value,\n this.observers = [],\n this.isDisposed = false,\n this.isStopped = false,\n this.hasError = false;\n }\n\n addProperties(BehaviorSubject.prototype, Observer, {\n /**\n * Gets the current value or throws an exception.\n * Value is frozen after onCompleted is called.\n * After onError is called always throws the specified exception.\n * An exception is always thrown after dispose is called.\n * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext.\n */\n getValue: function () {\n checkDisposed(this);\n if (this.hasError) {\n throw this.error;\n }\n return this.value;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.value = null;\n this.exception = null;\n }\n });\n\n return BehaviorSubject;\n }(Observable));\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.\n */\n var ReplaySubject = Rx.ReplaySubject = (function (__super__) {\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function createRemovableDisposable(subject, observer) {\n return disposableCreate(function () {\n observer.dispose();\n !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);\n });\n }\n\n function subscribe(observer) {\n var so = new ScheduledObserver(this.scheduler, observer),\n subscription = createRemovableDisposable(this, so);\n checkDisposed(this);\n this._trim(this.scheduler.now());\n this.observers.push(so);\n\n for (var i = 0, len = this.q.length; i < len; i++) {\n so.onNext(this.q[i].value);\n }\n\n if (this.hasError) {\n so.onError(this.error);\n } else if (this.isStopped) {\n so.onCompleted();\n }\n\n so.ensureActive();\n return subscription;\n }\n\n inherits(ReplaySubject, __super__);\n\n /**\n * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.\n * @param {Number} [bufferSize] Maximum element count of the replay buffer.\n * @param {Number} [windowSize] Maximum time length of the replay buffer.\n * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.\n */\n function ReplaySubject(bufferSize, windowSize, scheduler) {\n this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;\n this.windowSize = windowSize == null ? maxSafeInteger : windowSize;\n this.scheduler = scheduler || currentThreadScheduler;\n this.q = [];\n this.observers = [];\n this.isStopped = false;\n this.isDisposed = false;\n this.hasError = false;\n this.error = null;\n __super__.call(this, subscribe);\n }\n\n addProperties(ReplaySubject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n return this.observers.length > 0;\n },\n _trim: function (now) {\n while (this.q.length > this.bufferSize) {\n this.q.shift();\n }\n while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {\n this.q.shift();\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n var now = this.scheduler.now();\n this.q.push({ interval: now, value: value });\n this._trim(now);\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onNext(value);\n observer.ensureActive();\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onError(error);\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onCompleted();\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n return ReplaySubject;\n }(Observable));\n\r\n /**\n * Used to pause and resume streams.\n */\n Rx.Pauser = (function (__super__) {\n inherits(Pauser, __super__);\n\n function Pauser() {\n __super__.call(this);\n }\n\n /**\n * Pauses the underlying sequence.\n */\n Pauser.prototype.pause = function () { this.onNext(false); };\n\n /**\n * Resumes the underlying sequence.\n */\n Pauser.prototype.resume = function () { this.onNext(true); };\n\n return Pauser;\n }(Subject));\n\r\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n root.Rx = Rx;\n\n define(function() {\n return Rx;\n });\n } else if (freeExports && freeModule) {\n // in Node.js or RingoJS\n if (moduleExports) {\n (freeModule.exports = Rx).Rx = Rx;\n } else {\n freeExports.Rx = Rx;\n }\n } else {\n // in a browser or Rhino\n root.Rx = Rx;\n }\n\r\n // All code before this point will be filtered from stack traces.\n var rEndingLine = captureLine();\n\r\n}.call(this));\n", - "export default class AjaxAdapter {\n\n constructor(options) {\n this._base = (options && options.base) || \"\";\n };\n\n create(store, type, partial, success, error, context) {\n\n if (error && {}.toString.call(error) !== '[object Function]') {\n\n this.create(store, type, partial, success, null, error);\n\n } else if (store._types[type]) {\n\n let request = new XMLHttpRequest();\n\n request.open('POST', `${this._base}/${type}`, true);\n\n request.setRequestHeader(\"Content-Type\", \"application/vnd.api+json\");\n\n request.onload = function () {\n if (request.status >= 200 && request.status < 300) {\n let response = JSON.parse(request.responseText);\n try {\n store.push(response);\n if (success) {\n success.call(context, store.find(response.data.type, response.data.id));\n }\n } catch (e) {\n if (error) {\n error.call(context, e);\n }\n }\n } else {\n if (error) {\n error.call(context);\n }\n }\n };\n\n request.send(JSON.stringify({\n data: store.convert(type, partial)\n }));\n\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n\n }\n\n destroy(store, type, id, success, error, context) {\n\n if (error && {}.toString.call(error) !== '[object Function]') {\n\n this.destroy(store, type, id, success, null, error);\n\n } else if (store._types[type]) {\n\n let request = new XMLHttpRequest();\n\n request.open('DELETE', `${this._base}/${type}/${id}`, true);\n\n request.setRequestHeader(\"Content-Type\", \"application/vnd.api+json\");\n\n request.onload = function () {\n if (request.status >= 200 && request.status < 300) {\n try {\n store.remove(type, id);\n if (success) {\n success.call(context);\n }\n } catch (e) {\n error.call(context, e);\n }\n } else if (error) {\n error.call(context);\n }\n };\n\n request.send();\n\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n\n }\n\n load(store, type, id, options, success, error, context) {\n\n if (id && {}.toString.call(id) === '[object Function]') {\n this.load(store, type, null, null, id, options, success);\n } else if (id && typeof id === \"object\") {\n this.load(store, type, null, id, options, success, error);\n } else if (options && {}.toString.call(options) === '[object Function]') {\n this.load(store, type, id, {}, options, success, error);\n } else if (error && {}.toString.call(error) !== '[object Function]') {\n this.load(store, type, id, options, success, null, error);\n } else if (store._types[type]) {\n\n let request = new XMLHttpRequest();\n let url;\n\n options = options || {};\n url = id ? `${this._base}/${type}/${id}` : `${this._base}/${type}`;\n\n if (options) {\n\n let params = [];\n\n if (options.fields) {\n Object.keys(options.fields).forEach(field => {\n options[`fields[${field}]`] = options.fields[field];\n });\n delete options.fields;\n }\n\n params = Object.keys(options).map(key => {\n return key + \"=\" + encodeURIComponent(options[key]);\n }).sort();\n\n if (params.length) {\n url = `${url}?${params.join(\"&\")}`;\n }\n\n }\n\n request.open('GET', url, true);\n\n request.setRequestHeader(\"Content-Type\", \"application/vnd.api+json\");\n\n request.onload = function () {\n if (request.status >= 200 && request.status < 300) {\n try {\n store.push(JSON.parse(request.responseText));\n if (success) {\n success.call(context, id ? store.find(type, id) : store.find(type));\n }\n } catch (e) {\n error.call({}, e);\n }\n } else if (error) {\n error.call(context);\n }\n };\n\n request.send();\n\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n\n }\n\n update(store, type, id, partial, success, error, context) {\n\n if (error && {}.toString.call(error) !== '[object Function]') {\n\n this.update(store, type, id, partial, success, null, error);\n\n } else if (store._types[type]) {\n\n let request = new XMLHttpRequest();\n let data = store.convert(type, id, partial);\n\n request.open('PATCH', `${this._base}/${type}/${id}`, true);\n\n request.setRequestHeader(\"Content-Type\", \"application/vnd.api+json\");\n\n request.onload = function () {\n if (request.status >= 200 && request.status < 300) {\n try {\n store.add(data);\n if (success) {\n success.call(context, store.find(data.type, data.id));\n }\n } catch (e) {\n if (error) {\n error.call(context, e);\n }\n }\n } else if (error) {\n error.call(context);\n }\n };\n\n request.send(JSON.stringify({\n data: data\n }));\n\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n\n }\n\n}\n", - "import \"array.prototype.find\";\nimport Rx from \"rx-lite\";\nimport AjaxAdapter from \"./ajax-adapter\";\n\nexport default class Store {\n\n /**\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n */\n static attr(name, options) {\n if (name && typeof name === 'object') {\n return Store.attr(null, name);\n } else {\n return {\n type: \"attr\",\n default: options && options.default,\n deserialize: function (data, key) {\n return data.attributes && data.attributes[name || key];\n },\n serialize: function (resource, data, key) {\n data.attributes[name || key] = resource[key];\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasOne(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasOne(null, name);\n } else {\n return {\n type: \"has-one\",\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return null;\n } else if (data.relationships[name].data) {\n return this.find(data.relationships[name].data.type, data.relationships[name].data.id);\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key] === null) {\n data.relationships[name || key] = null;\n } else if (resource[key]) {\n data.relationships[name || key] = {\n data: {\n type: resource[key].type,\n id: resource[key].id\n }\n };\n }\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasMany(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasMany(null, name);\n } else {\n return {\n type: \"has-many\",\n default: [],\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return [];\n } else if (data.relationships[name].data) {\n return data.relationships[name].data.map((c) => {\n return this.find(c.type, c.id);\n });\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key]) {\n data.relationships[name || key] = {\n data: resource[key].map(x => {\n return { type: x.type, id: x.id };\n })\n };\n }\n }\n };\n }\n }\n\n constructor(adapter) {\n\n this._adapter = adapter;\n this._data = {};\n this._subject = new Rx.Subject();\n this._subscriptions = {};\n this._types = {};\n\n /**\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n */\n this.observable = this._subject.asObservable();\n\n }\n\n /**\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n */\n add(object) {\n if (object) {\n if (object.type && object.id) {\n let name = this._data[object.type] && this._data[object.type][object.id] ? \"updated\" : \"added\";\n let resource = this.find(object.type, object.id);\n let definition = this._types[object.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n this._addField(object, resource, definition, fieldName);\n }\n });\n this._subject.onNext({\n name: name,\n type: object.type,\n id: object.id,\n resource: resource\n });\n } else {\n throw new TypeError(`The data must have a type and id`);\n }\n } else {\n throw new TypeError(`You must provide data to add`);\n }\n }\n\n /**\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n */\n convert(type, id, partial) {\n if (type && typeof type === \"object\") {\n return this.convert(type.type, type.id, type);\n } else if (id && typeof id === \"object\") {\n return this.convert(type, id.id, id);\n } else {\n let data = {\n type: type,\n attributes: {},\n relationships: {}\n };\n if (id) {\n data.id = id;\n }\n let definition = this._types[data.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n definition[fieldName].serialize(partial, data, fieldName);\n }\n });\n return data;\n }\n }\n\n /**\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }, (product) => {\n * console.log(product.title);\n * });\n */\n create(type, partial, success, error, context) {\n if (this._adapter) {\n this._adapter.create(this, type, partial, success, error, context);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n */\n define(names, definition) {\n names = (names.constructor === Array) ? names : [ names ];\n if (definition) {\n definition._names = names;\n names.forEach(name => {\n if (!this._types[name]) {\n this._types[name] = definition;\n } else {\n throw new Error(`The type '${name}' has already been defined.`);\n }\n });\n } else {\n throw new Error(`You must provide a definition for the type '${names[0]}'.`);\n }\n }\n\n /**\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\", () => {\n * console.log(\"Destroyed!\");\n * });\n */\n destroy(type, id, success, error, context) {\n if (this._adapter) {\n this._adapter.destroy(this, type, id, success, error, context);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Find a resource or entire collection of resources.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to find.\n * @param {string} [id] - The id of the resource to find. If omitted all\n * resources of the type will be returned.\n * @return {Object|Object[]} - Either the resource or an array of resources.\n */\n find(type, id) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n if (id) {\n if (!this._data[type][id]) {\n this._data[type][id] = {\n _dependents: [],\n type: type,\n id: id\n };\n Object.keys(definition).forEach(key => {\n if (key[0] !== \"_\") {\n this._data[type][id][key] = definition[key].default;\n }\n });\n }\n return this._data[type][id];\n } else {\n return Object.keys(this._data[type]).map(x => this._data[type][x]);\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Attempts to load the resource(s) through the adapter and adds it/them to\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} [id] - ID of resource.\n * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options)\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"product\", \"1\", (product) => {\n * console.log(product.title);\n * });\n */\n load(type, id, options, success, error, context) {\n if (this._adapter) {\n this._adapter.load(this, type, id, options, success, error, context);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n */\n off(event, type, id, callback) {\n console.warn([\n \"The `store.off()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.off.call(this, event, type, null, id, callback);\n } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || \"*\"]) {\n this._subscriptions[event][type][id || \"*\"].dispose();\n delete this._subscriptions[event][type][id || \"*\"];\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n */\n on(event, type, id, callback, context) {\n console.warn([\n \"The `store.on()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.on.call(this, event, type, null, id, callback);\n } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || \"*\"]) {\n let subscription = this._subject.filter(e => e.name === event);\n subscription = subscription.filter(e => this._types[type]._names.indexOf(e.type) !== -1);\n if (id) {\n subscription = subscription.filter(e => e.id === id);\n }\n subscription = subscription.map(e => this.find(e.type, e.id));\n this._subscriptions[event] = this._subscriptions[event] || {};\n if (!this._subscriptions[event][type]) {\n let obj = {};\n this._types[type]._names.forEach(type => {\n this._subscriptions[event][type] = obj;\n });\n }\n this._subscriptions[event][type][id || \"*\"] = subscription.subscribe(callback.bind(context));\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n */\n push(root) {\n if (root.data.constructor === Array) {\n root.data.forEach(x => this.add(x));\n } else {\n this.add(root.data);\n }\n if (root.included) {\n root.included.forEach(x => this.add(x));\n }\n }\n\n /**\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n */\n remove(type, id) {\n if (type) {\n if (this._types[type]) {\n if (id) {\n let resource = this._data[type] && this._data[type][id];\n if (resource) {\n this._remove(resource);\n this._subject.onNext({\n name: \"removed\",\n type: type,\n id: id,\n resource: null\n });\n }\n } else {\n Object.keys(this._data[type]).forEach(id => this.remove(type, id));\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type to remove`);\n }\n }\n\n /**\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }, (product) => {\n * console.log(product.title);\n * });\n */\n update(type, id, partial, success, error, context) {\n if (this._adapter) {\n this._adapter.update(this, type, id, partial, success, error, context);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n _addField(object, resource, definition, fieldName) {\n var field = definition[fieldName];\n var newValue = field.deserialize.call(this, object, fieldName);\n if (typeof newValue !== \"undefined\") {\n if (field.type === \"has-one\") {\n if (resource[fieldName]) {\n this._removeInverseRelationship(resource, fieldName, resource[fieldName], field);\n }\n if (newValue) {\n this._addInverseRelationship(resource, fieldName, newValue, field);\n }\n } else if (field.type === \"has-many\") {\n resource[fieldName].forEach(r => {\n if (resource[fieldName].indexOf(r) !== -1) {\n this._removeInverseRelationship(resource, fieldName, r, field);\n }\n });\n newValue.forEach(r => {\n this._addInverseRelationship(resource, fieldName, r, field);\n });\n }\n resource[fieldName] = newValue;\n }\n }\n\n _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var sourceDefinition = this._types[sourceResource.type];\n if (targetDefinition) {\n let targetFieldName = [ sourceField.inverse ].concat(sourceDefinition._names).find(x => targetDefinition[x]);\n let targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n targetResource[targetFieldName] = sourceResource;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n if (targetResource[targetFieldName].indexOf(sourceResource) === -1) {\n targetResource[targetFieldName].push(sourceResource);\n }\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n }\n\n _remove(resource) {\n resource._dependents.forEach(dependent => {\n let dependentResource = this._data[dependent.type][dependent.id];\n switch (this._types[dependent.type][dependent.fieldName].type) {\n case \"has-one\": {\n dependentResource[dependent.fieldName] = null;\n break;\n }\n case \"has-many\": {\n let index = dependentResource[dependent.fieldName].indexOf(resource);\n if (index !== -1) {\n dependentResource[dependent.fieldName].splice(index, 1);\n }\n break;\n }\n default: {\n break;\n }\n }\n // TODO: This only needs to be run once for each dependent.\n dependentResource._dependents = dependentResource._dependents.filter(d => {\n return !(d.type === resource.type && d.id === resource.id);\n });\n });\n delete this._data[resource.type][resource.id];\n }\n\n _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var targetFieldName = sourceField.inverse || sourceResource.type;\n var targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents = targetResource._dependents.filter(r => {\n return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName);\n });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = null;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = targetResource[targetFieldName].filter(r => {\n return r !== sourceResource;\n });\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n\n}\n\nStore.AjaxAdapter = AjaxAdapter;\n" + "// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\n;(function (undefined) {\n\n var objectTypes = {\n 'function': true,\n 'object': true\n };\n\n var\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeSelf = objectTypes[typeof self] && self.Object && self,\n freeWindow = objectTypes[typeof window] && window && window.Object && window,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;\n\n var root = root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;\n\n var Rx = {\n internals: {},\n config: {\n Promise: root.Promise\n },\n helpers: { }\n };\n\n // Defaults\n var noop = Rx.helpers.noop = function () { },\n identity = Rx.helpers.identity = function (x) { return x; },\n defaultNow = Rx.helpers.defaultNow = Date.now,\n defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },\n defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },\n defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },\n defaultError = Rx.helpers.defaultError = function (err) { throw err; },\n isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; },\n isFunction = Rx.helpers.isFunction = (function () {\n\n var isFn = function (value) {\n return typeof value == 'function' || false;\n }\n\n // fallback for older versions of Chrome and Safari\n if (isFn(/x/)) {\n isFn = function(value) {\n return typeof value == 'function' && toString.call(value) == '[object Function]';\n };\n }\n\n return isFn;\n }());\n\n function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}\n\n var errorObj = {e: {}};\n \n function tryCatcherGen(tryCatchTarget) {\n return function tryCatcher() {\n try {\n return tryCatchTarget.apply(this, arguments);\n } catch (e) {\n errorObj.e = e;\n return errorObj;\n }\n };\n }\n\n var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) {\n if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }\n return tryCatcherGen(fn);\n };\n\n function thrower(e) {\n throw e;\n }\n\n Rx.config.longStackSupport = false;\n var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })();\n hasStacks = !!stacks.e && !!stacks.e.stack;\n\n // All code after this point will be filtered from stack traces reported by RxJS\n var rStartingLine = captureLine(), rFileName;\n\n var STACK_JUMP_SEPARATOR = 'From previous event:';\n\n function makeStackTraceLong(error, observable) {\n // If possible, transform the error stack trace by removing Node and RxJS\n // cruft, then concatenating with the stack trace of `observable`.\n if (hasStacks &&\n observable.stack &&\n typeof error === 'object' &&\n error !== null &&\n error.stack &&\n error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1\n ) {\n var stacks = [];\n for (var o = observable; !!o; o = o.source) {\n if (o.stack) {\n stacks.unshift(o.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join('\\n' + STACK_JUMP_SEPARATOR + '\\n');\n error.stack = filterStackString(concatedStacks);\n }\n }\n\n function filterStackString(stackString) {\n var lines = stackString.split('\\n'), desiredLines = [];\n for (var i = 0, len = lines.length; i < len; i++) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join('\\n');\n }\n\n function isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n if (!fileNameAndLineNumber) {\n return false;\n }\n var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];\n\n return fileName === rFileName &&\n lineNumber >= rStartingLine &&\n lineNumber <= rEndingLine;\n }\n\n function isNodeFrame(stackLine) {\n return stackLine.indexOf('(module.js:') !== -1 ||\n stackLine.indexOf('(node.js:') !== -1;\n }\n\n function captureLine() {\n if (!hasStacks) { return; }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split('\\n');\n var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) { return; }\n\n rFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n }\n\n function getFileNameAndLineNumber(stackLine) {\n // Named functions: 'at functionName (filename:lineNumber:columnNumber)'\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }\n\n // Anonymous functions: 'at filename:lineNumber:columnNumber'\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }\n\n // Firefox style: 'function@filename:lineNumber or @filename:lineNumber'\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }\n }\n\n var EmptyError = Rx.EmptyError = function() {\n this.message = 'Sequence contains no elements.';\n this.name = 'EmptyError';\n Error.call(this);\n };\n EmptyError.prototype = Object.create(Error.prototype);\n\n var ObjectDisposedError = Rx.ObjectDisposedError = function() {\n this.message = 'Object has been disposed';\n this.name = 'ObjectDisposedError';\n Error.call(this);\n };\n ObjectDisposedError.prototype = Object.create(Error.prototype);\n\n var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {\n this.message = 'Argument out of range';\n this.name = 'ArgumentOutOfRangeError';\n Error.call(this);\n };\n ArgumentOutOfRangeError.prototype = Object.create(Error.prototype);\n\n var NotSupportedError = Rx.NotSupportedError = function (message) {\n this.message = message || 'This operation is not supported';\n this.name = 'NotSupportedError';\n Error.call(this);\n };\n NotSupportedError.prototype = Object.create(Error.prototype);\n\n var NotImplementedError = Rx.NotImplementedError = function (message) {\n this.message = message || 'This operation is not implemented';\n this.name = 'NotImplementedError';\n Error.call(this);\n };\n NotImplementedError.prototype = Object.create(Error.prototype);\n\n var notImplemented = Rx.helpers.notImplemented = function () {\n throw new NotImplementedError();\n };\n\n var notSupported = Rx.helpers.notSupported = function () {\n throw new NotSupportedError();\n };\n\n // Shim in iterator support\n var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||\n '_es6shim_iterator_';\n // Bug for mozilla version\n if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {\n $iterator$ = '@@iterator';\n }\n\n var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };\n\n var isIterable = Rx.helpers.isIterable = function (o) {\n return o[$iterator$] !== undefined;\n }\n\n var isArrayLike = Rx.helpers.isArrayLike = function (o) {\n return o && o.length !== undefined;\n }\n\n Rx.helpers.iterator = $iterator$;\n\n var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {\n if (typeof thisArg === 'undefined') { return func; }\n switch(argCount) {\n case 0:\n return function() {\n return func.call(thisArg)\n };\n case 1:\n return function(arg) {\n return func.call(thisArg, arg);\n }\n case 2:\n return function(value, index) {\n return func.call(thisArg, value, index);\n };\n case 3:\n return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n }\n\n return function() {\n return func.apply(thisArg, arguments);\n };\n };\n\n /** Used to determine if values are of the language type Object */\n var dontEnums = ['toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'],\n dontEnumsLength = dontEnums.length;\n\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n errorClass = '[object Error]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n var toString = Object.prototype.toString,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n supportsArgsClass = toString.call(arguments) == argsClass, // For less -1);\n }\n });\n }\n }\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\n var hasProp = {}.hasOwnProperty,\n slice = Array.prototype.slice;\n\n var inherits = Rx.internals.inherits = function (child, parent) {\n function __() { this.constructor = child; }\n __.prototype = parent.prototype;\n child.prototype = new __();\n };\n\n var addProperties = Rx.internals.addProperties = function (obj) {\n for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n for (var idx = 0, ln = sources.length; idx < ln; idx++) {\n var source = sources[idx];\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n };\n\n // Rx Utils\n var addRef = Rx.internals.addRef = function (xs, r) {\n return new AnonymousObservable(function (observer) {\n return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer));\n });\n };\n\n function arrayInitialize(count, factory) {\n var a = new Array(count);\n for (var i = 0; i < count; i++) {\n a[i] = factory();\n }\n return a;\n }\n\n function IndexedItem(id, value) {\n this.id = id;\n this.value = value;\n }\n\n IndexedItem.prototype.compareTo = function (other) {\n var c = this.value.compareTo(other.value);\n c === 0 && (c = this.id - other.id);\n return c;\n };\n\n var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {\n this.items = new Array(capacity);\n this.length = 0;\n };\n\n var priorityProto = PriorityQueue.prototype;\n priorityProto.isHigherPriority = function (left, right) {\n return this.items[left].compareTo(this.items[right]) < 0;\n };\n\n priorityProto.percolate = function (index) {\n if (index >= this.length || index < 0) { return; }\n var parent = index - 1 >> 1;\n if (parent < 0 || parent === index) { return; }\n if (this.isHigherPriority(index, parent)) {\n var temp = this.items[index];\n this.items[index] = this.items[parent];\n this.items[parent] = temp;\n this.percolate(parent);\n }\n };\n\n priorityProto.heapify = function (index) {\n +index || (index = 0);\n if (index >= this.length || index < 0) { return; }\n var left = 2 * index + 1,\n right = 2 * index + 2,\n first = index;\n if (left < this.length && this.isHigherPriority(left, first)) {\n first = left;\n }\n if (right < this.length && this.isHigherPriority(right, first)) {\n first = right;\n }\n if (first !== index) {\n var temp = this.items[index];\n this.items[index] = this.items[first];\n this.items[first] = temp;\n this.heapify(first);\n }\n };\n\n priorityProto.peek = function () { return this.items[0].value; };\n\n priorityProto.removeAt = function (index) {\n this.items[index] = this.items[--this.length];\n this.items[this.length] = undefined;\n this.heapify();\n };\n\n priorityProto.dequeue = function () {\n var result = this.peek();\n this.removeAt(0);\n return result;\n };\n\n priorityProto.enqueue = function (item) {\n var index = this.length++;\n this.items[index] = new IndexedItem(PriorityQueue.count++, item);\n this.percolate(index);\n };\n\n priorityProto.remove = function (item) {\n for (var i = 0; i < this.length; i++) {\n if (this.items[i].value === item) {\n this.removeAt(i);\n return true;\n }\n }\n return false;\n };\n PriorityQueue.count = 0;\n\n /**\n * Represents a group of disposable resources that are disposed together.\n * @constructor\n */\n var CompositeDisposable = Rx.CompositeDisposable = function () {\n var args = [], i, len;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n len = args.length;\n } else {\n len = arguments.length;\n args = new Array(len);\n for(i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n this.disposables = args;\n this.isDisposed = false;\n this.length = args.length;\n };\n\n var CompositeDisposablePrototype = CompositeDisposable.prototype;\n\n /**\n * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.\n * @param {Mixed} item Disposable to add.\n */\n CompositeDisposablePrototype.add = function (item) {\n if (this.isDisposed) {\n item.dispose();\n } else {\n this.disposables.push(item);\n this.length++;\n }\n };\n\n /**\n * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.\n * @param {Mixed} item Disposable to remove.\n * @returns {Boolean} true if found; false otherwise.\n */\n CompositeDisposablePrototype.remove = function (item) {\n var shouldDispose = false;\n if (!this.isDisposed) {\n var idx = this.disposables.indexOf(item);\n if (idx !== -1) {\n shouldDispose = true;\n this.disposables.splice(idx, 1);\n this.length--;\n item.dispose();\n }\n }\n return shouldDispose;\n };\n\n /**\n * Disposes all disposables in the group and removes them from the group.\n */\n CompositeDisposablePrototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var len = this.disposables.length, currentDisposables = new Array(len);\n for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }\n this.disposables = [];\n this.length = 0;\n\n for (i = 0; i < len; i++) {\n currentDisposables[i].dispose();\n }\n }\n };\n\n /**\n * Provides a set of static methods for creating Disposables.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n */\n var Disposable = Rx.Disposable = function (action) {\n this.isDisposed = false;\n this.action = action || noop;\n };\n\n /** Performs the task of cleaning up resources. */\n Disposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.action();\n this.isDisposed = true;\n }\n };\n\n /**\n * Creates a disposable object that invokes the specified action when disposed.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n * @return {Disposable} The disposable object that runs the given action upon disposal.\n */\n var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };\n\n /**\n * Gets the disposable that does nothing when disposed.\n */\n var disposableEmpty = Disposable.empty = { dispose: noop };\n\n /**\n * Validates whether the given object is a disposable\n * @param {Object} Object to test whether it has a dispose method\n * @returns {Boolean} true if a disposable object, else false.\n */\n var isDisposable = Disposable.isDisposable = function (d) {\n return d && isFunction(d.dispose);\n };\n\n var checkDisposed = Disposable.checkDisposed = function (disposable) {\n if (disposable.isDisposed) { throw new ObjectDisposedError(); }\n };\n\n var disposableFixup = Disposable._fixup = function (result) {\n return isDisposable(result) ? result : disposableEmpty;\n };\n\n // Single assignment\n var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SingleAssignmentDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SingleAssignmentDisposable.prototype.setDisposable = function (value) {\n if (this.current) { throw new Error('Disposable has already been assigned'); }\n var shouldDispose = this.isDisposed;\n !shouldDispose && (this.current = value);\n shouldDispose && value && value.dispose();\n };\n SingleAssignmentDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n old && old.dispose();\n }\n };\n\n // Multiple assignment disposable\n var SerialDisposable = Rx.SerialDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SerialDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SerialDisposable.prototype.setDisposable = function (value) {\n var shouldDispose = this.isDisposed;\n if (!shouldDispose) {\n var old = this.current;\n this.current = value;\n }\n old && old.dispose();\n shouldDispose && value && value.dispose();\n };\n SerialDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\n var BinaryDisposable = Rx.BinaryDisposable = function (first, second) {\n this._first = first;\n this._second = second;\n this.isDisposed = false;\n };\n\n BinaryDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old1 = this._first;\n this._first = null;\n old1 && old1.dispose();\n var old2 = this._second;\n this._second = null;\n old2 && old2.dispose();\n }\n };\n\n var NAryDisposable = Rx.NAryDisposable = function (disposables) {\n this._disposables = disposables;\n this.isDisposed = false;\n };\n\n NAryDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n for (var i = 0, len = this._disposables.length; i < len; i++) {\n this._disposables[i].dispose();\n }\n this._disposables.length = 0;\n }\n };\n\n /**\n * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.\n */\n var RefCountDisposable = Rx.RefCountDisposable = (function () {\n\n function InnerDisposable(disposable) {\n this.disposable = disposable;\n this.disposable.count++;\n this.isInnerDisposed = false;\n }\n\n InnerDisposable.prototype.dispose = function () {\n if (!this.disposable.isDisposed && !this.isInnerDisposed) {\n this.isInnerDisposed = true;\n this.disposable.count--;\n if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {\n this.disposable.isDisposed = true;\n this.disposable.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Initializes a new instance of the RefCountDisposable with the specified disposable.\n * @constructor\n * @param {Disposable} disposable Underlying disposable.\n */\n function RefCountDisposable(disposable) {\n this.underlyingDisposable = disposable;\n this.isDisposed = false;\n this.isPrimaryDisposed = false;\n this.count = 0;\n }\n\n /**\n * Disposes the underlying disposable only when all dependent disposables have been disposed\n */\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed && !this.isPrimaryDisposed) {\n this.isPrimaryDisposed = true;\n if (this.count === 0) {\n this.isDisposed = true;\n this.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.\n * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.\n */\n RefCountDisposable.prototype.getDisposable = function () {\n return this.isDisposed ? disposableEmpty : new InnerDisposable(this);\n };\n\n return RefCountDisposable;\n })();\n\n function ScheduledDisposable(scheduler, disposable) {\n this.scheduler = scheduler;\n this.disposable = disposable;\n this.isDisposed = false;\n }\n\n function scheduleItem(s, self) {\n if (!self.isDisposed) {\n self.isDisposed = true;\n self.disposable.dispose();\n }\n }\n\n ScheduledDisposable.prototype.dispose = function () {\n this.scheduler.schedule(this, scheduleItem);\n };\n\n var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {\n this.scheduler = scheduler;\n this.state = state;\n this.action = action;\n this.dueTime = dueTime;\n this.comparer = comparer || defaultSubComparer;\n this.disposable = new SingleAssignmentDisposable();\n }\n\n ScheduledItem.prototype.invoke = function () {\n this.disposable.setDisposable(this.invokeCore());\n };\n\n ScheduledItem.prototype.compareTo = function (other) {\n return this.comparer(this.dueTime, other.dueTime);\n };\n\n ScheduledItem.prototype.isCancelled = function () {\n return this.disposable.isDisposed;\n };\n\n ScheduledItem.prototype.invokeCore = function () {\n return disposableFixup(this.action(this.scheduler, this.state));\n };\n\n /** Provides a set of static properties to access commonly used schedulers. */\n var Scheduler = Rx.Scheduler = (function () {\n\n function Scheduler() { }\n\n /** Determines whether the given object is a scheduler */\n Scheduler.isScheduler = function (s) {\n return s instanceof Scheduler;\n };\n\n var schedulerProto = Scheduler.prototype;\n\n /**\n * Schedules an action to be executed.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.schedule = function (state, action) {\n throw new NotImplementedError();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleFuture = function (state, dueTime, action) {\n var dt = dueTime;\n dt instanceof Date && (dt = dt - this.now());\n dt = Scheduler.normalize(dt);\n\n if (dt === 0) { return this.schedule(state, action); }\n\n return this._scheduleFuture(state, dt, action);\n };\n\n schedulerProto._scheduleFuture = function (state, dueTime, action) {\n throw new NotImplementedError();\n };\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.now = defaultNow;\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.prototype.now = defaultNow;\n\n /**\n * Normalizes the specified TimeSpan value to a positive value.\n * @param {Number} timeSpan The time span value to normalize.\n * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0\n */\n Scheduler.normalize = function (timeSpan) {\n timeSpan < 0 && (timeSpan = 0);\n return timeSpan;\n };\n\n return Scheduler;\n }());\n\n var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;\n\n (function (schedulerProto) {\n\n function invokeRecImmediate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2) {\n var isAdded = false, isDone = false;\n\n var d = scheduler.schedule(state2, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n function invokeRecDate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2, dueTime1) {\n var isAdded = false, isDone = false;\n\n var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursive = function (state, action) {\n return this.schedule([state, action], invokeRecImmediate);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative or absolute due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) {\n return this.scheduleFuture([state, action], dueTime, invokeRecDate);\n };\n\n }(Scheduler.prototype));\n\n (function (schedulerProto) {\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodic = function(state, period, action) {\n if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }\n period = normalizeTime(period);\n var s = state, id = root.setInterval(function () { s = action(s); }, period);\n return disposableCreate(function () { root.clearInterval(id); });\n };\n\n }(Scheduler.prototype));\n\n (function (schedulerProto) {\n /**\n * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.\n * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.\n * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.\n */\n schedulerProto.catchError = schedulerProto['catch'] = function (handler) {\n return new CatchScheduler(this, handler);\n };\n }(Scheduler.prototype));\n\n var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {\n function tick(command, recurse) {\n recurse(0, this._period);\n try {\n this._state = this._action(this._state);\n } catch (e) {\n this._cancel.dispose();\n throw e;\n }\n }\n\n function SchedulePeriodicRecursive(scheduler, state, period, action) {\n this._scheduler = scheduler;\n this._state = state;\n this._period = period;\n this._action = action;\n }\n\n SchedulePeriodicRecursive.prototype.start = function () {\n var d = new SingleAssignmentDisposable();\n this._cancel = d;\n d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this)));\n\n return d;\n };\n\n return SchedulePeriodicRecursive;\n }());\n\n /** Gets a scheduler that schedules work immediately on the current thread. */\n var ImmediateScheduler = (function (__super__) {\n inherits(ImmediateScheduler, __super__);\n function ImmediateScheduler() {\n __super__.call(this);\n }\n\n ImmediateScheduler.prototype.schedule = function (state, action) {\n return disposableFixup(action(this, state));\n };\n\n return ImmediateScheduler;\n }(Scheduler));\n\n var immediateScheduler = Scheduler.immediate = new ImmediateScheduler();\n\n /**\n * Gets a scheduler that schedules work as soon as possible on the current thread.\n */\n var CurrentThreadScheduler = (function (__super__) {\n var queue;\n\n function runTrampoline () {\n while (queue.length > 0) {\n var item = queue.dequeue();\n !item.isCancelled() && item.invoke();\n }\n }\n\n inherits(CurrentThreadScheduler, __super__);\n function CurrentThreadScheduler() {\n __super__.call(this);\n }\n\n CurrentThreadScheduler.prototype.schedule = function (state, action) {\n var si = new ScheduledItem(this, state, action, this.now());\n\n if (!queue) {\n queue = new PriorityQueue(4);\n queue.enqueue(si);\n\n var result = tryCatch(runTrampoline)();\n queue = null;\n if (result === errorObj) { thrower(result.e); }\n } else {\n queue.enqueue(si);\n }\n return si.disposable;\n };\n\n CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; };\n\n return CurrentThreadScheduler;\n }(Scheduler));\n\n var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler();\n\n var scheduleMethod, clearMethod;\n\n var localTimer = (function () {\n var localSetTimeout, localClearTimeout = noop;\n if (!!root.setTimeout) {\n localSetTimeout = root.setTimeout;\n localClearTimeout = root.clearTimeout;\n } else if (!!root.WScript) {\n localSetTimeout = function (fn, time) {\n root.WScript.Sleep(time);\n fn();\n };\n } else {\n throw new NotSupportedError();\n }\n\n return {\n setTimeout: localSetTimeout,\n clearTimeout: localClearTimeout\n };\n }());\n var localSetTimeout = localTimer.setTimeout,\n localClearTimeout = localTimer.clearTimeout;\n\n (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;\n\n clearMethod = function (handle) {\n delete tasksByHandle[handle];\n };\n\n function runTask(handle) {\n if (currentlyRunning) {\n localSetTimeout(function () { runTask(handle); }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n var result = tryCatch(task)();\n clearMethod(handle);\n currentlyRunning = false;\n if (result === errorObj) { thrower(result.e); }\n }\n }\n }\n\n var reNative = new RegExp('^' +\n String(toString)\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/toString| for [^\\]]+/g, '.*?') + '$'\n );\n\n var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&\n !reNative.test(setImmediate) && setImmediate;\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n if (isFunction(setImmediate)) {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n setImmediate(function () { runTask(id); });\n\n return id;\n };\n } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n process.nextTick(function () { runTask(id); });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent) {\n root.attachEvent('onmessage', onGlobalPostMessage);\n } else {\n root.onmessage = onGlobalPostMessage;\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (e) { runTask(e.data); };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n localSetTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n }());\n\n /**\n * Gets a scheduler that schedules work via a timed callback based upon platform.\n */\n var DefaultScheduler = (function (__super__) {\n inherits(DefaultScheduler, __super__);\n function DefaultScheduler() {\n __super__.call(this);\n }\n\n function DefaultSchedulerDisposable(id) {\n this._id = id;\n this.isDisposed = false;\n }\n\n DefaultSchedulerDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n localClearTimeout(this._id);\n }\n };\n\n DefaultScheduler.prototype.schedule = function (state, action) {\n var scheduler = this, disposable = new SingleAssignmentDisposable();\n var id = scheduleMethod(function () {\n !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state)));\n });\n return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id));\n };\n\n DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();\n if (dt === 0) { return scheduler.schedule(state, action); }\n var id = localSetTimeout(function () {\n !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state)));\n }, dt);\n return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id));\n };\n\n return DefaultScheduler;\n }(Scheduler));\n\n var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler();\n\n var CatchScheduler = (function (__super__) {\n inherits(CatchScheduler, __super__);\n\n function CatchScheduler(scheduler, handler) {\n this._scheduler = scheduler;\n this._handler = handler;\n this._recursiveOriginal = null;\n this._recursiveWrapper = null;\n __super__.call(this);\n }\n\n CatchScheduler.prototype.schedule = function (state, action) {\n return this._scheduler.schedule(state, this._wrap(action));\n };\n\n CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) {\n return this._scheduler.schedule(state, dueTime, this._wrap(action));\n };\n\n CatchScheduler.prototype.now = function () { return this._scheduler.now(); };\n\n CatchScheduler.prototype._clone = function (scheduler) {\n return new CatchScheduler(scheduler, this._handler);\n };\n\n CatchScheduler.prototype._wrap = function (action) {\n var parent = this;\n return function (self, state) {\n var res = tryCatch(action)(parent._getRecursiveWrapper(self), state);\n if (res === errorObj) {\n if (!parent._handler(res.e)) { thrower(res.e); }\n return disposableEmpty;\n }\n return disposableFixup(ret);\n };\n };\n\n CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {\n if (this._recursiveOriginal !== scheduler) {\n this._recursiveOriginal = scheduler;\n var wrapper = this._clone(scheduler);\n wrapper._recursiveOriginal = scheduler;\n wrapper._recursiveWrapper = wrapper;\n this._recursiveWrapper = wrapper;\n }\n return this._recursiveWrapper;\n };\n\n CatchScheduler.prototype.schedulePeriodic = function (state, period, action) {\n var self = this, failed = false, d = new SingleAssignmentDisposable();\n\n d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) {\n if (failed) { return null; }\n var res = tryCatch(action)(state1);\n if (res === errorObj) {\n failed = true;\n if (!self._handler(res.e)) { thrower(res.e); }\n d.dispose();\n return null;\n }\n return ret;\n }));\n\n return d;\n };\n\n return CatchScheduler;\n }(Scheduler));\n\n /**\n * Represents a notification to an observer.\n */\n var Notification = Rx.Notification = (function () {\n function Notification() {\n\n }\n\n Notification.prototype._accept = function (onNext, onError, onCompleted) {\n throw new NotImplementedError();\n };\n\n Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) {\n throw new NotImplementedError();\n };\n\n /**\n * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.\n *\n * @memberOf Notification\n * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..\n * @param {Function} onError Delegate to invoke for an OnError notification.\n * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.\n * @returns {Any} Result produced by the observation.\n */\n Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {\n return observerOrOnNext && typeof observerOrOnNext === 'object' ?\n this._acceptObservable(observerOrOnNext) :\n this._accept(observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Returns an observable sequence with a single notification.\n *\n * @memberOf Notifications\n * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.\n * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.\n */\n Notification.prototype.toObservable = function (scheduler) {\n var self = this;\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (o) {\n return scheduler.schedule(self, function (_, notification) {\n notification._acceptObservable(o);\n notification.kind === 'N' && o.onCompleted();\n });\n });\n };\n\n return Notification;\n })();\n\n var OnNextNotification = (function (__super__) {\n inherits(OnNextNotification, __super__);\n function OnNextNotification(value) {\n this.value = value;\n this.kind = 'N';\n }\n\n OnNextNotification.prototype._accept = function (onNext) {\n return onNext(this.value);\n };\n\n OnNextNotification.prototype._acceptObservable = function (o) {\n return o.onNext(this.value);\n };\n\n OnNextNotification.prototype.toString = function () {\n return 'OnNext(' + this.value + ')';\n };\n\n return OnNextNotification;\n }(Notification));\n\n var OnErrorNotification = (function (__super__) {\n inherits(OnErrorNotification, __super__);\n function OnErrorNotification(error) {\n this.error = error;\n this.kind = 'E';\n }\n\n OnErrorNotification.prototype._accept = function (onNext, onError) {\n return onError(this.error);\n };\n\n OnErrorNotification.prototype._acceptObservable = function (o) {\n return o.onError(this.error);\n };\n\n OnErrorNotification.prototype.toString = function () {\n return 'OnError(' + this.error + ')';\n };\n\n return OnErrorNotification;\n }(Notification));\n\n var OnCompletedNotification = (function (__super__) {\n inherits(OnCompletedNotification, __super__);\n function OnCompletedNotification() {\n this.kind = 'C';\n }\n\n OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) {\n return onCompleted();\n };\n\n OnCompletedNotification.prototype._acceptObservable = function (o) {\n return o.onCompleted();\n };\n\n OnCompletedNotification.prototype.toString = function () {\n return 'OnCompleted()';\n };\n\n return OnCompletedNotification;\n }(Notification));\n\n /**\n * Creates an object that represents an OnNext notification to an observer.\n * @param {Any} value The value contained in the notification.\n * @returns {Notification} The OnNext notification containing the value.\n */\n var notificationCreateOnNext = Notification.createOnNext = function (value) {\n return new OnNextNotification(value);\n };\n\n /**\n * Creates an object that represents an OnError notification to an observer.\n * @param {Any} error The exception contained in the notification.\n * @returns {Notification} The OnError notification containing the exception.\n */\n var notificationCreateOnError = Notification.createOnError = function (error) {\n return new OnErrorNotification(error);\n };\n\n /**\n * Creates an object that represents an OnCompleted notification to an observer.\n * @returns {Notification} The OnCompleted notification.\n */\n var notificationCreateOnCompleted = Notification.createOnCompleted = function () {\n return new OnCompletedNotification();\n };\n\n /**\n * Supports push-style iteration over an observable sequence.\n */\n var Observer = Rx.Observer = function () { };\n\n /**\n * Creates a notification callback from an observer.\n * @returns The action that forwards its input notification to the underlying observer.\n */\n Observer.prototype.toNotifier = function () {\n var observer = this;\n return function (n) { return n.accept(observer); };\n };\n\n /**\n * Hides the identity of an observer.\n * @returns An observer that hides the identity of the specified observer.\n */\n Observer.prototype.asObserver = function () {\n var self = this;\n return new AnonymousObserver(\n function (x) { self.onNext(x); },\n function (err) { self.onError(err); },\n function () { self.onCompleted(); });\n };\n\n /**\n * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.\n * If a violation is detected, an Error is thrown from the offending observer method call.\n * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.\n */\n Observer.prototype.checked = function () { return new CheckedObserver(this); };\n\n /**\n * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.\n * @param {Function} [onNext] Observer's OnNext action implementation.\n * @param {Function} [onError] Observer's OnError action implementation.\n * @param {Function} [onCompleted] Observer's OnCompleted action implementation.\n * @returns {Observer} The observer object implemented using the given actions.\n */\n var observerCreate = Observer.create = function (onNext, onError, onCompleted) {\n onNext || (onNext = noop);\n onError || (onError = defaultError);\n onCompleted || (onCompleted = noop);\n return new AnonymousObserver(onNext, onError, onCompleted);\n };\n\n /**\n * Creates an observer from a notification callback.\n * @param {Function} handler Action that handles a notification.\n * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.\n */\n Observer.fromNotifier = function (handler, thisArg) {\n var cb = bindCallback(handler, thisArg, 1);\n return new AnonymousObserver(function (x) {\n return cb(notificationCreateOnNext(x));\n }, function (e) {\n return cb(notificationCreateOnError(e));\n }, function () {\n return cb(notificationCreateOnCompleted());\n });\n };\n\n /**\n * Schedules the invocation of observer methods on the given scheduler.\n * @param {Scheduler} scheduler Scheduler to schedule observer messages on.\n * @returns {Observer} Observer whose messages are scheduled on the given scheduler.\n */\n Observer.prototype.notifyOn = function (scheduler) {\n return new ObserveOnObserver(scheduler, this);\n };\n\n Observer.prototype.makeSafe = function(disposable) {\n return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable);\n };\n\n /**\n * Abstract base class for implementations of the Observer class.\n * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.\n */\n var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {\n inherits(AbstractObserver, __super__);\n\n /**\n * Creates a new observer in a non-stopped state.\n */\n function AbstractObserver() {\n this.isStopped = false;\n }\n\n // Must be implemented by other observers\n AbstractObserver.prototype.next = notImplemented;\n AbstractObserver.prototype.error = notImplemented;\n AbstractObserver.prototype.completed = notImplemented;\n\n /**\n * Notifies the observer of a new element in the sequence.\n * @param {Any} value Next element in the sequence.\n */\n AbstractObserver.prototype.onNext = function (value) {\n !this.isStopped && this.next(value);\n };\n\n /**\n * Notifies the observer that an exception has occurred.\n * @param {Any} error The error that has occurred.\n */\n AbstractObserver.prototype.onError = function (error) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(error);\n }\n };\n\n /**\n * Notifies the observer of the end of the sequence.\n */\n AbstractObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.completed();\n }\n };\n\n /**\n * Disposes the observer, causing it to transition to the stopped state.\n */\n AbstractObserver.prototype.dispose = function () { this.isStopped = true; };\n\n AbstractObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(e);\n return true;\n }\n\n return false;\n };\n\n return AbstractObserver;\n }(Observer));\n\n /**\n * Class to create an Observer instance from delegate-based implementations of the on* methods.\n */\n var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {\n inherits(AnonymousObserver, __super__);\n\n /**\n * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.\n * @param {Any} onNext Observer's OnNext action implementation.\n * @param {Any} onError Observer's OnError action implementation.\n * @param {Any} onCompleted Observer's OnCompleted action implementation.\n */\n function AnonymousObserver(onNext, onError, onCompleted) {\n __super__.call(this);\n this._onNext = onNext;\n this._onError = onError;\n this._onCompleted = onCompleted;\n }\n\n /**\n * Calls the onNext action.\n * @param {Any} value Next element in the sequence.\n */\n AnonymousObserver.prototype.next = function (value) {\n this._onNext(value);\n };\n\n /**\n * Calls the onError action.\n * @param {Any} error The error that has occurred.\n */\n AnonymousObserver.prototype.error = function (error) {\n this._onError(error);\n };\n\n /**\n * Calls the onCompleted action.\n */\n AnonymousObserver.prototype.completed = function () {\n this._onCompleted();\n };\n\n return AnonymousObserver;\n }(AbstractObserver));\n\n var CheckedObserver = (function (__super__) {\n inherits(CheckedObserver, __super__);\n\n function CheckedObserver(observer) {\n __super__.call(this);\n this._observer = observer;\n this._state = 0; // 0 - idle, 1 - busy, 2 - done\n }\n\n var CheckedObserverPrototype = CheckedObserver.prototype;\n\n CheckedObserverPrototype.onNext = function (value) {\n this.checkAccess();\n var res = tryCatch(this._observer.onNext).call(this._observer, value);\n this._state = 0;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onError = function (err) {\n this.checkAccess();\n var res = tryCatch(this._observer.onError).call(this._observer, err);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onCompleted = function () {\n this.checkAccess();\n var res = tryCatch(this._observer.onCompleted).call(this._observer);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.checkAccess = function () {\n if (this._state === 1) { throw new Error('Re-entrancy detected'); }\n if (this._state === 2) { throw new Error('Observer completed'); }\n if (this._state === 0) { this._state = 1; }\n };\n\n return CheckedObserver;\n }(Observer));\n\n var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {\n inherits(ScheduledObserver, __super__);\n\n function ScheduledObserver(scheduler, observer) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.observer = observer;\n this.isAcquired = false;\n this.hasFaulted = false;\n this.queue = [];\n this.disposable = new SerialDisposable();\n }\n\n ScheduledObserver.prototype.next = function (value) {\n var self = this;\n this.queue.push(function () { self.observer.onNext(value); });\n };\n\n ScheduledObserver.prototype.error = function (e) {\n var self = this;\n this.queue.push(function () { self.observer.onError(e); });\n };\n\n ScheduledObserver.prototype.completed = function () {\n var self = this;\n this.queue.push(function () { self.observer.onCompleted(); });\n };\n\n ScheduledObserver.prototype.ensureActive = function () {\n var isOwner = false;\n if (!this.hasFaulted && this.queue.length > 0) {\n isOwner = !this.isAcquired;\n this.isAcquired = true;\n }\n if (isOwner) {\n this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) {\n var work;\n if (parent.queue.length > 0) {\n work = parent.queue.shift();\n } else {\n parent.isAcquired = false;\n return;\n }\n var res = tryCatch(work)();\n if (res === errorObj) {\n parent.queue = [];\n parent.hasFaulted = true;\n return thrower(res.e);\n }\n self(parent);\n }));\n }\n };\n\n ScheduledObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.disposable.dispose();\n };\n\n return ScheduledObserver;\n }(AbstractObserver));\n\n var ObserveOnObserver = (function (__super__) {\n inherits(ObserveOnObserver, __super__);\n\n function ObserveOnObserver(scheduler, observer, cancel) {\n __super__.call(this, scheduler, observer);\n this._cancel = cancel;\n }\n\n ObserveOnObserver.prototype.next = function (value) {\n __super__.prototype.next.call(this, value);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.error = function (e) {\n __super__.prototype.error.call(this, e);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.completed = function () {\n __super__.prototype.completed.call(this);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this._cancel && this._cancel.dispose();\n this._cancel = null;\n };\n\n return ObserveOnObserver;\n })(ScheduledObserver);\n\n var observableProto;\n\n /**\n * Represents a push-style collection.\n */\n var Observable = Rx.Observable = (function () {\n\n function makeSubscribe(self, subscribe) {\n return function (o) {\n var oldOnError = o.onError;\n o.onError = function (e) {\n makeStackTraceLong(e, self);\n oldOnError.call(o, e);\n };\n\n return subscribe.call(self, o);\n };\n }\n\n function Observable() {\n if (Rx.config.longStackSupport && hasStacks) {\n var oldSubscribe = this._subscribe;\n var e = tryCatch(thrower)(new Error()).e;\n this.stack = e.stack.substring(e.stack.indexOf('\\n') + 1);\n this._subscribe = makeSubscribe(this, oldSubscribe);\n }\n }\n\n observableProto = Observable.prototype;\n\n /**\n * Determines whether the given object is an Observable\n * @param {Any} An object to determine whether it is an Observable\n * @returns {Boolean} true if an Observable, else false.\n */\n Observable.isObservable = function (o) {\n return o && isFunction(o.subscribe);\n };\n\n /**\n * Subscribes an o to the observable sequence.\n * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.\n * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) {\n return this._subscribe(typeof oOrOnNext === 'object' ?\n oOrOnNext :\n observerCreate(oOrOnNext, onError, onCompleted));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onNext The function to invoke on each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnNext = function (onNext, thisArg) {\n return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));\n };\n\n /**\n * Subscribes to an exceptional condition in the sequence with an optional \"this\" argument.\n * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnError = function (onError, thisArg) {\n return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {\n return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));\n };\n\n return Observable;\n })();\n\n var ObservableBase = Rx.ObservableBase = (function (__super__) {\n inherits(ObservableBase, __super__);\n\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.subscribeCore).call(self, ado);\n if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function ObservableBase() {\n __super__.call(this);\n }\n\n ObservableBase.prototype._subscribe = function (o) {\n var ado = new AutoDetachObserver(o), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.schedule(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n };\n\n ObservableBase.prototype.subscribeCore = notImplemented;\n\n return ObservableBase;\n }(Observable));\n\nvar FlatMapObservable = Rx.FlatMapObservable = (function(__super__) {\n\n inherits(FlatMapObservable, __super__);\n\n function FlatMapObservable(source, selector, resultSelector, thisArg) {\n this.resultSelector = isFunction(resultSelector) ? resultSelector : null;\n this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3);\n this.source = source;\n __super__.call(this);\n }\n\n FlatMapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(observer, selector, resultSelector, source) {\n this.i = 0;\n this.selector = selector;\n this.resultSelector = resultSelector;\n this.source = source;\n this.o = observer;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype._wrapResult = function(result, x, i) {\n return this.resultSelector ?\n result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) :\n result;\n };\n\n InnerObserver.prototype.next = function(x) {\n var i = this.i++;\n var result = tryCatch(this.selector)(x, i, this.source);\n if (result === errorObj) { return this.o.onError(result.e); }\n\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result));\n this.o.onNext(this._wrapResult(result, x, i));\n };\n\n InnerObserver.prototype.error = function(e) { this.o.onError(e); };\n\n InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); };\n\n return FlatMapObservable;\n\n}(ObservableBase));\n\n var Enumerable = Rx.internals.Enumerable = function () { };\n\n function IsDisposedDisposable(state) {\n this._s = state;\n this.isDisposed = false;\n }\n\n IsDisposedDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._s.isDisposed = true;\n }\n };\n\n var ConcatEnumerableObservable = (function(__super__) {\n inherits(ConcatEnumerableObservable, __super__);\n function ConcatEnumerableObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n\n ConcatEnumerableObservable.prototype.subscribeCore = function (o) {\n var state = { isDisposed: false }, subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e)));\n });\n\n return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, s, e) {\n this._o = o;\n this._s = s;\n this._e = e;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); };\n InnerObserver.prototype.onError = function (e) { this._o.onError(e); };\n InnerObserver.prototype.onCompleted = function () { this._s(this._e); };\n\n return ConcatEnumerableObservable;\n }(ObservableBase));\n\n Enumerable.prototype.concat = function () {\n return new ConcatEnumerableObservable(this);\n };\n\n var CatchErrorObservable = (function(__super__) {\n inherits(CatchErrorObservable, __super__);\n function CatchErrorObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n\n CatchErrorObservable.prototype.subscribeCore = function (o) {\n var e = this.sources[$iterator$]();\n\n var state = { isDisposed: false }, subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return lastException !== null ? o.onError(lastException) : o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self)));\n });\n return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, recurse) {\n this._o = o;\n this._recurse = recurse;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function (x) { this._o.onNext(x); };\n InnerObserver.prototype.error = function (e) { this._recurse(e); };\n InnerObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return CatchErrorObservable;\n }(ObservableBase));\n\n Enumerable.prototype.catchError = function () {\n return new CatchErrorObservable(this);\n };\n\n Enumerable.prototype.catchErrorWhen = function (notificationHandler) {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var exceptions = new Subject(),\n notifier = new Subject(),\n handled = notificationHandler(exceptions),\n notificationDisposable = handled.subscribe(notifier);\n\n var e = sources[$iterator$]();\n\n var state = { isDisposed: false },\n lastException,\n subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n if (lastException) {\n o.onError(lastException);\n } else {\n o.onCompleted();\n }\n return;\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var outer = new SingleAssignmentDisposable();\n var inner = new SingleAssignmentDisposable();\n subscription.setDisposable(new BinaryDisposable(inner, outer));\n outer.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n function (exn) {\n inner.setDisposable(notifier.subscribe(self, function(ex) {\n o.onError(ex);\n }, function() {\n o.onCompleted();\n }));\n\n exceptions.onNext(exn);\n },\n function() { o.onCompleted(); }));\n });\n\n return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]);\n });\n };\n\n var RepeatEnumerable = (function (__super__) {\n inherits(RepeatEnumerable, __super__);\n\n function RepeatEnumerable(v, c) {\n this.v = v;\n this.c = c == null ? -1 : c;\n }\n RepeatEnumerable.prototype[$iterator$] = function () {\n return new RepeatEnumerator(this);\n };\n\n function RepeatEnumerator(p) {\n this.v = p.v;\n this.l = p.c;\n }\n RepeatEnumerator.prototype.next = function () {\n if (this.l === 0) { return doneEnumerator; }\n if (this.l > 0) { this.l--; }\n return { done: false, value: this.v };\n };\n\n return RepeatEnumerable;\n }(Enumerable));\n\n var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {\n return new RepeatEnumerable(value, repeatCount);\n };\n\n var OfEnumerable = (function(__super__) {\n inherits(OfEnumerable, __super__);\n function OfEnumerable(s, fn, thisArg) {\n this.s = s;\n this.fn = fn ? bindCallback(fn, thisArg, 3) : null;\n }\n OfEnumerable.prototype[$iterator$] = function () {\n return new OfEnumerator(this);\n };\n\n function OfEnumerator(p) {\n this.i = -1;\n this.s = p.s;\n this.l = this.s.length;\n this.fn = p.fn;\n }\n OfEnumerator.prototype.next = function () {\n return ++this.i < this.l ?\n { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } :\n doneEnumerator;\n };\n\n return OfEnumerable;\n }(Enumerable));\n\n var enumerableOf = Enumerable.of = function (source, selector, thisArg) {\n return new OfEnumerable(source, selector, thisArg);\n };\n\nvar ObserveOnObservable = (function (__super__) {\n inherits(ObserveOnObservable, __super__);\n function ObserveOnObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n ObserveOnObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ObserveOnObserver(this._s, o));\n };\n\n return ObserveOnObservable;\n}(ObservableBase));\n\n /**\n * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.\n *\n * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects\n * that require to be run on a scheduler, use subscribeOn.\n *\n * @param {Scheduler} scheduler Scheduler to notify observers on.\n * @returns {Observable} The source sequence whose observations happen on the specified scheduler.\n */\n observableProto.observeOn = function (scheduler) {\n return new ObserveOnObservable(this, scheduler);\n };\n\n var SubscribeOnObservable = (function (__super__) {\n inherits(SubscribeOnObservable, __super__);\n function SubscribeOnObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n function scheduleMethod(scheduler, state) {\n var source = state[0], d = state[1], o = state[2];\n d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o)));\n }\n\n SubscribeOnObservable.prototype.subscribeCore = function (o) {\n var m = new SingleAssignmentDisposable(), d = new SerialDisposable();\n d.setDisposable(m);\n m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod));\n return d;\n };\n\n return SubscribeOnObservable;\n }(ObservableBase));\n\n /**\n * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;\n * see the remarks section for more information on the distinction between subscribeOn and observeOn.\n\n * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer\n * callbacks on a scheduler, use observeOn.\n\n * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.\n * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.\n */\n observableProto.subscribeOn = function (scheduler) {\n return new SubscribeOnObservable(this, scheduler);\n };\n\n var FromPromiseObservable = (function(__super__) {\n inherits(FromPromiseObservable, __super__);\n function FromPromiseObservable(p) {\n this.p = p;\n __super__.call(this);\n }\n\n FromPromiseObservable.prototype.subscribeCore = function(o) {\n this.p\n .then(function (data) {\n o.onNext(data);\n o.onCompleted();\n }, function (err) {\n o.onError(err);\n });\n return disposableEmpty;\n };\n\n return FromPromiseObservable;\n }(ObservableBase));\n\n /**\n * Converts a Promise to an Observable sequence\n * @param {Promise} An ES6 Compliant promise.\n * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.\n */\n var observableFromPromise = Observable.fromPromise = function (promise) {\n return new FromPromiseObservable(promise);\n };\n\n /*\n * Converts an existing observable sequence to an ES6 Compatible Promise\n * @example\n * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);\n *\n * // With config\n * Rx.config.Promise = RSVP.Promise;\n * var promise = Rx.Observable.return(42).toPromise();\n * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.\n * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.\n */\n observableProto.toPromise = function (promiseCtor) {\n promiseCtor || (promiseCtor = Rx.config.Promise);\n if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }\n var source = this;\n return new promiseCtor(function (resolve, reject) {\n // No cancellation can be done\n var value;\n source.subscribe(function (v) {\n value = v;\n }, reject, function () {\n resolve(value);\n });\n });\n };\n\n var ToArrayObservable = (function(__super__) {\n inherits(ToArrayObservable, __super__);\n function ToArrayObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToArrayObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o) {\n this.o = o;\n this.a = [];\n AbstractObserver.call(this);\n }\n \n InnerObserver.prototype.next = function (x) { this.a.push(x); };\n InnerObserver.prototype.error = function (e) { this.o.onError(e); };\n InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); };\n\n return ToArrayObservable;\n }(ObservableBase));\n\n /**\n * Creates an array from an observable sequence.\n * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.\n */\n observableProto.toArray = function () {\n return new ToArrayObservable(this);\n };\n\n /**\n * Creates an observable sequence from a specified subscribe method implementation.\n * @example\n * var res = Rx.Observable.create(function (observer) { return function () { } );\n * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );\n * var res = Rx.Observable.create(function (observer) { } );\n * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.\n * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.\n */\n Observable.create = function (subscribe, parent) {\n return new AnonymousObservable(subscribe, parent);\n };\n\n var Defer = (function(__super__) {\n inherits(Defer, __super__);\n function Defer(factory) {\n this._f = factory;\n __super__.call(this);\n }\n\n Defer.prototype.subscribeCore = function (o) {\n var result = tryCatch(this._f)();\n if (result === errorObj) { return observableThrow(result.e).subscribe(o);}\n isPromise(result) && (result = observableFromPromise(result));\n return result.subscribe(o);\n };\n\n return Defer;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.\n *\n * @example\n * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });\n * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.\n * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.\n */\n var observableDefer = Observable.defer = function (observableFactory) {\n return new Defer(observableFactory);\n };\n\n var EmptyObservable = (function(__super__) {\n inherits(EmptyObservable, __super__);\n function EmptyObservable(scheduler) {\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n EmptyObservable.prototype.subscribeCore = function (observer) {\n var sink = new EmptySink(observer, this.scheduler);\n return sink.run();\n };\n\n function EmptySink(observer, scheduler) {\n this.observer = observer;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n state.onCompleted();\n return disposableEmpty;\n }\n\n EmptySink.prototype.run = function () {\n var state = this.observer;\n return this.scheduler === immediateScheduler ?\n scheduleItem(null, state) :\n this.scheduler.schedule(state, scheduleItem);\n };\n\n return EmptyObservable;\n }(ObservableBase));\n\n var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler);\n\n /**\n * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.\n *\n * @example\n * var res = Rx.Observable.empty();\n * var res = Rx.Observable.empty(Rx.Scheduler.timeout);\n * @param {Scheduler} [scheduler] Scheduler to send the termination call on.\n * @returns {Observable} An observable sequence with no elements.\n */\n var observableEmpty = Observable.empty = function (scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler);\n };\n\n var FromObservable = (function(__super__) {\n inherits(FromObservable, __super__);\n function FromObservable(iterable, mapper, scheduler) {\n this.iterable = iterable;\n this.mapper = mapper;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromObservable.prototype.subscribeCore = function (o) {\n var sink = new FromSink(o, this);\n return sink.run();\n };\n\n return FromObservable;\n }(ObservableBase));\n\n var FromSink = (function () {\n function FromSink(o, parent) {\n this.o = o;\n this.parent = parent;\n }\n\n FromSink.prototype.run = function () {\n var list = Object(this.parent.iterable),\n it = getIterable(list),\n o = this.o,\n mapper = this.parent.mapper;\n\n function loopRecursive(i, recurse) {\n var next = tryCatch(it.next).call(it);\n if (next === errorObj) { return o.onError(next.e); }\n if (next.done) { return o.onCompleted(); }\n\n var result = next.value;\n\n if (isFunction(mapper)) {\n result = tryCatch(mapper)(result, i);\n if (result === errorObj) { return o.onError(result.e); }\n }\n\n o.onNext(result);\n recurse(i + 1);\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n return FromSink;\n }());\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function StringIterable(s) {\n this._s = s;\n }\n\n StringIterable.prototype[$iterator$] = function () {\n return new StringIterator(this._s);\n };\n\n function StringIterator(s) {\n this._s = s;\n this._l = s.length;\n this._i = 0;\n }\n\n StringIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n StringIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;\n };\n\n function ArrayIterable(a) {\n this._a = a;\n }\n\n ArrayIterable.prototype[$iterator$] = function () {\n return new ArrayIterator(this._a);\n };\n\n function ArrayIterator(a) {\n this._a = a;\n this._l = toLength(a);\n this._i = 0;\n }\n\n ArrayIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n ArrayIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;\n };\n\n function numberIsFinite(value) {\n return typeof value === 'number' && root.isFinite(value);\n }\n\n function isNan(n) {\n return n !== n;\n }\n\n function getIterable(o) {\n var i = o[$iterator$], it;\n if (!i && typeof o === 'string') {\n it = new StringIterable(o);\n return it[$iterator$]();\n }\n if (!i && o.length !== undefined) {\n it = new ArrayIterable(o);\n return it[$iterator$]();\n }\n if (!i) { throw new TypeError('Object is not iterable'); }\n return o[$iterator$]();\n }\n\n function sign(value) {\n var number = +value;\n if (number === 0) { return number; }\n if (isNaN(number)) { return number; }\n return number < 0 ? -1 : 1;\n }\n\n function toLength(o) {\n var len = +o.length;\n if (isNaN(len)) { return 0; }\n if (len === 0 || !numberIsFinite(len)) { return len; }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) { return 0; }\n if (len > maxSafeInteger) { return maxSafeInteger; }\n return len;\n }\n\n /**\n * This method creates a new Observable sequence from an array-like or iterable object.\n * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.\n * @param {Function} [mapFn] Map function to call on every element of the array.\n * @param {Any} [thisArg] The context to use calling the mapFn if provided.\n * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.\n */\n var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {\n if (iterable == null) {\n throw new Error('iterable cannot be null.')\n }\n if (mapFn && !isFunction(mapFn)) {\n throw new Error('mapFn when provided must be a function');\n }\n if (mapFn) {\n var mapper = bindCallback(mapFn, thisArg, 2);\n }\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromObservable(iterable, mapper, scheduler);\n }\n\n var FromArrayObservable = (function(__super__) {\n inherits(FromArrayObservable, __super__);\n function FromArrayObservable(args, scheduler) {\n this.args = args;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromArrayObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromArraySink(observer, this);\n return sink.run();\n };\n\n return FromArrayObservable;\n }(ObservableBase));\n\n function FromArraySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromArraySink.prototype.run = function () {\n var observer = this.observer, args = this.parent.args, len = args.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n observer.onNext(args[i]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n /**\n * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.\n * @deprecated use Observable.from or Observable.of\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.\n */\n var observableFromArray = Observable.fromArray = function (array, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler)\n };\n\n var GenerateObservable = (function (__super__) {\n inherits(GenerateObservable, __super__);\n function GenerateObservable(state, cndFn, itrFn, resFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._s = s;\n this._first = true;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n var hasResult = tryCatch(self._cndFn)(self._state);\n if (hasResult === errorObj) { return self._o.onError(hasResult.e); }\n if (hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n self._o.onNext(result);\n recurse(self);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursive(this, scheduleRecursive);\n };\n\n return GenerateObservable;\n }(ObservableBase));\n\n /**\n * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.\n *\n * @example\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.\n * @returns {Observable} The generated sequence.\n */\n Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler);\n };\n\n function observableOf (scheduler, array) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler);\n }\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.of = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return new FromArrayObservable(args, currentThreadScheduler);\n };\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.ofWithScheduler = function (scheduler) {\n var len = arguments.length, args = new Array(len - 1);\n for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }\n return new FromArrayObservable(args, scheduler);\n };\n\n /**\n * Creates an Observable sequence from changes to an array using Array.observe.\n * @param {Array} array An array to observe changes.\n * @returns {Observable} An observable sequence containing changes to an array from Array.observe.\n */\n Observable.ofArrayChanges = function(array) {\n if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); }\n if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n \n Array.observe(array, observerFn);\n\n return function () {\n Array.unobserve(array, observerFn);\n };\n });\n };\n\n /**\n * Creates an Observable sequence from changes to an object using Object.observe.\n * @param {Object} obj An object to observe changes.\n * @returns {Observable} An observable sequence containing changes to an object from Object.observe.\n */\n Observable.ofObjectChanges = function(obj) {\n if (obj == null) { throw new TypeError('object must not be null or undefined.'); }\n if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n\n Object.observe(obj, observerFn);\n\n return function () {\n Object.unobserve(obj, observerFn);\n };\n });\n };\n\n var NeverObservable = (function(__super__) {\n inherits(NeverObservable, __super__);\n function NeverObservable() {\n __super__.call(this);\n }\n\n NeverObservable.prototype.subscribeCore = function (observer) {\n return disposableEmpty;\n };\n\n return NeverObservable;\n }(ObservableBase));\n\n var NEVER_OBSERVABLE = new NeverObservable();\n\n /**\n * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).\n * @returns {Observable} An observable sequence whose observers will never get called.\n */\n var observableNever = Observable.never = function () {\n return NEVER_OBSERVABLE;\n };\n\n var PairsObservable = (function(__super__) {\n inherits(PairsObservable, __super__);\n function PairsObservable(obj, scheduler) {\n this.obj = obj;\n this.keys = Object.keys(obj);\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n PairsObservable.prototype.subscribeCore = function (observer) {\n var sink = new PairsSink(observer, this);\n return sink.run();\n };\n\n return PairsObservable;\n }(ObservableBase));\n\n function PairsSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n PairsSink.prototype.run = function () {\n var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n var key = keys[i];\n observer.onNext([key, obj[key]]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n /**\n * Convert an object into an observable sequence of [key, value] pairs.\n * @param {Object} obj The object to inspect.\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} An observable sequence of [key, value] pairs from the object.\n */\n Observable.pairs = function (obj, scheduler) {\n scheduler || (scheduler = currentThreadScheduler);\n return new PairsObservable(obj, scheduler);\n };\n\n var RangeObservable = (function(__super__) {\n inherits(RangeObservable, __super__);\n function RangeObservable(start, count, scheduler) {\n this.start = start;\n this.rangeCount = count;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RangeObservable.prototype.subscribeCore = function (observer) {\n var sink = new RangeSink(observer, this);\n return sink.run();\n };\n\n return RangeObservable;\n }(ObservableBase));\n\n var RangeSink = (function () {\n function RangeSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RangeSink.prototype.run = function () {\n var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;\n function loopRecursive(i, recurse) {\n if (i < count) {\n observer.onNext(start + i);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n return RangeSink;\n }());\n\n /**\n * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.\n * @param {Number} start The value of the first integer in the sequence.\n * @param {Number} count The number of sequential integers to generate.\n * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.\n * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.\n */\n Observable.range = function (start, count, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RangeObservable(start, count, scheduler);\n };\n\n var RepeatObservable = (function(__super__) {\n inherits(RepeatObservable, __super__);\n function RepeatObservable(value, repeatCount, scheduler) {\n this.value = value;\n this.repeatCount = repeatCount == null ? -1 : repeatCount;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RepeatObservable.prototype.subscribeCore = function (observer) {\n var sink = new RepeatSink(observer, this);\n return sink.run();\n };\n\n return RepeatObservable;\n }(ObservableBase));\n\n function RepeatSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RepeatSink.prototype.run = function () {\n var observer = this.observer, value = this.parent.value;\n function loopRecursive(i, recurse) {\n if (i === -1 || i > 0) {\n observer.onNext(value);\n i > 0 && i--;\n }\n if (i === 0) { return observer.onCompleted(); }\n recurse(i);\n }\n\n return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive);\n };\n\n /**\n * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.\n * @param {Mixed} value Element to repeat.\n * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.\n * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence that repeats the given element the specified number of times.\n */\n Observable.repeat = function (value, repeatCount, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RepeatObservable(value, repeatCount, scheduler);\n };\n\n var JustObservable = (function(__super__) {\n inherits(JustObservable, __super__);\n function JustObservable(value, scheduler) {\n this.value = value;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n JustObservable.prototype.subscribeCore = function (observer) {\n var sink = new JustSink(observer, this.value, this.scheduler);\n return sink.run();\n };\n\n function JustSink(observer, value, scheduler) {\n this.observer = observer;\n this.value = value;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n var value = state[0], observer = state[1];\n observer.onNext(value);\n observer.onCompleted();\n return disposableEmpty;\n }\n\n JustSink.prototype.run = function () {\n var state = [this.value, this.observer];\n return this.scheduler === immediateScheduler ?\n scheduleItem(null, state) :\n this.scheduler.schedule(state, scheduleItem);\n };\n\n return JustObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.\n * There is an alias called 'just' or browsers 0) {\n parent.handleSubscribe(parent.q.shift());\n } else {\n parent.activeCount--;\n parent.done && parent.activeCount === 0 && parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeObserver;\n }());\n\n\n\n\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.\n * Or merges two observable sequences into a single observable sequence.\n *\n * @example\n * 1 - merged = sources.merge(1);\n * 2 - merged = source.merge(otherSource);\n * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.merge = function (maxConcurrentOrOther) {\n return typeof maxConcurrentOrOther !== 'number' ?\n observableMerge(this, maxConcurrentOrOther) :\n new MergeObservable(this, maxConcurrentOrOther);\n };\n\n /**\n * Merges all the observable sequences into a single observable sequence.\n * The scheduler is optional and if not specified, the immediate scheduler is used.\n * @returns {Observable} The observable sequence that merges the elements of the observable sequences.\n */\n var observableMerge = Observable.merge = function () {\n var scheduler, sources = [], i, len = arguments.length;\n if (!arguments[0]) {\n scheduler = immediateScheduler;\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else if (isScheduler(arguments[0])) {\n scheduler = arguments[0];\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else {\n scheduler = immediateScheduler;\n for(i = 0; i < len; i++) { sources.push(arguments[i]); }\n }\n if (Array.isArray(sources[0])) {\n sources = sources[0];\n }\n return observableOf(scheduler, sources).mergeAll();\n };\n\n var MergeAllObservable = (function (__super__) {\n inherits(MergeAllObservable, __super__);\n\n function MergeAllObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n MergeAllObservable.prototype.subscribeCore = function (observer) {\n var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();\n g.add(m);\n m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));\n return g;\n };\n\n function MergeAllObserver(o, g) {\n this.o = o;\n this.g = g;\n this.isStopped = false;\n this.done = false;\n }\n MergeAllObserver.prototype.onNext = function(innerSource) {\n if(this.isStopped) { return; }\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad)));\n };\n MergeAllObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeAllObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.g.length === 1 && this.o.onCompleted();\n }\n };\n MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeAllObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, sad) {\n this.parent = parent;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n var parent = this.parent;\n this.isStopped = true;\n parent.g.remove(this.sad);\n parent.done && parent.g.length === 1 && parent.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeAllObservable;\n }(ObservableBase));\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.mergeAll = function () {\n return new MergeAllObservable(this);\n };\n\n var CompositeError = Rx.CompositeError = function(errors) {\n this.name = \"NotImplementedError\";\n this.innerErrors = errors;\n this.message = 'This contains multiple errors. Check the innerErrors';\n Error.call(this);\n }\n CompositeError.prototype = Error.prototype;\n\n /**\n * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to\n * receive all successfully emitted items from all of the source Observables without being interrupted by\n * an error notification from one of them.\n *\n * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an\n * error via the Observer's onError, mergeDelayError will refrain from propagating that\n * error notification until all of the merged Observables have finished emitting items.\n * @param {Array | Arguments} args Arguments or an array to merge.\n * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable\n */\n Observable.mergeDelayError = function() {\n var args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n var len = arguments.length;\n args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n var source = observableOf(null, args);\n\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable(),\n m = new SingleAssignmentDisposable(),\n isStopped = false,\n errors = [];\n\n function setCompletion() {\n if (errors.length === 0) {\n o.onCompleted();\n } else if (errors.length === 1) {\n o.onError(errors[0]);\n } else {\n o.onError(new CompositeError(errors));\n }\n }\n\n group.add(m);\n\n m.setDisposable(source.subscribe(\n function (innerSource) {\n var innerSubscription = new SingleAssignmentDisposable();\n group.add(innerSubscription);\n\n // Check for promises support\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) {\n errors.push(e);\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n },\n function () {\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n }));\n },\n function (e) {\n errors.push(e);\n isStopped = true;\n group.length === 1 && setCompletion();\n },\n function () {\n isStopped = true;\n group.length === 1 && setCompletion();\n }));\n return group;\n });\n };\n\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.\n * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.\n */\n observableProto.onErrorResumeNext = function (second) {\n if (!second) { throw new Error('Second observable is required'); }\n return onErrorResumeNext([this, second]);\n };\n\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n *\n * @example\n * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);\n * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);\n * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.\n */\n var onErrorResumeNext = Observable.onErrorResumeNext = function () {\n var sources = [];\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (observer) {\n var pos = 0, subscription = new SerialDisposable(),\n cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) {\n var current, d;\n if (pos < sources.length) {\n current = sources[pos++];\n isPromise(current) && (current = observableFromPromise(current));\n d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));\n } else {\n observer.onCompleted();\n }\n });\n return new BinaryDisposable(subscription, cancelable);\n });\n };\n\n var SkipUntilObservable = (function(__super__) {\n inherits(SkipUntilObservable, __super__);\n\n function SkipUntilObservable(source, other) {\n this._s = source;\n this._o = isPromise(other) ? observableFromPromise(other) : other;\n this._open = false;\n __super__.call(this);\n }\n\n SkipUntilObservable.prototype.subscribeCore = function(o) {\n var leftSubscription = new SingleAssignmentDisposable();\n leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this)));\n\n isPromise(this._o) && (this._o = observableFromPromise(this._o));\n\n var rightSubscription = new SingleAssignmentDisposable();\n rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription)));\n\n return new BinaryDisposable(leftSubscription, rightSubscription);\n };\n\n return SkipUntilObservable;\n }(ObservableBase));\n\n var SkipUntilSourceObserver = (function(__super__) {\n inherits(SkipUntilSourceObserver, __super__);\n function SkipUntilSourceObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipUntilSourceObserver.prototype.next = function (x) {\n this._p._open && this._o.onNext(x);\n };\n\n SkipUntilSourceObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n SkipUntilSourceObserver.prototype.onCompleted = function () {\n this._p._open && this._o.onCompleted();\n };\n\n return SkipUntilSourceObserver;\n }(AbstractObserver));\n\n var SkipUntilOtherObserver = (function(__super__) {\n inherits(SkipUntilOtherObserver, __super__);\n function SkipUntilOtherObserver(o, p, r) {\n this._o = o;\n this._p = p;\n this._r = r;\n __super__.call(this);\n }\n\n SkipUntilOtherObserver.prototype.next = function () {\n this._p._open = true;\n this._r.dispose();\n };\n\n SkipUntilOtherObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n SkipUntilOtherObserver.prototype.onCompleted = function () {\n this._r.dispose();\n };\n\n return SkipUntilOtherObserver;\n }(AbstractObserver));\n\n /**\n * Returns the values from the source observable sequence only after the other observable sequence produces a value.\n * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.\n */\n observableProto.skipUntil = function (other) {\n return new SkipUntilObservable(this, other);\n };\n\n var SwitchObservable = (function(__super__) {\n inherits(SwitchObservable, __super__);\n function SwitchObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n SwitchObservable.prototype.subscribeCore = function (o) {\n var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner));\n return new BinaryDisposable(s, inner);\n };\n\n inherits(SwitchObserver, AbstractObserver);\n function SwitchObserver(o, inner) {\n this.o = o;\n this.inner = inner;\n this.stopped = false;\n this.latest = 0;\n this.hasLatest = false;\n AbstractObserver.call(this);\n }\n\n SwitchObserver.prototype.next = function (innerSource) {\n var d = new SingleAssignmentDisposable(), id = ++this.latest;\n this.hasLatest = true;\n this.inner.setDisposable(d);\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n d.setDisposable(innerSource.subscribe(new InnerObserver(this, id)));\n };\n\n SwitchObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n SwitchObserver.prototype.completed = function () {\n this.stopped = true;\n !this.hasLatest && this.o.onCompleted();\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(parent, id) {\n this.parent = parent;\n this.id = id;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.next = function (x) {\n this.parent.latest === this.id && this.parent.o.onNext(x);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.parent.latest === this.id && this.parent.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n if (this.parent.latest === this.id) {\n this.parent.hasLatest = false;\n this.parent.isStopped && this.parent.o.onCompleted();\n }\n };\n\n return SwitchObservable;\n }(ObservableBase));\n\n /**\n * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto['switch'] = observableProto.switchLatest = function () {\n return new SwitchObservable(this);\n };\n\n var TakeUntilObservable = (function(__super__) {\n inherits(TakeUntilObservable, __super__);\n\n function TakeUntilObservable(source, other) {\n this.source = source;\n this.other = isPromise(other) ? observableFromPromise(other) : other;\n __super__.call(this);\n }\n\n TakeUntilObservable.prototype.subscribeCore = function(o) {\n return new BinaryDisposable(\n this.source.subscribe(o),\n this.other.subscribe(new TakeUntilObserver(o))\n );\n };\n\n return TakeUntilObservable;\n }(ObservableBase));\n\n var TakeUntilObserver = (function(__super__) {\n inherits(TakeUntilObserver, __super__);\n function TakeUntilObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n TakeUntilObserver.prototype.next = function () {\n this._o.onCompleted();\n };\n\n TakeUntilObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n TakeUntilObserver.prototype.onCompleted = noop;\n\n return TakeUntilObserver;\n }(AbstractObserver));\n\n /**\n * Returns the values from the source observable sequence until the other observable sequence produces a value.\n * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.\n */\n observableProto.takeUntil = function (other) {\n return new TakeUntilObservable(this, other);\n };\n\n function falseFactory() { return false; }\n function argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n }\n\n var WithLatestFromObservable = (function(__super__) {\n inherits(WithLatestFromObservable, __super__);\n function WithLatestFromObservable(source, sources, resultSelector) {\n var len = sources.length;\n this._s = source;\n this._ss = sources;\n this._cb = resultSelector;\n this._hv = arrayInitialize(len, falseFactory);\n this._hvAll = false;\n this._v = new Array(len);\n __super__.call(this);\n }\n\n WithLatestFromObservable.prototype.subscribeCore = function (o) {\n var n = this._ss.length, subscriptions = new Array(n + 1);\n for (var i = 0; i < n; i++) {\n var other = this._ss[i], sad = new SingleAssignmentDisposable();\n isPromise(other) && (other = observableFromPromise(other));\n sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this)));\n subscriptions[i] = sad;\n }\n\n var sad = new SingleAssignmentDisposable();\n sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this)));\n subscriptions[n] = sad;\n\n return new NAryDisposable(subscriptions);\n };\n\n return WithLatestFromObservable;\n }(ObservableBase));\n\n var WithLatestFromOtherObserver = (function (__super__) {\n inherits(WithLatestFromOtherObserver, __super__);\n function WithLatestFromOtherObserver(o, i, p) {\n this._o = o;\n this._i = i;\n this._p = p;\n __super__.call(this);\n }\n\n WithLatestFromOtherObserver.prototype.next = function (x) {\n this._p._v[this._i] = x;\n this._p._hv[this._i] = true;\n this._p._hvAll = this._p._hv.every(identity);\n };\n\n WithLatestFromOtherObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n WithLatestFromOtherObserver.prototype.completed = noop;\n\n return WithLatestFromOtherObserver;\n }(AbstractObserver));\n\n var WithLatestFromSourceObserver = (function (__super__) {\n inherits(WithLatestFromSourceObserver, __super__);\n function WithLatestFromSourceObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n WithLatestFromSourceObserver.prototype.next = function (x) {\n var allValues = [x].concat(this._p._v);\n if (!this._p._hvAll) { return; }\n var res = tryCatch(this._p._cb).apply(null, allValues);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._o.onNext(res);\n };\n\n WithLatestFromSourceObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n WithLatestFromSourceObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return WithLatestFromSourceObserver;\n }(AbstractObserver));\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.withLatestFrom = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n Array.isArray(args[0]) && (args = args[0]);\n\n return new WithLatestFromObservable(this, args, resultSelector);\n };\n\n function falseFactory() { return false; }\n function emptyArrayFactory() { return []; }\n\n var ZipObservable = (function(__super__) {\n inherits(ZipObservable, __super__);\n function ZipObservable(sources, resultSelector) {\n var len = sources.length;\n this._s = sources;\n this._cb = resultSelector;\n this._done = arrayInitialize(len, falseFactory);\n this._q = arrayInitialize(len, emptyArrayFactory);\n __super__.call(this);\n }\n\n ZipObservable.prototype.subscribeCore = function(observer) {\n var n = this._s.length, subscriptions = new Array(n);\n\n for (var i = 0; i < n; i++) {\n var source = this._s[i], sad = new SingleAssignmentDisposable();\n subscriptions[i] = sad;\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this)));\n }\n\n return new NAryDisposable(subscriptions);\n };\n\n return ZipObservable;\n }(ObservableBase));\n\n var ZipObserver = (function (__super__) {\n inherits(ZipObserver, __super__);\n function ZipObserver(o, i, p) {\n this._o = o;\n this._i = i;\n this._p = p;\n __super__.call(this);\n }\n\n ZipObserver.prototype.next = function (x) {\n this._p._q[this._i].push(x);\n if (this._p._q.every(function (x) { return x.length > 0; })) {\n var queuedValues = this._p._q.map(function (x) { return x.shift(); });\n var res = tryCatch(this._p._cb).apply(null, queuedValues);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._o.onNext(res);\n } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) {\n this._o.onCompleted();\n }\n };\n\n ZipObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ZipObserver.prototype.completed = function () {\n this._p._done[this._i] = true;\n this._p._done.every(identity) && this._o.onCompleted();\n };\n\n return ZipObserver;\n }(AbstractObserver));\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\n observableProto.zip = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n Array.isArray(args[0]) && (args = args[0]);\n\n var parent = this;\n args.unshift(parent);\n\n return new ZipObservable(args, resultSelector);\n };\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n * @param arguments Observable sources.\n * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n Observable.zip = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n if (Array.isArray(args[0])) {\n args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];\n }\n var first = args.shift();\n return first.zip.apply(first, args);\n };\n\nfunction falseFactory() { return false; }\nfunction emptyArrayFactory() { return []; }\nfunction argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n}\n\n/**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\nobservableProto.zipIterable = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n\n var parent = this;\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n\n (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source));\n\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n};\n\n function asObservable(source) {\n return function subscribe(o) { return source.subscribe(o); };\n }\n\n /**\n * Hides the identity of an observable sequence.\n * @returns {Observable} An observable sequence that hides the identity of the source sequence.\n */\n observableProto.asObservable = function () {\n return new AnonymousObservable(asObservable(this), this);\n };\n\n function toArray(x) { return x.toArray(); }\n function notEmpty(x) { return x.length > 0; }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.\n * @param {Number} count Length of each buffer.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithCount = function (count, skip) {\n typeof skip !== 'number' && (skip = count);\n return this.windowWithCount(count, skip)\n .flatMap(toArray)\n .filter(notEmpty);\n };\n\n var DematerializeObservable = (function (__super__) {\n inherits(DematerializeObservable, __super__);\n function DematerializeObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n DematerializeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DematerializeObserver(o));\n };\n\n return DematerializeObservable;\n }(ObservableBase));\n\n var DematerializeObserver = (function (__super__) {\n inherits(DematerializeObserver, __super__);\n\n function DematerializeObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n DematerializeObserver.prototype.next = function (x) { x.accept(this._o); };\n DematerializeObserver.prototype.error = function (e) { this._o.onError(e); };\n DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return DematerializeObserver;\n }(AbstractObserver));\n\n /**\n * Dematerializes the explicit notification values of an observable sequence as implicit notifications.\n * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.\n */\n observableProto.dematerialize = function () {\n return new DematerializeObservable(this);\n };\n\n var DistinctUntilChangedObservable = (function(__super__) {\n inherits(DistinctUntilChangedObservable, __super__);\n function DistinctUntilChangedObservable(source, keyFn, comparer) {\n this.source = source;\n this.keyFn = keyFn;\n this.comparer = comparer;\n __super__.call(this);\n }\n\n DistinctUntilChangedObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer));\n };\n\n return DistinctUntilChangedObservable;\n }(ObservableBase));\n\n var DistinctUntilChangedObserver = (function(__super__) {\n inherits(DistinctUntilChangedObserver, __super__);\n function DistinctUntilChangedObserver(o, keyFn, comparer) {\n this.o = o;\n this.keyFn = keyFn;\n this.comparer = comparer;\n this.hasCurrentKey = false;\n this.currentKey = null;\n __super__.call(this);\n }\n\n DistinctUntilChangedObserver.prototype.next = function (x) {\n var key = x, comparerEquals;\n if (isFunction(this.keyFn)) {\n key = tryCatch(this.keyFn)(x);\n if (key === errorObj) { return this.o.onError(key.e); }\n }\n if (this.hasCurrentKey) {\n comparerEquals = tryCatch(this.comparer)(this.currentKey, key);\n if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); }\n }\n if (!this.hasCurrentKey || !comparerEquals) {\n this.hasCurrentKey = true;\n this.currentKey = key;\n this.o.onNext(x);\n }\n };\n DistinctUntilChangedObserver.prototype.error = function(e) {\n this.o.onError(e);\n };\n DistinctUntilChangedObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return DistinctUntilChangedObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer.\n * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value.\n * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.\n * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinctUntilChanged = function (keyFn, comparer) {\n comparer || (comparer = defaultComparer);\n return new DistinctUntilChangedObservable(this, keyFn, comparer);\n };\n\n var TapObservable = (function(__super__) {\n inherits(TapObservable,__super__);\n function TapObservable(source, observerOrOnNext, onError, onCompleted) {\n this.source = source;\n this._oN = observerOrOnNext;\n this._oE = onError;\n this._oC = onCompleted;\n __super__.call(this);\n }\n\n TapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, p) {\n this.o = o;\n this.t = !p._oN || isFunction(p._oN) ?\n observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) :\n p._oN;\n this.isStopped = false;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.next = function(x) {\n var res = tryCatch(this.t.onNext).call(this.t, x);\n if (res === errorObj) { this.o.onError(res.e); }\n this.o.onNext(x);\n };\n InnerObserver.prototype.error = function(err) {\n var res = tryCatch(this.t.onError).call(this.t, err);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onError(err);\n };\n InnerObserver.prototype.completed = function() {\n var res = tryCatch(this.t.onCompleted).call(this.t);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onCompleted();\n };\n\n return TapObservable;\n }(ObservableBase));\n\n /**\n * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {\n return new TapObservable(this, observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Invokes an action for each element in the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onNext Action to invoke for each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {\n return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);\n };\n\n /**\n * Invokes an action upon exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {\n return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);\n };\n\n /**\n * Invokes an action upon graceful termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {\n return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);\n };\n\n /**\n * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.\n * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.\n * @returns {Observable} Source sequence with the action-invoking termination behavior applied.\n */\n observableProto['finally'] = function (action) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription = tryCatch(source.subscribe).call(source, observer);\n if (subscription === errorObj) {\n action();\n return thrower(subscription.e);\n }\n return disposableCreate(function () {\n var r = tryCatch(subscription.dispose).call(subscription);\n action();\n r === errorObj && thrower(r.e);\n });\n }, this);\n };\n\n var IgnoreElementsObservable = (function(__super__) {\n inherits(IgnoreElementsObservable, __super__);\n\n function IgnoreElementsObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IgnoreElementsObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = noop;\n InnerObserver.prototype.onError = function (err) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n\n return false;\n };\n\n return IgnoreElementsObservable;\n }(ObservableBase));\n\n /**\n * Ignores all elements in an observable sequence leaving only the termination messages.\n * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.\n */\n observableProto.ignoreElements = function () {\n return new IgnoreElementsObservable(this);\n };\n\n var MaterializeObservable = (function (__super__) {\n inherits(MaterializeObservable, __super__);\n function MaterializeObservable(source, fn) {\n this.source = source;\n __super__.call(this);\n }\n\n MaterializeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new MaterializeObserver(o));\n };\n\n return MaterializeObservable;\n }(ObservableBase));\n\n var MaterializeObserver = (function (__super__) {\n inherits(MaterializeObserver, __super__);\n\n function MaterializeObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) };\n MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); };\n MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); };\n\n return MaterializeObserver;\n }(AbstractObserver));\n\n /**\n * Materializes the implicit notifications of an observable sequence as explicit notification values.\n * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.\n */\n observableProto.materialize = function () {\n return new MaterializeObservable(this);\n };\n\n /**\n * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.\n * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.\n * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.\n */\n observableProto.repeat = function (repeatCount) {\n return enumerableRepeat(this, repeatCount).concat();\n };\n\n /**\n * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.\n * Note if you encounter an error and want it to retry once, then you must use .retry(2);\n *\n * @example\n * var res = retried = retry.repeat();\n * var res = retried = retry.repeat(2);\n * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retry = function (retryCount) {\n return enumerableRepeat(this, retryCount).catchError();\n };\n\n /**\n * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. \n * if the notifier completes, the observable sequence completes.\n *\n * @example\n * var timer = Observable.timer(500);\n * var source = observable.retryWhen(timer);\n * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retryWhen = function (notifier) {\n return enumerableRepeat(this).catchErrorWhen(notifier);\n };\n var ScanObservable = (function(__super__) {\n inherits(ScanObservable, __super__);\n function ScanObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ScanObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new ScanObserver(o,this));\n };\n\n return ScanObservable;\n }(ObservableBase));\n\n var ScanObserver = (function (__super__) {\n inherits(ScanObserver, __super__);\n function ScanObserver(o, parent) {\n this._o = o;\n this._p = parent;\n this._fn = parent.accumulator;\n this._hs = parent.hasSeed;\n this._s = parent.seed;\n this._ha = false;\n this._a = null;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n ScanObserver.prototype.next = function (x) {\n !this._hv && (this._hv = true);\n if (this._ha) {\n this._a = tryCatch(this._fn)(this._a, x, this._i, this._p);\n } else {\n this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x;\n this._ha = true;\n }\n if (this._a === errorObj) { return this._o.onError(this._a.e); }\n this._o.onNext(this._a);\n this._i++;\n };\n\n ScanObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ScanObserver.prototype.completed = function () {\n !this._hv && this._hs && this._o.onNext(this._s);\n this._o.onCompleted();\n };\n\n return ScanObserver;\n }(AbstractObserver));\n\n /**\n * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.\n * For aggregation behavior with no intermediate results, see Observable.aggregate.\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing the accumulated values.\n */\n observableProto.scan = function () {\n var hasSeed = false, seed, accumulator = arguments[0];\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[1];\n }\n return new ScanObservable(this, accumulator, hasSeed, seed);\n };\n\n var SkipLastObservable = (function (__super__) {\n inherits(SkipLastObservable, __super__);\n function SkipLastObservable(source, c) {\n this.source = source;\n this._c = c;\n __super__.call(this);\n }\n\n SkipLastObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipLastObserver(o, this._c));\n };\n\n return SkipLastObservable;\n }(ObservableBase));\n\n var SkipLastObserver = (function (__super__) {\n inherits(SkipLastObserver, __super__);\n function SkipLastObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n SkipLastObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._o.onNext(this._q.shift());\n };\n\n SkipLastObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n SkipLastObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return SkipLastObserver;\n }(AbstractObserver));\n\n /**\n * Bypasses a specified number of elements at the end of an observable sequence.\n * @description\n * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are\n * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.\n * @param count Number of elements to bypass at the end of the source sequence.\n * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.\n */\n observableProto.skipLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipLastObservable(this, count);\n };\n\n /**\n * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.\n * @example\n * var res = source.startWith(1, 2, 3);\n * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);\n * @param {Arguments} args The specified values to prepend to the observable sequence\n * @returns {Observable} The source sequence prepended with the specified values.\n */\n observableProto.startWith = function () {\n var values, scheduler, start = 0;\n if (!!arguments.length && isScheduler(arguments[0])) {\n scheduler = arguments[0];\n start = 1;\n } else {\n scheduler = immediateScheduler;\n }\n for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n return enumerableOf([observableFromArray(args, scheduler), this]).concat();\n };\n\n var TakeLastObserver = (function (__super__) {\n inherits(TakeLastObserver, __super__);\n function TakeLastObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._q.shift();\n };\n\n TakeLastObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TakeLastObserver.prototype.completed = function () {\n while (this._q.length > 0) { this._o.onNext(this._q.shift()); }\n this._o.onCompleted();\n };\n\n return TakeLastObserver;\n }(AbstractObserver));\n\n /**\n * Returns a specified number of contiguous elements from the end of an observable sequence.\n * @description\n * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of\n * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(new TakeLastObserver(o, count));\n }, source);\n };\n\n var TakeLastBufferObserver = (function (__super__) {\n inherits(TakeLastBufferObserver, __super__);\n function TakeLastBufferObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastBufferObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._q.shift();\n };\n\n TakeLastBufferObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TakeLastBufferObserver.prototype.completed = function () {\n this._o.onNext(this._q);\n this._o.onCompleted();\n };\n\n return TakeLastBufferObserver;\n }(AbstractObserver));\n\n /**\n * Returns an array with the specified number of contiguous elements from the end of an observable sequence.\n *\n * @description\n * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the\n * source sequence, this buffer is produced on the result sequence.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLastBuffer = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(new TakeLastBufferObserver(o, count));\n }, source);\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.\n * @param {Number} count Length of each window.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithCount = function (count, skip) {\n var source = this;\n +count || (count = 0);\n Math.abs(count) === Infinity && (count = 0);\n if (count <= 0) { throw new ArgumentOutOfRangeError(); }\n skip == null && (skip = count);\n +skip || (skip = 0);\n Math.abs(skip) === Infinity && (skip = 0);\n\n if (skip <= 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(),\n refCountDisposable = new RefCountDisposable(m),\n n = 0,\n q = [];\n\n function createWindow () {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n\n createWindow();\n\n m.setDisposable(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n var c = n - count + 1;\n c >= 0 && c % skip === 0 && q.shift().onCompleted();\n ++n % skip === 0 && createWindow();\n },\n function (e) {\n while (q.length > 0) { q.shift().onError(e); }\n observer.onError(e);\n },\n function () {\n while (q.length > 0) { q.shift().onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n function concatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).concatAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the\n * source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.concatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n });\n }\n return isFunction(selector) ?\n concatMap(this, selector, thisArg) :\n concatMap(this, function () { return selector; });\n };\n\n /**\n * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {\n var source = this,\n onNextFunc = bindCallback(onNext, thisArg, 2),\n onErrorFunc = bindCallback(onError, thisArg, 1),\n onCompletedFunc = bindCallback(onCompleted, thisArg, 0);\n return new AnonymousObservable(function (observer) {\n var index = 0;\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNextFunc(x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onErrorFunc(err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompletedFunc();\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, this).concatAll();\n };\n\n var DefaultIfEmptyObserver = (function (__super__) {\n inherits(DefaultIfEmptyObserver, __super__);\n function DefaultIfEmptyObserver(o, d) {\n this._o = o;\n this._d = d;\n this._f = false;\n __super__.call(this);\n }\n\n DefaultIfEmptyObserver.prototype.next = function (x) {\n this._f = true;\n this._o.onNext(x);\n };\n\n DefaultIfEmptyObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n DefaultIfEmptyObserver.prototype.completed = function () {\n !this._f && this._o.onNext(defaultValue);\n this._o.onCompleted();\n };\n\n return DefaultIfEmptyObserver;\n }(AbstractObserver));\n\n /**\n * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.\n *\n * var res = obs = xs.defaultIfEmpty();\n * 2 - obs = xs.defaultIfEmpty(false);\n *\n * @memberOf Observable#\n * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.\n * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.\n */\n observableProto.defaultIfEmpty = function (defaultValue) {\n var source = this;\n defaultValue === undefined && (defaultValue = null);\n return new AnonymousObservable(function (o) {\n return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue));\n }, source);\n };\n\n // Swap out for Array.findIndex\n function arrayIndexOfComparer(array, item, comparer) {\n for (var i = 0, len = array.length; i < len; i++) {\n if (comparer(array[i], item)) { return i; }\n }\n return -1;\n }\n\n function HashSet(comparer) {\n this.comparer = comparer;\n this.set = [];\n }\n HashSet.prototype.push = function(value) {\n var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1;\n retValue && this.set.push(value);\n return retValue;\n };\n\n var DistinctObservable = (function (__super__) {\n inherits(DistinctObservable, __super__);\n function DistinctObservable(source, keyFn, cmpFn) {\n this.source = source;\n this._keyFn = keyFn;\n this._cmpFn = cmpFn;\n __super__.call(this);\n }\n\n DistinctObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn));\n };\n\n return DistinctObservable;\n }(ObservableBase));\n\n var DistinctObserver = (function (__super__) {\n inherits(DistinctObserver, __super__);\n function DistinctObserver(o, keyFn, cmpFn) {\n this._o = o;\n this._keyFn = keyFn;\n this._h = new HashSet(cmpFn);\n __super__.call(this);\n }\n\n DistinctObserver.prototype.next = function (x) {\n var key = x;\n if (isFunction(this._keyFn)) {\n key = tryCatch(this._keyFn)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n }\n this._h.push(key) && this._o.onNext(x);\n };\n\n DistinctObserver.prototype.error = function (e) { this._o.onError(e); };\n DistinctObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return DistinctObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.\n * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.\n *\n * @example\n * var res = obs = xs.distinct();\n * 2 - obs = xs.distinct(function (x) { return x.id; });\n * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });\n * @param {Function} [keySelector] A function to compute the comparison key for each element.\n * @param {Function} [comparer] Used to compare items in the collection.\n * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinct = function (keySelector, comparer) {\n comparer || (comparer = defaultComparer);\n return new DistinctObservable(this, keySelector, comparer);\n };\n\n /**\n * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.\n *\n * @example\n * var res = observable.groupBy(function (x) { return x.id; });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.\n * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n */\n observableProto.groupBy = function (keySelector, elementSelector) {\n return this.groupByUntil(keySelector, elementSelector, observableNever);\n };\n\n /**\n * Groups the elements of an observable sequence according to a specified key selector function.\n * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same\n * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.\n *\n * @example\n * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} durationSelector A function to signal the expiration of a group.\n * @returns {Observable}\n * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.\n *\n */\n observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var map = new Map(),\n groupDisposable = new CompositeDisposable(),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n handleError = function (e) { return function (item) { item.onError(e); }; };\n\n groupDisposable.add(\n source.subscribe(function (x) {\n var key = tryCatch(keySelector)(x);\n if (key === errorObj) {\n map.forEach(handleError(key.e));\n return o.onError(key.e);\n }\n\n var fireNewMapEntry = false, writer = map.get(key);\n if (writer === undefined) {\n writer = new Subject();\n map.set(key, writer);\n fireNewMapEntry = true;\n }\n\n if (fireNewMapEntry) {\n var group = new GroupedObservable(key, writer, refCountDisposable),\n durationGroup = new GroupedObservable(key, writer);\n var duration = tryCatch(durationSelector)(durationGroup);\n if (duration === errorObj) {\n map.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n o.onNext(group);\n\n var md = new SingleAssignmentDisposable();\n groupDisposable.add(md);\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n map.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n if (map['delete'](key)) { writer.onCompleted(); }\n groupDisposable.remove(md);\n }));\n }\n\n var element = x;\n if (isFunction(elementSelector)) {\n element = tryCatch(elementSelector)(x);\n if (element === errorObj) {\n map.forEach(handleError(element.e));\n return o.onError(element.e);\n }\n }\n\n writer.onNext(element);\n }, function (e) {\n map.forEach(handleError(e));\n o.onError(e);\n }, function () {\n map.forEach(function (item) { item.onCompleted(); });\n o.onCompleted();\n }));\n\n return refCountDisposable;\n }, source);\n };\n\n var MapObservable = (function (__super__) {\n inherits(MapObservable, __super__);\n\n function MapObservable(source, selector, thisArg) {\n this.source = source;\n this.selector = bindCallback(selector, thisArg, 3);\n __super__.call(this);\n }\n\n function innerMap(selector, self) {\n return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }\n }\n\n MapObservable.prototype.internalMap = function (selector, thisArg) {\n return new MapObservable(this.source, innerMap(selector, this), thisArg);\n };\n\n MapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, selector, source) {\n this.o = o;\n this.selector = selector;\n this.source = source;\n this.i = 0;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function(x) {\n var result = tryCatch(this.selector)(x, this.i++, this.source);\n if (result === errorObj) { return this.o.onError(result.e); }\n this.o.onNext(result);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return MapObservable;\n\n }(ObservableBase));\n\n /**\n * Projects each element of an observable sequence into a new form by incorporating the element's index.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.\n */\n observableProto.map = observableProto.select = function (selector, thisArg) {\n var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };\n return this instanceof MapObservable ?\n this.internalMap(selectorFn, thisArg) :\n new MapObservable(this, selectorFn, thisArg);\n };\n\n function plucker(args, len) {\n return function mapper(x) {\n var currentProp = x;\n for (var i = 0; i < len; i++) {\n var p = currentProp[args[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n }\n }\n\n /**\n * Retrieves the value of a specified nested property from all elements in\n * the Observable sequence.\n * @param {Arguments} arguments The nested properties to pluck.\n * @returns {Observable} Returns a new Observable sequence of property values.\n */\n observableProto.pluck = function () {\n var len = arguments.length, args = new Array(len);\n if (len === 0) { throw new Error('List of properties cannot be empty.'); }\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return this.map(plucker(args, len));\n };\n\nobservableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll();\n};\n\n\n//\n//Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) {\n// return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit);\n//};\n//\n\n /**\n * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var index = 0;\n\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNext.call(thisArg, x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onError.call(thisArg, err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompleted.call(thisArg);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, source).mergeAll();\n };\n\nRx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest();\n};\n var SkipObservable = (function(__super__) {\n inherits(SkipObservable, __super__);\n function SkipObservable(source, count) {\n this.source = source;\n this.skipCount = count;\n __super__.call(this);\n }\n \n SkipObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.skipCount));\n };\n \n function InnerObserver(o, c) {\n this.c = c;\n this.r = c;\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n if (this.r <= 0) { \n this.o.onNext(x);\n } else {\n this.r--;\n }\n };\n InnerObserver.prototype.onError = function(e) {\n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n \n return SkipObservable;\n }(ObservableBase)); \n \n /**\n * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.\n * @param {Number} count The number of elements to skip before returning the remaining elements.\n * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.\n */\n observableProto.skip = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipObservable(this, count);\n };\n var SkipWhileObservable = (function (__super__) {\n inherits(SkipWhileObservable, __super__);\n function SkipWhileObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SkipWhileObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipWhileObserver(o, this));\n };\n\n return SkipWhileObservable;\n }(ObservableBase));\n\n var SkipWhileObserver = (function (__super__) {\n inherits(SkipWhileObserver, __super__);\n\n function SkipWhileObserver(o, p) {\n this._o = o;\n this._p = p;\n this._i = 0;\n this._r = false;\n __super__.call(this);\n }\n\n SkipWhileObserver.prototype.next = function (x) {\n if (!this._r) {\n var res = tryCatch(this._p._fn)(x, this._i++, this._p);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._r = !res;\n }\n this._r && this._o.onNext(x);\n };\n SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipWhileObserver;\n }(AbstractObserver));\n\n /**\n * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.\n * The element's index is used in the logic of the predicate function.\n *\n * var res = source.skipWhile(function (value) { return value < 10; });\n * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\n observableProto.skipWhile = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new SkipWhileObservable(this, fn);\n };\n\n var TakeObservable = (function(__super__) {\n inherits(TakeObservable, __super__);\n \n function TakeObservable(source, count) {\n this.source = source;\n this.takeCount = count;\n __super__.call(this);\n }\n \n TakeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.takeCount));\n };\n \n function InnerObserver(o, c) {\n this.o = o;\n this.c = c;\n this.r = c;\n this.isStopped = false;\n }\n InnerObserver.prototype = {\n onNext: function (x) {\n if (this.isStopped) { return; }\n if (this.r-- > 0) {\n this.o.onNext(x);\n this.r <= 0 && this.o.onCompleted();\n }\n },\n onError: function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n },\n onCompleted: function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n },\n dispose: function () { this.isStopped = true; },\n fail: function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n }\n };\n \n return TakeObservable;\n }(ObservableBase)); \n \n /**\n * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).\n * @param {Number} count The number of elements to return.\n * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case is set to 0.\n * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.\n */\n observableProto.take = function (count, scheduler) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n if (count === 0) { return observableEmpty(scheduler); }\n return new TakeObservable(this, count);\n };\n\n var TakeWhileObservable = (function (__super__) {\n inherits(TakeWhileObservable, __super__);\n function TakeWhileObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n TakeWhileObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TakeWhileObserver(o, this));\n };\n\n return TakeWhileObservable;\n }(ObservableBase));\n\n var TakeWhileObserver = (function (__super__) {\n inherits(TakeWhileObserver, __super__);\n\n function TakeWhileObserver(o, p) {\n this._o = o;\n this._p = p;\n this._i = 0;\n this._r = true;\n __super__.call(this);\n }\n\n TakeWhileObserver.prototype.next = function (x) {\n if (this._r) {\n this._r = tryCatch(this._p._fn)(x, this._i++, this._p);\n if (this._r === errorObj) { return this._o.onError(this._r.e); }\n }\n if (this._r) {\n this._o.onNext(x);\n } else {\n this._o.onCompleted();\n }\n };\n TakeWhileObserver.prototype.error = function (e) { this._o.onError(e); };\n TakeWhileObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return TakeWhileObserver;\n }(AbstractObserver));\n\n /**\n * Returns elements from an observable sequence as long as a specified condition is true.\n * The element's index is used in the logic of the predicate function.\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.\n */\n observableProto.takeWhile = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new TakeWhileObservable(this, fn);\n };\n\n var FilterObservable = (function (__super__) {\n inherits(FilterObservable, __super__);\n\n function FilterObservable(source, predicate, thisArg) {\n this.source = source;\n this.predicate = bindCallback(predicate, thisArg, 3);\n __super__.call(this);\n }\n\n FilterObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.predicate, this));\n };\n\n function innerPredicate(predicate, self) {\n return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }\n }\n\n FilterObservable.prototype.internalFilter = function(predicate, thisArg) {\n return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, predicate, source) {\n this.o = o;\n this.predicate = predicate;\n this.source = source;\n this.i = 0;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function(x) {\n var shouldYield = tryCatch(this.predicate)(x, this.i++, this.source);\n if (shouldYield === errorObj) {\n return this.o.onError(shouldYield.e);\n }\n shouldYield && this.o.onNext(x);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return FilterObservable;\n\n }(ObservableBase));\n\n /**\n * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.\n * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.\n */\n observableProto.filter = observableProto.where = function (predicate, thisArg) {\n return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :\n new FilterObservable(this, predicate, thisArg);\n };\n\n var ExtremaByObservable = (function (__super__) {\n inherits(ExtremaByObservable, __super__);\n function ExtremaByObservable(source, k, c) {\n this.source = source;\n this._k = k;\n this._c = c;\n __super__.call(this);\n }\n\n ExtremaByObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ExtremaByObserver(o, this._k, this._c));\n };\n\n return ExtremaByObservable;\n }(ObservableBase));\n\n var ExtremaByObserver = (function (__super__) {\n inherits(ExtremaByObserver, __super__);\n function ExtremaByObserver(o, k, c) {\n this._o = o;\n this._k = k;\n this._c = c;\n this._v = null;\n this._hv = false;\n this._l = [];\n __super__.call(this);\n }\n\n ExtremaByObserver.prototype.next = function (x) {\n var key = tryCatch(this._k)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n var comparison = 0;\n if (!this._hv) {\n this._hv = true;\n this._v = key;\n } else {\n comparison = tryCatch(this._c)(key, this._v);\n if (comparison === errorObj) { return this._o.onError(comparison.e); }\n }\n if (comparison > 0) {\n this._v = key;\n this._l = [];\n }\n if (comparison >= 0) { this._l.push(x); }\n };\n\n ExtremaByObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ExtremaByObserver.prototype.completed = function () {\n this._o.onNext(this._l);\n this._o.onCompleted();\n };\n\n return ExtremaByObserver;\n }(AbstractObserver));\n\n function firstOnly(x) {\n if (x.length === 0) { throw new EmptyError(); }\n return x[0];\n }\n\n var ReduceObservable = (function(__super__) {\n inherits(ReduceObservable, __super__);\n function ReduceObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ReduceObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new ReduceObserver(observer,this));\n };\n\n return ReduceObservable;\n }(ObservableBase));\n\n var ReduceObserver = (function (__super__) {\n inherits(ReduceObserver, __super__);\n function ReduceObserver(o, parent) {\n this._o = o;\n this._p = parent;\n this._fn = parent.accumulator;\n this._hs = parent.hasSeed;\n this._s = parent.seed;\n this._ha = false;\n this._a = null;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n ReduceObserver.prototype.next = function (x) {\n !this._hv && (this._hv = true);\n if (this._ha) {\n this._a = tryCatch(this._fn)(this._a, x, this._i, this._p);\n } else {\n this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x;\n this._ha = true;\n }\n if (this._a === errorObj) { return this._o.onError(this._a.e); }\n this._i++;\n };\n\n ReduceObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ReduceObserver.prototype.completed = function () {\n this._hv && this._o.onNext(this._a);\n !this._hv && this._hs && this._o.onNext(this._s);\n !this._hv && !this._hs && this._o.onError(new EmptyError());\n this._o.onCompleted();\n };\n\n return ReduceObserver;\n }(AbstractObserver));\n\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @param {Any} [seed] The initial accumulator value.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.reduce = function () {\n var hasSeed = false, seed, accumulator = arguments[0];\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[1];\n }\n return new ReduceObservable(this, accumulator, hasSeed, seed);\n };\n\n var SomeObservable = (function (__super__) {\n inherits(SomeObservable, __super__);\n function SomeObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SomeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SomeObserver(o, this._fn, this.source));\n };\n\n return SomeObservable;\n }(ObservableBase));\n\n var SomeObserver = (function (__super__) {\n inherits(SomeObserver, __super__);\n\n function SomeObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n SomeObserver.prototype.next = function (x) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n if (Boolean(result)) {\n this._o.onNext(true);\n this._o.onCompleted();\n }\n };\n SomeObserver.prototype.error = function (e) { this._o.onError(e); };\n SomeObserver.prototype.completed = function () {\n this._o.onNext(false);\n this._o.onCompleted();\n };\n\n return SomeObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.\n */\n observableProto.some = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new SomeObservable(this, fn);\n };\n\n var IsEmptyObservable = (function (__super__) {\n inherits(IsEmptyObservable, __super__);\n function IsEmptyObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IsEmptyObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new IsEmptyObserver(o));\n };\n\n return IsEmptyObservable;\n }(ObservableBase));\n\n var IsEmptyObserver = (function(__super__) {\n inherits(IsEmptyObserver, __super__);\n function IsEmptyObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n IsEmptyObserver.prototype.next = function () {\n this._o.onNext(false);\n this._o.onCompleted();\n };\n IsEmptyObserver.prototype.error = function (e) { this._o.onError(e); };\n IsEmptyObserver.prototype.completed = function () {\n this._o.onNext(true);\n this._o.onCompleted();\n };\n\n return IsEmptyObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether an observable sequence is empty.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.\n */\n observableProto.isEmpty = function () {\n return new IsEmptyObservable(this);\n };\n\n var EveryObservable = (function (__super__) {\n inherits(EveryObservable, __super__);\n function EveryObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n EveryObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new EveryObserver(o, this._fn, this.source));\n };\n\n return EveryObservable;\n }(ObservableBase));\n\n var EveryObserver = (function (__super__) {\n inherits(EveryObserver, __super__);\n\n function EveryObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n EveryObserver.prototype.next = function (x) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n if (!Boolean(result)) {\n this._o.onNext(false);\n this._o.onCompleted();\n }\n };\n EveryObserver.prototype.error = function (e) { this._o.onError(e); };\n EveryObserver.prototype.completed = function () {\n this._o.onNext(true);\n this._o.onCompleted();\n };\n\n return EveryObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether all elements of an observable sequence satisfy a condition.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.\n */\n observableProto.every = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new EveryObservable(this, fn);\n };\n\n var IncludesObservable = (function (__super__) {\n inherits(IncludesObservable, __super__);\n function IncludesObservable(source, elem, idx) {\n var n = +idx || 0;\n Math.abs(n) === Infinity && (n = 0);\n\n this.source = source;\n this._elem = elem;\n this._n = n;\n __super__.call(this);\n }\n\n IncludesObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(false);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new IncludesObserver(o, this._elem, this._n));\n };\n\n return IncludesObservable;\n }(ObservableBase));\n\n var IncludesObserver = (function (__super__) {\n inherits(IncludesObserver, __super__);\n function IncludesObserver(o, elem, n) {\n this._o = o;\n this._elem = elem;\n this._n = n;\n this._i = 0;\n __super__.call(this);\n }\n\n function comparer(a, b) {\n return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));\n }\n\n IncludesObserver.prototype.next = function (x) {\n if (this._i++ >= this._n && comparer(x, this._elem)) {\n this._o.onNext(true);\n this._o.onCompleted();\n }\n };\n IncludesObserver.prototype.error = function (e) { this._o.onError(e); };\n IncludesObserver.prototype.completed = function () { this._o.onNext(false); this._o.onCompleted(); };\n\n return IncludesObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether an observable sequence includes a specified element with an optional equality comparer.\n * @param searchElement The value to locate in the source sequence.\n * @param {Number} [fromIndex] An equality comparer to compare elements.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.\n */\n observableProto.includes = function (searchElement, fromIndex) {\n return new IncludesObservable(this, searchElement, fromIndex);\n };\n\n var CountObservable = (function (__super__) {\n inherits(CountObservable, __super__);\n function CountObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n CountObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new CountObserver(o, this._fn, this.source));\n };\n\n return CountObservable;\n }(ObservableBase));\n\n var CountObserver = (function (__super__) {\n inherits(CountObserver, __super__);\n\n function CountObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n this._c = 0;\n __super__.call(this);\n }\n\n CountObserver.prototype.next = function (x) {\n if (this._fn) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n Boolean(result) && (this._c++);\n } else {\n this._c++;\n }\n };\n CountObserver.prototype.error = function (e) { this._o.onError(e); };\n CountObserver.prototype.completed = function () {\n this._o.onNext(this._c);\n this._o.onCompleted();\n };\n\n return CountObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.\n * @example\n * res = source.count();\n * res = source.count(function (x) { return x > 3; });\n * @param {Function} [predicate]A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.\n */\n observableProto.count = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new CountObservable(this, fn);\n };\n\n var IndexOfObservable = (function (__super__) {\n inherits(IndexOfObservable, __super__);\n function IndexOfObservable(source, e, n) {\n this.source = source;\n this._e = e;\n this._n = n;\n __super__.call(this);\n }\n\n IndexOfObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new IndexOfObserver(o, this._e, this._n));\n };\n\n return IndexOfObservable;\n }(ObservableBase));\n\n var IndexOfObserver = (function (__super__) {\n inherits(IndexOfObserver, __super__);\n function IndexOfObserver(o, e, n) {\n this._o = o;\n this._e = e;\n this._n = n;\n this._i = 0;\n __super__.call(this);\n }\n\n IndexOfObserver.prototype.next = function (x) {\n if (this._i >= this._n && x === this._e) {\n this._o.onNext(this._i);\n this._o.onCompleted();\n }\n this._i++;\n };\n IndexOfObserver.prototype.error = function (e) { this._o.onError(e); };\n IndexOfObserver.prototype.completed = function () { this._o.onNext(-1); this._o.onCompleted(); };\n\n return IndexOfObserver;\n }(AbstractObserver));\n\n /**\n * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.indexOf = function(searchElement, fromIndex) {\n var n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n return new IndexOfObservable(this, searchElement, n);\n };\n\n var SumObservable = (function (__super__) {\n inherits(SumObservable, __super__);\n function SumObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SumObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SumObserver(o, this._fn, this.source));\n };\n\n return SumObservable;\n }(ObservableBase));\n\n var SumObserver = (function (__super__) {\n inherits(SumObserver, __super__);\n\n function SumObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n this._c = 0;\n __super__.call(this);\n }\n\n SumObserver.prototype.next = function (x) {\n if (this._fn) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n this._c += result;\n } else {\n this._c += x;\n }\n };\n SumObserver.prototype.error = function (e) { this._o.onError(e); };\n SumObserver.prototype.completed = function () {\n this._o.onNext(this._c);\n this._o.onCompleted();\n };\n\n return SumObserver;\n }(AbstractObserver));\n\n /**\n * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.\n */\n observableProto.sum = function (keySelector, thisArg) {\n var fn = bindCallback(keySelector, thisArg, 3);\n return new SumObservable(this, fn);\n };\n\n /**\n * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.\n * @example\n * var res = source.minBy(function (x) { return x.value; });\n * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.\n */\n observableProto.minBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return new ExtremaByObservable(this, keySelector, function (x, y) { return comparer(x, y) * -1; });\n };\n\n /**\n * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.\n * @example\n * var res = source.min();\n * var res = source.min(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.\n */\n observableProto.min = function (comparer) {\n return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\n /**\n * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.\n * @example\n * var res = source.maxBy(function (x) { return x.value; });\n * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.\n */\n observableProto.maxBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return new ExtremaByObservable(this, keySelector, comparer);\n };\n\n /**\n * Returns the maximum value in an observable sequence according to the specified comparer.\n * @example\n * var res = source.max();\n * var res = source.max(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.\n */\n observableProto.max = function (comparer) {\n return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\n var AverageObservable = (function (__super__) {\n inherits(AverageObservable, __super__);\n function AverageObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n AverageObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new AverageObserver(o, this._fn, this.source));\n };\n\n return AverageObservable;\n }(ObservableBase));\n\n var AverageObserver = (function(__super__) {\n inherits(AverageObserver, __super__);\n function AverageObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._c = 0;\n this._t = 0;\n __super__.call(this);\n }\n\n AverageObserver.prototype.next = function (x) {\n if(this._fn) {\n var r = tryCatch(this._fn)(x, this._c++, this._s);\n if (r === errorObj) { return this._o.onError(r.e); }\n this._t += r;\n } else {\n this._c++;\n this._t += x;\n }\n };\n AverageObserver.prototype.error = function (e) { this._o.onError(e); };\n AverageObserver.prototype.completed = function () {\n if (this._c === 0) { return this._o.onError(new EmptyError()); }\n this._o.onNext(this._t / this._c);\n this._o.onCompleted();\n };\n\n return AverageObserver;\n }(AbstractObserver));\n\n /**\n * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.\n */\n observableProto.average = function (keySelector, thisArg) {\n var source = this, fn;\n if (isFunction(keySelector)) {\n fn = bindCallback(keySelector, thisArg, 3);\n }\n return new AverageObservable(source, fn);\n };\n\n /**\n * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.\n *\n * @example\n * var res = res = source.sequenceEqual([1,2,3]);\n * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });\n * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));\n * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });\n * @param {Observable} second Second observable sequence or array to compare.\n * @param {Function} [comparer] Comparer used to compare elements of both sequences.\n * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.\n */\n observableProto.sequenceEqual = function (second, comparer) {\n var first = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var donel = false, doner = false, ql = [], qr = [];\n var subscription1 = first.subscribe(function (x) {\n if (qr.length > 0) {\n var v = qr.shift();\n var equal = tryCatch(comparer)(v, x);\n if (equal === errorObj) { return o.onError(equal.e); }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (doner) {\n o.onNext(false);\n o.onCompleted();\n } else {\n ql.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n donel = true;\n if (ql.length === 0) {\n if (qr.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (doner) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n\n (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));\n isPromise(second) && (second = observableFromPromise(second));\n var subscription2 = second.subscribe(function (x) {\n if (ql.length > 0) {\n var v = ql.shift();\n var equal = tryCatch(comparer)(v, x);\n if (equal === errorObj) { return o.onError(equal.e); }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (donel) {\n o.onNext(false);\n o.onCompleted();\n } else {\n qr.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n doner = true;\n if (qr.length === 0) {\n if (ql.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (donel) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n return new BinaryDisposable(subscription1, subscription2);\n }, first);\n };\n\n var ElementAtObservable = (function (__super__) {\n inherits(ElementAtObservable, __super__);\n function ElementAtObservable(source, i, d) {\n this.source = source;\n this._i = i;\n this._d = d;\n __super__.call(this);\n }\n\n ElementAtObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ElementAtObserver(o, this._i, this._d));\n };\n\n return ElementAtObservable;\n }(ObservableBase));\n\n var ElementAtObserver = (function (__super__) {\n inherits(ElementAtObserver, __super__);\n\n function ElementAtObserver(o, i, d) {\n this._o = o;\n this._i = i;\n this._d = d;\n __super__.call(this);\n }\n\n ElementAtObserver.prototype.next = function (x) {\n if (this._i-- === 0) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n };\n ElementAtObserver.prototype.error = function (e) { this._o.onError(e); };\n ElementAtObserver.prototype.completed = function () {\n if (this._d === undefined) {\n this._o.onError(new ArgumentOutOfRangeError());\n } else {\n this._o.onNext(this._d);\n this._o.onCompleted();\n }\n };\n\n return ElementAtObserver;\n }(AbstractObserver));\n\n /**\n * Returns the element at a specified index in a sequence or default value if not found.\n * @param {Number} index The zero-based index of the element to retrieve.\n * @param {Any} [defaultValue] The default value to use if elementAt does not find a value.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.\n */\n observableProto.elementAt = function (index, defaultValue) {\n if (index < 0) { throw new ArgumentOutOfRangeError(); }\n return new ElementAtObservable(this, index, defaultValue);\n };\n\n var SingleObserver = (function(__super__) {\n inherits(SingleObserver, __super__);\n function SingleObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n this._hv = false;\n this._v = null;\n __super__.call(this);\n }\n\n SingleObserver.prototype.next = function (x) {\n var shouldYield = false;\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n Boolean(res) && (shouldYield = true);\n } else if (!this._obj.predicate) {\n shouldYield = true;\n }\n if (shouldYield) {\n if (this._hv) {\n return this._o.onError(new Error('Sequence contains more than one matching element'));\n }\n this._hv = true;\n this._v = x;\n }\n };\n SingleObserver.prototype.error = function (e) { this._o.onError(e); };\n SingleObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n this._o.onCompleted();\n }\n else if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return SingleObserver;\n }(AbstractObserver));\n\n\n /**\n * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.single = function (predicate, thisArg) {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new AnonymousObservable(function (o) {\n return source.subscribe(new SingleObserver(o, obj, source));\n }, source);\n };\n\n var FirstObservable = (function (__super__) {\n inherits(FirstObservable, __super__);\n function FirstObservable(source, obj) {\n this.source = source;\n this._obj = obj;\n __super__.call(this);\n }\n\n FirstObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new FirstObserver(o, this._obj, this.source));\n };\n\n return FirstObservable;\n }(ObservableBase));\n\n var FirstObserver = (function(__super__) {\n inherits(FirstObserver, __super__);\n function FirstObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n FirstObserver.prototype.next = function (x) {\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n if (Boolean(res)) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n } else if (!this._obj.predicate) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n };\n FirstObserver.prototype.error = function (e) { this._o.onError(e); };\n FirstObserver.prototype.completed = function () {\n if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return FirstObserver;\n }(AbstractObserver));\n\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.\n */\n observableProto.first = function () {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new FirstObservable(this, obj);\n };\n\n var LastObservable = (function (__super__) {\n inherits(LastObservable, __super__);\n function LastObservable(source, obj) {\n this.source = source;\n this._obj = obj;\n __super__.call(this);\n }\n\n LastObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new LastObserver(o, this._obj, this.source));\n };\n\n return LastObservable;\n }(ObservableBase));\n\n var LastObserver = (function(__super__) {\n inherits(LastObserver, __super__);\n function LastObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n this._hv = false;\n this._v = null;\n __super__.call(this);\n }\n\n LastObserver.prototype.next = function (x) {\n var shouldYield = false;\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n Boolean(res) && (shouldYield = true);\n } else if (!this._obj.predicate) {\n shouldYield = true;\n }\n if (shouldYield) {\n this._hv = true;\n this._v = x;\n }\n };\n LastObserver.prototype.error = function (e) { this._o.onError(e); };\n LastObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n this._o.onCompleted();\n }\n else if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return LastObserver;\n }(AbstractObserver));\n\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.last = function () {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new LastObservable(this, obj);\n };\n\n var FindValueObserver = (function(__super__) {\n inherits(FindValueObserver, __super__);\n function FindValueObserver(observer, source, callback, yieldIndex) {\n this._o = observer;\n this._s = source;\n this._cb = callback;\n this._y = yieldIndex;\n this._i = 0;\n __super__.call(this);\n }\n\n FindValueObserver.prototype.next = function (x) {\n var shouldRun = tryCatch(this._cb)(x, this._i, this._s);\n if (shouldRun === errorObj) { return this._o.onError(shouldRun.e); }\n if (shouldRun) {\n this._o.onNext(this._y ? this._i : x);\n this._o.onCompleted();\n } else {\n this._i++;\n }\n };\n\n FindValueObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n FindValueObserver.prototype.completed = function () {\n this._y && this._o.onNext(-1);\n this._o.onCompleted();\n };\n\n return FindValueObserver;\n }(AbstractObserver));\n\n function findValue (source, predicate, thisArg, yieldIndex) {\n var callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n return source.subscribe(new FindValueObserver(o, source, callback, yieldIndex));\n }, source);\n }\n\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.\n */\n observableProto.find = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, false);\n };\n\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns\n * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.\n */\n observableProto.findIndex = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, true);\n };\n\n var ToSetObservable = (function (__super__) {\n inherits(ToSetObservable, __super__);\n function ToSetObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToSetObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ToSetObserver(o));\n };\n\n return ToSetObservable;\n }(ObservableBase));\n\n var ToSetObserver = (function (__super__) {\n inherits(ToSetObserver, __super__);\n function ToSetObserver(o) {\n this._o = o;\n this._s = new root.Set();\n __super__.call(this);\n }\n\n ToSetObserver.prototype.next = function (x) {\n this._s.add(x);\n };\n\n ToSetObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ToSetObserver.prototype.completed = function () {\n this._o.onNext(this._s);\n this._o.onCompleted();\n };\n\n return ToSetObserver;\n }(AbstractObserver));\n\n /**\n * Converts the observable sequence to a Set if it exists.\n * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.\n */\n observableProto.toSet = function () {\n if (typeof root.Set === 'undefined') { throw new TypeError(); }\n return new ToSetObservable(this);\n };\n\n var ToMapObservable = (function (__super__) {\n inherits(ToMapObservable, __super__);\n function ToMapObservable(source, k, e) {\n this.source = source;\n this._k = k;\n this._e = e;\n __super__.call(this);\n }\n\n ToMapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ToMapObserver(o, this._k, this._e));\n };\n\n return ToMapObservable;\n }(ObservableBase));\n\n var ToMapObserver = (function (__super__) {\n inherits(ToMapObserver, __super__);\n function ToMapObserver(o, k, e) {\n this._o = o;\n this._k = k;\n this._e = e;\n this._m = new root.Map();\n __super__.call(this);\n }\n\n ToMapObserver.prototype.next = function (x) {\n var key = tryCatch(this._k)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n var elem = x;\n if (this._e) {\n elem = tryCatch(this._e)(x);\n if (elem === errorObj) { return this._o.onError(elem.e); }\n }\n\n this._m.set(key, elem);\n };\n\n ToMapObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ToMapObserver.prototype.completed = function () {\n this._o.onNext(this._m);\n this._o.onCompleted();\n };\n\n return ToMapObserver;\n }(AbstractObserver));\n\n /**\n * Converts the observable sequence to a Map if it exists.\n * @param {Function} keySelector A function which produces the key for the Map.\n * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.\n * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.\n */\n observableProto.toMap = function (keySelector, elementSelector) {\n if (typeof root.Map === 'undefined') { throw new TypeError(); }\n return new ToMapObservable(this, keySelector, elementSelector);\n };\n\n var SliceObservable = (function (__super__) {\n inherits(SliceObservable, __super__);\n function SliceObservable(source, b, e) {\n this.source = source;\n this._b = b;\n this._e = e;\n __super__.call(this);\n }\n\n SliceObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SliceObserver(o, this._b, this._e));\n };\n\n return SliceObservable;\n }(ObservableBase));\n\n var SliceObserver = (function (__super__) {\n inherits(SliceObserver, __super__);\n\n function SliceObserver(o, b, e) {\n this._o = o;\n this._b = b;\n this._e = e;\n this._i = 0;\n __super__.call(this);\n }\n\n SliceObserver.prototype.next = function (x) {\n if (this._i >= this._b) {\n if (this._e === this._i) {\n this._o.onCompleted();\n } else {\n this._o.onNext(x);\n }\n }\n this._i++;\n };\n SliceObserver.prototype.error = function (e) { this._o.onError(e); };\n SliceObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SliceObserver;\n }(AbstractObserver));\n\n /*\n * The slice() method returns a shallow copy of a portion of an Observable into a new Observable object.\n * Unlike the array version, this does not support negative numbers for being or end.\n * @param {Number} [begin] Zero-based index at which to begin extraction. If omitted, this will default to zero.\n * @param {Number} [end] Zero-based index at which to end extraction. slice extracts up to but not including end.\n * If omitted, this will emit the rest of the Observable object.\n * @returns {Observable} A shallow copy of a portion of an Observable into a new Observable object.\n */\n observableProto.slice = function (begin, end) {\n var start = begin || 0;\n if (start < 0) { throw new Rx.ArgumentOutOfRangeError(); }\n if (typeof end === 'number' && end < start) {\n throw new Rx.ArgumentOutOfRangeError();\n }\n return new SliceObservable(this, start, end);\n };\n\n var LastIndexOfObservable = (function (__super__) {\n inherits(LastIndexOfObservable, __super__);\n function LastIndexOfObservable(source, e, n) {\n this.source = source;\n this._e = e;\n this._n = n;\n __super__.call(this);\n }\n\n LastIndexOfObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new LastIndexOfObserver(o, this._e, this._n));\n };\n\n return LastIndexOfObservable;\n }(ObservableBase));\n\n var LastIndexOfObserver = (function (__super__) {\n inherits(LastIndexOfObserver, __super__);\n function LastIndexOfObserver(o, e, n) {\n this._o = o;\n this._e = e;\n this._n = n;\n this._v = 0;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n LastIndexOfObserver.prototype.next = function (x) {\n if (this._i >= this._n && x === this._e) {\n this._hv = true;\n this._v = this._i;\n }\n this._i++;\n };\n LastIndexOfObserver.prototype.error = function (e) { this._o.onError(e); };\n LastIndexOfObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n } else {\n this._o.onNext(-1);\n }\n this._o.onCompleted();\n };\n\n return LastIndexOfObserver;\n }(AbstractObserver));\n\n /**\n * Returns the last index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the last index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.lastIndexOf = function(searchElement, fromIndex) {\n var n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n return new LastIndexOfObservable(this, searchElement, n);\n };\n\n Observable.wrap = function (fn) {\n createObservable.__generatorFunction__ = fn;\n return createObservable;\n\n function createObservable() {\n return Observable.spawn.call(this, fn.apply(this, arguments));\n }\n };\n\n var spawn = Observable.spawn = function () {\n var gen = arguments[0], self = this, args = [];\n for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n\n return new AnonymousObservable(function (o) {\n var g = new CompositeDisposable();\n\n if (isFunction(gen)) { gen = gen.apply(self, args); }\n if (!gen || !isFunction(gen.next)) {\n o.onNext(gen);\n return o.onCompleted();\n }\n\n processGenerator();\n\n function processGenerator(res) {\n var ret = tryCatch(gen.next).call(gen, res);\n if (ret === errorObj) { return o.onError(ret.e); }\n next(ret);\n }\n\n function onError(err) {\n var ret = tryCatch(gen.next).call(gen, err);\n if (ret === errorObj) { return o.onError(ret.e); }\n next(ret);\n }\n\n function next(ret) {\n if (ret.done) {\n o.onNext(ret.value);\n o.onCompleted();\n return;\n }\n var value = toObservable.call(self, ret.value);\n if (Observable.isObservable(value)) {\n g.add(value.subscribe(processGenerator, onError));\n } else {\n onError(new TypeError('type not supported'));\n }\n }\n\n return g;\n });\n };\n\n function toObservable(obj) {\n if (!obj) { return obj; }\n if (Observable.isObservable(obj)) { return obj; }\n if (isPromise(obj)) { return Observable.fromPromise(obj); }\n if (isGeneratorFunction(obj) || isGenerator(obj)) { return spawn.call(this, obj); }\n if (isFunction(obj)) { return thunkToObservable.call(this, obj); }\n if (isArrayLike(obj) || isIterable(obj)) { return arrayToObservable.call(this, obj); }\n if (isObject(obj)) {return objectToObservable.call(this, obj);}\n return obj;\n }\n\n function arrayToObservable (obj) {\n return Observable.from(obj)\n .flatMap(toObservable)\n .toArray();\n }\n\n function objectToObservable (obj) {\n var results = new obj.constructor(), keys = Object.keys(obj), observables = [];\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i];\n var observable = toObservable.call(this, obj[key]);\n\n if(observable && Observable.isObservable(observable)) {\n defer(observable, key);\n } else {\n results[key] = obj[key];\n }\n }\n\n return Observable.forkJoin.apply(Observable, observables).map(function() {\n return results;\n });\n\n\n function defer (observable, key) {\n results[key] = undefined;\n observables.push(observable.map(function (next) {\n results[key] = next;\n }));\n }\n }\n\n function thunkToObservable(fn) {\n var self = this;\n return new AnonymousObservable(function (o) {\n fn.call(self, function () {\n var err = arguments[0], res = arguments[1];\n if (err) { return o.onError(err); }\n if (arguments.length > 2) {\n var args = [];\n for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n res = args;\n }\n o.onNext(res);\n o.onCompleted();\n });\n });\n }\n\n function isGenerator(obj) {\n return isFunction (obj.next) && isFunction (obj.throw);\n }\n\n function isGeneratorFunction(obj) {\n var ctor = obj.constructor;\n if (!ctor) { return false; }\n if (ctor.name === 'GeneratorFunction' || ctor.displayName === 'GeneratorFunction') { return true; }\n return isGenerator(ctor.prototype);\n }\n\n function isObject(val) {\n return Object == val.constructor;\n }\n\n /**\n * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.\n *\n * @example\n * var res = Rx.Observable.start(function () { console.log('hello'); });\n * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);\n * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);\n *\n * @param {Function} func Function to run asynchronously.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n *\n * Remarks\n * * The function is called immediately, not during the subscription of the resulting sequence.\n * * Multiple subscriptions to the resulting sequence can observe the function's result.\n */\n Observable.start = function (func, context, scheduler) {\n return observableToAsync(func, context, scheduler)();\n };\n\n /**\n * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.\n * @param {Function} function Function to convert to an asynchronous function.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Function} Asynchronous function.\n */\n var observableToAsync = Observable.toAsync = function (func, context, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return function () {\n var args = arguments,\n subject = new AsyncSubject();\n\n scheduler.schedule(null, function () {\n var result;\n try {\n result = func.apply(context, args);\n } catch (e) {\n subject.onError(e);\n return;\n }\n subject.onNext(result);\n subject.onCompleted();\n });\n return subject.asObservable();\n };\n };\n\nfunction createCbObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createCbHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createCbHandler(o, ctx, selector) {\n return function handler () {\n var len = arguments.length, results = new Array(len);\n for(var i = 0; i < len; i++) { results[i] = arguments[i]; }\n\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a callback function to an observable sequence.\n *\n * @param {Function} fn Function with a callback as the last parameter to convert to an Observable sequence.\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.\n * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.\n */\nObservable.fromCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createCbObservable(fn, ctx, selector, args);\n };\n};\n\nfunction createNodeObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createNodeHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createNodeHandler(o, ctx, selector) {\n return function handler () {\n var err = arguments[0];\n if (err) { return o.onError(err); }\n\n var len = arguments.length, results = [];\n for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }\n\n if (isFunction(selector)) {\n var results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.\n * @param {Function} fn The function to call\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.\n * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.\n */\nObservable.fromNodeCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createNodeObservable(fn, ctx, selector, args);\n };\n};\n\n function ListenDisposable(e, n, fn) {\n this._e = e;\n this._n = n;\n this._fn = fn;\n this._e.addEventListener(this._n, this._fn, false);\n this.isDisposed = false;\n }\n ListenDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this._e.removeEventListener(this._n, this._fn, false);\n this.isDisposed = true;\n }\n };\n\n function createEventListener (el, eventName, handler) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var elemToString = Object.prototype.toString.call(el);\n if (elemToString === '[object NodeList]' || elemToString === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler));\n }\n } else if (el) {\n disposables.add(new ListenDisposable(el, eventName, handler));\n }\n\n return disposables;\n }\n\n /**\n * Configuration option to determine whether to use native events only\n */\n Rx.config.useNativeEvents = false;\n\n function eventHandler(o, selector) {\n return function handler () {\n var results = arguments[0];\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(null, arguments);\n if (results === errorObj) { return o.onError(results.e); }\n }\n o.onNext(results);\n };\n }\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n Observable.fromEvent = function (element, eventName, selector) {\n // Node.js specific\n if (element.addListener) {\n return fromEventPattern(\n function (h) { element.addListener(eventName, h); },\n function (h) { element.removeListener(eventName, h); },\n selector);\n }\n\n // Use only if non-native events are allowed\n if (!Rx.config.useNativeEvents) {\n // Handles jq, Angular.js, Zepto, Marionette, Ember.js\n if (typeof element.on === 'function' && typeof element.off === 'function') {\n return fromEventPattern(\n function (h) { element.on(eventName, h); },\n function (h) { element.off(eventName, h); },\n selector);\n }\n }\n\n return new AnonymousObservable(function (o) {\n return createEventListener(\n element,\n eventName,\n eventHandler(o, selector));\n }).publish().refCount();\n };\n\n /**\n * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.\n * @param {Function} addHandler The function to add a handler to the emitter.\n * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @param {Scheduler} [scheduler] A scheduler used to schedule the remove handler.\n * @returns {Observable} An observable sequence which wraps an event from an event emitter\n */\n var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (o) {\n function innerHandler () {\n var result = arguments[0];\n if (isFunction(selector)) {\n result = tryCatch(selector).apply(null, arguments);\n if (result === errorObj) { return o.onError(result.e); }\n }\n o.onNext(result);\n }\n\n var returnValue = addHandler(innerHandler);\n return disposableCreate(function () {\n isFunction(removeHandler) && removeHandler(innerHandler, returnValue);\n });\n }).publish().refCount();\n };\n\n /**\n * Invokes the asynchronous function, surfacing the result through an observable sequence.\n * @param {Function} functionAsync Asynchronous function which returns a Promise to run.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n */\n Observable.startAsync = function (functionAsync) {\n var promise = tryCatch(functionAsync)();\n if (promise === errorObj) { return observableThrow(promise.e); }\n return observableFromPromise(promise);\n };\n\n var PausableObservable = (function (__super__) {\n inherits(PausableObservable, __super__);\n function PausableObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this);\n }\n\n PausableObservable.prototype._subscribe = function (o) {\n var conn = this.source.publish(),\n subscription = conn.subscribe(o),\n connection = disposableEmpty;\n\n var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {\n if (b) {\n connection = conn.connect();\n } else {\n connection.dispose();\n connection = disposableEmpty;\n }\n });\n\n return new NAryDisposable([subscription, connection, pausable]);\n };\n\n PausableObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausable(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausable = function (pauser) {\n return new PausableObservable(this, pauser);\n };\n\n function combineLatestSource(source, subject, resultSelector) {\n return new AnonymousObservable(function (o) {\n var hasValue = [false, false],\n hasValueAll = false,\n isDone = false,\n values = new Array(2),\n err;\n\n function next(x, i) {\n values[i] = x;\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n if (err) { return o.onError(err); }\n var res = tryCatch(resultSelector).apply(null, values);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n }\n isDone && values[1] && o.onCompleted();\n }\n\n return new BinaryDisposable(\n source.subscribe(\n function (x) {\n next(x, 0);\n },\n function (e) {\n if (values[1]) {\n o.onError(e);\n } else {\n err = e;\n }\n },\n function () {\n isDone = true;\n values[1] && o.onCompleted();\n }),\n subject.subscribe(\n function (x) {\n next(x, 1);\n },\n function (e) { o.onError(e); },\n function () {\n isDone = true;\n next(true, 1);\n })\n );\n }, source);\n }\n\n var PausableBufferedObservable = (function (__super__) {\n inherits(PausableBufferedObservable, __super__);\n function PausableBufferedObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this);\n }\n\n PausableBufferedObservable.prototype._subscribe = function (o) {\n var q = [], previousShouldFire;\n\n function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } }\n\n var subscription =\n combineLatestSource(\n this.source,\n this.pauser.startWith(false).distinctUntilChanged(),\n function (data, shouldFire) {\n return { data: data, shouldFire: shouldFire };\n })\n .subscribe(\n function (results) {\n if (previousShouldFire !== undefined && results.shouldFire !== previousShouldFire) {\n previousShouldFire = results.shouldFire;\n // change in shouldFire\n if (results.shouldFire) { drainQueue(); }\n } else {\n previousShouldFire = results.shouldFire;\n // new data\n if (results.shouldFire) {\n o.onNext(results.data);\n } else {\n q.push(results.data);\n }\n }\n },\n function (err) {\n drainQueue();\n o.onError(err);\n },\n function () {\n drainQueue();\n o.onCompleted();\n }\n );\n return subscription; \n };\n\n PausableBufferedObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableBufferedObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableBufferedObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,\n * and yields the values that were buffered while paused.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausableBuffered(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausableBuffered = function (subject) {\n return new PausableBufferedObservable(this, subject);\n };\n\n var ControlledObservable = (function (__super__) {\n inherits(ControlledObservable, __super__);\n function ControlledObservable (source, enableQueue, scheduler) {\n __super__.call(this);\n this.subject = new ControlledSubject(enableQueue, scheduler);\n this.source = source.multicast(this.subject).refCount();\n }\n\n ControlledObservable.prototype._subscribe = function (o) {\n return this.source.subscribe(o);\n };\n\n ControlledObservable.prototype.request = function (numberOfItems) {\n return this.subject.request(numberOfItems == null ? -1 : numberOfItems);\n };\n\n return ControlledObservable;\n\n }(Observable));\n\n var ControlledSubject = (function (__super__) {\n inherits(ControlledSubject, __super__);\n function ControlledSubject(enableQueue, scheduler) {\n enableQueue == null && (enableQueue = true);\n\n __super__.call(this);\n this.subject = new Subject();\n this.enableQueue = enableQueue;\n this.queue = enableQueue ? [] : null;\n this.requestedCount = 0;\n this.requestedDisposable = null;\n this.error = null;\n this.hasFailed = false;\n this.hasCompleted = false;\n this.scheduler = scheduler || currentThreadScheduler;\n }\n\n addProperties(ControlledSubject.prototype, Observer, {\n _subscribe: function (o) {\n return this.subject.subscribe(o);\n },\n onCompleted: function () {\n this.hasCompleted = true;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onCompleted();\n this.disposeCurrentRequest();\n } else {\n this.queue.push(Notification.createOnCompleted());\n }\n },\n onError: function (error) {\n this.hasFailed = true;\n this.error = error;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onError(error);\n this.disposeCurrentRequest();\n } else {\n this.queue.push(Notification.createOnError(error));\n }\n },\n onNext: function (value) {\n if (this.requestedCount <= 0) {\n this.enableQueue && this.queue.push(Notification.createOnNext(value));\n } else {\n (this.requestedCount-- === 0) && this.disposeCurrentRequest();\n this.subject.onNext(value);\n }\n },\n _processRequest: function (numberOfItems) {\n if (this.enableQueue) {\n while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) {\n var first = this.queue.shift();\n first.accept(this.subject);\n if (first.kind === 'N') {\n numberOfItems--;\n } else {\n this.disposeCurrentRequest();\n this.queue = [];\n }\n }\n }\n\n return numberOfItems;\n },\n request: function (number) {\n this.disposeCurrentRequest();\n var self = this;\n\n this.requestedDisposable = this.scheduler.schedule(number,\n function(s, i) {\n var remaining = self._processRequest(i);\n var stopped = self.hasCompleted || self.hasFailed;\n if (!stopped && remaining > 0) {\n self.requestedCount = remaining;\n\n return disposableCreate(function () {\n self.requestedCount = 0;\n });\n // Scheduled item is still in progress. Return a new\n // disposable to allow the request to be interrupted\n // via dispose.\n }\n });\n\n return this.requestedDisposable;\n },\n disposeCurrentRequest: function () {\n if (this.requestedDisposable) {\n this.requestedDisposable.dispose();\n this.requestedDisposable = null;\n }\n }\n });\n\n return ControlledSubject;\n }(Observable));\n\n /**\n * Attaches a controller to the observable sequence with the ability to queue.\n * @example\n * var source = Rx.Observable.interval(100).controlled();\n * source.request(3); // Reads 3 values\n * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request\n * @param {Scheduler} scheduler determines how the requests will be scheduled\n * @returns {Observable} The observable sequence which only propagates values on request.\n */\n observableProto.controlled = function (enableQueue, scheduler) {\n\n if (enableQueue && isScheduler(enableQueue)) {\n scheduler = enableQueue;\n enableQueue = true;\n }\n\n if (enableQueue == null) { enableQueue = true; }\n return new ControlledObservable(this, enableQueue, scheduler);\n };\n\n var StopAndWaitObservable = (function (__super__) {\n inherits(StopAndWaitObservable, __super__);\n function StopAndWaitObservable (source) {\n __super__.call(this);\n this.source = source;\n }\n\n function scheduleMethod(s, self) {\n self.source.request(1);\n }\n\n StopAndWaitObservable.prototype._subscribe = function (o) {\n this.subscription = this.source.subscribe(new StopAndWaitObserver(o, this, this.subscription));\n return new BinaryDisposable(\n this.subscription,\n defaultScheduler.schedule(this, scheduleMethod)\n );\n };\n\n var StopAndWaitObserver = (function (__sub__) {\n inherits(StopAndWaitObserver, __sub__);\n function StopAndWaitObserver (observer, observable, cancel) {\n __sub__.call(this);\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.scheduleDisposable = null;\n }\n\n StopAndWaitObserver.prototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n StopAndWaitObserver.prototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n function innerScheduleMethod(s, self) {\n self.observable.source.request(1);\n }\n\n StopAndWaitObserver.prototype.next = function (value) {\n this.observer.onNext(value);\n this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod);\n };\n\n StopAndWaitObservable.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n if (this.scheduleDisposable) {\n this.scheduleDisposable.dispose();\n this.scheduleDisposable = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return StopAndWaitObserver;\n }(AbstractObserver));\n\n return StopAndWaitObservable;\n }(Observable));\n\n\n /**\n * Attaches a stop and wait observable to the current observable.\n * @returns {Observable} A stop and wait observable.\n */\n ControlledObservable.prototype.stopAndWait = function () {\n return new StopAndWaitObservable(this);\n };\n\n var WindowedObservable = (function (__super__) {\n inherits(WindowedObservable, __super__);\n function WindowedObservable(source, windowSize) {\n __super__.call(this);\n this.source = source;\n this.windowSize = windowSize;\n }\n\n function scheduleMethod(s, self) {\n self.source.request(self.windowSize);\n }\n\n WindowedObservable.prototype._subscribe = function (o) {\n this.subscription = this.source.subscribe(new WindowedObserver(o, this, this.subscription));\n return new BinaryDisposable(\n this.subscription,\n defaultScheduler.schedule(this, scheduleMethod)\n );\n };\n\n var WindowedObserver = (function (__sub__) {\n inherits(WindowedObserver, __sub__);\n function WindowedObserver(observer, observable, cancel) {\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.received = 0;\n this.scheduleDisposable = null;\n __sub__.call(this);\n }\n\n WindowedObserver.prototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n WindowedObserver.prototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n function innerScheduleMethod(s, self) {\n self.observable.source.request(self.observable.windowSize);\n }\n\n WindowedObserver.prototype.next = function (value) {\n this.observer.onNext(value);\n this.received = ++this.received % this.observable.windowSize;\n this.received === 0 && (this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod));\n };\n\n WindowedObserver.prototype.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n if (this.scheduleDisposable) {\n this.scheduleDisposable.dispose();\n this.scheduleDisposable = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return WindowedObserver;\n }(AbstractObserver));\n\n return WindowedObservable;\n }(Observable));\n\n /**\n * Creates a sliding windowed observable based upon the window size.\n * @param {Number} windowSize The number of items in the window\n * @returns {Observable} A windowed observable based upon the window size.\n */\n ControlledObservable.prototype.windowed = function (windowSize) {\n return new WindowedObservable(this, windowSize);\n };\n\n /**\n * Pipes the existing Observable sequence into a Node.js Stream.\n * @param {Stream} dest The destination Node.js stream.\n * @returns {Stream} The destination stream.\n */\n observableProto.pipe = function (dest) {\n var source = this.pausableBuffered();\n\n function onDrain() {\n source.resume();\n }\n\n dest.addListener('drain', onDrain);\n\n source.subscribe(\n function (x) {\n !dest.write(String(x)) && source.pause();\n },\n function (err) {\n dest.emit('error', err);\n },\n function () {\n // Hack check because STDIO is not closable\n !dest._isStdio && dest.end();\n dest.removeListener('drain', onDrain);\n });\n\n source.resume();\n\n return dest;\n };\n\n var MulticastObservable = (function (__super__) {\n inherits(MulticastObservable, __super__);\n function MulticastObservable(source, fn1, fn2) {\n this.source = source;\n this._fn1 = fn1;\n this._fn2 = fn2;\n __super__.call(this);\n }\n\n MulticastObservable.prototype.subscribeCore = function (o) {\n var connectable = this.source.multicast(this._fn1());\n return new BinaryDisposable(this._fn2(connectable).subscribe(o), connectable.connect());\n };\n\n return MulticastObservable;\n }(ObservableBase));\n\n /**\n * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each\n * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's\n * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.\n *\n * @example\n * 1 - res = source.multicast(observable);\n * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });\n *\n * @param {Function|Subject} subjectOrSubjectSelector\n * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.\n * Or:\n * Subject to push source elements into.\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.value = null;\n this.error = null;\n }\n });\n\n return BehaviorSubject;\n }(Observable));\n\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.\n */\n var ReplaySubject = Rx.ReplaySubject = (function (__super__) {\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function createRemovableDisposable(subject, observer) {\n return disposableCreate(function () {\n observer.dispose();\n !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);\n });\n }\n\n inherits(ReplaySubject, __super__);\n\n /**\n * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.\n * @param {Number} [bufferSize] Maximum element count of the replay buffer.\n * @param {Number} [windowSize] Maximum time length of the replay buffer.\n * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.\n */\n function ReplaySubject(bufferSize, windowSize, scheduler) {\n this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;\n this.windowSize = windowSize == null ? maxSafeInteger : windowSize;\n this.scheduler = scheduler || currentThreadScheduler;\n this.q = [];\n this.observers = [];\n this.isStopped = false;\n this.isDisposed = false;\n this.hasError = false;\n this.error = null;\n __super__.call(this);\n }\n\n addProperties(ReplaySubject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n checkDisposed(this);\n var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so);\n\n this._trim(this.scheduler.now());\n this.observers.push(so);\n\n for (var i = 0, len = this.q.length; i < len; i++) {\n so.onNext(this.q[i].value);\n }\n\n if (this.hasError) {\n so.onError(this.error);\n } else if (this.isStopped) {\n so.onCompleted();\n }\n\n so.ensureActive();\n return subscription;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n return this.observers.length > 0;\n },\n _trim: function (now) {\n while (this.q.length > this.bufferSize) {\n this.q.shift();\n }\n while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {\n this.q.shift();\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n var now = this.scheduler.now();\n this.q.push({ interval: now, value: value });\n this._trim(now);\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onNext(value);\n observer.ensureActive();\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onError(error);\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onCompleted();\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n return ReplaySubject;\n }(Observable));\n\n var RefCountObservable = (function (__super__) {\n inherits(RefCountObservable, __super__);\n function RefCountObservable(source) {\n this.source = source;\n this._count = 0;\n this._connectableSubscription = null;\n __super__.call(this);\n }\n\n RefCountObservable.prototype.subscribeCore = function (o) {\n var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o);\n shouldConnect && (this._connectableSubscription = this.source.connect());\n return new RefCountDisposable(this, subscription);\n };\n\n function RefCountDisposable(p, s) {\n this._p = p;\n this._s = s;\n this.isDisposed = false;\n }\n\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._s.dispose();\n --this._p._count === 0 && this._p._connectableSubscription.dispose();\n }\n };\n\n return RefCountObservable;\n }(ObservableBase));\n\n var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {\n inherits(ConnectableObservable, __super__);\n function ConnectableObservable(source, subject) {\n this.source = source;\n this._hasSubscription = false;\n this._subscription = null;\n this._sourceObservable = source.asObservable();\n this._subject = subject;\n __super__.call(this);\n }\n\n function ConnectDisposable(parent) {\n this._p = parent;\n this.isDisposed = false;\n }\n\n ConnectDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._p._hasSubscription = false;\n }\n };\n\n ConnectableObservable.prototype.connect = function () {\n if (!this._hasSubscription) {\n this._hasSubscription = true;\n this._subscription = new BinaryDisposable(\n this._sourceObservable.subscribe(this._subject),\n new ConnectDisposable(this)\n );\n }\n return this._subscription;\n };\n\n ConnectableObservable.prototype._subscribe = function (o) {\n return this._subject.subscribe(o);\n };\n\n ConnectableObservable.prototype.refCount = function () {\n return new RefCountObservable(this);\n };\n\n return ConnectableObservable;\n }(Observable));\n\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence\n * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`)\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source.\n */\n observableProto.singleInstance = function() {\n var source = this, hasObservable = false, observable;\n\n function getObservable() {\n if (!hasObservable) {\n hasObservable = true;\n observable = source.finally(function() { hasObservable = false; }).publish().refCount();\n }\n return observable;\n }\n\n return new AnonymousObservable(function(o) {\n return getObservable().subscribe(o);\n });\n };\n\n /**\n * Correlates the elements of two sequences based on overlapping durations.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable();\n var leftDone = false, rightDone = false;\n var leftId = 0, rightId = 0;\n var leftMap = new Map(), rightMap = new Map();\n var handleError = function (e) { o.onError(e); };\n\n group.add(left.subscribe(\n function (value) {\n var id = leftId++, md = new SingleAssignmentDisposable();\n\n leftMap.set(id, value);\n group.add(md);\n\n var duration = tryCatch(leftDurationSelector)(value);\n if (duration === errorObj) { return o.onError(duration.e); }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n handleError,\n function () {\n leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted();\n group.remove(md);\n }));\n\n rightMap.forEach(function (v) {\n var result = tryCatch(resultSelector)(value, v);\n if (result === errorObj) { return o.onError(result.e); }\n o.onNext(result);\n });\n },\n handleError,\n function () {\n leftDone = true;\n (rightDone || leftMap.size === 0) && o.onCompleted();\n })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++, md = new SingleAssignmentDisposable();\n\n rightMap.set(id, value);\n group.add(md);\n\n var duration = tryCatch(rightDurationSelector)(value);\n if (duration === errorObj) { return o.onError(duration.e); }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n handleError,\n function () {\n rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted();\n group.remove(md);\n }));\n\n leftMap.forEach(function (v) {\n var result = tryCatch(resultSelector)(v, value);\n if (result === errorObj) { return o.onError(result.e); }\n o.onNext(result);\n });\n },\n handleError,\n function () {\n rightDone = true;\n (leftDone || rightMap.size === 0) && o.onCompleted();\n })\n );\n return group;\n }, left);\n };\n\n /**\n * Correlates the elements of two sequences based on overlapping durations, and groups the results.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable();\n var r = new RefCountDisposable(group);\n var leftMap = new Map(), rightMap = new Map();\n var leftId = 0, rightId = 0;\n var handleError = function (e) { return function (v) { v.onError(e); }; };\n\n function handleError(e) { };\n\n group.add(left.subscribe(\n function (value) {\n var s = new Subject();\n var id = leftId++;\n leftMap.set(id, s);\n\n var result = tryCatch(resultSelector)(value, addRef(s, r));\n if (result === errorObj) {\n leftMap.forEach(handleError(result.e));\n return o.onError(result.e);\n }\n o.onNext(result);\n\n rightMap.forEach(function (v) { s.onNext(v); });\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var duration = tryCatch(leftDurationSelector)(value);\n if (duration === errorObj) {\n leftMap.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n leftMap['delete'](id) && s.onCompleted();\n group.remove(md);\n }));\n },\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () { o.onCompleted(); })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n rightMap.set(id, value);\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var duration = tryCatch(rightDurationSelector)(value);\n if (duration === errorObj) {\n leftMap.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n rightMap['delete'](id);\n group.remove(md);\n }));\n\n leftMap.forEach(function (v) { v.onNext(value); });\n },\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n })\n );\n\n return r;\n }, left);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers.\n * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.buffer = function () {\n return this.window.apply(this, arguments)\n .flatMap(toArray);\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows.\n *\n * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) {\n if (arguments.length === 1 && typeof arguments[0] !== 'function') {\n return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector);\n }\n return typeof windowOpeningsOrClosingSelector === 'function' ?\n observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) :\n observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector);\n };\n\n function observableWindowWithOpenings(windowOpenings, windowClosingSelector) {\n return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) {\n return win;\n });\n }\n\n function observableWindowWithBoundaries(windowBoundaries) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var win = new Subject(),\n d = new CompositeDisposable(),\n r = new RefCountDisposable(d);\n\n observer.onNext(addRef(win, r));\n\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries));\n\n d.add(windowBoundaries.subscribe(function (w) {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n return r;\n }, source);\n }\n\n function observableWindowWithClosingSelector(windowClosingSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n r = new RefCountDisposable(d),\n win = new Subject();\n observer.onNext(addRef(win, r));\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n function createWindowClose () {\n var windowClose;\n try {\n windowClose = windowClosingSelector();\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(windowClose) && (windowClose = observableFromPromise(windowClose));\n\n var m1 = new SingleAssignmentDisposable();\n m.setDisposable(m1);\n m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n createWindowClose();\n }));\n }\n\n createWindowClose();\n return r;\n }, source);\n }\n\n /**\n * Returns a new observable that triggers on the second and subsequent triggerings of the input observable.\n * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.\n * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.\n * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.\n */\n observableProto.pairwise = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var previous, hasPrevious = false;\n return source.subscribe(\n function (x) {\n if (hasPrevious) {\n observer.onNext([previous, x]);\n } else {\n hasPrevious = true;\n }\n previous = x;\n },\n observer.onError.bind(observer),\n observer.onCompleted.bind(observer));\n }, source);\n };\n\n /**\n * Returns two observables which partition the observations of the source by the given function.\n * The first will trigger observations for those values for which the predicate returns true.\n * The second will trigger observations for those values where the predicate returns false.\n * The predicate is executed once for each subscribed observer.\n * Both also propagate all error observations arising from the source and each completes\n * when the source completes.\n * @param {Function} predicate\n * The function to determine which output Observable will trigger a particular observation.\n * @returns {Array}\n * An array of observables. The first triggers when the predicate returns true,\n * and the second triggers when the predicate returns false.\n */\n observableProto.partition = function(predicate, thisArg) {\n return [\n this.filter(predicate, thisArg),\n this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); })\n ];\n };\n\n var WhileEnumerable = (function(__super__) {\n inherits(WhileEnumerable, __super__);\n function WhileEnumerable(c, s) {\n this.c = c;\n this.s = s;\n }\n WhileEnumerable.prototype[$iterator$] = function () {\n var self = this;\n return {\n next: function () {\n return self.c() ?\n { done: false, value: self.s } :\n { done: true, value: void 0 };\n }\n };\n };\n return WhileEnumerable;\n }(Enumerable));\n \n function enumerableWhile(condition, source) {\n return new WhileEnumerable(condition, source);\n } \n\n /**\n * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.\n * This operator allows for a fluent style of writing queries that use the same sequence multiple times.\n *\n * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.letBind = observableProto['let'] = function (func) {\n return func(this);\n };\n\n /**\n * Determines whether an observable collection contains values. \n *\n * @example\n * 1 - res = Rx.Observable.if(condition, obs1);\n * 2 - res = Rx.Observable.if(condition, obs1, obs2);\n * 3 - res = Rx.Observable.if(condition, obs1, scheduler);\n * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.\n * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.\n * @returns {Observable} An observable sequence which is either the thenSource or elseSource.\n */\n Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) {\n return observableDefer(function () {\n elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());\n\n isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));\n isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));\n\n // Assume a scheduler for empty only\n typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));\n return condition() ? thenSource : elseSourceOrScheduler;\n });\n };\n\n /**\n * Concatenates the observable sequences obtained by running the specified result selector for each element in source.\n * There is an alias for this method called 'forIn' for browsers 0) {\n isOwner = !isAcquired;\n isAcquired = true;\n }\n if (isOwner) {\n m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) {\n var work;\n if (q.length > 0) {\n work = q.shift();\n } else {\n isAcquired = false;\n return;\n }\n var m1 = new SingleAssignmentDisposable();\n d.add(m1);\n m1.setDisposable(work.subscribe(function (x) {\n o.onNext(x);\n var result = null;\n try {\n result = selector(x);\n } catch (e) {\n o.onError(e);\n }\n q.push(result);\n activeCount++;\n ensureActive();\n }, function (e) { o.onError(e); }, function () {\n d.remove(m1);\n activeCount--;\n if (activeCount === 0) {\n o.onCompleted();\n }\n }));\n self();\n }));\n }\n };\n\n q.push(source);\n activeCount++;\n ensureActive();\n return d;\n }, this);\n };\n\n /**\n * Runs all observable sequences in parallel and collect their last elements.\n *\n * @example\n * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);\n * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);\n * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.\n */\n Observable.forkJoin = function () {\n var allSources = [];\n if (Array.isArray(arguments[0])) {\n allSources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (subscriber) {\n var count = allSources.length;\n if (count === 0) {\n subscriber.onCompleted();\n return disposableEmpty;\n }\n var group = new CompositeDisposable(),\n finished = false,\n hasResults = new Array(count),\n hasCompleted = new Array(count),\n results = new Array(count);\n\n for (var idx = 0; idx < count; idx++) {\n (function (i) {\n var source = allSources[i];\n isPromise(source) && (source = observableFromPromise(source));\n group.add(\n source.subscribe(\n function (value) {\n if (!finished) {\n hasResults[i] = true;\n results[i] = value;\n }\n },\n function (e) {\n finished = true;\n subscriber.onError(e);\n group.dispose();\n },\n function () {\n if (!finished) {\n if (!hasResults[i]) {\n subscriber.onCompleted();\n return;\n }\n hasCompleted[i] = true;\n for (var ix = 0; ix < count; ix++) {\n if (!hasCompleted[ix]) { return; }\n }\n finished = true;\n subscriber.onNext(results);\n subscriber.onCompleted();\n }\n }));\n })(idx);\n }\n\n return group;\n });\n };\n\n /**\n * Runs two observable sequences in parallel and combines their last elemenets.\n * @param {Observable} second Second observable sequence.\n * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.\n * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.\n */\n observableProto.forkJoin = function (second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (observer) {\n var leftStopped = false, rightStopped = false,\n hasLeft = false, hasRight = false,\n lastLeft, lastRight,\n leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(second) && (second = observableFromPromise(second));\n\n leftSubscription.setDisposable(\n first.subscribe(function (left) {\n hasLeft = true;\n lastLeft = left;\n }, function (err) {\n rightSubscription.dispose();\n observer.onError(err);\n }, function () {\n leftStopped = true;\n if (rightStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result = tryCatch(resultSelector)(lastLeft, lastRight);\n if (result === errorObj) { return observer.onError(e); }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n rightSubscription.setDisposable(\n second.subscribe(function (right) {\n hasRight = true;\n lastRight = right;\n }, function (err) {\n leftSubscription.dispose();\n observer.onError(err);\n }, function () {\n rightStopped = true;\n if (leftStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result = tryCatch(resultSelector)(lastLeft, lastRight);\n if (result === errorObj) { return observer.onError(result.e); }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n return new BinaryDisposable(leftSubscription, rightSubscription);\n }, first);\n };\n\n /**\n * Comonadic bind operator.\n * @param {Function} selector A transform function to apply to each element.\n * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.\n * @returns {Observable} An observable sequence which results from the comonadic bind operation.\n */\n observableProto.manySelect = observableProto.extend = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return observableDefer(function () {\n var chain;\n\n return source\n .map(function (x) {\n var curr = new ChainObservable(x);\n\n chain && chain.onNext(x);\n chain = curr;\n\n return curr;\n })\n .tap(\n noop,\n function (e) { chain && chain.onError(e); },\n function () { chain && chain.onCompleted(); }\n )\n .observeOn(scheduler)\n .map(selector);\n }, source);\n };\n\n var ChainObservable = (function (__super__) {\n inherits(ChainObservable, __super__);\n function ChainObservable(head) {\n __super__.call(this);\n this.head = head;\n this.tail = new AsyncSubject();\n }\n\n addProperties(ChainObservable.prototype, Observer, {\n _subscribe: function (o) {\n var g = new CompositeDisposable();\n g.add(currentThreadScheduler.schedule(this, function (_, self) {\n o.onNext(self.head);\n g.add(self.tail.mergeAll().subscribe(o));\n }));\n\n return g;\n },\n onCompleted: function () {\n this.onNext(Observable.empty());\n },\n onError: function (e) {\n this.onNext(Observable['throw'](e));\n },\n onNext: function (v) {\n this.tail.onNext(v);\n this.tail.onCompleted();\n }\n });\n\n return ChainObservable;\n\n }(Observable));\n\n var Map = root.Map || (function () {\n function Map() {\n this.size = 0;\n this._values = [];\n this._keys = [];\n }\n\n Map.prototype['delete'] = function (key) {\n var i = this._keys.indexOf(key);\n if (i === -1) { return false; }\n this._values.splice(i, 1);\n this._keys.splice(i, 1);\n this.size--;\n return true;\n };\n\n Map.prototype.get = function (key) {\n var i = this._keys.indexOf(key);\n return i === -1 ? undefined : this._values[i];\n };\n\n Map.prototype.set = function (key, value) {\n var i = this._keys.indexOf(key);\n if (i === -1) {\n this._keys.push(key);\n this._values.push(value);\n this.size++;\n } else {\n this._values[i] = value;\n }\n return this;\n };\n\n Map.prototype.forEach = function (cb, thisArg) {\n for (var i = 0; i < this.size; i++) {\n cb.call(thisArg, this._values[i], this._keys[i]);\n }\n };\n\n return Map;\n }());\n\n /**\n * @constructor\n * Represents a join pattern over observable sequences.\n */\n function Pattern(patterns) {\n this.patterns = patterns;\n }\n\n /**\n * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.\n * @param other Observable sequence to match in addition to the current pattern.\n * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.\n */\n Pattern.prototype.and = function (other) {\n return new Pattern(this.patterns.concat(other));\n };\n\n /**\n * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.\n * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.\n * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n Pattern.prototype.thenDo = function (selector) {\n return new Plan(this, selector);\n };\n\n function Plan(expression, selector) {\n this.expression = expression;\n this.selector = selector;\n }\n\n Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {\n var self = this;\n var joinObservers = [];\n for (var i = 0, len = this.expression.patterns.length; i < len; i++) {\n joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));\n }\n var activePlan = new ActivePlan(joinObservers, function () {\n var result;\n try {\n result = self.selector.apply(self, arguments);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n }, function () {\n for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {\n joinObservers[j].removeActivePlan(activePlan);\n }\n deactivate(activePlan);\n });\n for (i = 0, len = joinObservers.length; i < len; i++) {\n joinObservers[i].addActivePlan(activePlan);\n }\n return activePlan;\n };\n\n function planCreateObserver(externalSubscriptions, observable, onError) {\n var entry = externalSubscriptions.get(observable);\n if (!entry) {\n var observer = new JoinObserver(observable, onError);\n externalSubscriptions.set(observable, observer);\n return observer;\n }\n return entry;\n }\n\n function ActivePlan(joinObserverArray, onNext, onCompleted) {\n this.joinObserverArray = joinObserverArray;\n this.onNext = onNext;\n this.onCompleted = onCompleted;\n this.joinObservers = new Map();\n for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {\n var joinObserver = this.joinObserverArray[i];\n this.joinObservers.set(joinObserver, joinObserver);\n }\n }\n\n ActivePlan.prototype.dequeue = function () {\n this.joinObservers.forEach(function (v) { v.queue.shift(); });\n };\n\n ActivePlan.prototype.match = function () {\n var i, len, hasValues = true;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n if (this.joinObserverArray[i].queue.length === 0) {\n hasValues = false;\n break;\n }\n }\n if (hasValues) {\n var firstValues = [],\n isCompleted = false;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n firstValues.push(this.joinObserverArray[i].queue[0]);\n this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);\n }\n if (isCompleted) {\n this.onCompleted();\n } else {\n this.dequeue();\n var values = [];\n for (i = 0, len = firstValues.length; i < firstValues.length; i++) {\n values.push(firstValues[i].value);\n }\n this.onNext.apply(this, values);\n }\n }\n };\n\n var JoinObserver = (function (__super__) {\n inherits(JoinObserver, __super__);\n\n function JoinObserver(source, onError) {\n __super__.call(this);\n this.source = source;\n this.onError = onError;\n this.queue = [];\n this.activePlans = [];\n this.subscription = new SingleAssignmentDisposable();\n this.isDisposed = false;\n }\n\n var JoinObserverPrototype = JoinObserver.prototype;\n\n JoinObserverPrototype.next = function (notification) {\n if (!this.isDisposed) {\n if (notification.kind === 'E') {\n return this.onError(notification.error);\n }\n this.queue.push(notification);\n var activePlans = this.activePlans.slice(0);\n for (var i = 0, len = activePlans.length; i < len; i++) {\n activePlans[i].match();\n }\n }\n };\n\n JoinObserverPrototype.error = noop;\n JoinObserverPrototype.completed = noop;\n\n JoinObserverPrototype.addActivePlan = function (activePlan) {\n this.activePlans.push(activePlan);\n };\n\n JoinObserverPrototype.subscribe = function () {\n this.subscription.setDisposable(this.source.materialize().subscribe(this));\n };\n\n JoinObserverPrototype.removeActivePlan = function (activePlan) {\n this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);\n this.activePlans.length === 0 && this.dispose();\n };\n\n JoinObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n if (!this.isDisposed) {\n this.isDisposed = true;\n this.subscription.dispose();\n }\n };\n\n return JoinObserver;\n } (AbstractObserver));\n\n /**\n * Creates a pattern that matches when both observable sequences have an available value.\n *\n * @param right Observable sequence to match with the current sequence.\n * @return {Pattern} Pattern object that matches when both observable sequences have an available value.\n */\n observableProto.and = function (right) {\n return new Pattern([this, right]);\n };\n\n /**\n * Matches when the observable sequence has an available value and projects the value.\n *\n * @param {Function} selector Selector that will be invoked for values in the source sequence.\n * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n observableProto.thenDo = function (selector) {\n return new Pattern([this]).thenDo(selector);\n };\n\n /**\n * Joins together the results from several patterns.\n *\n * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.\n * @returns {Observable} Observable sequence with the results form matching several patterns.\n */\n Observable.when = function () {\n var len = arguments.length, plans;\n if (Array.isArray(arguments[0])) {\n plans = arguments[0];\n } else {\n plans = new Array(len);\n for(var i = 0; i < len; i++) { plans[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var activePlans = [],\n externalSubscriptions = new Map();\n var outObserver = observerCreate(\n function (x) { o.onNext(x); },\n function (err) {\n externalSubscriptions.forEach(function (v) { v.onError(err); });\n o.onError(err);\n },\n function (x) { o.onCompleted(); }\n );\n try {\n for (var i = 0, len = plans.length; i < len; i++) {\n activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {\n var idx = activePlans.indexOf(activePlan);\n activePlans.splice(idx, 1);\n activePlans.length === 0 && o.onCompleted();\n }));\n }\n } catch (e) {\n observableThrow(e).subscribe(o);\n }\n var group = new CompositeDisposable();\n externalSubscriptions.forEach(function (joinObserver) {\n joinObserver.subscribe();\n group.add(joinObserver);\n });\n\n return group;\n });\n };\n\n var TimerObservable = (function(__super__) {\n inherits(TimerObservable, __super__);\n function TimerObservable(dt, s) {\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n TimerObservable.prototype.subscribeCore = function (o) {\n return this._s.scheduleFuture(o, this._dt, scheduleMethod);\n };\n\n function scheduleMethod(s, o) {\n o.onNext(0);\n o.onCompleted();\n }\n\n return TimerObservable;\n }(ObservableBase));\n\n function _observableTimer(dueTime, scheduler) {\n return new TimerObservable(dueTime, scheduler);\n }\n\n function observableTimerDateAndPeriod(dueTime, period, scheduler) {\n return new AnonymousObservable(function (observer) {\n var d = dueTime, p = normalizeTime(period);\n return scheduler.scheduleRecursiveFuture(0, d, function (count, self) {\n if (p > 0) {\n var now = scheduler.now();\n d = d + p;\n d <= now && (d = now + p);\n }\n observer.onNext(count);\n self(count + 1, new Date(d));\n });\n });\n }\n\n function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) {\n return dueTime === period ?\n new AnonymousObservable(function (observer) {\n return scheduler.schedulePeriodic(0, period, function (count) {\n observer.onNext(count);\n return count + 1;\n });\n }) :\n observableDefer(function () {\n return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler);\n });\n }\n\n /**\n * Returns an observable sequence that produces a value after each period.\n *\n * @example\n * 1 - res = Rx.Observable.interval(1000);\n * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);\n *\n * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.\n * @returns {Observable} An observable sequence that produces a value after each period.\n */\n var observableinterval = Observable.interval = function (period, scheduler) {\n return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler);\n };\n\n /**\n * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.\n * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.\n */\n var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) {\n var period;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n if (periodOrScheduler != null && typeof periodOrScheduler === 'number') {\n period = periodOrScheduler;\n } else if (isScheduler(periodOrScheduler)) {\n scheduler = periodOrScheduler;\n }\n if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) {\n return _observableTimer(dueTime, scheduler);\n }\n if (dueTime instanceof Date && period !== undefined) {\n return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler);\n }\n return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler);\n };\n\n function observableDelayRelative(source, dueTime, scheduler) {\n return new AnonymousObservable(function (o) {\n var active = false,\n cancelable = new SerialDisposable(),\n exception = null,\n q = [],\n running = false,\n subscription;\n subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) {\n var d, shouldRun;\n if (notification.value.kind === 'E') {\n q = [];\n q.push(notification);\n exception = notification.value.error;\n shouldRun = !running;\n } else {\n q.push({ value: notification.value, timestamp: notification.timestamp + dueTime });\n shouldRun = !active;\n active = true;\n }\n if (shouldRun) {\n if (exception !== null) {\n o.onError(exception);\n } else {\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) {\n var e, recurseDueTime, result, shouldRecurse;\n if (exception !== null) {\n return;\n }\n running = true;\n do {\n result = null;\n if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) {\n result = q.shift().value;\n }\n if (result !== null) {\n result.accept(o);\n }\n } while (result !== null);\n shouldRecurse = false;\n recurseDueTime = 0;\n if (q.length > 0) {\n shouldRecurse = true;\n recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now());\n } else {\n active = false;\n }\n e = exception;\n running = false;\n if (e !== null) {\n o.onError(e);\n } else if (shouldRecurse) {\n self(null, recurseDueTime);\n }\n }));\n }\n }\n });\n return new BinaryDisposable(subscription, cancelable);\n }, source);\n }\n\n function observableDelayAbsolute(source, dueTime, scheduler) {\n return observableDefer(function () {\n return observableDelayRelative(source, dueTime - scheduler.now(), scheduler);\n });\n }\n\n function delayWithSelector(source, subscriptionDelay, delayDurationSelector) {\n var subDelay, selector;\n if (isFunction(subscriptionDelay)) {\n selector = subscriptionDelay;\n } else {\n subDelay = subscriptionDelay;\n selector = delayDurationSelector;\n }\n return new AnonymousObservable(function (o) {\n var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();\n\n function start() {\n subscription.setDisposable(source.subscribe(\n function (x) {\n var delay = tryCatch(selector)(x);\n if (delay === errorObj) { return o.onError(delay.e); }\n var d = new SingleAssignmentDisposable();\n delays.add(d);\n d.setDisposable(delay.subscribe(\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n }\n ));\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n subscription.dispose();\n done();\n }\n ));\n }\n\n function done () {\n atEnd && delays.length === 0 && o.onCompleted();\n }\n\n if (!subDelay) {\n start();\n } else {\n subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start));\n }\n\n return new BinaryDisposable(subscription, delays);\n }, this);\n }\n\n /**\n * Time shifts the observable sequence by dueTime.\n * The relative time intervals between the values are preserved.\n *\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delay = function () {\n var firstArg = arguments[0];\n if (typeof firstArg === 'number' || firstArg instanceof Date) {\n var dueTime = firstArg, scheduler = arguments[1];\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return dueTime instanceof Date ?\n observableDelayAbsolute(this, dueTime, scheduler) :\n observableDelayRelative(this, dueTime, scheduler);\n } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) {\n return delayWithSelector(this, firstArg, arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n var DebounceObservable = (function (__super__) {\n inherits(DebounceObservable, __super__);\n function DebounceObservable(source, dt, s) {\n isScheduler(s) || (s = defaultScheduler);\n this.source = source;\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n DebounceObservable.prototype.subscribeCore = function (o) {\n var cancelable = new SerialDisposable();\n return new BinaryDisposable(\n this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)),\n cancelable);\n };\n\n return DebounceObservable;\n }(ObservableBase));\n\n var DebounceObserver = (function (__super__) {\n inherits(DebounceObserver, __super__);\n function DebounceObserver(observer, source, dueTime, scheduler, cancelable) {\n this._o = observer;\n this._s = source;\n this._d = dueTime;\n this._scheduler = scheduler;\n this._c = cancelable;\n this._v = null;\n this._hv = false;\n this._id = 0;\n __super__.call(this);\n }\n\n DebounceObserver.prototype.next = function (x) {\n this._hv = true;\n this._v = x;\n var currentId = ++this._id, d = new SingleAssignmentDisposable();\n this._c.setDisposable(d);\n d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) {\n self._hv && self._id === currentId && self._o.onNext(x);\n self._hv = false;\n }));\n };\n\n DebounceObserver.prototype.error = function (e) {\n this._c.dispose();\n this._o.onError(e);\n this._hv = false;\n this._id++;\n };\n\n DebounceObserver.prototype.completed = function () {\n this._c.dispose();\n this._hv && this._o.onNext(this._v);\n this._o.onCompleted();\n this._hv = false;\n this._id++;\n };\n\n return DebounceObserver;\n }(AbstractObserver));\n\n function debounceWithSelector(source, durationSelector) {\n return new AnonymousObservable(function (o) {\n var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;\n var subscription = source.subscribe(\n function (x) {\n var throttle = tryCatch(durationSelector)(x);\n if (throttle === errorObj) { return o.onError(throttle.e); }\n\n isPromise(throttle) && (throttle = observableFromPromise(throttle));\n\n hasValue = true;\n value = x;\n id++;\n var currentid = id, d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(throttle.subscribe(\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n },\n function (e) { o.onError(e); },\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n }\n ));\n },\n function (e) {\n cancelable.dispose();\n o.onError(e);\n hasValue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasValue && o.onNext(value);\n o.onCompleted();\n hasValue = false;\n id++;\n }\n );\n return new BinaryDisposable(subscription, cancelable);\n }, source);\n }\n\n observableProto.debounce = function () {\n if (isFunction (arguments[0])) {\n return debounceWithSelector(this, arguments[0]);\n } else if (typeof arguments[0] === 'number') {\n return new DebounceObservable(this, arguments[0], arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.\n * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n var source = this, timeShift;\n timeShiftOrScheduler == null && (timeShift = timeSpan);\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n if (typeof timeShiftOrScheduler === 'number') {\n timeShift = timeShiftOrScheduler;\n } else if (isScheduler(timeShiftOrScheduler)) {\n timeShift = timeSpan;\n scheduler = timeShiftOrScheduler;\n }\n return new AnonymousObservable(function (observer) {\n var groupDisposable,\n nextShift = timeShift,\n nextSpan = timeSpan,\n q = [],\n refCountDisposable,\n timerD = new SerialDisposable(),\n totalTime = 0;\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n function createTimer () {\n var m = new SingleAssignmentDisposable(),\n isSpan = false,\n isShift = false;\n timerD.setDisposable(m);\n if (nextSpan === nextShift) {\n isSpan = true;\n isShift = true;\n } else if (nextSpan < nextShift) {\n isSpan = true;\n } else {\n isShift = true;\n }\n var newTotalTime = isSpan ? nextSpan : nextShift,\n ts = newTotalTime - totalTime;\n totalTime = newTotalTime;\n if (isSpan) {\n nextSpan += timeShift;\n }\n if (isShift) {\n nextShift += timeShift;\n }\n m.setDisposable(scheduler.scheduleFuture(null, ts, function () {\n if (isShift) {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n isSpan && q.shift().onCompleted();\n createTimer();\n }));\n };\n q.push(new Subject());\n observer.onNext(addRef(q[0], refCountDisposable));\n createTimer();\n groupDisposable.add(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n },\n function (e) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); }\n observer.onError(e);\n },\n function () {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n /**\n * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a window.\n * @param {Number} count Maximum element count of a window.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new AnonymousObservable(function (observer) {\n var timerD = new SerialDisposable(),\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n n = 0,\n windowId = 0,\n s = new Subject();\n\n function createTimer(id) {\n var m = new SingleAssignmentDisposable();\n timerD.setDisposable(m);\n m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () {\n if (id !== windowId) { return; }\n n = 0;\n var newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(newId);\n }));\n }\n\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(0);\n\n groupDisposable.add(source.subscribe(\n function (x) {\n var newId = 0, newWindow = false;\n s.onNext(x);\n if (++n === count) {\n newWindow = true;\n n = 0;\n newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n }\n newWindow && createTimer(newId);\n },\n function (e) {\n s.onError(e);\n observer.onError(e);\n }, function () {\n s.onCompleted();\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.\n * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.\n * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a buffer.\n * @param {Number} count Maximum element count of a buffer.\n * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) {\n return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray);\n };\n\n var TimeIntervalObservable = (function (__super__) {\n inherits(TimeIntervalObservable, __super__);\n function TimeIntervalObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n TimeIntervalObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TimeIntervalObserver(o, this._s));\n };\n\n return TimeIntervalObservable;\n }(ObservableBase));\n\n var TimeIntervalObserver = (function (__super__) {\n inherits(TimeIntervalObserver, __super__);\n\n function TimeIntervalObserver(o, s) {\n this._o = o;\n this._s = s;\n this._l = s.now();\n __super__.call(this);\n }\n\n TimeIntervalObserver.prototype.next = function (x) {\n var now = this._s.now(), span = now - this._l;\n this._l = now;\n this._o.onNext({ value: x, interval: span });\n };\n TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); };\n TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return TimeIntervalObserver;\n }(AbstractObserver));\n\n /**\n * Records the time interval between consecutive values in an observable sequence.\n *\n * @example\n * 1 - res = source.timeInterval();\n * 2 - res = source.timeInterval(Rx.Scheduler.timeout);\n *\n * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence with time interval information on values.\n */\n observableProto.timeInterval = function (scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TimeIntervalObservable(this, scheduler);\n };\n\n var TimestampObservable = (function (__super__) {\n inherits(TimestampObservable, __super__);\n function TimestampObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n TimestampObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TimestampObserver(o, this._s));\n };\n\n return TimestampObservable;\n }(ObservableBase));\n\n var TimestampObserver = (function (__super__) {\n inherits(TimestampObserver, __super__);\n function TimestampObserver(o, s) {\n this._o = o;\n this._s = s;\n __super__.call(this);\n }\n\n TimestampObserver.prototype.next = function (x) {\n this._o.onNext({ value: x, timestamp: this._s.now() });\n };\n\n TimestampObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TimestampObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return TimestampObserver;\n }(AbstractObserver));\n\n /**\n * Records the timestamp for each value in an observable sequence.\n *\n * @example\n * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }\n * 2 - res = source.timestamp(Rx.Scheduler.default);\n *\n * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.\n * @returns {Observable} An observable sequence with timestamp information on values.\n */\n observableProto.timestamp = function (scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TimestampObservable(this, scheduler);\n };\n\n function sampleObservable(source, sampler) {\n return new AnonymousObservable(function (o) {\n var atEnd = false, value, hasValue = false;\n\n function sampleSubscribe() {\n if (hasValue) {\n hasValue = false;\n o.onNext(value);\n }\n atEnd && o.onCompleted();\n }\n\n var sourceSubscription = new SingleAssignmentDisposable();\n sourceSubscription.setDisposable(source.subscribe(\n function (newValue) {\n hasValue = true;\n value = newValue;\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n sourceSubscription.dispose();\n }\n ));\n\n return new BinaryDisposable(\n sourceSubscription,\n sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe)\n );\n }, source);\n }\n\n /**\n * Samples the observable sequence at each interval.\n *\n * @example\n * 1 - res = source.sample(sampleObservable); // Sampler tick sequence\n * 2 - res = source.sample(5000); // 5 seconds\n * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds\n *\n * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.\n * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Sampled observable sequence.\n */\n observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return typeof intervalOrSampler === 'number' ?\n sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :\n sampleObservable(this, intervalOrSampler);\n };\n\n var TimeoutError = Rx.TimeoutError = function(message) {\n this.message = message || 'Timeout has occurred';\n this.name = 'TimeoutError';\n Error.call(this);\n };\n TimeoutError.prototype = Object.create(Error.prototype);\n\n function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) {\n if (isFunction(firstTimeout)) {\n other = timeoutDurationSelector;\n timeoutDurationSelector = firstTimeout;\n firstTimeout = observableNever();\n }\n other || (other = observableThrow(new TimeoutError()));\n return new AnonymousObservable(function (o) {\n var subscription = new SerialDisposable(),\n timer = new SerialDisposable(),\n original = new SingleAssignmentDisposable();\n\n subscription.setDisposable(original);\n\n var id = 0, switched = false;\n\n function setTimer(timeout) {\n var myId = id, d = new SingleAssignmentDisposable();\n\n function timerWins() {\n switched = (myId === id);\n return switched;\n }\n\n timer.setDisposable(d);\n d.setDisposable(timeout.subscribe(function () {\n timerWins() && subscription.setDisposable(other.subscribe(o));\n d.dispose();\n }, function (e) {\n timerWins() && o.onError(e);\n }, function () {\n timerWins() && subscription.setDisposable(other.subscribe(o));\n }));\n };\n\n setTimer(firstTimeout);\n\n function oWins() {\n var res = !switched;\n if (res) { id++; }\n return res;\n }\n\n original.setDisposable(source.subscribe(function (x) {\n if (oWins()) {\n o.onNext(x);\n var timeout = tryCatch(timeoutDurationSelector)(x);\n if (timeout === errorObj) { return o.onError(timeout.e); }\n setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);\n }\n }, function (e) {\n oWins() && o.onError(e);\n }, function () {\n oWins() && o.onCompleted();\n }));\n return new BinaryDisposable(subscription, timer);\n }, source);\n }\n\n function timeout(source, dueTime, other, scheduler) {\n if (isScheduler(other)) {\n scheduler = other;\n other = observableThrow(new TimeoutError());\n }\n if (other instanceof Error) { other = observableThrow(other); }\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n\n return new AnonymousObservable(function (o) {\n var id = 0,\n original = new SingleAssignmentDisposable(),\n subscription = new SerialDisposable(),\n switched = false,\n timer = new SerialDisposable();\n\n subscription.setDisposable(original);\n\n function createTimer() {\n var myId = id;\n timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () {\n switched = id === myId;\n if (switched) {\n isPromise(other) && (other = observableFromPromise(other));\n subscription.setDisposable(other.subscribe(o));\n }\n }));\n }\n\n createTimer();\n\n original.setDisposable(source.subscribe(function (x) {\n if (!switched) {\n id++;\n o.onNext(x);\n createTimer();\n }\n }, function (e) {\n if (!switched) {\n id++;\n o.onError(e);\n }\n }, function () {\n if (!switched) {\n id++;\n o.onCompleted();\n }\n }));\n return new BinaryDisposable(subscription, timer);\n }, source);\n }\n\n observableProto.timeout = function () {\n var firstArg = arguments[0];\n if (firstArg instanceof Date || typeof firstArg === 'number') {\n return timeout(this, firstArg, arguments[1], arguments[2]);\n } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) {\n return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n var GenerateAbsoluteObservable = (function (__super__) {\n inherits(GenerateAbsoluteObservable, __super__);\n function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._timeFn = timeFn;\n this._s = s;\n this._first = true;\n this._hasResult = false;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n self._hasResult && self._o.onNext(self._state);\n\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n self._hasResult = tryCatch(self._cndFn)(self._state);\n if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); }\n if (self._hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n var time = tryCatch(self._timeFn)(self._state);\n if (time === errorObj) { return self._o.onError(time.e); }\n recurse(self, time);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateAbsoluteObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive);\n };\n\n return GenerateAbsoluteObservable;\n }(ObservableBase));\n\n /**\n * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithAbsoluteTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return new Date(); }\n * });\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler);\n };\n\n var GenerateRelativeObservable = (function (__super__) {\n inherits(GenerateRelativeObservable, __super__);\n function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._timeFn = timeFn;\n this._s = s;\n this._first = true;\n this._hasResult = false;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n self._hasResult && self._o.onNext(self._state);\n\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n self._hasResult = tryCatch(self._cndFn)(self._state);\n if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); }\n if (self._hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n var time = tryCatch(self._timeFn)(self._state);\n if (time === errorObj) { return self._o.onError(time.e); }\n recurse(self, time);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateRelativeObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive);\n };\n\n return GenerateRelativeObservable;\n }(ObservableBase));\n\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithRelativeTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return 500; }\n * );\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler);\n };\n\n var DelaySubscription = (function(__super__) {\n inherits(DelaySubscription, __super__);\n function DelaySubscription(source, dt, s) {\n this.source = source;\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n DelaySubscription.prototype.subscribeCore = function (o) {\n var d = new SerialDisposable();\n\n d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod));\n\n return d;\n };\n\n function scheduleMethod(s, state) {\n var source = state[0], o = state[1], d = state[2];\n d.setDisposable(source.subscribe(o));\n }\n\n return DelaySubscription;\n }(ObservableBase));\n\n /**\n * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.delaySubscription(5000); // 5s\n * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds\n *\n * @param {Number} dueTime Relative or absolute time shift of the subscription.\n * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delaySubscription = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new DelaySubscription(this, dueTime, scheduler);\n };\n\n var SkipLastWithTimeObservable = (function (__super__) {\n inherits(SkipLastWithTimeObservable, __super__);\n function SkipLastWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n SkipLastWithTimeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipLastWithTimeObserver(o, this));\n };\n\n return SkipLastWithTimeObservable;\n }(ObservableBase));\n\n var SkipLastWithTimeObserver = (function (__super__) {\n inherits(SkipLastWithTimeObserver, __super__);\n\n function SkipLastWithTimeObserver(o, p) {\n this._o = o;\n this._s = p._s;\n this._d = p._d;\n this._q = [];\n __super__.call(this);\n }\n\n SkipLastWithTimeObserver.prototype.next = function (x) {\n var now = this._s.now();\n this._q.push({ interval: now, value: x });\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._o.onNext(this._q.shift().value);\n }\n };\n SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipLastWithTimeObserver.prototype.completed = function () {\n var now = this._s.now();\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._o.onNext(this._q.shift().value);\n }\n this._o.onCompleted();\n };\n\n return SkipLastWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for skipping elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.\n */\n observableProto.skipLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipLastWithTimeObservable(this, duration, scheduler);\n };\n\n var TakeLastWithTimeObservable = (function (__super__) {\n inherits(TakeLastWithTimeObservable, __super__);\n function TakeLastWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n TakeLastWithTimeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s));\n };\n\n return TakeLastWithTimeObservable;\n }(ObservableBase));\n\n var TakeLastWithTimeObserver = (function (__super__) {\n inherits(TakeLastWithTimeObserver, __super__);\n\n function TakeLastWithTimeObserver(o, d, s) {\n this._o = o;\n this._d = d;\n this._s = s;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastWithTimeObserver.prototype.next = function (x) {\n var now = this._s.now();\n this._q.push({ interval: now, value: x });\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._q.shift();\n }\n };\n TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n TakeLastWithTimeObserver.prototype.completed = function () {\n var now = this._s.now();\n while (this._q.length > 0) {\n var next = this._q.shift();\n if (now - next.interval <= this._d) { this._o.onNext(next.value); }\n }\n this._o.onCompleted();\n };\n\n return TakeLastWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TakeLastWithTimeObservable(this, duration, scheduler);\n };\n\n /**\n * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastBufferWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now(), res = [];\n while (q.length > 0) {\n var next = q.shift();\n now - next.interval <= duration && res.push(next.value);\n }\n o.onNext(res);\n o.onCompleted();\n });\n }, source);\n };\n\n var TakeWithTimeObservable = (function (__super__) {\n inherits(TakeWithTimeObservable, __super__);\n function TakeWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n function scheduleMethod(s, o) {\n o.onCompleted();\n }\n\n TakeWithTimeObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(\n this._s.scheduleFuture(o, this._d, scheduleMethod),\n this.source.subscribe(o)\n );\n };\n\n return TakeWithTimeObservable;\n }(ObservableBase));\n\n /**\n * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.takeWithTime(5000, [optional scheduler]);\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.\n */\n observableProto.takeWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TakeWithTimeObservable(this, duration, scheduler);\n };\n\n var SkipWithTimeObservable = (function (__super__) {\n inherits(SkipWithTimeObservable, __super__);\n function SkipWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n this._open = false;\n __super__.call(this);\n }\n\n function scheduleMethod(s, self) {\n self._open = true;\n }\n\n SkipWithTimeObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(\n this._s.scheduleFuture(this, this._d, scheduleMethod),\n this.source.subscribe(new SkipWithTimeObserver(o, this))\n );\n };\n\n return SkipWithTimeObservable;\n }(ObservableBase));\n\n var SkipWithTimeObserver = (function (__super__) {\n inherits(SkipWithTimeObserver, __super__);\n\n function SkipWithTimeObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };\n SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.\n * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded\n * may not execute immediately, despite the zero due time.\n *\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.\n * @param {Number} duration Duration for skipping elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.\n */\n observableProto.skipWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipWithTimeObservable(this, duration, scheduler);\n };\n\n var SkipUntilWithTimeObservable = (function (__super__) {\n inherits(SkipUntilWithTimeObservable, __super__);\n function SkipUntilWithTimeObservable(source, startTime, scheduler) {\n this.source = source;\n this._st = startTime;\n this._s = scheduler;\n __super__.call(this);\n }\n\n function scheduleMethod(s, state) {\n state._open = true;\n }\n\n SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) {\n this._open = false;\n return new BinaryDisposable(\n this._s.scheduleFuture(this, this._st, scheduleMethod),\n this.source.subscribe(new SkipUntilWithTimeObserver(o, this))\n );\n };\n\n return SkipUntilWithTimeObservable;\n }(ObservableBase));\n\n var SkipUntilWithTimeObserver = (function (__super__) {\n inherits(SkipUntilWithTimeObserver, __super__);\n\n function SkipUntilWithTimeObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };\n SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipUntilWithTimeObserver;\n }(AbstractObserver));\n\n\n /**\n * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.\n *\n * @examples\n * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);\n * 2 - res = source.skipUntilWithTime(5000, [scheduler]);\n * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped until the specified start time.\n */\n observableProto.skipUntilWithTime = function (startTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipUntilWithTimeObservable(this, startTime, scheduler);\n };\n\n /**\n * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.\n * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on.\n * @returns {Observable} An observable sequence with the elements taken until the specified end time.\n */\n observableProto.takeUntilWithTime = function (endTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n var source = this;\n return new AnonymousObservable(function (o) {\n return new BinaryDisposable(\n scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }),\n source.subscribe(o));\n }, source);\n };\n\n /**\n * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.\n * @param {Number} windowDuration time to wait before emitting another item after emitting the last item\n * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.\n * @returns {Observable} An Observable that performs the throttle operation.\n */\n observableProto.throttle = function (windowDuration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n var duration = +windowDuration || 0;\n if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var lastOnNext = 0;\n return source.subscribe(\n function (x) {\n var now = scheduler.now();\n if (lastOnNext === 0 || now - lastOnNext >= duration) {\n lastOnNext = now;\n o.onNext(x);\n }\n },function (e) { o.onError(e); }, function () { o.onCompleted(); }\n );\n }, source);\n };\n\n var TransduceObserver = (function (__super__) {\n inherits(TransduceObserver, __super__);\n function TransduceObserver(o, xform) {\n this._o = o;\n this._xform = xform;\n __super__.call(this);\n }\n\n TransduceObserver.prototype.next = function (x) {\n var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x);\n if (res === errorObj) { this._o.onError(res.e); }\n };\n\n TransduceObserver.prototype.error = function (e) { this._o.onError(e); };\n\n TransduceObserver.prototype.completed = function () {\n this._xform['@@transducer/result'](this._o);\n };\n\n return TransduceObserver;\n }(AbstractObserver));\n\n function transformForObserver(o) {\n return {\n '@@transducer/init': function() {\n return o;\n },\n '@@transducer/step': function(obs, input) {\n return obs.onNext(input);\n },\n '@@transducer/result': function(obs) {\n return obs.onCompleted();\n }\n };\n }\n\n /**\n * Executes a transducer to transform the observable sequence\n * @param {Transducer} transducer A transducer to execute\n * @returns {Observable} An Observable sequence containing the results from the transducer.\n */\n observableProto.transduce = function(transducer) {\n var source = this;\n return new AnonymousObservable(function(o) {\n var xform = transducer(transformForObserver(o));\n return source.subscribe(new TransduceObserver(o, xform));\n }, source);\n };\n\n /**\n * Performs a exclusive waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @returns {Observable} A exclusive observable with only the results that happen when subscribed.\n */\n observableProto.switchFirst = function () {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var hasCurrent = false,\n isStopped = false,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n if (!hasCurrent) {\n hasCurrent = true;\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n var innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) { o.onError(e); },\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n isStopped && g.length === 1 && o.onCompleted();\n }));\n }\n },\n function (e) { o.onError(e); },\n function () {\n isStopped = true;\n !hasCurrent && g.length === 1 && o.onCompleted();\n }));\n\n return g;\n }, this);\n };\n\nobservableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst();\n};\n\nRx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit);\n};\n /** Provides a set of extension methods for virtual time scheduling. */\n var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) {\n inherits(VirtualTimeScheduler, __super__);\n\n /**\n * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.\n *\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function VirtualTimeScheduler(initialClock, comparer) {\n this.clock = initialClock;\n this.comparer = comparer;\n this.isEnabled = false;\n this.queue = new PriorityQueue(1024);\n __super__.call(this);\n }\n\n var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;\n\n VirtualTimeSchedulerPrototype.now = function () {\n return this.toAbsoluteTime(this.clock);\n };\n\n VirtualTimeSchedulerPrototype.schedule = function (state, action) {\n return this.scheduleAbsolute(state, this.clock, action);\n };\n\n VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) {\n var dt = dueTime instanceof Date ?\n this.toRelativeTime(dueTime - this.now()) :\n this.toRelativeTime(dueTime);\n\n return this.scheduleRelative(state, dt, action);\n };\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n VirtualTimeSchedulerPrototype.add = notImplemented;\n\n /**\n * Converts an absolute time to a number\n * @param {Any} The absolute time.\n * @returns {Number} The absolute time in ms\n */\n VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented;\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented;\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) {\n var s = new SchedulePeriodicRecursive(this, state, period, action);\n return s.start();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) {\n var runAt = this.add(this.clock, dueTime);\n return this.scheduleAbsolute(state, runAt, action);\n };\n\n /**\n * Starts the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.start = function () {\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n }\n };\n\n /**\n * Stops the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.stop = function () {\n this.isEnabled = false;\n };\n\n /**\n * Advances the scheduler's clock to the specified time, running all work till that point.\n * @param {Number} time Absolute time to advance the scheduler's clock to.\n */\n VirtualTimeSchedulerPrototype.advanceTo = function (time) {\n var dueToClock = this.comparer(this.clock, time);\n if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null && this.comparer(next.dueTime, time) <= 0) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n this.clock = time;\n }\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.advanceBy = function (time) {\n var dt = this.add(this.clock, time),\n dueToClock = this.comparer(this.clock, dt);\n if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n\n this.advanceTo(dt);\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.sleep = function (time) {\n var dt = this.add(this.clock, time);\n if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); }\n\n this.clock = dt;\n };\n\n /**\n * Gets the next scheduled item to be executed.\n * @returns {ScheduledItem} The next scheduled item.\n */\n VirtualTimeSchedulerPrototype.getNext = function () {\n while (this.queue.length > 0) {\n var next = this.queue.peek();\n if (next.isCancelled()) {\n this.queue.dequeue();\n } else {\n return next;\n }\n }\n return null;\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) {\n var self = this;\n\n function run(scheduler, state1) {\n self.queue.remove(si);\n return action(scheduler, state1);\n }\n\n var si = new ScheduledItem(this, state, run, dueTime, this.comparer);\n this.queue.enqueue(si);\n\n return si.disposable;\n };\n\n return VirtualTimeScheduler;\n }(Scheduler));\n\n /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */\n Rx.HistoricalScheduler = (function (__super__) {\n inherits(HistoricalScheduler, __super__);\n\n /**\n * Creates a new historical scheduler with the specified initial clock value.\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function HistoricalScheduler(initialClock, comparer) {\n var clock = initialClock == null ? 0 : initialClock;\n var cmp = comparer || defaultSubComparer;\n __super__.call(this, clock, cmp);\n }\n\n var HistoricalSchedulerProto = HistoricalScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n HistoricalSchedulerProto.add = function (absolute, relative) {\n return absolute + relative;\n };\n\n HistoricalSchedulerProto.toAbsoluteTime = function (absolute) {\n return new Date(absolute).getTime();\n };\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @memberOf HistoricalScheduler\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n HistoricalSchedulerProto.toRelativeTime = function (timeSpan) {\n return timeSpan;\n };\n\n return HistoricalScheduler;\n }(Rx.VirtualTimeScheduler));\n\nfunction OnNextPredicate(predicate) {\n this.predicate = predicate;\n}\n\nOnNextPredicate.prototype.equals = function (other) {\n if (other === this) { return true; }\n if (other == null) { return false; }\n if (other.kind !== 'N') { return false; }\n return this.predicate(other.value);\n};\n\nfunction OnErrorPredicate(predicate) {\n this.predicate = predicate;\n}\n\nOnErrorPredicate.prototype.equals = function (other) {\n if (other === this) { return true; }\n if (other == null) { return false; }\n if (other.kind !== 'E') { return false; }\n return this.predicate(other.error);\n};\n\nvar ReactiveTest = Rx.ReactiveTest = {\n /** Default virtual time used for creation of observable sequences in unit tests. */\n created: 100,\n /** Default virtual time used to subscribe to observable sequences in unit tests. */\n subscribed: 200,\n /** Default virtual time used to dispose subscriptions in unit tests. */\n disposed: 1000,\n\n /**\n * Factory method for an OnNext notification record at a given time with a given value or a predicate function.\n *\n * 1 - ReactiveTest.onNext(200, 42);\n * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });\n *\n * @param ticks Recorded virtual time the OnNext notification occurs.\n * @param value Recorded value stored in the OnNext notification or a predicate.\n * @return Recorded OnNext notification.\n */\n onNext: function (ticks, value) {\n return typeof value === 'function' ?\n new Recorded(ticks, new OnNextPredicate(value)) :\n new Recorded(ticks, Notification.createOnNext(value));\n },\n /**\n * Factory method for an OnError notification record at a given time with a given error.\n *\n * 1 - ReactiveTest.onNext(200, new Error('error'));\n * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });\n *\n * @param ticks Recorded virtual time the OnError notification occurs.\n * @param exception Recorded exception stored in the OnError notification.\n * @return Recorded OnError notification.\n */\n onError: function (ticks, error) {\n return typeof error === 'function' ?\n new Recorded(ticks, new OnErrorPredicate(error)) :\n new Recorded(ticks, Notification.createOnError(error));\n },\n /**\n * Factory method for an OnCompleted notification record at a given time.\n *\n * @param ticks Recorded virtual time the OnCompleted notification occurs.\n * @return Recorded OnCompleted notification.\n */\n onCompleted: function (ticks) {\n return new Recorded(ticks, Notification.createOnCompleted());\n },\n /**\n * Factory method for a subscription record based on a given subscription and disposal time.\n *\n * @param start Virtual time indicating when the subscription was created.\n * @param end Virtual time indicating when the subscription was disposed.\n * @return Subscription object.\n */\n subscribe: function (start, end) {\n return new Subscription(start, end);\n }\n};\n\n /**\n * Creates a new object recording the production of the specified value at the given virtual time.\n *\n * @constructor\n * @param {Number} time Virtual time the value was produced on.\n * @param {Mixed} value Value that was produced.\n * @param {Function} comparer An optional comparer.\n */\n var Recorded = Rx.Recorded = function (time, value, comparer) {\n this.time = time;\n this.value = value;\n this.comparer = comparer || defaultComparer;\n };\n\n /**\n * Checks whether the given recorded object is equal to the current instance.\n *\n * @param {Recorded} other Recorded object to check for equality.\n * @returns {Boolean} true if both objects are equal; false otherwise.\n */\n Recorded.prototype.equals = function (other) {\n return this.time === other.time && this.comparer(this.value, other.value);\n };\n\n /**\n * Returns a string representation of the current Recorded value.\n *\n * @returns {String} String representation of the current Recorded value.\n */\n Recorded.prototype.toString = function () {\n return this.value.toString() + '@' + this.time;\n };\n\n /**\n * Creates a new subscription object with the given virtual subscription and unsubscription time.\n *\n * @constructor\n * @param {Number} subscribe Virtual time at which the subscription occurred.\n * @param {Number} unsubscribe Virtual time at which the unsubscription occurred.\n */\n var Subscription = Rx.Subscription = function (start, end) {\n this.subscribe = start;\n this.unsubscribe = end || Number.MAX_VALUE;\n };\n\n /**\n * Checks whether the given subscription is equal to the current instance.\n * @param other Subscription object to check for equality.\n * @returns {Boolean} true if both objects are equal; false otherwise.\n */\n Subscription.prototype.equals = function (other) {\n return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;\n };\n\n /**\n * Returns a string representation of the current Subscription value.\n * @returns {String} String representation of the current Subscription value.\n */\n Subscription.prototype.toString = function () {\n return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')';\n };\n\n var MockDisposable = Rx.MockDisposable = function (scheduler) {\n this.scheduler = scheduler;\n this.disposes = [];\n this.disposes.push(this.scheduler.clock);\n };\n\n MockDisposable.prototype.dispose = function () {\n this.disposes.push(this.scheduler.clock);\n };\n\n var MockObserver = (function (__super__) {\n inherits(MockObserver, __super__);\n\n function MockObserver(scheduler) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.messages = [];\n }\n\n var MockObserverPrototype = MockObserver.prototype;\n\n MockObserverPrototype.onNext = function (value) {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));\n };\n\n MockObserverPrototype.onError = function (e) {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e)));\n };\n\n MockObserverPrototype.onCompleted = function () {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));\n };\n\n return MockObserver;\n })(Observer);\n\n function MockPromise(scheduler, messages) {\n var self = this;\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n this.observers = [];\n for (var i = 0, len = this.messages.length; i < len; i++) {\n var message = this.messages[i],\n notification = message.value;\n (function (innerNotification) {\n scheduler.scheduleAbsolute(null, message.time, function () {\n var obs = self.observers.slice(0);\n\n for (var j = 0, jLen = obs.length; j < jLen; j++) {\n innerNotification.accept(obs[j]);\n }\n return disposableEmpty;\n });\n })(notification);\n }\n }\n\n MockPromise.prototype.then = function (onResolved, onRejected) {\n var self = this;\n\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n\n var newPromise;\n\n var observer = Rx.Observer.create(\n function (x) {\n var retValue = onResolved(x);\n if (retValue && typeof retValue.then === 'function') {\n newPromise = retValue;\n } else {\n var ticks = self.scheduler.clock;\n newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]);\n }\n var idx = self.observers.indexOf(observer);\n self.observers.splice(idx, 1);\n self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);\n },\n function (err) {\n onRejected(err);\n var idx = self.observers.indexOf(observer);\n self.observers.splice(idx, 1);\n self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);\n }\n );\n this.observers.push(observer);\n\n return newPromise || new MockPromise(this.scheduler, this.messages);\n };\n\n var HotObservable = (function (__super__) {\n inherits(HotObservable, __super__);\n\n function HotObservable(scheduler, messages) {\n __super__.call(this);\n var message, notification, observable = this;\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n this.observers = [];\n for (var i = 0, len = this.messages.length; i < len; i++) {\n message = this.messages[i];\n notification = message.value;\n (function (innerNotification) {\n scheduler.scheduleAbsolute(null, message.time, function () {\n var obs = observable.observers.slice(0);\n\n for (var j = 0, jLen = obs.length; j < jLen; j++) {\n innerNotification.accept(obs[j]);\n }\n return disposableEmpty;\n });\n })(notification);\n }\n }\n\n HotObservable.prototype._subscribe = function (o) {\n var observable = this;\n this.observers.push(o);\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n return disposableCreate(function () {\n var idx = observable.observers.indexOf(o);\n observable.observers.splice(idx, 1);\n observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);\n });\n };\n\n return HotObservable;\n })(Observable);\n\n var ColdObservable = (function (__super__) {\n inherits(ColdObservable, __super__);\n\n function ColdObservable(scheduler, messages) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n }\n\n ColdObservable.prototype._subscribe = function (o) {\n var message, notification, observable = this;\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n var d = new CompositeDisposable();\n for (var i = 0, len = this.messages.length; i < len; i++) {\n message = this.messages[i];\n notification = message.value;\n (function (innerNotification) {\n d.add(observable.scheduler.scheduleRelative(null, message.time, function () {\n innerNotification.accept(o);\n return disposableEmpty;\n }));\n })(notification);\n }\n return disposableCreate(function () {\n observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);\n d.dispose();\n });\n };\n\n return ColdObservable;\n })(Observable);\n\n /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */\n Rx.TestScheduler = (function (__super__) {\n inherits(TestScheduler, __super__);\n\n function baseComparer(x, y) {\n return x > y ? 1 : (x < y ? -1 : 0);\n }\n\n function TestScheduler() {\n __super__.call(this, 0, baseComparer);\n }\n\n /**\n * Schedules an action to be executed at the specified virtual time.\n *\n * @param state State passed to the action to be executed.\n * @param dueTime Absolute virtual time at which to execute the action.\n * @param action Action to be executed.\n * @return Disposable object used to cancel the scheduled action (best effort).\n */\n TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) {\n dueTime <= this.clock && (dueTime = this.clock + 1);\n return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action);\n };\n /**\n * Adds a relative virtual time to an absolute virtual time value.\n *\n * @param absolute Absolute virtual time value.\n * @param relative Relative virtual time value to add.\n * @return Resulting absolute virtual time sum value.\n */\n TestScheduler.prototype.add = function (absolute, relative) {\n return absolute + relative;\n };\n /**\n * Converts the absolute virtual time value to a DateTimeOffset value.\n *\n * @param absolute Absolute virtual time value to convert.\n * @return Corresponding DateTimeOffset value.\n */\n TestScheduler.prototype.toAbsoluteTime = function (absolute) {\n return new Date(absolute).getTime();\n };\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n *\n * @param timeSpan TimeSpan value to convert.\n * @return Corresponding relative virtual time value.\n */\n TestScheduler.prototype.toRelativeTime = function (timeSpan) {\n return timeSpan;\n };\n /**\n * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription.\n *\n * @param create Factory method to create an observable sequence.\n * @param created Virtual time at which to invoke the factory to create an observable sequence.\n * @param subscribed Virtual time at which to subscribe to the created observable sequence.\n * @param disposed Virtual time at which to dispose the subscription.\n * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.\n */\n TestScheduler.prototype.startScheduler = function (createFn, settings) {\n settings || (settings = {});\n settings.created == null && (settings.created = ReactiveTest.created);\n settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed);\n settings.disposed == null && (settings.disposed = ReactiveTest.disposed);\n\n var observer = this.createObserver(), source, subscription;\n\n this.scheduleAbsolute(null, settings.created, function () {\n source = createFn();\n return disposableEmpty;\n });\n\n this.scheduleAbsolute(null, settings.subscribed, function () {\n subscription = source.subscribe(observer);\n return disposableEmpty;\n });\n\n this.scheduleAbsolute(null, settings.disposed, function () {\n subscription.dispose();\n return disposableEmpty;\n });\n\n this.start();\n\n return observer;\n };\n\n /**\n * Creates a hot observable using the specified timestamped notification messages either as an array or arguments.\n * @param messages Notifications to surface through the created sequence at their specified absolute virtual times.\n * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications.\n */\n TestScheduler.prototype.createHotObservable = function () {\n var len = arguments.length, args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n args = new Array(len);\n for (var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n return new HotObservable(this, args);\n };\n\n /**\n * Creates a cold observable using the specified timestamped notification messages either as an array or arguments.\n * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time.\n * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications.\n */\n TestScheduler.prototype.createColdObservable = function () {\n var len = arguments.length, args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n args = new Array(len);\n for (var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n return new ColdObservable(this, args);\n };\n\n /**\n * Creates a resolved promise with the given value and ticks\n * @param {Number} ticks The absolute time of the resolution.\n * @param {Any} value The value to yield at the given tick.\n * @returns {MockPromise} A mock Promise which fulfills with the given value.\n */\n TestScheduler.prototype.createResolvedPromise = function (ticks, value) {\n return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]);\n };\n\n /**\n * Creates a rejected promise with the given reason and ticks\n * @param {Number} ticks The absolute time of the resolution.\n * @param {Any} reason The reason for rejection to yield at the given tick.\n * @returns {MockPromise} A mock Promise which rejects with the given reason.\n */\n TestScheduler.prototype.createRejectedPromise = function (ticks, reason) {\n return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]);\n };\n\n /**\n * Creates an observer that records received notification messages and timestamps those.\n * @return Observer that can be used to assert the timing of received notifications.\n */\n TestScheduler.prototype.createObserver = function () {\n return new MockObserver(this);\n };\n\n return TestScheduler;\n })(VirtualTimeScheduler);\n\n var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {\n inherits(AnonymousObservable, __super__);\n\n // Fix subscriber to check for undefined or function returned to decorate as Disposable\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.__subscribe).call(self, ado);\n if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function AnonymousObservable(subscribe, parent) {\n this.source = parent;\n this.__subscribe = subscribe;\n __super__.call(this);\n }\n\n AnonymousObservable.prototype._subscribe = function (o) {\n var ado = new AutoDetachObserver(o), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.schedule(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n };\n\n return AnonymousObservable;\n\n }(Observable));\n\n var AutoDetachObserver = (function (__super__) {\n inherits(AutoDetachObserver, __super__);\n\n function AutoDetachObserver(observer) {\n __super__.call(this);\n this.observer = observer;\n this.m = new SingleAssignmentDisposable();\n }\n\n var AutoDetachObserverPrototype = AutoDetachObserver.prototype;\n\n AutoDetachObserverPrototype.next = function (value) {\n var result = tryCatch(this.observer.onNext).call(this.observer, value);\n if (result === errorObj) {\n this.dispose();\n thrower(result.e);\n }\n };\n\n AutoDetachObserverPrototype.error = function (err) {\n var result = tryCatch(this.observer.onError).call(this.observer, err);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.completed = function () {\n var result = tryCatch(this.observer.onCompleted).call(this.observer);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };\n AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };\n\n AutoDetachObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.m.dispose();\n };\n\n return AutoDetachObserver;\n }(AbstractObserver));\n\n var UnderlyingObservable = (function (__super__) {\n inherits(UnderlyingObservable, __super__);\n function UnderlyingObservable(m, u) {\n this._m = m;\n this._u = u;\n __super__.call(this);\n }\n\n UnderlyingObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o));\n };\n\n return UnderlyingObservable;\n }(ObservableBase));\n\n var GroupedObservable = (function (__super__) {\n inherits(GroupedObservable, __super__);\n function GroupedObservable(key, underlyingObservable, mergedDisposable) {\n __super__.call(this);\n this.key = key;\n this.underlyingObservable = !mergedDisposable ?\n underlyingObservable :\n new UnderlyingObservable(mergedDisposable, underlyingObservable);\n }\n\n GroupedObservable.prototype._subscribe = function (o) {\n return this.underlyingObservable.subscribe(o);\n };\n\n return GroupedObservable;\n }(Observable));\n\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed observers.\n */\n var Subject = Rx.Subject = (function (__super__) {\n inherits(Subject, __super__);\n function Subject() {\n __super__.call(this);\n this.isDisposed = false;\n this.isStopped = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(Subject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(o);\n return new InnerSubscription(this, o);\n }\n if (this.hasError) {\n o.onError(this.error);\n return disposableEmpty;\n }\n o.onCompleted();\n return disposableEmpty;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (!this.isStopped) {\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n /**\n * Creates a subject from the specified observer and observable.\n * @param {Observer} observer The observer used to send messages to the subject.\n * @param {Observable} observable The observable used to subscribe to messages sent from the subject.\n * @returns {Subject} Subject implemented using the given observer and observable.\n */\n Subject.create = function (observer, observable) {\n return new AnonymousSubject(observer, observable);\n };\n\n return Subject;\n }(Observable));\n\n /**\n * Represents the result of an asynchronous operation.\n * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.\n */\n var AsyncSubject = Rx.AsyncSubject = (function (__super__) {\n inherits(AsyncSubject, __super__);\n\n /**\n * Creates a subject that can only receive one value and that value is cached for all future observations.\n * @constructor\n */\n function AsyncSubject() {\n __super__.call(this);\n this.isDisposed = false;\n this.isStopped = false;\n this.hasValue = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(AsyncSubject.prototype, Observer, {\n _subscribe: function (o) {\n checkDisposed(this);\n\n if (!this.isStopped) {\n this.observers.push(o);\n return new InnerSubscription(this, o);\n }\n\n if (this.hasError) {\n o.onError(this.error);\n } else if (this.hasValue) {\n o.onNext(this.value);\n o.onCompleted();\n } else {\n o.onCompleted();\n }\n\n return disposableEmpty;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n checkDisposed(this);\n return this.observers.length > 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).\n */\n onCompleted: function () {\n var i, len;\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n var os = cloneArray(this.observers), len = os.length;\n\n if (this.hasValue) {\n for (i = 0; i < len; i++) {\n var o = os[i];\n o.onNext(this.value);\n o.onCompleted();\n }\n } else {\n for (i = 0; i < len; i++) {\n os[i].onCompleted();\n }\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the error.\n * @param {Mixed} error The Error to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.\n * @param {Mixed} value The value to store in the subject.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n this.hasValue = true;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.error = null;\n this.value = null;\n }\n });\n\n return AsyncSubject;\n }(Observable));\n\n var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {\n inherits(AnonymousSubject, __super__);\n function AnonymousSubject(observer, observable) {\n this.observer = observer;\n this.observable = observable;\n __super__.call(this);\n }\n\n addProperties(AnonymousSubject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n return this.observable.subscribe(o);\n },\n onCompleted: function () {\n this.observer.onCompleted();\n },\n onError: function (error) {\n this.observer.onError(error);\n },\n onNext: function (value) {\n this.observer.onNext(value);\n }\n });\n\n return AnonymousSubject;\n }(Observable));\n\n /**\n * Used to pause and resume streams.\n */\n Rx.Pauser = (function (__super__) {\n inherits(Pauser, __super__);\n function Pauser() {\n __super__.call(this);\n }\n\n /**\n * Pauses the underlying sequence.\n */\n Pauser.prototype.pause = function () { this.onNext(false); };\n\n /**\n * Resumes the underlying sequence.\n */\n Pauser.prototype.resume = function () { this.onNext(true); };\n\n return Pauser;\n }(Subject));\n\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n root.Rx = Rx;\n\n define(function() {\n return Rx;\n });\n } else if (freeExports && freeModule) {\n // in Node.js or RingoJS\n if (moduleExports) {\n (freeModule.exports = Rx).Rx = Rx;\n } else {\n freeExports.Rx = Rx;\n }\n } else {\n // in a browser or Rhino\n root.Rx = Rx;\n }\n\n // All code before this point will be filtered from stack traces.\n var rEndingLine = captureLine();\n\n}.call(this));\n", + "import ajax from \"./ajax\";\n\nexport default class AjaxAdapter {\n\n constructor(options) {\n this._base = (options && options.base) || \"\";\n };\n\n create(store, type, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n body: JSON.stringify({\n data: store.convert(type, partial)\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"POST\",\n responseType: \"auto\",\n url: this._getUrl(type, null, options)\n }).do(e => store.push(e.response))\n .map(e => store.find(e.response.data.type, e.response.data.id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n destroy(store, type, id, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"DELETE\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.remove(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n load(store, type, id, options) {\n\n if (id && typeof id === \"object\") {\n return this.load(store, type, null, id);\n }\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"GET\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(e => store.push(e.response))\n .map(() => id ? store.find(type, id) : store.findAll(type))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n update(store, type, id, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let data = store.convert(type, id, partial);\n\n let source = ajax({\n body: JSON.stringify({\n data: data\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"PATCH\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.add(data))\n .map(() => store.find(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n _getUrl(type, id, options) {\n\n let params = [];\n let url = id ? `${this._base}/${type}/${id}` : `${this._base}/${type}`;\n\n if (options) {\n\n if (options.fields) {\n Object.keys(options.fields).forEach(field => {\n options[`fields[${field}]`] = options.fields[field];\n });\n delete options.fields;\n }\n\n params = Object.keys(options).map(key => {\n return key + \"=\" + encodeURIComponent(options[key]);\n }).sort();\n\n if (params.length) {\n url = `${url}?${params.join(\"&\")}`;\n }\n\n }\n\n return url;\n\n }\n\n}\n", + "import Rx from \"rx\";\n\n/**\n *\n * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM\n *\n * The original source file can be viewed here:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js\n *\n * Licensed under the Apache License, Version 2.0:\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Modifications from original:\n *\n * - extracted from \"Rx.DOM\" namespace\n * - minor eslinter cleanup (\"var\" to \"let\" etc)\n * - addition of \"auto\" responseType\n *\n */\n\nvar root = (typeof window !== \"undefined\" && window) || this;\n\n// Gets the proper XMLHttpRequest for support for older IE\nfunction getXMLHttpRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n } else {\n let progId;\n try {\n let progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n for(let i = 0; i < 3; i++) {\n try {\n progId = progIds[i];\n if (new root.ActiveXObject(progId)) {\n break;\n }\n } catch(e) { }\n }\n return new root.ActiveXObject(progId);\n } catch (e) {\n throw new Error('XMLHttpRequest is not supported by your browser');\n }\n }\n}\n\n// Get CORS support even for older IE\nfunction getCORSRequest() {\n var xhr = new root.XMLHttpRequest();\n if ('withCredentials' in xhr) {\n return xhr;\n } else if (!!root.XDomainRequest) {\n return new XDomainRequest();\n } else {\n throw new Error('CORS is not supported by your browser');\n }\n}\n\nfunction normalizeAjaxSuccessEvent(e, xhr, settings) {\n var response = ('response' in xhr) ? xhr.response : xhr.responseText;\n if (settings.responseType === 'auto') {\n try {\n response = JSON.parse(response);\n } catch (e) {}\n } else {\n response = settings.responseType === 'json' ? JSON.parse(response) : response;\n }\n return {\n response: response,\n status: xhr.status,\n responseType: xhr.responseType,\n xhr: xhr,\n originalEvent: e\n };\n}\n\nfunction normalizeAjaxErrorEvent(e, xhr, type) {\n return {\n type: type,\n status: xhr.status,\n xhr: xhr,\n originalEvent: e\n };\n}\n\n/**\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n*/\nexport default function (options) {\n var settings = {\n method: 'GET',\n crossDomain: false,\n async: true,\n headers: {},\n responseType: 'text',\n createXHR: function(){\n return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();\n },\n normalizeError: normalizeAjaxErrorEvent,\n normalizeSuccess: normalizeAjaxSuccessEvent\n };\n\n if(typeof options === 'string') {\n settings.url = options;\n } else {\n for(let prop in options) {\n if(hasOwnProperty.call(options, prop)) {\n settings[prop] = options[prop];\n }\n }\n }\n\n let normalizeError = settings.normalizeError;\n let normalizeSuccess = settings.normalizeSuccess;\n\n if (!settings.crossDomain && !settings.headers['X-Requested-With']) {\n settings.headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n settings.hasContent = settings.body !== undefined;\n\n return new Rx.AnonymousObservable(function (observer) {\n var isDone = false;\n var xhr;\n\n var processResponse = function(xhr, e){\n var status = xhr.status === 1223 ? 204 : xhr.status;\n if ((status >= 200 && status <= 300) || status === 0 || status === '') {\n observer.onNext(normalizeSuccess(e, xhr, settings));\n observer.onCompleted();\n } else {\n observer.onError(normalizeError(e, xhr, 'error'));\n }\n isDone = true;\n };\n\n try {\n xhr = settings.createXHR();;\n } catch (err) {\n observer.onError(err);\n }\n\n try {\n if (settings.user) {\n xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password);\n } else {\n xhr.open(settings.method, settings.url, settings.async);\n }\n\n let headers = settings.headers;\n for (let header in headers) {\n if (hasOwnProperty.call(headers, header)) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n\n if(!!xhr.upload || (!('withCredentials' in xhr) && !!root.XDomainRequest)) {\n xhr.onload = function(e) {\n if(settings.progressObserver) {\n settings.progressObserver.onNext(e);\n settings.progressObserver.onCompleted();\n }\n processResponse(xhr, e);\n };\n\n if(settings.progressObserver) {\n xhr.onprogress = function(e) {\n settings.progressObserver.onNext(e);\n };\n }\n\n xhr.onerror = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'error'));\n isDone = true;\n };\n\n xhr.onabort = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'abort'));\n isDone = true;\n };\n } else {\n\n xhr.onreadystatechange = function (e) {\n if (xhr.readyState === 4) {\n processResponse(xhr, e);\n }\n };\n }\n\n xhr.send(settings.hasContent && settings.body || null);\n } catch (e) {\n observer.onError(e);\n }\n\n return function () {\n if (!isDone && xhr.readyState !== 4) { xhr.abort(); }\n };\n });\n};\n", + "import \"array.prototype.find\";\nimport Rx from \"rx\";\nimport AjaxAdapter from \"./ajax-adapter\";\n\nexport default class Store {\n\n /**\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n */\n static attr(name, options) {\n if (name && typeof name === 'object') {\n return Store.attr(null, name);\n } else {\n return {\n type: \"attr\",\n default: options && options.default,\n deserialize: function (data, key) {\n return data.attributes && data.attributes[name || key];\n },\n serialize: function (resource, data, key) {\n data.attributes[name || key] = resource[key];\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasOne(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasOne(null, name);\n } else {\n return {\n type: \"has-one\",\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return null;\n } else if (data.relationships[name].data) {\n return this.find(data.relationships[name].data.type, data.relationships[name].data.id);\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key] === null) {\n data.relationships[name || key] = null;\n } else if (resource[key]) {\n data.relationships[name || key] = {\n data: {\n type: resource[key].type,\n id: resource[key].id\n }\n };\n }\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasMany(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasMany(null, name);\n } else {\n return {\n type: \"has-many\",\n default: [],\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return [];\n } else if (data.relationships[name].data) {\n return data.relationships[name].data.map((c) => {\n return this.find(c.type, c.id);\n });\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key]) {\n data.relationships[name || key] = {\n data: resource[key].map(x => {\n return { type: x.type, id: x.id };\n })\n };\n }\n }\n };\n }\n }\n\n constructor(adapter) {\n\n this._adapter = adapter;\n this._data = {};\n this._subject = new Rx.Subject();\n this._subscriptions = {};\n this._types = {};\n\n /**\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n */\n this.observable = this._subject.asObservable();\n\n }\n\n /**\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n */\n add(object) {\n if (object) {\n if (object.type && object.id) {\n let name = this._data[object.type] && this._data[object.type][object.id] ? \"updated\" : \"added\";\n let resource = this.find(object.type, object.id);\n let definition = this._types[object.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n this._addField(object, resource, definition, fieldName);\n }\n });\n this._subject.onNext({\n name: name,\n type: object.type,\n id: object.id,\n resource: resource\n });\n } else {\n throw new TypeError(`The data must have a type and id`);\n }\n } else {\n throw new TypeError(`You must provide data to add`);\n }\n }\n\n /**\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n */\n convert(type, id, partial) {\n if (type && typeof type === \"object\") {\n return this.convert(type.type, type.id, type);\n } else if (id && typeof id === \"object\") {\n return this.convert(type, id.id, id);\n } else {\n let data = {\n type: type,\n attributes: {},\n relationships: {}\n };\n if (id) {\n data.id = id;\n }\n let definition = this._types[data.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n definition[fieldName].serialize(partial, data, fieldName);\n }\n });\n return data;\n }\n }\n\n /**\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n create(type, partial, options) {\n if (this._adapter) {\n return this._adapter.create(this, type, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n */\n define(names, definition) {\n names = (names.constructor === Array) ? names : [ names ];\n if (definition) {\n definition._names = names;\n names.forEach(name => {\n if (!this._types[name]) {\n this._types[name] = definition;\n } else {\n throw new Error(`The type '${name}' has already been defined.`);\n }\n });\n } else {\n throw new Error(`You must provide a definition for the type '${names[0]}'.`);\n }\n }\n\n /**\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n */\n destroy(type, id, options) {\n if (this._adapter) {\n return this._adapter.destroy(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n */\n find(type, id) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n if (id) {\n if (!this._data[type][id]) {\n this._data[type][id] = {\n _dependents: [],\n type: type,\n id: id\n };\n Object.keys(definition).forEach(key => {\n if (key[0] !== \"_\") {\n this._data[type][id][key] = definition[key].default;\n }\n });\n }\n return this._data[type][id];\n } else {\n // throw new TypeError(`You must provide an id`);\n /*eslint-disable*/\n console.warn([\n \"Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n return this.findAll(type);\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n */\n findAll(type) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n return Object.keys(this._data[type]).map(x => this._data[type][x]);\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n */\n load(type, id, options) {\n if (!id || typeof id === \"object\") {\n /*eslint-disable*/\n console.warn([\n \"Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n }\n if (this._adapter) {\n return this._adapter.load(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n */\n loadAll(type, options) {\n if (this._adapter) {\n return this._adapter.load(this, type, null, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n */\n off(event, type, id, callback) {\n /*eslint-disable*/\n console.warn([\n \"The `store.off()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.off.call(this, event, type, null, id, callback);\n } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || \"*\"]) {\n this._subscriptions[event][type][id || \"*\"].dispose();\n delete this._subscriptions[event][type][id || \"*\"];\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n */\n on(event, type, id, callback, context) {\n /*eslint-disable*/\n console.warn([\n \"The `store.on()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.on.call(this, event, type, null, id, callback);\n } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || \"*\"]) {\n let subscription = this._subject.filter(e => e.name === event);\n subscription = subscription.filter(e => this._types[type]._names.indexOf(e.type) !== -1);\n if (id) {\n subscription = subscription.filter(e => e.id === id);\n }\n subscription = subscription.map(e => this.find(e.type, e.id));\n this._subscriptions[event] = this._subscriptions[event] || {};\n if (!this._subscriptions[event][type]) {\n let obj = {};\n this._types[type]._names.forEach(type => {\n this._subscriptions[event][type] = obj;\n });\n }\n this._subscriptions[event][type][id || \"*\"] = subscription.subscribe(callback.bind(context));\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n */\n push(root) {\n if (root.data.constructor === Array) {\n root.data.forEach(x => this.add(x));\n } else {\n this.add(root.data);\n }\n if (root.included) {\n root.included.forEach(x => this.add(x));\n }\n }\n\n /**\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n */\n remove(type, id) {\n if (type) {\n if (this._types[type]) {\n if (id) {\n let resource = this._data[type] && this._data[type][id];\n if (resource) {\n this._remove(resource);\n this._subject.onNext({\n name: \"removed\",\n type: type,\n id: id,\n resource: null\n });\n }\n } else {\n Object.keys(this._data[type]).forEach(id => this.remove(type, id));\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type to remove`);\n }\n }\n\n /**\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n update(type, id, partial, options) {\n if (this._adapter) {\n return this._adapter.update(this, type, id, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n _addField(object, resource, definition, fieldName) {\n var field = definition[fieldName];\n var newValue = field.deserialize.call(this, object, fieldName);\n if (typeof newValue !== \"undefined\") {\n if (field.type === \"has-one\") {\n if (resource[fieldName]) {\n this._removeInverseRelationship(resource, fieldName, resource[fieldName], field);\n }\n if (newValue) {\n this._addInverseRelationship(resource, fieldName, newValue, field);\n }\n } else if (field.type === \"has-many\") {\n resource[fieldName].forEach(r => {\n if (resource[fieldName].indexOf(r) !== -1) {\n this._removeInverseRelationship(resource, fieldName, r, field);\n }\n });\n newValue.forEach(r => {\n this._addInverseRelationship(resource, fieldName, r, field);\n });\n }\n resource[fieldName] = newValue;\n }\n }\n\n _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var sourceDefinition = this._types[sourceResource.type];\n if (targetDefinition) {\n let targetFieldName = [ sourceField.inverse ].concat(sourceDefinition._names).find(x => targetDefinition[x]);\n let targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n targetResource[targetFieldName] = sourceResource;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n if (targetResource[targetFieldName].indexOf(sourceResource) === -1) {\n targetResource[targetFieldName].push(sourceResource);\n }\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n }\n\n _remove(resource) {\n resource._dependents.forEach(dependent => {\n let dependentResource = this._data[dependent.type][dependent.id];\n switch (this._types[dependent.type][dependent.fieldName].type) {\n case \"has-one\": {\n dependentResource[dependent.fieldName] = null;\n break;\n }\n case \"has-many\": {\n let index = dependentResource[dependent.fieldName].indexOf(resource);\n if (index !== -1) {\n dependentResource[dependent.fieldName].splice(index, 1);\n }\n break;\n }\n default: {\n break;\n }\n }\n // TODO: This only needs to be run once for each dependent.\n dependentResource._dependents = dependentResource._dependents.filter(d => {\n return !(d.type === resource.type && d.id === resource.id);\n });\n });\n delete this._data[resource.type][resource.id];\n }\n\n _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var targetFieldName = sourceField.inverse || sourceResource.type;\n var targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents = targetResource._dependents.filter(r => {\n return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName);\n });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = null;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = targetResource[targetFieldName].filter(r => {\n return r !== sourceResource;\n });\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n\n}\n\nStore.Rx = Rx;\nStore.AjaxAdapter = AjaxAdapter;\n" ] } \ No newline at end of file diff --git a/dist/store.js b/dist/store.js index 2a837ef..fbe02a5 100644 --- a/dist/store.js +++ b/dist/store.js @@ -12,9 +12,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons require("array.prototype.find"); -var _rxLite = require("rx-lite"); +var _rx = require("rx"); -var _rxLite2 = _interopRequireDefault(_rxLite); +var _rx2 = _interopRequireDefault(_rx); var _ajaxAdapter = require("./ajax-adapter"); @@ -146,7 +146,7 @@ var Store = (function () { this._adapter = adapter; this._data = {}; - this._subject = new _rxLite2["default"].Subject(); + this._subject = new _rx2["default"].Subject(); this._subscriptions = {}; this._types = {}; @@ -281,22 +281,21 @@ var Store = (function () { * @since 0.5.0 * @param {!string} type - Type of resource. * @param {!Object} partial - Data to create the resource with. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.create("product", { title: "A Book" }, (product) => { + * store.create("product", { title: "A Book" }).subscribe((product) => { * console.log(product.title); * }); */ }, { key: "create", - value: function create(type, partial, success, error, context) { + value: function create(type, partial, options) { if (this._adapter) { - this._adapter.create(this, type, partial, success, error, context); + return this._adapter.create(this, type, partial, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -336,38 +335,36 @@ var Store = (function () { * @since 0.5.0 * @param {!string} type - Type of resource. * @param {!string} id - ID of resource. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.destroy("product", "1", () => { + * store.destroy("product", "1").subscribe(() => { * console.log("Destroyed!"); * }); */ }, { key: "destroy", - value: function destroy(type, id, success, error, context) { + value: function destroy(type, id, options) { if (this._adapter) { - this._adapter.destroy(this, type, id, success, error, context); + return this._adapter.destroy(this, type, id, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } } /** - * Find a resource or entire collection of resources. + * Finds a resource by type and id. * * NOTE: If the resource hasn't been loaded via an add() or push() call it * will be automatically created when find is called. * * @since 0.1.0 - * @param {!string} type - Type of the resource(s) to find. - * @param {string} [id] - The id of the resource to find. If omitted all - * resources of the type will be returned. - * @return {Object|Object[]} - Either the resource or an array of resources. + * @param {!string} type - Type of the resource to find. + * @param {!string} id - The id of the resource to find. + * @return {Object} - The resource. */ }, { key: "find", @@ -403,10 +400,12 @@ var Store = (function () { v: _this5._data[type][id] }; } else { + // throw new TypeError(`You must provide an id`); + /*eslint-disable*/ + console.warn(["Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ return { - v: Object.keys(_this5._data[type]).map(function (x) { - return _this5._data[type][x]; - }) + v: _this5.findAll(type) }; } } else { @@ -421,29 +420,92 @@ var Store = (function () { } /** - * Attempts to load the resource(s) through the adapter and adds it/them to - * the store if successful. + * Finds all the resources of a given type. + * + * @since 0.7.0 + * @param {!string} type - Type of the resource to find. + * @return {Object[]} - An array of resources. + */ + }, { + key: "findAll", + value: function findAll(type) { + var _this6 = this; + + if (type) { + var definition = this._types[type]; + if (definition) { + if (!this._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this6._data[t] = collection; + }); + })(); + } + return Object.keys(this._data[type]).map(function (x) { + return _this6._data[type][x]; + }); + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Attempts to load the given resource through the adapter and adds it to the + * store if successful. * * @since 0.5.0 * @param {!string} type - Type of resource. - * @param {!string} [id] - ID of resource. - * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options) - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.load("product", "1", (product) => { + * store.load("products", "1").subscribe((product) => { * console.log(product.title); * }); */ }, { key: "load", - value: function load(type, id, options, success, error, context) { + value: function load(type, id, options) { + if (!id || typeof id === "object") { + /*eslint-disable*/ + console.warn(["Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + } + if (this._adapter) { + return this._adapter.load(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Attempts to load all the resources of the given type through the adapter + * and adds them to the store if successful. + * + * @since 0.7.0 + * @param {!string} type - Type of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.loadAll("products").subscribe((products) => { + * console.log(products); + * }); + */ + }, { + key: "loadAll", + value: function loadAll(type, options) { if (this._adapter) { - this._adapter.load(this, type, id, options, success, error, context); + return this._adapter.load(this, type, null, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -462,7 +524,9 @@ var Store = (function () { }, { key: "off", value: function off(event, type, id, callback) { + /*eslint-disable*/ console.warn(["The `store.off()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ if (event === "added" || event === "updated" || event === "removed") { if (this._types[type]) { if (id && ({}).toString.call(id) === '[object Function]') { @@ -493,9 +557,11 @@ var Store = (function () { }, { key: "on", value: function on(event, type, id, callback, context) { - var _this6 = this; + var _this7 = this; + /*eslint-disable*/ console.warn(["The `store.on()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ if (event === "added" || event === "updated" || event === "removed") { if (this._types[type]) { if (id && ({}).toString.call(id) === '[object Function]') { @@ -505,7 +571,7 @@ var Store = (function () { return e.name === event; }); subscription = subscription.filter(function (e) { - return _this6._types[type]._names.indexOf(e.type) !== -1; + return _this7._types[type]._names.indexOf(e.type) !== -1; }); if (id) { subscription = subscription.filter(function (e) { @@ -513,14 +579,14 @@ var Store = (function () { }); } subscription = subscription.map(function (e) { - return _this6.find(e.type, e.id); + return _this7.find(e.type, e.id); }); this._subscriptions[event] = this._subscriptions[event] || {}; if (!this._subscriptions[event][type]) { (function () { var obj = {}; - _this6._types[type]._names.forEach(function (type) { - _this6._subscriptions[event][type] = obj; + _this7._types[type]._names.forEach(function (type) { + _this7._subscriptions[event][type] = obj; }); })(); } @@ -545,18 +611,18 @@ var Store = (function () { }, { key: "push", value: function push(root) { - var _this7 = this; + var _this8 = this; if (root.data.constructor === Array) { root.data.forEach(function (x) { - return _this7.add(x); + return _this8.add(x); }); } else { this.add(root.data); } if (root.included) { root.included.forEach(function (x) { - return _this7.add(x); + return _this8.add(x); }); } } @@ -572,7 +638,7 @@ var Store = (function () { }, { key: "remove", value: function remove(type, id) { - var _this8 = this; + var _this9 = this; if (type) { if (this._types[type]) { @@ -589,7 +655,7 @@ var Store = (function () { } } else { Object.keys(this._data[type]).forEach(function (id) { - return _this8.remove(type, id); + return _this9.remove(type, id); }); } } else { @@ -608,22 +674,21 @@ var Store = (function () { * @param {!string} type - Type of resource. * @param {!string} id - ID of resource. * @param {!Object} partial - Data to update the resource with. - * @param {function} [success] - Callback on success. - * @param {function} [error] - Callback on error. - * @param {Object} [context] - Context for the callbacks. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} * * @example * let adapter = new Store.AjaxAdapter(); * let store = new Store(adpater); - * store.update("product", "1", { title: "foo" }, (product) => { + * store.update("product", "1", { title: "foo" }).subscribe((product) => { * console.log(product.title); * }); */ }, { key: "update", - value: function update(type, id, partial, success, error, context) { + value: function update(type, id, partial, options) { if (this._adapter) { - this._adapter.update(this, type, id, partial, success, error, context); + return this._adapter.update(this, type, id, partial, options); } else { throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); } @@ -631,7 +696,7 @@ var Store = (function () { }, { key: "_addField", value: function _addField(object, resource, definition, fieldName) { - var _this9 = this; + var _this10 = this; var field = definition[fieldName]; var newValue = field.deserialize.call(this, object, fieldName); @@ -646,11 +711,11 @@ var Store = (function () { } else if (field.type === "has-many") { resource[fieldName].forEach(function (r) { if (resource[fieldName].indexOf(r) !== -1) { - _this9._removeInverseRelationship(resource, fieldName, r, field); + _this10._removeInverseRelationship(resource, fieldName, r, field); } }); newValue.forEach(function (r) { - _this9._addInverseRelationship(resource, fieldName, r, field); + _this10._addInverseRelationship(resource, fieldName, r, field); }); } resource[fieldName] = newValue; @@ -687,11 +752,11 @@ var Store = (function () { }, { key: "_remove", value: function _remove(resource) { - var _this10 = this; + var _this11 = this; resource._dependents.forEach(function (dependent) { - var dependentResource = _this10._data[dependent.type][dependent.id]; - switch (_this10._types[dependent.type][dependent.fieldName].type) { + var dependentResource = _this11._data[dependent.type][dependent.id]; + switch (_this11._types[dependent.type][dependent.fieldName].type) { case "has-one": { dependentResource[dependent.fieldName] = null; @@ -753,5 +818,6 @@ var Store = (function () { exports["default"] = Store; +Store.Rx = _rx2["default"]; Store.AjaxAdapter = _ajaxAdapter2["default"]; module.exports = exports["default"]; diff --git a/dist/store.prod.js b/dist/store.prod.js index 2f9a92f..2a995d7 100644 --- a/dist/store.prod.js +++ b/dist/store.prod.js @@ -129,7 +129,7 @@ process.umask = function() { return 0; }; },{}],3:[function(require,module,exports){ (function (process,global){ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. - + ;(function (undefined) { var objectTypes = { @@ -154,7 +154,7 @@ process.umask = function() { return 0; }; }, helpers: { } }; - + // Defaults var noop = Rx.helpers.noop = function () { }, identity = Rx.helpers.identity = function (x) { return x; }, @@ -180,13 +180,10 @@ process.umask = function() { return 0; }; return isFn; }()); - function cloneArray(arr) { - var len = arr.length, a = new Array(len); - for(var i = 0; i < len; i++) { a[i] = arr[i]; } - return a; - } - + function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;} + var errorObj = {e: {}}; + function tryCatcherGen(tryCatchTarget) { return function tryCatcher() { try { @@ -195,23 +192,25 @@ process.umask = function() { return 0; }; errorObj.e = e; return errorObj; } - } + }; } + var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } return tryCatcherGen(fn); - } + }; + function thrower(e) { throw e; } - + Rx.config.longStackSupport = false; var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })(); hasStacks = !!stacks.e && !!stacks.e.stack; // All code after this point will be filtered from stack traces reported by RxJS var rStartingLine = captureLine(), rFileName; - + var STACK_JUMP_SEPARATOR = 'From previous event:'; function makeStackTraceLong(error, observable) { @@ -295,7 +294,7 @@ process.umask = function() { return 0; }; var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine); if (attempt3) { return [attempt3[1], Number(attempt3[2])]; } } - + var EmptyError = Rx.EmptyError = function() { this.message = 'Sequence contains no elements.'; this.name = 'EmptyError'; @@ -338,7 +337,7 @@ process.umask = function() { return 0; }; var notSupported = Rx.helpers.notSupported = function () { throw new NotSupportedError(); }; - + // Shim in iterator support var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || '_es6shim_iterator_'; @@ -358,7 +357,7 @@ process.umask = function() { return 0; }; } Rx.helpers.iterator = $iterator$; - + var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) { if (typeof thisArg === 'undefined') { return func; } switch(argCount) { @@ -384,7 +383,7 @@ process.umask = function() { return 0; }; return func.apply(thisArg, arguments); }; }; - + /** Used to determine if values are of the language type Object */ var dontEnums = ['toString', 'toLocaleString', @@ -394,7 +393,7 @@ process.umask = function() { return 0; }; 'propertyIsEnumerable', 'constructor'], dontEnumsLength = dontEnums.length; - + /** `Object#toString` result shortcuts */ var argsClass = '[object Arguments]', arrayClass = '[object Array]', @@ -669,7 +668,7 @@ process.umask = function() { return 0; }; return result; } - + var hasProp = {}.hasOwnProperty, slice = Array.prototype.slice; @@ -692,7 +691,7 @@ process.umask = function() { return 0; }; // Rx Utils var addRef = Rx.internals.addRef = function (xs, r) { return new AnonymousObservable(function (observer) { - return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer)); + return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer)); }); }; @@ -703,7 +702,91 @@ process.umask = function() { return 0; }; } return a; } - + + function IndexedItem(id, value) { + this.id = id; + this.value = value; + } + + IndexedItem.prototype.compareTo = function (other) { + var c = this.value.compareTo(other.value); + c === 0 && (c = this.id - other.id); + return c; + }; + + var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) { + this.items = new Array(capacity); + this.length = 0; + }; + + var priorityProto = PriorityQueue.prototype; + priorityProto.isHigherPriority = function (left, right) { + return this.items[left].compareTo(this.items[right]) < 0; + }; + + priorityProto.percolate = function (index) { + if (index >= this.length || index < 0) { return; } + var parent = index - 1 >> 1; + if (parent < 0 || parent === index) { return; } + if (this.isHigherPriority(index, parent)) { + var temp = this.items[index]; + this.items[index] = this.items[parent]; + this.items[parent] = temp; + this.percolate(parent); + } + }; + + priorityProto.heapify = function (index) { + +index || (index = 0); + if (index >= this.length || index < 0) { return; } + var left = 2 * index + 1, + right = 2 * index + 2, + first = index; + if (left < this.length && this.isHigherPriority(left, first)) { + first = left; + } + if (right < this.length && this.isHigherPriority(right, first)) { + first = right; + } + if (first !== index) { + var temp = this.items[index]; + this.items[index] = this.items[first]; + this.items[first] = temp; + this.heapify(first); + } + }; + + priorityProto.peek = function () { return this.items[0].value; }; + + priorityProto.removeAt = function (index) { + this.items[index] = this.items[--this.length]; + this.items[this.length] = undefined; + this.heapify(); + }; + + priorityProto.dequeue = function () { + var result = this.peek(); + this.removeAt(0); + return result; + }; + + priorityProto.enqueue = function (item) { + var index = this.length++; + this.items[index] = new IndexedItem(PriorityQueue.count++, item); + this.percolate(index); + }; + + priorityProto.remove = function (item) { + for (var i = 0; i < this.length; i++) { + if (this.items[i].value === item) { + this.removeAt(i); + return true; + } + } + return false; + }; + PriorityQueue.count = 0; + /** * Represents a group of disposable resources that are disposed together. * @constructor @@ -718,9 +801,6 @@ process.umask = function() { return 0; }; args = new Array(len); for(i = 0; i < len; i++) { args[i] = arguments[i]; } } - for(i = 0; i < len; i++) { - if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); } - } this.disposables = args; this.isDisposed = false; this.length = args.length; @@ -776,7 +856,7 @@ process.umask = function() { return 0; }; } } }; - + /** * Provides a set of static methods for creating Disposables. * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. @@ -818,7 +898,11 @@ process.umask = function() { return 0; }; var checkDisposed = Disposable.checkDisposed = function (disposable) { if (disposable.isDisposed) { throw new ObjectDisposedError(); } }; - + + var disposableFixup = Disposable._fixup = function (result) { + return isDisposable(result) ? result : disposableEmpty; + }; + // Single assignment var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () { this.isDisposed = false; @@ -838,8 +922,8 @@ process.umask = function() { return 0; }; this.isDisposed = true; var old = this.current; this.current = null; + old && old.dispose(); } - old && old.dispose(); }; // Multiple assignment disposable @@ -867,7 +951,40 @@ process.umask = function() { return 0; }; } old && old.dispose(); }; - + + var BinaryDisposable = Rx.BinaryDisposable = function (first, second) { + this._first = first; + this._second = second; + this.isDisposed = false; + }; + + BinaryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old1 = this._first; + this._first = null; + old1 && old1.dispose(); + var old2 = this._second; + this._second = null; + old2 && old2.dispose(); + } + }; + + var NAryDisposable = Rx.NAryDisposable = function (disposables) { + this._disposables = disposables; + this.isDisposed = false; + }; + + NAryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + for (var i = 0, len = this._disposables.length; i < len; i++) { + this._disposables[i].dispose(); + } + this._disposables.length = 0; + } + }; + /** * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. */ @@ -925,7 +1042,24 @@ process.umask = function() { return 0; }; return RefCountDisposable; })(); - + + function ScheduledDisposable(scheduler, disposable) { + this.scheduler = scheduler; + this.disposable = disposable; + this.isDisposed = false; + } + + function scheduleItem(s, self) { + if (!self.isDisposed) { + self.isDisposed = true; + self.disposable.dispose(); + } + } + + ScheduledDisposable.prototype.dispose = function () { + this.scheduler.schedule(this, scheduleItem); + }; + var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) { this.scheduler = scheduler; this.state = state; @@ -948,95 +1082,58 @@ process.umask = function() { return 0; }; }; ScheduledItem.prototype.invokeCore = function () { - return this.action(this.scheduler, this.state); + return disposableFixup(this.action(this.scheduler, this.state)); }; - + /** Provides a set of static properties to access commonly used schedulers. */ var Scheduler = Rx.Scheduler = (function () { - function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute) { - this.now = now; - this._schedule = schedule; - this._scheduleRelative = scheduleRelative; - this._scheduleAbsolute = scheduleAbsolute; - } + function Scheduler() { } /** Determines whether the given object is a scheduler */ Scheduler.isScheduler = function (s) { return s instanceof Scheduler; - } - - function invokeAction(scheduler, action) { - action(); - return disposableEmpty; - } + }; var schedulerProto = Scheduler.prototype; /** - * Schedules an action to be executed. - * @param {Function} action Action to execute. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.schedule = function (action) { - return this._schedule(action, invokeAction); - }; - - /** - * Schedules an action to be executed. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithState = function (state, action) { - return this._schedule(state, action); + * Schedules an action to be executed. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.schedule = function (state, action) { + throw new NotImplementedError(); }; - /** - * Schedules an action to be executed after the specified relative due time. - * @param {Function} action Action to execute. - * @param {Number} dueTime Relative time after which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithRelative = function (dueTime, action) { - return this._scheduleRelative(action, dueTime, invokeAction); - }; + /** + * Schedules an action to be executed after dueTime. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime; + dt instanceof Date && (dt = dt - this.now()); + dt = Scheduler.normalize(dt); - /** - * Schedules an action to be executed after dueTime. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @param {Number} dueTime Relative time after which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithRelativeAndState = function (state, dueTime, action) { - return this._scheduleRelative(state, dueTime, action); - }; + if (dt === 0) { return this.schedule(state, action); } - /** - * Schedules an action to be executed at the specified absolute due time. - * @param {Function} action Action to execute. - * @param {Number} dueTime Absolute time at which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithAbsolute = function (dueTime, action) { - return this._scheduleAbsolute(action, dueTime, invokeAction); + return this._scheduleFuture(state, dt, action); }; - /** - * Schedules an action to be executed at dueTime. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @param {Number}dueTime Absolute time at which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleWithAbsoluteAndState = function (state, dueTime, action) { - return this._scheduleAbsolute(state, dueTime, action); + schedulerProto._scheduleFuture = function (state, dueTime, action) { + throw new NotImplementedError(); }; /** Gets the current time according to the local machine's system clock. */ Scheduler.now = defaultNow; + /** Gets the current time according to the local machine's system clock. */ + Scheduler.prototype.now = defaultNow; + /** * Normalizes the specified TimeSpan value to a positive value. * @param {Number} timeSpan The time span value to normalize. @@ -1051,7 +1148,7 @@ process.umask = function() { return 0; }; }()); var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler; - + (function (schedulerProto) { function invokeRecImmediate(scheduler, pair) { @@ -1062,7 +1159,7 @@ process.umask = function() { return 0; }; function innerAction(state2) { var isAdded = false, isDone = false; - var d = scheduler.scheduleWithState(state2, scheduleWork); + var d = scheduler.schedule(state2, scheduleWork); if (!isDone) { group.add(d); isAdded = true; @@ -1080,7 +1177,7 @@ process.umask = function() { return 0; }; } } - function invokeRecDate(scheduler, pair, method) { + function invokeRecDate(scheduler, pair) { var state = pair[0], action = pair[1], group = new CompositeDisposable(); action(state, innerAction); return group; @@ -1088,7 +1185,7 @@ process.umask = function() { return 0; }; function innerAction(state2, dueTime1) { var isAdded = false, isDone = false; - var d = scheduler[method](state2, dueTime1, scheduleWork); + var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork); if (!isDone) { group.add(d); isAdded = true; @@ -1106,91 +1203,30 @@ process.umask = function() { return 0; }; } } - function invokeRecDateRelative(s, p) { - return invokeRecDate(s, p, 'scheduleWithRelativeAndState'); - } - - function invokeRecDateAbsolute(s, p) { - return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState'); - } - - function scheduleInnerRecursive(action, self) { - action(function(dt) { self(action, dt); }); - } - - /** - * Schedules an action to be executed recursively. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursive = function (action) { - return this.scheduleRecursiveWithState(action, scheduleInnerRecursive); - }; - /** * Schedules an action to be executed recursively. * @param {Mixed} state State passed to the action to be executed. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ - schedulerProto.scheduleRecursiveWithState = function (state, action) { - return this.scheduleWithState([state, action], invokeRecImmediate); - }; - - /** - * Schedules an action to be executed recursively after a specified relative due time. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time. - * @param {Number}dueTime Relative time after which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithRelative = function (dueTime, action) { - return this.scheduleRecursiveWithRelativeAndState(action, dueTime, scheduleInnerRecursive); + schedulerProto.scheduleRecursive = function (state, action) { + return this.schedule([state, action], invokeRecImmediate); }; /** - * Schedules an action to be executed recursively after a specified relative due time. + * Schedules an action to be executed recursively after a specified relative or absolute due time. * @param {Mixed} state State passed to the action to be executed. * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. - * @param {Number}dueTime Relative time after which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) { - return this._scheduleRelative([state, action], dueTime, invokeRecDateRelative); - }; - - /** - * Schedules an action to be executed recursively at a specified absolute due time. - * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time. - * @param {Number}dueTime Absolute time at which to execute the action for the first time. + * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ - schedulerProto.scheduleRecursiveWithAbsolute = function (dueTime, action) { - return this.scheduleRecursiveWithAbsoluteAndState(action, dueTime, scheduleInnerRecursive); + schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) { + return this.scheduleFuture([state, action], dueTime, invokeRecDate); }; - /** - * Schedules an action to be executed recursively at a specified absolute due time. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. - * @param {Number}dueTime Absolute time at which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) { - return this._scheduleAbsolute([state, action], dueTime, invokeRecDateAbsolute); - }; }(Scheduler.prototype)); - - (function (schedulerProto) { - /** - * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. - * @param {Number} period Period for running the work periodically. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). - */ - Scheduler.prototype.schedulePeriodic = function (period, action) { - return this.schedulePeriodicWithState(null, period, action); - }; + (function (schedulerProto) { /** * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. @@ -1199,7 +1235,7 @@ process.umask = function() { return 0; }; * @param {Function} action Action to be executed, potentially updating the state. * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). */ - Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) { + Scheduler.prototype.schedulePeriodic = function(state, period, action) { if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); } period = normalizeTime(period); var s = state, id = root.setInterval(function () { s = action(s); }, period); @@ -1207,47 +1243,18 @@ process.umask = function() { return 0; }; }; }(Scheduler.prototype)); - - /** Gets a scheduler that schedules work immediately on the current thread. */ - var immediateScheduler = Scheduler.immediate = (function () { - function scheduleNow(state, action) { return action(this, state); } - return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported); - }()); - - /** - * Gets a scheduler that schedules work as soon as possible on the current thread. - */ - var currentThreadScheduler = Scheduler.currentThread = (function () { - var queue; - - function runTrampoline () { - while (queue.length > 0) { - var item = queue.shift(); - !item.isCancelled() && item.invoke(); - } - } - - function scheduleNow(state, action) { - var si = new ScheduledItem(this, state, action, this.now()); - - if (!queue) { - queue = [si]; - - var result = tryCatch(runTrampoline)(); - queue = null; - if (result === errorObj) { return thrower(result.e); } - } else { - queue.push(si); - } - return si.disposable; - } - var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported); - currentScheduler.scheduleRequired = function () { return !queue; }; + (function (schedulerProto) { + /** + * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions. + * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false. + * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling. + */ + schedulerProto.catchError = schedulerProto['catch'] = function (handler) { + return new CatchScheduler(this, handler); + }; + }(Scheduler.prototype)); - return currentScheduler; - }()); - var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () { function tick(command, recurse) { recurse(0, this._period); @@ -1269,14 +1276,71 @@ process.umask = function() { return 0; }; SchedulePeriodicRecursive.prototype.start = function () { var d = new SingleAssignmentDisposable(); this._cancel = d; - d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this))); + d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this))); return d; }; return SchedulePeriodicRecursive; }()); - + + /** Gets a scheduler that schedules work immediately on the current thread. */ + var ImmediateScheduler = (function (__super__) { + inherits(ImmediateScheduler, __super__); + function ImmediateScheduler() { + __super__.call(this); + } + + ImmediateScheduler.prototype.schedule = function (state, action) { + return disposableFixup(action(this, state)); + }; + + return ImmediateScheduler; + }(Scheduler)); + + var immediateScheduler = Scheduler.immediate = new ImmediateScheduler(); + + /** + * Gets a scheduler that schedules work as soon as possible on the current thread. + */ + var CurrentThreadScheduler = (function (__super__) { + var queue; + + function runTrampoline () { + while (queue.length > 0) { + var item = queue.dequeue(); + !item.isCancelled() && item.invoke(); + } + } + + inherits(CurrentThreadScheduler, __super__); + function CurrentThreadScheduler() { + __super__.call(this); + } + + CurrentThreadScheduler.prototype.schedule = function (state, action) { + var si = new ScheduledItem(this, state, action, this.now()); + + if (!queue) { + queue = new PriorityQueue(4); + queue.enqueue(si); + + var result = tryCatch(runTrampoline)(); + queue = null; + if (result === errorObj) { thrower(result.e); } + } else { + queue.enqueue(si); + } + return si.disposable; + }; + + CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; }; + + return CurrentThreadScheduler; + }(Scheduler)); + + var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler(); + var scheduleMethod, clearMethod; var localTimer = (function () { @@ -1311,7 +1375,7 @@ process.umask = function() { return 0; }; function runTask(handle) { if (currentlyRunning) { - localSetTimeout(function () { runTask(handle) }, 0); + localSetTimeout(function () { runTask(handle); }, 0); } else { var task = tasksByHandle[handle]; if (task) { @@ -1319,12 +1383,12 @@ process.umask = function() { return 0; }; var result = tryCatch(task)(); clearMethod(handle); currentlyRunning = false; - if (result === errorObj) { return thrower(result.e); } + if (result === errorObj) { thrower(result.e); } } } } - var reNative = RegExp('^' + + var reNative = new RegExp('^' + String(toString) .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/toString| for [^\]]+/g, '.*?') + '$' @@ -1430,56 +1494,138 @@ process.umask = function() { return 0; }; /** * Gets a scheduler that schedules work via a timed callback based upon platform. */ - var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () { - - function scheduleNow(state, action) { + var DefaultScheduler = (function (__super__) { + inherits(DefaultScheduler, __super__); + function DefaultScheduler() { + __super__.call(this); + } + + function DefaultSchedulerDisposable(id) { + this._id = id; + this.isDisposed = false; + } + + DefaultSchedulerDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + localClearTimeout(this._id); + } + }; + + DefaultScheduler.prototype.schedule = function (state, action) { var scheduler = this, disposable = new SingleAssignmentDisposable(); var id = scheduleMethod(function () { - !disposable.isDisposed && disposable.setDisposable(action(scheduler, state)); + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); }); - return new CompositeDisposable(disposable, disposableCreate(function () { - clearMethod(id); - })); - } + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; - function scheduleRelative(state, dueTime, action) { + DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) { var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable(); - if (dt === 0) { return scheduler.scheduleWithState(state, action); } + if (dt === 0) { return scheduler.schedule(state, action); } var id = localSetTimeout(function () { - !disposable.isDisposed && disposable.setDisposable(action(scheduler, state)); + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); }, dt); - return new CompositeDisposable(disposable, disposableCreate(function () { - localClearTimeout(id); - })); - } + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; - function scheduleAbsolute(state, dueTime, action) { - return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action); - } + return DefaultScheduler; + }(Scheduler)); - return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute); - })(); - - /** - * Represents a notification to an observer. - */ - var Notification = Rx.Notification = (function () { - function Notification(kind, value, exception, accept, acceptObservable, toString) { - this.kind = kind; - this.value = value; - this.exception = exception; - this._accept = accept; - this._acceptObservable = acceptObservable; - this.toString = toString; + var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler(); + + var CatchScheduler = (function (__super__) { + inherits(CatchScheduler, __super__); + + function CatchScheduler(scheduler, handler) { + this._scheduler = scheduler; + this._handler = handler; + this._recursiveOriginal = null; + this._recursiveWrapper = null; + __super__.call(this); } - /** - * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. - * - * @memberOf Notification - * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. - * @param {Function} onError Delegate to invoke for an OnError notification. - * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. + CatchScheduler.prototype.schedule = function (state, action) { + return this._scheduler.schedule(state, this._wrap(action)); + }; + + CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + return this._scheduler.schedule(state, dueTime, this._wrap(action)); + }; + + CatchScheduler.prototype.now = function () { return this._scheduler.now(); }; + + CatchScheduler.prototype._clone = function (scheduler) { + return new CatchScheduler(scheduler, this._handler); + }; + + CatchScheduler.prototype._wrap = function (action) { + var parent = this; + return function (self, state) { + var res = tryCatch(action)(parent._getRecursiveWrapper(self), state); + if (res === errorObj) { + if (!parent._handler(res.e)) { thrower(res.e); } + return disposableEmpty; + } + return disposableFixup(ret); + }; + }; + + CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { + if (this._recursiveOriginal !== scheduler) { + this._recursiveOriginal = scheduler; + var wrapper = this._clone(scheduler); + wrapper._recursiveOriginal = scheduler; + wrapper._recursiveWrapper = wrapper; + this._recursiveWrapper = wrapper; + } + return this._recursiveWrapper; + }; + + CatchScheduler.prototype.schedulePeriodic = function (state, period, action) { + var self = this, failed = false, d = new SingleAssignmentDisposable(); + + d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) { + if (failed) { return null; } + var res = tryCatch(action)(state1); + if (res === errorObj) { + failed = true; + if (!self._handler(res.e)) { thrower(res.e); } + d.dispose(); + return null; + } + return ret; + })); + + return d; + }; + + return CatchScheduler; + }(Scheduler)); + + /** + * Represents a notification to an observer. + */ + var Notification = Rx.Notification = (function () { + function Notification() { + + } + + Notification.prototype._accept = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + /** + * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. + * + * @memberOf Notification + * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. + * @param {Function} onError Delegate to invoke for an OnError notification. + * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. * @returns {Any} Result produced by the observation. */ Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) { @@ -1498,10 +1644,10 @@ process.umask = function() { return 0; }; Notification.prototype.toObservable = function (scheduler) { var self = this; isScheduler(scheduler) || (scheduler = immediateScheduler); - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithState(self, function (_, notification) { - notification._acceptObservable(observer); - notification.kind === 'N' && observer.onCompleted(); + return new AnonymousObservable(function (o) { + return scheduler.schedule(self, function (_, notification) { + notification._acceptObservable(o); + notification.kind === 'N' && o.onCompleted(); }); }); }; @@ -1509,55 +1655,130 @@ process.umask = function() { return 0; }; return Notification; })(); + var OnNextNotification = (function (__super__) { + inherits(OnNextNotification, __super__); + function OnNextNotification(value) { + this.value = value; + this.kind = 'N'; + } + + OnNextNotification.prototype._accept = function (onNext) { + return onNext(this.value); + }; + + OnNextNotification.prototype._acceptObservable = function (o) { + return o.onNext(this.value); + }; + + OnNextNotification.prototype.toString = function () { + return 'OnNext(' + this.value + ')'; + }; + + return OnNextNotification; + }(Notification)); + + var OnErrorNotification = (function (__super__) { + inherits(OnErrorNotification, __super__); + function OnErrorNotification(error) { + this.error = error; + this.kind = 'E'; + } + + OnErrorNotification.prototype._accept = function (onNext, onError) { + return onError(this.error); + }; + + OnErrorNotification.prototype._acceptObservable = function (o) { + return o.onError(this.error); + }; + + OnErrorNotification.prototype.toString = function () { + return 'OnError(' + this.error + ')'; + }; + + return OnErrorNotification; + }(Notification)); + + var OnCompletedNotification = (function (__super__) { + inherits(OnCompletedNotification, __super__); + function OnCompletedNotification() { + this.kind = 'C'; + } + + OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) { + return onCompleted(); + }; + + OnCompletedNotification.prototype._acceptObservable = function (o) { + return o.onCompleted(); + }; + + OnCompletedNotification.prototype.toString = function () { + return 'OnCompleted()'; + }; + + return OnCompletedNotification; + }(Notification)); + /** * Creates an object that represents an OnNext notification to an observer. * @param {Any} value The value contained in the notification. * @returns {Notification} The OnNext notification containing the value. */ - var notificationCreateOnNext = Notification.createOnNext = (function () { - function _accept(onNext) { return onNext(this.value); } - function _acceptObservable(observer) { return observer.onNext(this.value); } - function toString() { return 'OnNext(' + this.value + ')'; } - - return function (value) { - return new Notification('N', value, null, _accept, _acceptObservable, toString); - }; - }()); + var notificationCreateOnNext = Notification.createOnNext = function (value) { + return new OnNextNotification(value); + }; /** * Creates an object that represents an OnError notification to an observer. * @param {Any} error The exception contained in the notification. * @returns {Notification} The OnError notification containing the exception. */ - var notificationCreateOnError = Notification.createOnError = (function () { - function _accept (onNext, onError) { return onError(this.exception); } - function _acceptObservable(observer) { return observer.onError(this.exception); } - function toString () { return 'OnError(' + this.exception + ')'; } - - return function (e) { - return new Notification('E', null, e, _accept, _acceptObservable, toString); - }; - }()); + var notificationCreateOnError = Notification.createOnError = function (error) { + return new OnErrorNotification(error); + }; /** * Creates an object that represents an OnCompleted notification to an observer. * @returns {Notification} The OnCompleted notification. */ - var notificationCreateOnCompleted = Notification.createOnCompleted = (function () { - function _accept (onNext, onError, onCompleted) { return onCompleted(); } - function _acceptObservable(observer) { return observer.onCompleted(); } - function toString () { return 'OnCompleted()'; } + var notificationCreateOnCompleted = Notification.createOnCompleted = function () { + return new OnCompletedNotification(); + }; - return function () { - return new Notification('C', null, null, _accept, _acceptObservable, toString); - }; - }()); - /** * Supports push-style iteration over an observable sequence. */ var Observer = Rx.Observer = function () { }; + /** + * Creates a notification callback from an observer. + * @returns The action that forwards its input notification to the underlying observer. + */ + Observer.prototype.toNotifier = function () { + var observer = this; + return function (n) { return n.accept(observer); }; + }; + + /** + * Hides the identity of an observer. + * @returns An observer that hides the identity of the specified observer. + */ + Observer.prototype.asObserver = function () { + var self = this; + return new AnonymousObserver( + function (x) { self.onNext(x); }, + function (err) { self.onError(err); }, + function () { self.onCompleted(); }); + }; + + /** + * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods. + * If a violation is detected, an Error is thrown from the offending observer method call. + * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer. + */ + Observer.prototype.checked = function () { return new CheckedObserver(this); }; + /** * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions. * @param {Function} [onNext] Observer's OnNext action implementation. @@ -1571,7 +1792,36 @@ process.umask = function() { return 0; }; onCompleted || (onCompleted = noop); return new AnonymousObserver(onNext, onError, onCompleted); }; - + + /** + * Creates an observer from a notification callback. + * @param {Function} handler Action that handles a notification. + * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives. + */ + Observer.fromNotifier = function (handler, thisArg) { + var cb = bindCallback(handler, thisArg, 1); + return new AnonymousObserver(function (x) { + return cb(notificationCreateOnNext(x)); + }, function (e) { + return cb(notificationCreateOnError(e)); + }, function () { + return cb(notificationCreateOnCompleted()); + }); + }; + + /** + * Schedules the invocation of observer methods on the given scheduler. + * @param {Scheduler} scheduler Scheduler to schedule observer messages on. + * @returns {Observer} Observer whose messages are scheduled on the given scheduler. + */ + Observer.prototype.notifyOn = function (scheduler) { + return new ObserveOnObserver(scheduler, this); + }; + + Observer.prototype.makeSafe = function(disposable) { + return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable); + }; + /** * Abstract base class for implementations of the Observer class. * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages. @@ -1637,7 +1887,7 @@ process.umask = function() { return 0; }; return AbstractObserver; }(Observer)); - + /** * Class to create an Observer instance from delegate-based implementations of the on* methods. */ @@ -1682,93 +1932,48 @@ process.umask = function() { return 0; }; return AnonymousObserver; }(AbstractObserver)); - - var observableProto; - - /** - * Represents a push-style collection. - */ - var Observable = Rx.Observable = (function () { - - function makeSubscribe(self, subscribe) { - return function (o) { - var oldOnError = o.onError; - o.onError = function (e) { - makeStackTraceLong(e, self); - oldOnError.call(o, e); - }; - return subscribe.call(self, o); - }; - } + var CheckedObserver = (function (__super__) { + inherits(CheckedObserver, __super__); - function Observable(subscribe) { - if (Rx.config.longStackSupport && hasStacks) { - var e = tryCatch(thrower)(new Error()).e; - this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); - this._subscribe = makeSubscribe(this, subscribe); - } else { - this._subscribe = subscribe; - } + function CheckedObserver(observer) { + __super__.call(this); + this._observer = observer; + this._state = 0; // 0 - idle, 1 - busy, 2 - done } - observableProto = Observable.prototype; - - /** - * Determines whether the given object is an Observable - * @param {Any} An object to determine whether it is an Observable - * @returns {Boolean} true if an Observable, else false. - */ - Observable.isObservable = function (o) { - return o && isFunction(o.subscribe); - } + var CheckedObserverPrototype = CheckedObserver.prototype; - /** - * Subscribes an o to the observable sequence. - * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. - * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. - * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. - * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { - return this._subscribe(typeof oOrOnNext === 'object' ? - oOrOnNext : - observerCreate(oOrOnNext, onError, onCompleted)); + CheckedObserverPrototype.onNext = function (value) { + this.checkAccess(); + var res = tryCatch(this._observer.onNext).call(this._observer, value); + this._state = 0; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onNext The function to invoke on each element in the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnNext = function (onNext, thisArg) { - return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + CheckedObserverPrototype.onError = function (err) { + this.checkAccess(); + var res = tryCatch(this._observer.onError).call(this._observer, err); + this._state = 2; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to an exceptional condition in the sequence with an optional "this" argument. - * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnError = function (onError, thisArg) { - return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + CheckedObserverPrototype.onCompleted = function () { + this.checkAccess(); + var res = tryCatch(this._observer.onCompleted).call(this._observer); + this._state = 2; + res === errorObj && thrower(res.e); }; - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { - return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + CheckedObserverPrototype.checkAccess = function () { + if (this._state === 1) { throw new Error('Re-entrancy detected'); } + if (this._state === 2) { throw new Error('Observer completed'); } + if (this._state === 0) { this._state = 1; } }; - return Observable; - })(); - + return CheckedObserver; + }(Observer)); + var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) { inherits(ScheduledObserver, __super__); @@ -1804,7 +2009,7 @@ process.umask = function() { return 0; }; this.isAcquired = true; } if (isOwner) { - this.disposable.setDisposable(this.scheduler.scheduleRecursiveWithState(this, function (parent, self) { + this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) { var work; if (parent.queue.length > 0) { work = parent.queue.shift(); @@ -1830,122 +2035,233 @@ process.umask = function() { return 0; }; return ScheduledObserver; }(AbstractObserver)); - - var ObservableBase = Rx.ObservableBase = (function (__super__) { - inherits(ObservableBase, __super__); - - function fixSubscriber(subscriber) { - return subscriber && isFunction(subscriber.dispose) ? subscriber : - isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; - } - - function setDisposable(s, state) { - var ado = state[0], self = state[1]; - var sub = tryCatch(self.subscribeCore).call(self, ado); - - if (sub === errorObj) { - if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); } - } - ado.setDisposable(fixSubscriber(sub)); - } - - function subscribe(observer) { - var ado = new AutoDetachObserver(observer), state = [ado, this]; - - if (currentThreadScheduler.scheduleRequired()) { - currentThreadScheduler.scheduleWithState(state, setDisposable); - } else { - setDisposable(null, state); - } - return ado; - } - - function ObservableBase() { - __super__.call(this, subscribe); - } - - ObservableBase.prototype.subscribeCore = notImplemented; - - return ObservableBase; - }(Observable)); - -var FlatMapObservable = (function(__super__){ - - inherits(FlatMapObservable, __super__); - function FlatMapObservable(source, selector, resultSelector, thisArg) { - this.resultSelector = Rx.helpers.isFunction(resultSelector) ? - resultSelector : null; - - this.selector = Rx.internals.bindCallback(Rx.helpers.isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); - this.source = source; - - __super__.call(this); + var ObserveOnObserver = (function (__super__) { + inherits(ObserveOnObserver, __super__); + function ObserveOnObserver(scheduler, observer, cancel) { + __super__.call(this, scheduler, observer); + this._cancel = cancel; } - FlatMapObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + ObserveOnObserver.prototype.next = function (value) { + __super__.prototype.next.call(this, value); + this.ensureActive(); }; - function InnerObserver(observer, selector, resultSelector, source) { - this.i = 0; - this.selector = selector; - this.resultSelector = resultSelector; - this.source = source; - this.isStopped = false; - this.o = observer; - } + ObserveOnObserver.prototype.error = function (e) { + __super__.prototype.error.call(this, e); + this.ensureActive(); + }; - InnerObserver.prototype._wrapResult = function(result, x, i) { - return this.resultSelector ? - result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : - result; + ObserveOnObserver.prototype.completed = function () { + __super__.prototype.completed.call(this); + this.ensureActive(); }; - InnerObserver.prototype.onNext = function(x) { + ObserveOnObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this._cancel && this._cancel.dispose(); + this._cancel = null; + }; - if (this.isStopped) return; + return ObserveOnObserver; + })(ScheduledObserver); - var i = this.i++; - var result = tryCatch(this.selector)(x, i, this.source); + var observableProto; - if (result === errorObj) { - return this.o.onError(result.e); - } + /** + * Represents a push-style collection. + */ + var Observable = Rx.Observable = (function () { - Rx.helpers.isPromise(result) && (result = Rx.Observable.fromPromise(result)); - (Rx.helpers.isArrayLike(result) || Rx.helpers.isIterable(result)) && (result = Rx.Observable.from(result)); + function makeSubscribe(self, subscribe) { + return function (o) { + var oldOnError = o.onError; + o.onError = function (e) { + makeStackTraceLong(e, self); + oldOnError.call(o, e); + }; - this.o.onNext(this._wrapResult(result, x, i)); + return subscribe.call(self, o); + }; + } - }; + function Observable() { + if (Rx.config.longStackSupport && hasStacks) { + var oldSubscribe = this._subscribe; + var e = tryCatch(thrower)(new Error()).e; + this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); + this._subscribe = makeSubscribe(this, oldSubscribe); + } + } - InnerObserver.prototype.onError = function(e) { - if(!this.isStopped) { this.isStopped = true; this.o.onError(e); } - }; + observableProto = Observable.prototype; - InnerObserver.prototype.onCompleted = function() { - if (!this.isStopped) {this.isStopped = true; this.o.onCompleted(); } + /** + * Determines whether the given object is an Observable + * @param {Any} An object to determine whether it is an Observable + * @returns {Boolean} true if an Observable, else false. + */ + Observable.isObservable = function (o) { + return o && isFunction(o.subscribe); }; + /** + * Subscribes an o to the observable sequence. + * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. + * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { + return this._subscribe(typeof oOrOnNext === 'object' ? + oOrOnNext : + observerCreate(oOrOnNext, onError, onCompleted)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onNext The function to invoke on each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnNext = function (onNext, thisArg) { + return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + }; + + /** + * Subscribes to an exceptional condition in the sequence with an optional "this" argument. + * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnError = function (onError, thisArg) { + return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { + return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + }; + + return Observable; + })(); + + var ObservableBase = Rx.ObservableBase = (function (__super__) { + inherits(ObservableBase, __super__); + + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.subscribeCore).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function ObservableBase() { + __super__.call(this); + } + + ObservableBase.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + ObservableBase.prototype.subscribeCore = notImplemented; + + return ObservableBase; + }(Observable)); + +var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) { + + inherits(FlatMapObservable, __super__); + + function FlatMapObservable(source, selector, resultSelector, thisArg) { + this.resultSelector = isFunction(resultSelector) ? resultSelector : null; + this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); + this.source = source; + __super__.call(this); + } + + FlatMapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(observer, selector, resultSelector, source) { + this.i = 0; + this.selector = selector; + this.resultSelector = resultSelector; + this.source = source; + this.o = observer; + AbstractObserver.call(this); + } + + InnerObserver.prototype._wrapResult = function(result, x, i) { + return this.resultSelector ? + result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : + result; + }; + + InnerObserver.prototype.next = function(x) { + var i = this.i++; + var result = tryCatch(this.selector)(x, i, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result)); + this.o.onNext(this._wrapResult(result, x, i)); + }; + + InnerObserver.prototype.error = function(e) { this.o.onError(e); }; + + InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); }; + return FlatMapObservable; }(ObservableBase)); - + var Enumerable = Rx.internals.Enumerable = function () { }; + function IsDisposedDisposable(state) { + this._s = state; + this.isDisposed = false; + } + + IsDisposedDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.isDisposed = true; + } + }; + var ConcatEnumerableObservable = (function(__super__) { inherits(ConcatEnumerableObservable, __super__); function ConcatEnumerableObservable(sources) { this.sources = sources; __super__.call(this); } - + ConcatEnumerableObservable.prototype.subscribeCore = function (o) { - var isDisposed, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) { - if (isDisposed) { return; } + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -1962,60 +2278,40 @@ var FlatMapObservable = (function(__super__){ d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e))); }); - return new CompositeDisposable(subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); }; - + + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, s, e) { - this.o = o; - this.s = s; - this.e = e; - this.isStopped = false; + this._o = o; + this._s = s; + this._e = e; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } }; - InnerObserver.prototype.onError = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.s(this.e); - } - }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; }; - InnerObserver.prototype.fail = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - return true; - } - return false; - }; - + InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.onError = function (e) { this._o.onError(e); }; + InnerObserver.prototype.onCompleted = function () { this._s(this._e); }; + return ConcatEnumerableObservable; }(ObservableBase)); Enumerable.prototype.concat = function () { return new ConcatEnumerableObservable(this); }; - + var CatchErrorObservable = (function(__super__) { inherits(CatchErrorObservable, __super__); function CatchErrorObservable(sources) { this.sources = sources; __super__.call(this); } - + CatchErrorObservable.prototype.subscribeCore = function (o) { var e = this.sources[$iterator$](); - var isDisposed, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) { - if (isDisposed) { return; } + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -2029,16 +2325,22 @@ var FlatMapObservable = (function(__super__){ var d = new SingleAssignmentDisposable(); subscription.setDisposable(d); - d.setDisposable(currentValue.subscribe( - function(x) { o.onNext(x); }, - self, - function() { o.onCompleted(); })); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self))); }); - return new CompositeDisposable(subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); }; - + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, recurse) { + this._o = o; + this._recurse = recurse; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.error = function (e) { this._recurse(e); }; + InnerObserver.prototype.completed = function () { this._o.onCompleted(); }; + return CatchErrorObservable; }(ObservableBase)); @@ -2056,11 +2358,11 @@ var FlatMapObservable = (function(__super__){ var e = sources[$iterator$](); - var isDisposed, + var state = { isDisposed: false }, lastException, subscription = new SerialDisposable(); - var cancelable = immediateScheduler.scheduleRecursive(function (self) { - if (isDisposed) { return; } + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) { + if (state.isDisposed) { return; } var currentItem = tryCatch(e.next).call(e); if (currentItem === errorObj) { return o.onError(currentItem.e); } @@ -2079,7 +2381,7 @@ var FlatMapObservable = (function(__super__){ var outer = new SingleAssignmentDisposable(); var inner = new SingleAssignmentDisposable(); - subscription.setDisposable(new CompositeDisposable(inner, outer)); + subscription.setDisposable(new BinaryDisposable(inner, outer)); outer.setDisposable(currentValue.subscribe( function(x) { o.onNext(x); }, function (exn) { @@ -2094,23 +2396,21 @@ var FlatMapObservable = (function(__super__){ function() { o.onCompleted(); })); }); - return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () { - isDisposed = true; - })); + return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]); }); }; - + var RepeatEnumerable = (function (__super__) { inherits(RepeatEnumerable, __super__); - + function RepeatEnumerable(v, c) { this.v = v; this.c = c == null ? -1 : c; } RepeatEnumerable.prototype[$iterator$] = function () { - return new RepeatEnumerator(this); + return new RepeatEnumerator(this); }; - + function RepeatEnumerator(p) { this.v = p.v; this.l = p.c; @@ -2118,16 +2418,16 @@ var FlatMapObservable = (function(__super__){ RepeatEnumerator.prototype.next = function () { if (this.l === 0) { return doneEnumerator; } if (this.l > 0) { this.l--; } - return { done: false, value: this.v }; + return { done: false, value: this.v }; }; - + return RepeatEnumerable; }(Enumerable)); var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) { return new RepeatEnumerable(value, repeatCount); }; - + var OfEnumerable = (function(__super__) { inherits(OfEnumerable, __super__); function OfEnumerable(s, fn, thisArg) { @@ -2137,7 +2437,7 @@ var FlatMapObservable = (function(__super__){ OfEnumerable.prototype[$iterator$] = function () { return new OfEnumerator(this); }; - + function OfEnumerator(p) { this.i = -1; this.s = p.s; @@ -2147,71 +2447,173 @@ var FlatMapObservable = (function(__super__){ OfEnumerator.prototype.next = function () { return ++this.i < this.l ? { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } : - doneEnumerator; + doneEnumerator; }; - + return OfEnumerable; }(Enumerable)); var enumerableOf = Enumerable.of = function (source, selector, thisArg) { return new OfEnumerable(source, selector, thisArg); }; - - var ToArrayObservable = (function(__super__) { - inherits(ToArrayObservable, __super__); - function ToArrayObservable(source) { + +var ObserveOnObservable = (function (__super__) { + inherits(ObserveOnObservable, __super__); + function ObserveOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + ObserveOnObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ObserveOnObserver(this._s, o)); + }; + + return ObserveOnObservable; +}(ObservableBase)); + + /** + * Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + * + * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects + * that require to be run on a scheduler, use subscribeOn. + * + * @param {Scheduler} scheduler Scheduler to notify observers on. + * @returns {Observable} The source sequence whose observations happen on the specified scheduler. + */ + observableProto.observeOn = function (scheduler) { + return new ObserveOnObservable(this, scheduler); + }; + + var SubscribeOnObservable = (function (__super__) { + inherits(SubscribeOnObservable, __super__); + function SubscribeOnObservable(source, s) { this.source = source; + this._s = s; __super__.call(this); } - ToArrayObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o)); + function scheduleMethod(scheduler, state) { + var source = state[0], d = state[1], o = state[2]; + d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o))); + } + + SubscribeOnObservable.prototype.subscribeCore = function (o) { + var m = new SingleAssignmentDisposable(), d = new SerialDisposable(); + d.setDisposable(m); + m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod)); + return d; }; - function InnerObserver(o) { - this.o = o; - this.a = []; - this.isStopped = false; + return SubscribeOnObservable; + }(ObservableBase)); + + /** + * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used; + * see the remarks section for more information on the distinction between subscribeOn and observeOn. + + * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer + * callbacks on a scheduler, use observeOn. + + * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on. + * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + observableProto.subscribeOn = function (scheduler) { + return new SubscribeOnObservable(this, scheduler); + }; + + var FromPromiseObservable = (function(__super__) { + inherits(FromPromiseObservable, __super__); + function FromPromiseObservable(p) { + this.p = p; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } }; - InnerObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.o.onNext(this.a); - this.o.onCompleted(); - } - }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; } - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - - return false; + + FromPromiseObservable.prototype.subscribeCore = function(o) { + this.p + .then(function (data) { + o.onNext(data); + o.onCompleted(); + }, function (err) { + o.onError(err); + }); + return disposableEmpty; }; - return ToArrayObservable; + return FromPromiseObservable; }(ObservableBase)); /** - * Creates an array from an observable sequence. - * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + * Converts a Promise to an Observable sequence + * @param {Promise} An ES6 Compliant promise. + * @returns {Observable} An Observable sequence which wraps the existing promise success and failure. */ - observableProto.toArray = function () { - return new ToArrayObservable(this); + var observableFromPromise = Observable.fromPromise = function (promise) { + return new FromPromiseObservable(promise); }; - - /** - * Creates an observable sequence from a specified subscribe method implementation. - * @example + + /* + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence. + */ + observableProto.toPromise = function (promiseCtor) { + promiseCtor || (promiseCtor = Rx.config.Promise); + if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); } + var source = this; + return new promiseCtor(function (resolve, reject) { + // No cancellation can be done + var value; + source.subscribe(function (v) { + value = v; + }, reject, function () { + resolve(value); + }); + }); + }; + + var ToArrayObservable = (function(__super__) { + inherits(ToArrayObservable, __super__); + function ToArrayObservable(source) { + this.source = source; + __super__.call(this); + } + + ToArrayObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o) { + this.o = o; + this.a = []; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this.a.push(x); }; + InnerObserver.prototype.error = function (e) { this.o.onError(e); }; + InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); }; + + return ToArrayObservable; + }(ObservableBase)); + + /** + * Creates an array from an observable sequence. + * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + */ + observableProto.toArray = function () { + return new ToArrayObservable(this); + }; + + /** + * Creates an observable sequence from a specified subscribe method implementation. + * @example * var res = Rx.Observable.create(function (observer) { return function () { } ); * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } ); * var res = Rx.Observable.create(function (observer) { } ); @@ -2221,7 +2623,24 @@ var FlatMapObservable = (function(__super__){ Observable.create = function (subscribe, parent) { return new AnonymousObservable(subscribe, parent); }; - + + var Defer = (function(__super__) { + inherits(Defer, __super__); + function Defer(factory) { + this._f = factory; + __super__.call(this); + } + + Defer.prototype.subscribeCore = function (o) { + var result = tryCatch(this._f)(); + if (result === errorObj) { return observableThrow(result.e).subscribe(o);} + isPromise(result) && (result = observableFromPromise(result)); + return result.subscribe(o); + }; + + return Defer; + }(ObservableBase)); + /** * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. * @@ -2231,18 +2650,9 @@ var FlatMapObservable = (function(__super__){ * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function. */ var observableDefer = Observable.defer = function (observableFactory) { - return new AnonymousObservable(function (observer) { - var result; - try { - result = observableFactory(); - } catch (e) { - return observableThrow(e).subscribe(observer); - } - isPromise(result) && (result = observableFromPromise(result)); - return result.subscribe(observer); - }); + return new Defer(observableFactory); }; - + var EmptyObservable = (function(__super__) { inherits(EmptyObservable, __super__); function EmptyObservable(scheduler) { @@ -2266,7 +2676,10 @@ var FlatMapObservable = (function(__super__){ } EmptySink.prototype.run = function () { - return this.scheduler.scheduleWithState(this.observer, scheduleItem); + var state = this.observer; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); }; return EmptyObservable; @@ -2287,7 +2700,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler); }; - + var FromObservable = (function(__super__) { inherits(FromObservable, __super__); function FromObservable(iterable, mapper, scheduler) { @@ -2333,7 +2746,7 @@ var FlatMapObservable = (function(__super__){ recurse(i + 1); } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; return FromSink; @@ -2444,7 +2857,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromObservable(iterable, mapper, scheduler); } - + var FromArrayObservable = (function(__super__) { inherits(FromArrayObservable, __super__); function FromArrayObservable(args, scheduler) { @@ -2477,9 +2890,9 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; - + /** * Converts an array to an observable sequence, using an optional scheduler to enumerate the array. * @deprecated use Observable.from or Observable.of @@ -2490,30 +2903,64 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromArrayObservable(array, scheduler) }; - - var NeverObservable = (function(__super__) { - inherits(NeverObservable, __super__); - function NeverObservable() { + + var GenerateObservable = (function (__super__) { + inherits(GenerateObservable, __super__); + function GenerateObservable(state, cndFn, itrFn, resFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._s = s; + this._first = true; __super__.call(this); } - NeverObservable.prototype.subscribeCore = function (observer) { - return disposableEmpty; + function scheduleRecursive(self, recurse) { + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + var hasResult = tryCatch(self._cndFn)(self._state); + if (hasResult === errorObj) { return self._o.onError(hasResult.e); } + if (hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + self._o.onNext(result); + recurse(self); + } else { + self._o.onCompleted(); + } + } + + GenerateObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursive(this, scheduleRecursive); }; - return NeverObservable; + return GenerateObservable; }(ObservableBase)); - var NEVER_OBSERVABLE = new NeverObservable(); - /** - * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). - * @returns {Observable} An observable sequence whose observers will never get called. + * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. + * + * @example + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }); + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout); + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread. + * @returns {Observable} The generated sequence. */ - var observableNever = Observable.never = function () { - return NEVER_OBSERVABLE; + Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler); }; - + function observableOf (scheduler, array) { isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new FromArrayObservable(array, scheduler); @@ -2539,7 +2986,76 @@ var FlatMapObservable = (function(__super__){ for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; } return new FromArrayObservable(args, scheduler); }; - + + /** + * Creates an Observable sequence from changes to an array using Array.observe. + * @param {Array} array An array to observe changes. + * @returns {Observable} An observable sequence containing changes to an array from Array.observe. + */ + Observable.ofArrayChanges = function(array) { + if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); } + if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Array.observe(array, observerFn); + + return function () { + Array.unobserve(array, observerFn); + }; + }); + }; + + /** + * Creates an Observable sequence from changes to an object using Object.observe. + * @param {Object} obj An object to observe changes. + * @returns {Observable} An observable sequence containing changes to an object from Object.observe. + */ + Observable.ofObjectChanges = function(obj) { + if (obj == null) { throw new TypeError('object must not be null or undefined.'); } + if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Object.observe(obj, observerFn); + + return function () { + Object.unobserve(obj, observerFn); + }; + }); + }; + + var NeverObservable = (function(__super__) { + inherits(NeverObservable, __super__); + function NeverObservable() { + __super__.call(this); + } + + NeverObservable.prototype.subscribeCore = function (observer) { + return disposableEmpty; + }; + + return NeverObservable; + }(ObservableBase)); + + var NEVER_OBSERVABLE = new NeverObservable(); + + /** + * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). + * @returns {Observable} An observable sequence whose observers will never get called. + */ + var observableNever = Observable.never = function () { + return NEVER_OBSERVABLE; + }; + var PairsObservable = (function(__super__) { inherits(PairsObservable, __super__); function PairsObservable(obj, scheduler) { @@ -2574,7 +3090,7 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; /** @@ -2587,7 +3103,7 @@ var FlatMapObservable = (function(__super__){ scheduler || (scheduler = currentThreadScheduler); return new PairsObservable(obj, scheduler); }; - + var RangeObservable = (function(__super__) { inherits(RangeObservable, __super__); function RangeObservable(start, count, scheduler) { @@ -2622,7 +3138,7 @@ var FlatMapObservable = (function(__super__){ } } - return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive); + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); }; return RangeSink; @@ -2639,7 +3155,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new RangeObservable(start, count, scheduler); }; - + var RepeatObservable = (function(__super__) { inherits(RepeatObservable, __super__); function RepeatObservable(value, repeatCount, scheduler) { @@ -2673,7 +3189,7 @@ var FlatMapObservable = (function(__super__){ recurse(i); } - return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive); + return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive); }; /** @@ -2687,7 +3203,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = currentThreadScheduler); return new RepeatObservable(value, repeatCount, scheduler); }; - + var JustObservable = (function(__super__) { inherits(JustObservable, __super__); function JustObservable(value, scheduler) { @@ -2718,7 +3234,7 @@ var FlatMapObservable = (function(__super__){ var state = [this.value, this.observer]; return this.scheduler === immediateScheduler ? scheduleItem(null, state) : - this.scheduler.scheduleWithState(state, scheduleItem); + this.scheduler.schedule(state, scheduleItem); }; return JustObservable; @@ -2735,7 +3251,7 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return new JustObservable(value, scheduler); }; - + var ThrowObservable = (function(__super__) { inherits(ThrowObservable, __super__); function ThrowObservable(error, scheduler) { @@ -2760,7 +3276,7 @@ var FlatMapObservable = (function(__super__){ } ThrowSink.prototype.run = function () { - return this.p.scheduler.scheduleWithState([this.p.error, this.o], scheduleItem); + return this.p.scheduler.schedule([this.p.error, this.o], scheduleItem); }; return ThrowObservable; @@ -2777,7 +3293,146 @@ var FlatMapObservable = (function(__super__){ isScheduler(scheduler) || (scheduler = immediateScheduler); return new ThrowObservable(error, scheduler); }; - + + var UsingObservable = (function (__super__) { + inherits(UsingObservable, __super__); + function UsingObservable(resFn, obsFn) { + this._resFn = resFn; + this._obsFn = obsFn; + __super__.call(this); + } + + UsingObservable.prototype.subscribeCore = function (o) { + var disposable = disposableEmpty; + var resource = tryCatch(this._resFn)(); + if (resource === errorObj) { + return new BinaryDisposable(observableThrow(resource.e).subscribe(o), disposable); + } + resource && (disposable = resource); + var source = tryCatch(this._obsFn)(resource); + if (source === errorObj) { + return new BinaryDisposable(observableThrow(source.e).subscribe(o), disposable); + } + return new BinaryDisposable(source.subscribe(o), disposable); + }; + + return UsingObservable; + }(ObservableBase)); + + /** + * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. + * @param {Function} resourceFactory Factory function to obtain a resource object. + * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource. + * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object. + */ + Observable.using = function (resourceFactory, observableFactory) { + return new UsingObservable(resourceFactory, observableFactory); + }; + + /** + * Propagates the observable sequence or Promise that reacts first. + * @param {Observable} rightSource Second observable sequence or Promise. + * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first. + */ + observableProto.amb = function (rightSource) { + var leftSource = this; + return new AnonymousObservable(function (observer) { + var choice, + leftChoice = 'L', rightChoice = 'R', + leftSubscription = new SingleAssignmentDisposable(), + rightSubscription = new SingleAssignmentDisposable(); + + isPromise(rightSource) && (rightSource = observableFromPromise(rightSource)); + + function choiceL() { + if (!choice) { + choice = leftChoice; + rightSubscription.dispose(); + } + } + + function choiceR() { + if (!choice) { + choice = rightChoice; + leftSubscription.dispose(); + } + } + + var leftSubscribe = observerCreate( + function (left) { + choiceL(); + choice === leftChoice && observer.onNext(left); + }, + function (e) { + choiceL(); + choice === leftChoice && observer.onError(e); + }, + function () { + choiceL(); + choice === leftChoice && observer.onCompleted(); + } + ); + var rightSubscribe = observerCreate( + function (right) { + choiceR(); + choice === rightChoice && observer.onNext(right); + }, + function (e) { + choiceR(); + choice === rightChoice && observer.onError(e); + }, + function () { + choiceR(); + choice === rightChoice && observer.onCompleted(); + } + ); + + leftSubscription.setDisposable(leftSource.subscribe(leftSubscribe)); + rightSubscription.setDisposable(rightSource.subscribe(rightSubscribe)); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }); + }; + + function amb(p, c) { return p.amb(c); } + + /** + * Propagates the observable sequence or Promise that reacts first. + * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first. + */ + Observable.amb = function () { + var acc = observableNever(), items; + if (Array.isArray(arguments[0])) { + items = arguments[0]; + } else { + var len = arguments.length; + items = new Array(items); + for(var i = 0; i < len; i++) { items[i] = arguments[i]; } + } + for (var i = 0, len = items.length; i < len; i++) { + acc = amb(acc, items[i]); + } + return acc; + }; + + var CatchObservable = (function (__super__) { + inherits(CatchObservable, __super__); + function CatchObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + CatchObservable.prototype.subscribeCore = function (o) { + var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable(); + subscription.setDisposable(d1); + d1.setDisposable(this.source.subscribe(new CatchObserver(o, subscription, this._fn))); + return subscription; + }; + + return CatchObservable; + }(ObservableBase)); + var CatchObserver = (function(__super__) { inherits(CatchObserver, __super__); function CatchObserver(o, s, fn) { @@ -2802,24 +3457,15 @@ var FlatMapObservable = (function(__super__){ return CatchObserver; }(AbstractObserver)); - function observableCatchHandler(source, handler) { - return new AnonymousObservable(function (o) { - var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable(); - subscription.setDisposable(d1); - d1.setDisposable(source.subscribe(new CatchObserver(o, subscription, handler))); - return subscription; - }, source); - } - /** * Continues an observable sequence that is terminated by an exception with the next observable sequence. * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence. * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred. */ observableProto['catch'] = function (handlerOrSecond) { - return isFunction(handlerOrSecond) ? observableCatchHandler(this, handlerOrSecond) : observableCatch([this, handlerOrSecond]); + return isFunction(handlerOrSecond) ? new CatchObservable(this, handlerOrSecond) : observableCatch([this, handlerOrSecond]); }; - + /** * Continues an observable sequence that is terminated by an exception with the next observable sequence. * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs. @@ -2836,7 +3482,7 @@ var FlatMapObservable = (function(__super__){ } return enumerableOf(items).catchError(); }; - + /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. * This can be in the form of an argument list of observables or an array. @@ -2856,7 +3502,7 @@ var FlatMapObservable = (function(__super__){ } return combineLatest.apply(this, args); }; - + function falseFactory() { return false; } function argumentsToArray() { var len = arguments.length, args = new Array(len); @@ -2864,66 +3510,84 @@ var FlatMapObservable = (function(__super__){ return args; } - /** - * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. - * - * @example - * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; }); - * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; }); - * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - var combineLatest = Observable.combineLatest = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - Array.isArray(args[0]) && (args = args[0]); + var CombineLatestObservable = (function(__super__) { + inherits(CombineLatestObservable, __super__); + function CombineLatestObservable(params, cb) { + var len = params.length; + this._params = params; + this._cb = cb; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._done = arrayInitialize(len, falseFactory); + this._v = new Array(len); + __super__.call(this); + } - return new AnonymousObservable(function (o) { - var n = args.length, - hasValue = arrayInitialize(n, falseFactory), - hasValueAll = false, - isDone = arrayInitialize(n, falseFactory), - values = new Array(n); + CombineLatestObservable.prototype.subscribeCore = function(observer) { + var len = this._params.length, subscriptions = new Array(len); - function next(i) { - hasValue[i] = true; - if (hasValueAll || (hasValueAll = hasValue.every(identity))) { - try { - var res = resultSelector.apply(null, values); - } catch (e) { - return o.onError(e); - } - o.onNext(res); - } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { - o.onCompleted(); - } + for (var i = 0; i < len; i++) { + var source = this._params[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new CombineLatestObserver(observer, i, this))); } - function done (i) { - isDone[i] = true; - isDone.every(identity) && o.onCompleted(); - } + return new NAryDisposable(subscriptions); + }; - var subscriptions = new Array(n); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var source = args[i], sad = new SingleAssignmentDisposable(); - isPromise(source) && (source = observableFromPromise(source)); - sad.setDisposable(source.subscribe(function (x) { - values[i] = x; - next(i); - }, - function(e) { o.onError(e); }, - function () { done(i); } - )); - subscriptions[i] = sad; - }(idx)); + return CombineLatestObservable; + }(ObservableBase)); + + var CombineLatestObserver = (function (__super__) { + inherits(CombineLatestObserver, __super__); + function CombineLatestObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + CombineLatestObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + if (this._p._hvAll || (this._p._hvAll = this._p._hv.every(identity))) { + var res = tryCatch(this._p._cb).apply(null, this._p._v); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); } + }; - return new CompositeDisposable(subscriptions); - }, this); + CombineLatestObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + CombineLatestObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return CombineLatestObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element. + * + * @example + * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; }); + * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; }); + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + var combineLatest = Observable.combineLatest = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + return new CombineLatestObservable(args, resultSelector); }; - + /** * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate. * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order. @@ -2933,7 +3597,7 @@ var FlatMapObservable = (function(__super__){ args.unshift(this); return observableConcat.apply(null, args); }; - + var ConcatObservable = (function(__super__) { inherits(ConcatObservable, __super__); function ConcatObservable(sources) { @@ -2952,7 +3616,7 @@ var FlatMapObservable = (function(__super__){ } ConcatSink.prototype.run = function () { var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o; - var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) { + var cancelable = immediateScheduler.scheduleRecursive(0, function (i, self) { if (isDisposed) { return; } if (i === length) { return o.onCompleted(); @@ -2995,7 +3659,7 @@ var FlatMapObservable = (function(__super__){ } return new ConcatObservable(args); }; - + /** * Concatenates an observable sequence of observable sequences. * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order. @@ -3003,7 +3667,7 @@ var FlatMapObservable = (function(__super__){ observableProto.concatAll = function () { return this.merge(1); }; - + var MergeObservable = (function (__super__) { inherits(MergeObservable, __super__); @@ -3130,7 +3794,7 @@ var FlatMapObservable = (function(__super__){ observableMerge(this, maxConcurrentOrOther) : new MergeObservable(this, maxConcurrentOrOther); }; - + /** * Merges all the observable sequences into a single observable sequence. * The scheduler is optional and if not specified, the immediate scheduler is used. @@ -3153,7 +3817,103 @@ var FlatMapObservable = (function(__super__){ } return observableOf(scheduler, sources).mergeAll(); }; - + + var MergeAllObservable = (function (__super__) { + inherits(MergeAllObservable, __super__); + + function MergeAllObservable(source) { + this.source = source; + __super__.call(this); + } + + MergeAllObservable.prototype.subscribeCore = function (observer) { + var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); + g.add(m); + m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); + return g; + }; + + function MergeAllObserver(o, g) { + this.o = o; + this.g = g; + this.isStopped = false; + this.done = false; + } + MergeAllObserver.prototype.onNext = function(innerSource) { + if(this.isStopped) { return; } + var sad = new SingleAssignmentDisposable(); + this.g.add(sad); + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + }; + MergeAllObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + } + }; + MergeAllObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.done = true; + this.g.length === 1 && this.o.onCompleted(); + } + }; + MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; + MergeAllObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + + return false; + }; + + function InnerObserver(parent, sad) { + this.parent = parent; + this.sad = sad; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; + InnerObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + var parent = this.parent; + this.isStopped = true; + parent.g.remove(this.sad); + parent.done && parent.g.length === 1 && parent.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeAllObservable; + }(ObservableBase)); + + /** + * Merges an observable sequence of observable sequences into an observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.mergeAll = function () { + return new MergeAllObservable(this); + }; + var CompositeError = Rx.CompositeError = function(errors) { this.name = "NotImplementedError"; this.innerErrors = errors; @@ -3234,133 +3994,132 @@ var FlatMapObservable = (function(__super__){ return group; }); }; - - var MergeAllObservable = (function (__super__) { - inherits(MergeAllObservable, __super__); - function MergeAllObservable(source) { - this.source = source; - __super__.call(this); + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates. + * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally. + */ + observableProto.onErrorResumeNext = function (second) { + if (!second) { throw new Error('Second observable is required'); } + return onErrorResumeNext([this, second]); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * + * @example + * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs); + * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]); + * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. + */ + var onErrorResumeNext = Observable.onErrorResumeNext = function () { + var sources = []; + if (Array.isArray(arguments[0])) { + sources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } } + return new AnonymousObservable(function (observer) { + var pos = 0, subscription = new SerialDisposable(), + cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) { + var current, d; + if (pos < sources.length) { + current = sources[pos++]; + isPromise(current) && (current = observableFromPromise(current)); + d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self)); + } else { + observer.onCompleted(); + } + }); + return new BinaryDisposable(subscription, cancelable); + }); + }; - MergeAllObservable.prototype.subscribeCore = function (observer) { - var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); - g.add(m); - m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); - return g; - }; + var SkipUntilObservable = (function(__super__) { + inherits(SkipUntilObservable, __super__); - function MergeAllObserver(o, g) { - this.o = o; - this.g = g; - this.isStopped = false; - this.done = false; + function SkipUntilObservable(source, other) { + this._s = source; + this._o = isPromise(other) ? observableFromPromise(other) : other; + this._open = false; + __super__.call(this); } - MergeAllObserver.prototype.onNext = function(innerSource) { - if(this.isStopped) { return; } - var sad = new SingleAssignmentDisposable(); - this.g.add(sad); - isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + SkipUntilObservable.prototype.subscribeCore = function(o) { + var leftSubscription = new SingleAssignmentDisposable(); + leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this))); - sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + isPromise(this._o) && (this._o = observableFromPromise(this._o)); + + var rightSubscription = new SingleAssignmentDisposable(); + rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription))); + + return new BinaryDisposable(leftSubscription, rightSubscription); }; - MergeAllObserver.prototype.onError = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } + + return SkipUntilObservable; + }(ObservableBase)); + + var SkipUntilSourceObserver = (function(__super__) { + inherits(SkipUntilSourceObserver, __super__); + function SkipUntilSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilSourceObserver.prototype.next = function (x) { + this._p._open && this._o.onNext(x); }; - MergeAllObserver.prototype.onCompleted = function () { - if(!this.isStopped) { - this.isStopped = true; - this.done = true; - this.g.length === 1 && this.o.onCompleted(); - } + + SkipUntilSourceObserver.prototype.error = function (err) { + this._o.onError(err); }; - MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; - MergeAllObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + SkipUntilSourceObserver.prototype.onCompleted = function () { + this._p._open && this._o.onCompleted(); }; - function InnerObserver(parent, sad) { - this.parent = parent; - this.sad = sad; - this.isStopped = false; + return SkipUntilSourceObserver; + }(AbstractObserver)); + + var SkipUntilOtherObserver = (function(__super__) { + inherits(SkipUntilOtherObserver, __super__); + function SkipUntilOtherObserver(o, p, r) { + this._o = o; + this._p = p; + this._r = r; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; - InnerObserver.prototype.onError = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - } + + SkipUntilOtherObserver.prototype.next = function () { + this._p._open = true; + this._r.dispose(); }; - InnerObserver.prototype.onCompleted = function () { - if(!this.isStopped) { - var parent = this.parent; - this.isStopped = true; - parent.g.remove(this.sad); - parent.done && parent.g.length === 1 && parent.o.onCompleted(); - } + + SkipUntilOtherObserver.prototype.error = function (err) { + this._o.onError(err); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - return true; - } - return false; + SkipUntilOtherObserver.prototype.onCompleted = function () { + this._r.dispose(); }; - return MergeAllObservable; - }(ObservableBase)); + return SkipUntilOtherObserver; + }(AbstractObserver)); - /** - * Merges an observable sequence of observable sequences into an observable sequence. - * @returns {Observable} The observable sequence that merges the elements of the inner sequences. - */ - observableProto.mergeAll = function () { - return new MergeAllObservable(this); - }; - /** * Returns the values from the source observable sequence only after the other observable sequence produces a value. * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence. * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation. */ observableProto.skipUntil = function (other) { - var source = this; - return new AnonymousObservable(function (o) { - var isOpen = false; - var disposables = new CompositeDisposable(source.subscribe(function (left) { - isOpen && o.onNext(left); - }, function (e) { o.onError(e); }, function () { - isOpen && o.onCompleted(); - })); - - isPromise(other) && (other = observableFromPromise(other)); - - var rightSubscription = new SingleAssignmentDisposable(); - disposables.add(rightSubscription); - rightSubscription.setDisposable(other.subscribe(function () { - isOpen = true; - rightSubscription.dispose(); - }, function (e) { o.onError(e); }, function () { - rightSubscription.dispose(); - })); - - return disposables; - }, source); + return new SkipUntilObservable(this, other); }; - + var SwitchObservable = (function(__super__) { inherits(SwitchObservable, __super__); function SwitchObservable(source) { @@ -3370,80 +4129,55 @@ var FlatMapObservable = (function(__super__){ SwitchObservable.prototype.subscribeCore = function (o) { var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner)); - return new CompositeDisposable(s, inner); + return new BinaryDisposable(s, inner); }; + inherits(SwitchObserver, AbstractObserver); function SwitchObserver(o, inner) { this.o = o; this.inner = inner; this.stopped = false; this.latest = 0; this.hasLatest = false; - this.isStopped = false; + AbstractObserver.call(this); } - SwitchObserver.prototype.onNext = function (innerSource) { - if (this.isStopped) { return; } + + SwitchObserver.prototype.next = function (innerSource) { var d = new SingleAssignmentDisposable(), id = ++this.latest; this.hasLatest = true; this.inner.setDisposable(d); isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); d.setDisposable(innerSource.subscribe(new InnerObserver(this, id))); }; - SwitchObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }; - SwitchObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.stopped = true; - !this.hasLatest && this.o.onCompleted(); - } + + SwitchObserver.prototype.error = function (e) { + this.o.onError(e); }; - SwitchObserver.prototype.dispose = function () { this.isStopped = true; }; - SwitchObserver.prototype.fail = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + + SwitchObserver.prototype.completed = function () { + this.stopped = true; + !this.hasLatest && this.o.onCompleted(); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(parent, id) { this.parent = parent; this.id = id; - this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function (x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function (x) { this.parent.latest === this.id && this.parent.o.onNext(x); }; - InnerObserver.prototype.onError = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.parent.latest === this.id && this.parent.o.onError(e); - } - }; - InnerObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - if (this.parent.latest === this.id) { - this.parent.hasLatest = false; - this.parent.isStopped && this.parent.o.onCompleted(); - } - } + + InnerObserver.prototype.error = function (e) { + this.parent.latest === this.id && this.parent.o.onError(e); }; - InnerObserver.prototype.dispose = function () { this.isStopped = true; } - InnerObserver.prototype.fail = function (e) { - if(!this.isStopped) { - this.isStopped = true; - this.parent.o.onError(e); - return true; + + InnerObserver.prototype.completed = function () { + if (this.parent.latest === this.id) { + this.parent.hasLatest = false; + this.parent.isStopped && this.parent.o.onCompleted(); } - return false; }; return SwitchObservable; @@ -3456,7 +4190,7 @@ var FlatMapObservable = (function(__super__){ observableProto['switch'] = observableProto.switchLatest = function () { return new SwitchObservable(this); }; - + var TakeUntilObservable = (function(__super__) { inherits(TakeUntilObservable, __super__); @@ -3467,41 +4201,34 @@ var FlatMapObservable = (function(__super__){ } TakeUntilObservable.prototype.subscribeCore = function(o) { - return new CompositeDisposable( + return new BinaryDisposable( this.source.subscribe(o), - this.other.subscribe(new InnerObserver(o)) + this.other.subscribe(new TakeUntilObserver(o)) ); }; - function InnerObserver(o) { - this.o = o; - this.isStopped = false; + return TakeUntilObservable; + }(ObservableBase)); + + var TakeUntilObserver = (function(__super__) { + inherits(TakeUntilObserver, __super__); + function TakeUntilObserver(o) { + this._o = o; + __super__.call(this); } - InnerObserver.prototype.onNext = function (x) { - if (this.isStopped) { return; } - this.o.onCompleted(); - }; - InnerObserver.prototype.onError = function (err) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function () { - !this.isStopped && (this.isStopped = true); + + TakeUntilObserver.prototype.next = function () { + this._o.onCompleted(); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + + TakeUntilObserver.prototype.error = function (err) { + this._o.onError(err); }; - return TakeUntilObservable; - }(ObservableBase)); + TakeUntilObserver.prototype.onCompleted = noop; + + return TakeUntilObserver; + }(AbstractObserver)); /** * Returns the values from the source observable sequence until the other observable sequence produces a value. @@ -3511,62 +4238,174 @@ var FlatMapObservable = (function(__super__){ observableProto.takeUntil = function (other) { return new TakeUntilObservable(this, other); }; - + function falseFactory() { return false; } + function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; + } + + var WithLatestFromObservable = (function(__super__) { + inherits(WithLatestFromObservable, __super__); + function WithLatestFromObservable(source, sources, resultSelector) { + var len = sources.length; + this._s = source; + this._ss = sources; + this._cb = resultSelector; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._v = new Array(len); + __super__.call(this); + } + + WithLatestFromObservable.prototype.subscribeCore = function (o) { + var n = this._ss.length, subscriptions = new Array(n + 1); + for (var i = 0; i < n; i++) { + var other = this._ss[i], sad = new SingleAssignmentDisposable(); + isPromise(other) && (other = observableFromPromise(other)); + sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this))); + subscriptions[i] = sad; + } + + var sad = new SingleAssignmentDisposable(); + sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this))); + subscriptions[n] = sad; + + return new NAryDisposable(subscriptions); + }; + + return WithLatestFromObservable; + }(ObservableBase)); + + var WithLatestFromOtherObserver = (function (__super__) { + inherits(WithLatestFromOtherObserver, __super__); + function WithLatestFromOtherObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + WithLatestFromOtherObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + this._p._hvAll = this._p._hv.every(identity); + }; + + WithLatestFromOtherObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromOtherObserver.prototype.completed = noop; + + return WithLatestFromOtherObserver; + }(AbstractObserver)); + + var WithLatestFromSourceObserver = (function (__super__) { + inherits(WithLatestFromSourceObserver, __super__); + function WithLatestFromSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + WithLatestFromSourceObserver.prototype.next = function (x) { + var allValues = [x].concat(this._p._v); + if (!this._p._hvAll) { return; } + var res = tryCatch(this._p._cb).apply(null, allValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + }; + + WithLatestFromSourceObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromSourceObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return WithLatestFromSourceObserver; + }(AbstractObserver)); /** * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element. * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. */ observableProto.withLatestFrom = function () { - var len = arguments.length, args = new Array(len) + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = args.pop(), source = this; + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; Array.isArray(args[0]) && (args = args[0]); - return new AnonymousObservable(function (observer) { - var n = args.length, - hasValue = arrayInitialize(n, falseFactory), - hasValueAll = false, - values = new Array(n); + return new WithLatestFromObservable(this, args, resultSelector); + }; - var subscriptions = new Array(n + 1); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var other = args[i], sad = new SingleAssignmentDisposable(); - isPromise(other) && (other = observableFromPromise(other)); - sad.setDisposable(other.subscribe(function (x) { - values[i] = x; - hasValue[i] = true; - hasValueAll = hasValue.every(identity); - }, function (e) { observer.onError(e); }, noop)); - subscriptions[i] = sad; - }(idx)); + function falseFactory() { return false; } + function emptyArrayFactory() { return []; } + + var ZipObservable = (function(__super__) { + inherits(ZipObservable, __super__); + function ZipObservable(sources, resultSelector) { + var len = sources.length; + this._s = sources; + this._cb = resultSelector; + this._done = arrayInitialize(len, falseFactory); + this._q = arrayInitialize(len, emptyArrayFactory); + __super__.call(this); + } + + ZipObservable.prototype.subscribeCore = function(observer) { + var n = this._s.length, subscriptions = new Array(n); + + for (var i = 0; i < n; i++) { + var source = this._s[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this))); } - var sad = new SingleAssignmentDisposable(); - sad.setDisposable(source.subscribe(function (x) { - var allValues = [x].concat(values); - if (!hasValueAll) { return; } - var res = tryCatch(resultSelector).apply(null, allValues); - if (res === errorObj) { return observer.onError(res.e); } - observer.onNext(res); - }, function (e) { observer.onError(e); }, function () { - observer.onCompleted(); - })); - subscriptions[n] = sad; + return new NAryDisposable(subscriptions); + }; - return new CompositeDisposable(subscriptions); - }, this); - }; - - function falseFactory() { return false; } - function emptyArrayFactory() { return []; } - function argumentsToArray() { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return args; - } + return ZipObservable; + }(ObservableBase)); + + var ZipObserver = (function (__super__) { + inherits(ZipObserver, __super__); + function ZipObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + ZipObserver.prototype.next = function (x) { + this._p._q[this._i].push(x); + if (this._p._q.every(function (x) { return x.length > 0; })) { + var queuedValues = this._p._q.map(function (x) { return x.shift(); }); + var res = tryCatch(this._p._cb).apply(null, queuedValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); + } + }; + + ZipObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ZipObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return ZipObserver; + }(AbstractObserver)); /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. @@ -3583,40 +4422,10 @@ var FlatMapObservable = (function(__super__){ var parent = this; args.unshift(parent); - return new AnonymousObservable(function (o) { - var n = args.length, - queues = arrayInitialize(n, emptyArrayFactory), - isDone = arrayInitialize(n, falseFactory); - - var subscriptions = new Array(n); - for (var idx = 0; idx < n; idx++) { - (function (i) { - var source = args[i], sad = new SingleAssignmentDisposable(); - - isPromise(source) && (source = observableFromPromise(source)); - - sad.setDisposable(source.subscribe(function (x) { - queues[i].push(x); - if (queues.every(function (x) { return x.length > 0; })) { - var queuedValues = queues.map(function (x) { return x.shift(); }), - res = tryCatch(resultSelector).apply(parent, queuedValues); - if (res === errorObj) { return o.onError(res.e); } - o.onNext(res); - } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { - o.onCompleted(); - } - }, function (e) { o.onError(e); }, function () { - isDone[i] = true; - isDone.every(identity) && o.onCompleted(); - })); - subscriptions[i] = sad; - })(idx); - } - return new CompositeDisposable(subscriptions); - }, parent); + return new ZipObservable(args, resultSelector); }; - + /** * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. * @param arguments Observable sources. @@ -3632,7 +4441,7 @@ var FlatMapObservable = (function(__super__){ var first = args.shift(); return first.zip.apply(first, args); }; - + function falseFactory() { return false; } function emptyArrayFactory() { return []; } function argumentsToArray() { @@ -3688,7 +4497,7 @@ observableProto.zipIterable = function () { return new CompositeDisposable(subscriptions); }, parent); }; - + function asObservable(source) { return function subscribe(o) { return source.subscribe(o); }; } @@ -3700,18 +4509,60 @@ observableProto.zipIterable = function () { observableProto.asObservable = function () { return new AnonymousObservable(asObservable(this), this); }; - + + function toArray(x) { return x.toArray(); } + function notEmpty(x) { return x.length > 0; } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information. + * @param {Number} count Length of each buffer. + * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithCount = function (count, skip) { + typeof skip !== 'number' && (skip = count); + return this.windowWithCount(count, skip) + .flatMap(toArray) + .filter(notEmpty); + }; + + var DematerializeObservable = (function (__super__) { + inherits(DematerializeObservable, __super__); + function DematerializeObservable(source) { + this.source = source; + __super__.call(this); + } + + DematerializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DematerializeObserver(o)); + }; + + return DematerializeObservable; + }(ObservableBase)); + + var DematerializeObserver = (function (__super__) { + inherits(DematerializeObserver, __super__); + + function DematerializeObserver(o) { + this._o = o; + __super__.call(this); + } + + DematerializeObserver.prototype.next = function (x) { x.accept(this._o); }; + DematerializeObserver.prototype.error = function (e) { this._o.onError(e); }; + DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DematerializeObserver; + }(AbstractObserver)); + /** * Dematerializes the explicit notification values of an observable sequence as implicit notifications. * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. */ observableProto.dematerialize = function () { - var source = this; - return new AnonymousObservable(function (o) { - return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); }); - }, this); + return new DematerializeObservable(this); }; - + var DistinctUntilChangedObservable = (function(__super__) { inherits(DistinctUntilChangedObservable, __super__); function DistinctUntilChangedObservable(source, keyFn, comparer) { @@ -3775,7 +4626,7 @@ observableProto.zipIterable = function () { comparer || (comparer = defaultComparer); return new DistinctUntilChangedObservable(this, keyFn, comparer); }; - + var TapObservable = (function(__super__) { inherits(TapObservable,__super__); function TapObservable(source, observerOrOnNext, onError, onCompleted) { @@ -3790,43 +4641,29 @@ observableProto.zipIterable = function () { return this.source.subscribe(new InnerObserver(o, this)); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, p) { this.o = o; this.t = !p._oN || isFunction(p._oN) ? observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) : p._oN; this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function(x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function(x) { var res = tryCatch(this.t.onNext).call(this.t, x); if (res === errorObj) { this.o.onError(res.e); } this.o.onNext(x); }; - InnerObserver.prototype.onError = function(err) { - if (!this.isStopped) { - this.isStopped = true; - var res = tryCatch(this.t.onError).call(this.t, err); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function() { - if (!this.isStopped) { - this.isStopped = true; - var res = tryCatch(this.t.onCompleted).call(this.t); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onCompleted(); - } + InnerObserver.prototype.error = function(err) { + var res = tryCatch(this.t.onError).call(this.t, err); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onError(err); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + InnerObserver.prototype.completed = function() { + var res = tryCatch(this.t.onCompleted).call(this.t); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onCompleted(); }; return TapObservable; @@ -3876,7 +4713,7 @@ observableProto.zipIterable = function () { observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) { return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted); }; - + /** * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. * @param {Function} finallyAction Action to invoke after the source observable sequence terminates. @@ -3897,7 +4734,7 @@ observableProto.zipIterable = function () { }); }, this); }; - + var IgnoreElementsObservable = (function(__super__) { inherits(IgnoreElementsObservable, __super__); @@ -3948,26 +4785,44 @@ observableProto.zipIterable = function () { observableProto.ignoreElements = function () { return new IgnoreElementsObservable(this); }; - + + var MaterializeObservable = (function (__super__) { + inherits(MaterializeObservable, __super__); + function MaterializeObservable(source, fn) { + this.source = source; + __super__.call(this); + } + + MaterializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new MaterializeObserver(o)); + }; + + return MaterializeObservable; + }(ObservableBase)); + + var MaterializeObserver = (function (__super__) { + inherits(MaterializeObserver, __super__); + + function MaterializeObserver(o) { + this._o = o; + __super__.call(this); + } + + MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) }; + MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); }; + MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); }; + + return MaterializeObserver; + }(AbstractObserver)); + /** * Materializes the implicit notifications of an observable sequence as explicit notification values. * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence. */ observableProto.materialize = function () { - var source = this; - return new AnonymousObservable(function (observer) { - return source.subscribe(function (value) { - observer.onNext(notificationCreateOnNext(value)); - }, function (e) { - observer.onNext(notificationCreateOnError(e)); - observer.onCompleted(); - }, function () { - observer.onNext(notificationCreateOnCompleted()); - observer.onCompleted(); - }); - }, source); + return new MaterializeObservable(this); }; - + /** * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely. * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely. @@ -3976,7 +4831,7 @@ observableProto.zipIterable = function () { observableProto.repeat = function (repeatCount) { return enumerableRepeat(this, repeatCount).concat(); }; - + /** * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely. * Note if you encounter an error and want it to retry once, then you must use .retry(2); @@ -3990,7 +4845,7 @@ observableProto.zipIterable = function () { observableProto.retry = function (retryCount) { return enumerableRepeat(this, retryCount).catchError(); }; - + /** * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. * if the notifier completes, the observable sequence completes. @@ -4003,7 +4858,7 @@ observableProto.zipIterable = function () { */ observableProto.retryWhen = function (notifier) { return enumerableRepeat(this).catchErrorWhen(notifier); - }; + }; var ScanObservable = (function(__super__) { inherits(ScanObservable, __super__); function ScanObservable(source, accumulator, hasSeed, seed) { @@ -4015,58 +4870,51 @@ observableProto.zipIterable = function () { } ScanObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o,this)); + return this.source.subscribe(new ScanObserver(o,this)); }; return ScanObservable; }(ObservableBase)); - function InnerObserver(o, parent) { - this.o = o; - this.accumulator = parent.accumulator; - this.hasSeed = parent.hasSeed; - this.seed = parent.seed; - this.hasAccumulation = false; - this.accumulation = null; - this.hasValue = false; - this.isStopped = false; - } - InnerObserver.prototype = { - onNext: function (x) { - if (this.isStopped) { return; } - !this.hasValue && (this.hasValue = true); - if (this.hasAccumulation) { - this.accumulation = tryCatch(this.accumulator)(this.accumulation, x); + var ScanObserver = (function (__super__) { + inherits(ScanObserver, __super__); + function ScanObserver(o, parent) { + this._o = o; + this._p = parent; + this._fn = parent.accumulator; + this._hs = parent.hasSeed; + this._s = parent.seed; + this._ha = false; + this._a = null; + this._hv = false; + this._i = 0; + __super__.call(this); + } + + ScanObserver.prototype.next = function (x) { + !this._hv && (this._hv = true); + if (this._ha) { + this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); } else { - this.accumulation = this.hasSeed ? tryCatch(this.accumulator)(this.seed, x) : x; - this.hasAccumulation = true; + this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; + this._ha = true; } - if (this.accumulation === errorObj) { return this.o.onError(this.accumulation.e); } - this.o.onNext(this.accumulation); - }, - onError: function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - } - }, - onCompleted: function () { - if (!this.isStopped) { - this.isStopped = true; - !this.hasValue && this.hasSeed && this.o.onNext(this.seed); - this.o.onCompleted(); - } - }, - dispose: function() { this.isStopped = true; }, - fail: function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; - } - }; + if (this._a === errorObj) { return this._o.onError(this._a.e); } + this._o.onNext(this._a); + this._i++; + }; + + ScanObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ScanObserver.prototype.completed = function () { + !this._hv && this._hs && this._o.onNext(this._s); + this._o.onCompleted(); + }; + + return ScanObserver; + }(AbstractObserver)); /** * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. @@ -4083,7 +4931,47 @@ observableProto.zipIterable = function () { } return new ScanObservable(this, accumulator, hasSeed, seed); }; - + + var SkipLastObservable = (function (__super__) { + inherits(SkipLastObservable, __super__); + function SkipLastObservable(source, c) { + this.source = source; + this._c = c; + __super__.call(this); + } + + SkipLastObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastObserver(o, this._c)); + }; + + return SkipLastObservable; + }(ObservableBase)); + + var SkipLastObserver = (function (__super__) { + inherits(SkipLastObserver, __super__); + function SkipLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + SkipLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._o.onNext(this._q.shift()); + }; + + SkipLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + SkipLastObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return SkipLastObserver; + }(AbstractObserver)); + /** * Bypasses a specified number of elements at the end of an observable sequence. * @description @@ -4094,16 +4982,9 @@ observableProto.zipIterable = function () { */ observableProto.skipLast = function (count) { if (count < 0) { throw new ArgumentOutOfRangeError(); } - var source = this; - return new AnonymousObservable(function (o) { - var q = []; - return source.subscribe(function (x) { - q.push(x); - q.length > count && o.onNext(q.shift()); - }, function (e) { o.onError(e); }, function () { o.onCompleted(); }); - }, source); + return new SkipLastObservable(this, count); }; - + /** * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend. * @example @@ -4123,7 +5004,33 @@ observableProto.zipIterable = function () { for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); } return enumerableOf([observableFromArray(args, scheduler), this]).concat(); }; - + + var TakeLastObserver = (function (__super__) { + inherits(TakeLastObserver, __super__); + function TakeLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastObserver.prototype.completed = function () { + while (this._q.length > 0) { this._o.onNext(this._q.shift()); } + this._o.onCompleted(); + }; + + return TakeLastObserver; + }(AbstractObserver)); + /** * Returns a specified number of contiguous elements from the end of an observable sequence. * @description @@ -4136,20 +5043,424 @@ observableProto.zipIterable = function () { if (count < 0) { throw new ArgumentOutOfRangeError(); } var source = this; return new AnonymousObservable(function (o) { - var q = []; - return source.subscribe(function (x) { - q.push(x); - q.length > count && q.shift(); - }, function (e) { o.onError(e); }, function () { - while (q.length > 0) { o.onNext(q.shift()); } - o.onCompleted(); + return source.subscribe(new TakeLastObserver(o, count)); + }, source); + }; + + var TakeLastBufferObserver = (function (__super__) { + inherits(TakeLastBufferObserver, __super__); + function TakeLastBufferObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastBufferObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastBufferObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastBufferObserver.prototype.completed = function () { + this._o.onNext(this._q); + this._o.onCompleted(); + }; + + return TakeLastBufferObserver; + }(AbstractObserver)); + + /** + * Returns an array with the specified number of contiguous elements from the end of an observable sequence. + * + * @description + * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the + * source sequence, this buffer is produced on the result sequence. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence. + */ + observableProto.takeLastBuffer = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastBufferObserver(o, count)); + }, source); + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on element count information. + * @param {Number} count Length of each window. + * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithCount = function (count, skip) { + var source = this; + +count || (count = 0); + Math.abs(count) === Infinity && (count = 0); + if (count <= 0) { throw new ArgumentOutOfRangeError(); } + skip == null && (skip = count); + +skip || (skip = 0); + Math.abs(skip) === Infinity && (skip = 0); + + if (skip <= 0) { throw new ArgumentOutOfRangeError(); } + return new AnonymousObservable(function (observer) { + var m = new SingleAssignmentDisposable(), + refCountDisposable = new RefCountDisposable(m), + n = 0, + q = []; + + function createWindow () { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + + createWindow(); + + m.setDisposable(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + var c = n - count + 1; + c >= 0 && c % skip === 0 && q.shift().onCompleted(); + ++n % skip === 0 && createWindow(); + }, + function (e) { + while (q.length > 0) { q.shift().onError(e); } + observer.onError(e); + }, + function () { + while (q.length > 0) { q.shift().onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function concatMap(source, selector, thisArg) { + var selectorFunc = bindCallback(selector, thisArg, 3); + return source.map(function (x, i) { + var result = selectorFunc(x, i, source); + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result)); + return result; + }).concatAll(); + } + + /** + * One of the Following: + * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * + * @example + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }); + * Or: + * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence. + * + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; }); + * Or: + * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence. + * + * var res = source.concatMap(Rx.Observable.fromArray([1,2,3])); + * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the + * source sequence onto which could be either an observable or Promise. + * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element. + */ + observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) { + if (isFunction(selector) && isFunction(resultSelector)) { + return this.concatMap(function (x, i) { + var selectorResult = selector(x, i); + isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult)); + (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult)); + + return selectorResult.map(function (y, i2) { + return resultSelector(x, y, i, i2); + }); }); + } + return isFunction(selector) ? + concatMap(this, selector, thisArg) : + concatMap(this, function () { return selector; }); + }; + + /** + * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) { + var source = this, + onNextFunc = bindCallback(onNext, thisArg, 2), + onErrorFunc = bindCallback(onError, thisArg, 1), + onCompletedFunc = bindCallback(onCompleted, thisArg, 0); + return new AnonymousObservable(function (observer) { + var index = 0; + return source.subscribe( + function (x) { + var result; + try { + result = onNextFunc(x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onErrorFunc(err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompletedFunc(); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, this).concatAll(); + }; + + var DefaultIfEmptyObserver = (function (__super__) { + inherits(DefaultIfEmptyObserver, __super__); + function DefaultIfEmptyObserver(o, d) { + this._o = o; + this._d = d; + this._f = false; + __super__.call(this); + } + + DefaultIfEmptyObserver.prototype.next = function (x) { + this._f = true; + this._o.onNext(x); + }; + + DefaultIfEmptyObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + DefaultIfEmptyObserver.prototype.completed = function () { + !this._f && this._o.onNext(defaultValue); + this._o.onCompleted(); + }; + + return DefaultIfEmptyObserver; + }(AbstractObserver)); + + /** + * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty. + * + * var res = obs = xs.defaultIfEmpty(); + * 2 - obs = xs.defaultIfEmpty(false); + * + * @memberOf Observable# + * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null. + * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. + */ + observableProto.defaultIfEmpty = function (defaultValue) { + var source = this; + defaultValue === undefined && (defaultValue = null); + return new AnonymousObservable(function (o) { + return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue)); + }, source); + }; + + // Swap out for Array.findIndex + function arrayIndexOfComparer(array, item, comparer) { + for (var i = 0, len = array.length; i < len; i++) { + if (comparer(array[i], item)) { return i; } + } + return -1; + } + + function HashSet(comparer) { + this.comparer = comparer; + this.set = []; + } + HashSet.prototype.push = function(value) { + var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1; + retValue && this.set.push(value); + return retValue; + }; + + var DistinctObservable = (function (__super__) { + inherits(DistinctObservable, __super__); + function DistinctObservable(source, keyFn, cmpFn) { + this.source = source; + this._keyFn = keyFn; + this._cmpFn = cmpFn; + __super__.call(this); + } + + DistinctObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn)); + }; + + return DistinctObservable; + }(ObservableBase)); + + var DistinctObserver = (function (__super__) { + inherits(DistinctObserver, __super__); + function DistinctObserver(o, keyFn, cmpFn) { + this._o = o; + this._keyFn = keyFn; + this._h = new HashSet(cmpFn); + __super__.call(this); + } + + DistinctObserver.prototype.next = function (x) { + var key = x; + if (isFunction(this._keyFn)) { + key = tryCatch(this._keyFn)(x); + if (key === errorObj) { return this._o.onError(key.e); } + } + this._h.push(key) && this._o.onNext(x); + }; + + DistinctObserver.prototype.error = function (e) { this._o.onError(e); }; + DistinctObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DistinctObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. + * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. + * + * @example + * var res = obs = xs.distinct(); + * 2 - obs = xs.distinct(function (x) { return x.id; }); + * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; }); + * @param {Function} [keySelector] A function to compute the comparison key for each element. + * @param {Function} [comparer] Used to compare items in the collection. + * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. + */ + observableProto.distinct = function (keySelector, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctObservable(this, keySelector, comparer); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. + * + * @example + * var res = observable.groupBy(function (x) { return x.id; }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} [elementSelector] A function to map each source element to an element in an observable group. + * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + */ + observableProto.groupBy = function (keySelector, elementSelector) { + return this.groupByUntil(keySelector, elementSelector, observableNever); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function. + * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same + * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request. + * + * @example + * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} durationSelector A function to signal the expiration of a group. + * @returns {Observable} + * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered. + * + */ + observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) { + var source = this; + return new AnonymousObservable(function (o) { + var map = new Map(), + groupDisposable = new CompositeDisposable(), + refCountDisposable = new RefCountDisposable(groupDisposable), + handleError = function (e) { return function (item) { item.onError(e); }; }; + + groupDisposable.add( + source.subscribe(function (x) { + var key = tryCatch(keySelector)(x); + if (key === errorObj) { + map.forEach(handleError(key.e)); + return o.onError(key.e); + } + + var fireNewMapEntry = false, writer = map.get(key); + if (writer === undefined) { + writer = new Subject(); + map.set(key, writer); + fireNewMapEntry = true; + } + + if (fireNewMapEntry) { + var group = new GroupedObservable(key, writer, refCountDisposable), + durationGroup = new GroupedObservable(key, writer); + var duration = tryCatch(durationSelector)(durationGroup); + if (duration === errorObj) { + map.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + o.onNext(group); + + var md = new SingleAssignmentDisposable(); + groupDisposable.add(md); + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, + function () { + if (map['delete'](key)) { writer.onCompleted(); } + groupDisposable.remove(md); + })); + } + + var element = x; + if (isFunction(elementSelector)) { + element = tryCatch(elementSelector)(x); + if (element === errorObj) { + map.forEach(handleError(element.e)); + return o.onError(element.e); + } + } + + writer.onNext(element); + }, function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, function () { + map.forEach(function (item) { item.onCompleted(); }); + o.onCompleted(); + })); + + return refCountDisposable; }, source); }; - -observableProto.flatMapConcat = observableProto.concatMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(1); -}; + var MapObservable = (function (__super__) { inherits(MapObservable, __super__); @@ -4171,35 +5482,27 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r return this.source.subscribe(new InnerObserver(o, this.selector, this)); }; + inherits(InnerObserver, AbstractObserver); function InnerObserver(o, selector, source) { this.o = o; this.selector = selector; this.source = source; this.i = 0; - this.isStopped = false; + AbstractObserver.call(this); } - InnerObserver.prototype.onNext = function(x) { - if (this.isStopped) { return; } + InnerObserver.prototype.next = function(x) { var result = tryCatch(this.selector)(x, this.i++, this.source); if (result === errorObj) { return this.o.onError(result.e); } this.o.onNext(result); }; - InnerObserver.prototype.onError = function (e) { - if(!this.isStopped) { this.isStopped = true; this.o.onError(e); } - }; - InnerObserver.prototype.onCompleted = function () { - if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); } + + InnerObserver.prototype.error = function (e) { + this.o.onError(e); }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.o.onError(e); - return true; - } - return false; + InnerObserver.prototype.completed = function () { + this.o.onCompleted(); }; return MapObservable; @@ -4218,7 +5521,7 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r this.internalMap(selectorFn, thisArg) : new MapObservable(this, selectorFn, thisArg); }; - + function plucker(args, len) { return function mapper(x) { var currentProp = x; @@ -4246,7 +5549,7 @@ observableProto.flatMapConcat = observableProto.concatMap = function(selector, r for(var i = 0; i < len; i++) { args[i] = arguments[i]; } return this.map(plucker(args, len)); }; - + observableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) { return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll(); }; @@ -4257,15 +5560,67 @@ observableProto.flatMap = observableProto.selectMany = function(selector, result // return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); //}; // - -Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); -}; - var SkipObservable = (function(__super__) { - inherits(SkipObservable, __super__); - function SkipObservable(source, count) { - this.source = source; - this.skipCount = count; + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) { + var source = this; + return new AnonymousObservable(function (observer) { + var index = 0; + + return source.subscribe( + function (x) { + var result; + try { + result = onNext.call(thisArg, x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onError.call(thisArg, err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompleted.call(thisArg); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, source).mergeAll(); + }; + +Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); +}; + var SkipObservable = (function(__super__) { + inherits(SkipObservable, __super__); + function SkipObservable(source, count) { + this.source = source; + this.skipCount = count; __super__.call(this); } @@ -4314,7 +5669,47 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA observableProto.skip = function (count) { if (count < 0) { throw new ArgumentOutOfRangeError(); } return new SkipObservable(this, count); - }; + }; + var SkipWhileObservable = (function (__super__) { + inherits(SkipWhileObservable, __super__); + function SkipWhileObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + SkipWhileObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipWhileObserver(o, this)); + }; + + return SkipWhileObservable; + }(ObservableBase)); + + var SkipWhileObserver = (function (__super__) { + inherits(SkipWhileObserver, __super__); + + function SkipWhileObserver(o, p) { + this._o = o; + this._p = p; + this._i = 0; + this._r = false; + __super__.call(this); + } + + SkipWhileObserver.prototype.next = function (x) { + if (!this._r) { + var res = tryCatch(this._p._fn)(x, this._i++, this._p); + if (res === errorObj) { return this._o.onError(res.e); } + this._r = !res; + } + this._r && this._o.onNext(x); + }; + SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWhileObserver; + }(AbstractObserver)); + /** * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. * The element's index is used in the logic of the predicate function. @@ -4326,29 +5721,65 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. */ observableProto.skipWhile = function (predicate, thisArg) { - var source = this, - callback = bindCallback(predicate, thisArg, 3); - return new AnonymousObservable(function (o) { - var i = 0, running = false; - return source.subscribe(function (x) { - if (!running) { - try { - running = !callback(x, i++, source); - } catch (e) { - o.onError(e); - return; - } - } - running && o.onNext(x); - }, function (e) { o.onError(e); }, function () { o.onCompleted(); }); - }, source); + var fn = bindCallback(predicate, thisArg, 3); + return new SkipWhileObservable(this, fn); }; - + + var TakeObservable = (function(__super__) { + inherits(TakeObservable, __super__); + + function TakeObservable(source, count) { + this.source = source; + this.takeCount = count; + __super__.call(this); + } + + TakeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.takeCount)); + }; + + function InnerObserver(o, c) { + this.o = o; + this.c = c; + this.r = c; + this.isStopped = false; + } + InnerObserver.prototype = { + onNext: function (x) { + if (this.isStopped) { return; } + if (this.r-- > 0) { + this.o.onNext(x); + this.r <= 0 && this.o.onCompleted(); + } + }, + onError: function (err) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }, + onCompleted: function () { + if (!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }, + dispose: function () { this.isStopped = true; }, + fail: function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + } + }; + + return TakeObservable; + }(ObservableBase)); + /** * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0). - * - * var res = source.take(5); - * var res = source.take(0, Rx.Scheduler.timeout); * @param {Number} count The number of elements to return. * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case 0) { + var v = qr.shift(); + var equal = tryCatch(comparer)(v, x); + if (equal === errorObj) { return o.onError(equal.e); } + if (!equal) { + o.onNext(false); + o.onCompleted(); + } + } else if (doner) { + o.onNext(false); + o.onCompleted(); + } else { + ql.push(x); + } + }, function(e) { o.onError(e); }, function () { + donel = true; + if (ql.length === 0) { + if (qr.length > 0) { + o.onNext(false); + o.onCompleted(); + } else if (doner) { + o.onNext(true); + o.onCompleted(); + } + } + }); - function ConnectableObservable(source, subject) { - var hasSubscription = false, - subscription, - sourceObservable = source.asObservable(); - - this.connect = function () { - if (!hasSubscription) { - hasSubscription = true; - subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () { - hasSubscription = false; - })); + (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second)); + isPromise(second) && (second = observableFromPromise(second)); + var subscription2 = second.subscribe(function (x) { + if (ql.length > 0) { + var v = ql.shift(); + var equal = tryCatch(comparer)(v, x); + if (equal === errorObj) { return o.onError(equal.e); } + if (!equal) { + o.onNext(false); + o.onCompleted(); + } + } else if (donel) { + o.onNext(false); + o.onCompleted(); + } else { + qr.push(x); } - return subscription; - }; + }, function(e) { o.onError(e); }, function () { + doner = true; + if (qr.length === 0) { + if (ql.length > 0) { + o.onNext(false); + o.onCompleted(); + } else if (donel) { + o.onNext(true); + o.onCompleted(); + } + } + }); + return new BinaryDisposable(subscription1, subscription2); + }, first); + }; - __super__.call(this, function (o) { return subject.subscribe(o); }); + var ElementAtObservable = (function (__super__) { + inherits(ElementAtObservable, __super__); + function ElementAtObservable(source, i, d) { + this.source = source; + this._i = i; + this._d = d; + __super__.call(this); } - ConnectableObservable.prototype.refCount = function () { - var connectableSubscription, count = 0, source = this; - return new AnonymousObservable(function (observer) { - var shouldConnect = ++count === 1, - subscription = source.subscribe(observer); - shouldConnect && (connectableSubscription = source.connect()); - return function () { - subscription.dispose(); - --count === 0 && connectableSubscription.dispose(); - }; - }); + ElementAtObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ElementAtObserver(o, this._i, this._d)); }; - return ConnectableObservable; - }(Observable)); - - function observableTimerDate(dueTime, scheduler) { - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithAbsolute(dueTime, function () { - observer.onNext(0); - observer.onCompleted(); - }); - }); - } - - function observableTimerDateAndPeriod(dueTime, period, scheduler) { - return new AnonymousObservable(function (observer) { - var d = dueTime, p = normalizeTime(period); - return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) { - if (p > 0) { - var now = scheduler.now(); - d = d + p; - d <= now && (d = now + p); + return ElementAtObservable; + }(ObservableBase)); + + var ElementAtObserver = (function (__super__) { + inherits(ElementAtObserver, __super__); + + function ElementAtObserver(o, i, d) { + this._o = o; + this._i = i; + this._d = d; + __super__.call(this); + } + + ElementAtObserver.prototype.next = function (x) { + if (this._i-- === 0) { + this._o.onNext(x); + this._o.onCompleted(); + } + }; + ElementAtObserver.prototype.error = function (e) { this._o.onError(e); }; + ElementAtObserver.prototype.completed = function () { + if (this._d === undefined) { + this._o.onError(new ArgumentOutOfRangeError()); + } else { + this._o.onNext(this._d); + this._o.onCompleted(); + } + }; + + return ElementAtObserver; + }(AbstractObserver)); + + /** + * Returns the element at a specified index in a sequence or default value if not found. + * @param {Number} index The zero-based index of the element to retrieve. + * @param {Any} [defaultValue] The default value to use if elementAt does not find a value. + * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence. + */ + observableProto.elementAt = function (index, defaultValue) { + if (index < 0) { throw new ArgumentOutOfRangeError(); } + return new ElementAtObservable(this, index, defaultValue); + }; + + var SingleObserver = (function(__super__) { + inherits(SingleObserver, __super__); + function SingleObserver(o, obj, s) { + this._o = o; + this._obj = obj; + this._s = s; + this._i = 0; + this._hv = false; + this._v = null; + __super__.call(this); + } + + SingleObserver.prototype.next = function (x) { + var shouldYield = false; + if (this._obj.predicate) { + var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); + if (res === errorObj) { return this._o.onError(res.e); } + Boolean(res) && (shouldYield = true); + } else if (!this._obj.predicate) { + shouldYield = true; + } + if (shouldYield) { + if (this._hv) { + return this._o.onError(new Error('Sequence contains more than one matching element')); } - observer.onNext(count); - self(count + 1, d); - }); - }); - } - - function observableTimerTimeSpan(dueTime, scheduler) { - return new AnonymousObservable(function (observer) { - return scheduler.scheduleWithRelative(normalizeTime(dueTime), function () { - observer.onNext(0); - observer.onCompleted(); + this._hv = true; + this._v = x; + } + }; + SingleObserver.prototype.error = function (e) { this._o.onError(e); }; + SingleObserver.prototype.completed = function () { + if (this._hv) { + this._o.onNext(this._v); + this._o.onCompleted(); + } + else if (this._obj.defaultValue === undefined) { + this._o.onError(new EmptyError()); + } else { + this._o.onNext(this._obj.defaultValue); + this._o.onCompleted(); + } + }; + + return SingleObserver; + }(AbstractObserver)); + + + /** + * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence. + * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate. + */ + observableProto.single = function (predicate, thisArg) { + var obj = {}, source = this; + if (typeof arguments[0] === 'object') { + obj = arguments[0]; + } else { + obj = { + predicate: arguments[0], + thisArg: arguments[1], + defaultValue: arguments[2] + }; + } + if (isFunction (obj.predicate)) { + var fn = obj.predicate; + obj.predicate = bindCallback(fn, obj.thisArg, 3); + } + return new AnonymousObservable(function (o) { + return source.subscribe(new SingleObserver(o, obj, source)); + }, source); + }; + + var FirstObservable = (function (__super__) { + inherits(FirstObservable, __super__); + function FirstObservable(source, obj) { + this.source = source; + this._obj = obj; + __super__.call(this); + } + + FirstObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new FirstObserver(o, this._obj, this.source)); + }; + + return FirstObservable; + }(ObservableBase)); + + var FirstObserver = (function(__super__) { + inherits(FirstObserver, __super__); + function FirstObserver(o, obj, s) { + this._o = o; + this._obj = obj; + this._s = s; + this._i = 0; + __super__.call(this); + } + + FirstObserver.prototype.next = function (x) { + if (this._obj.predicate) { + var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); + if (res === errorObj) { return this._o.onError(res.e); } + if (Boolean(res)) { + this._o.onNext(x); + this._o.onCompleted(); + } + } else if (!this._obj.predicate) { + this._o.onNext(x); + this._o.onCompleted(); + } + }; + FirstObserver.prototype.error = function (e) { this._o.onError(e); }; + FirstObserver.prototype.completed = function () { + if (this._obj.defaultValue === undefined) { + this._o.onError(new EmptyError()); + } else { + this._o.onNext(this._obj.defaultValue); + this._o.onCompleted(); + } + }; + + return FirstObserver; + }(AbstractObserver)); + + /** + * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence. + * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence. + */ + observableProto.first = function () { + var obj = {}, source = this; + if (typeof arguments[0] === 'object') { + obj = arguments[0]; + } else { + obj = { + predicate: arguments[0], + thisArg: arguments[1], + defaultValue: arguments[2] + }; + } + if (isFunction (obj.predicate)) { + var fn = obj.predicate; + obj.predicate = bindCallback(fn, obj.thisArg, 3); + } + return new FirstObservable(this, obj); + }; + + var LastObservable = (function (__super__) { + inherits(LastObservable, __super__); + function LastObservable(source, obj) { + this.source = source; + this._obj = obj; + __super__.call(this); + } + + LastObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new LastObserver(o, this._obj, this.source)); + }; + + return LastObservable; + }(ObservableBase)); + + var LastObserver = (function(__super__) { + inherits(LastObserver, __super__); + function LastObserver(o, obj, s) { + this._o = o; + this._obj = obj; + this._s = s; + this._i = 0; + this._hv = false; + this._v = null; + __super__.call(this); + } + + LastObserver.prototype.next = function (x) { + var shouldYield = false; + if (this._obj.predicate) { + var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); + if (res === errorObj) { return this._o.onError(res.e); } + Boolean(res) && (shouldYield = true); + } else if (!this._obj.predicate) { + shouldYield = true; + } + if (shouldYield) { + this._hv = true; + this._v = x; + } + }; + LastObserver.prototype.error = function (e) { this._o.onError(e); }; + LastObserver.prototype.completed = function () { + if (this._hv) { + this._o.onNext(this._v); + this._o.onCompleted(); + } + else if (this._obj.defaultValue === undefined) { + this._o.onError(new EmptyError()); + } else { + this._o.onNext(this._obj.defaultValue); + this._o.onCompleted(); + } + }; + + return LastObserver; + }(AbstractObserver)); + + /** + * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element. + * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate. + */ + observableProto.last = function () { + var obj = {}, source = this; + if (typeof arguments[0] === 'object') { + obj = arguments[0]; + } else { + obj = { + predicate: arguments[0], + thisArg: arguments[1], + defaultValue: arguments[2] + }; + } + if (isFunction (obj.predicate)) { + var fn = obj.predicate; + obj.predicate = bindCallback(fn, obj.thisArg, 3); + } + return new LastObservable(this, obj); + }; + + var FindValueObserver = (function(__super__) { + inherits(FindValueObserver, __super__); + function FindValueObserver(observer, source, callback, yieldIndex) { + this._o = observer; + this._s = source; + this._cb = callback; + this._y = yieldIndex; + this._i = 0; + __super__.call(this); + } + + FindValueObserver.prototype.next = function (x) { + var shouldRun = tryCatch(this._cb)(x, this._i, this._s); + if (shouldRun === errorObj) { return this._o.onError(shouldRun.e); } + if (shouldRun) { + this._o.onNext(this._y ? this._i : x); + this._o.onCompleted(); + } else { + this._i++; + } + }; + + FindValueObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + FindValueObserver.prototype.completed = function () { + this._y && this._o.onNext(-1); + this._o.onCompleted(); + }; + + return FindValueObserver; + }(AbstractObserver)); + + function findValue (source, predicate, thisArg, yieldIndex) { + var callback = bindCallback(predicate, thisArg, 3); + return new AnonymousObservable(function (o) { + return source.subscribe(new FindValueObserver(o, source, callback, yieldIndex)); + }, source); + } + + /** + * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence. + * @param {Function} predicate The predicate that defines the conditions of the element to search for. + * @param {Any} [thisArg] Object to use as `this` when executing the predicate. + * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined. + */ + observableProto.find = function (predicate, thisArg) { + return findValue(this, predicate, thisArg, false); + }; + + /** + * Searches for an element that matches the conditions defined by the specified predicate, and returns + * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence. + * @param {Function} predicate The predicate that defines the conditions of the element to search for. + * @param {Any} [thisArg] Object to use as `this` when executing the predicate. + * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1. + */ + observableProto.findIndex = function (predicate, thisArg) { + return findValue(this, predicate, thisArg, true); + }; + + var ToSetObservable = (function (__super__) { + inherits(ToSetObservable, __super__); + function ToSetObservable(source) { + this.source = source; + __super__.call(this); + } + + ToSetObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ToSetObserver(o)); + }; + + return ToSetObservable; + }(ObservableBase)); + + var ToSetObserver = (function (__super__) { + inherits(ToSetObserver, __super__); + function ToSetObserver(o) { + this._o = o; + this._s = new root.Set(); + __super__.call(this); + } + + ToSetObserver.prototype.next = function (x) { + this._s.add(x); + }; + + ToSetObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ToSetObserver.prototype.completed = function () { + this._o.onNext(this._s); + this._o.onCompleted(); + }; + + return ToSetObserver; + }(AbstractObserver)); + + /** + * Converts the observable sequence to a Set if it exists. + * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence. + */ + observableProto.toSet = function () { + if (typeof root.Set === 'undefined') { throw new TypeError(); } + return new ToSetObservable(this); + }; + + var ToMapObservable = (function (__super__) { + inherits(ToMapObservable, __super__); + function ToMapObservable(source, k, e) { + this.source = source; + this._k = k; + this._e = e; + __super__.call(this); + } + + ToMapObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ToMapObserver(o, this._k, this._e)); + }; + + return ToMapObservable; + }(ObservableBase)); + + var ToMapObserver = (function (__super__) { + inherits(ToMapObserver, __super__); + function ToMapObserver(o, k, e) { + this._o = o; + this._k = k; + this._e = e; + this._m = new root.Map(); + __super__.call(this); + } + + ToMapObserver.prototype.next = function (x) { + var key = tryCatch(this._k)(x); + if (key === errorObj) { return this._o.onError(key.e); } + var elem = x; + if (this._e) { + elem = tryCatch(this._e)(x); + if (elem === errorObj) { return this._o.onError(elem.e); } + } + + this._m.set(key, elem); + }; + + ToMapObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ToMapObserver.prototype.completed = function () { + this._o.onNext(this._m); + this._o.onCompleted(); + }; + + return ToMapObserver; + }(AbstractObserver)); + + /** + * Converts the observable sequence to a Map if it exists. + * @param {Function} keySelector A function which produces the key for the Map. + * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence. + * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence. + */ + observableProto.toMap = function (keySelector, elementSelector) { + if (typeof root.Map === 'undefined') { throw new TypeError(); } + return new ToMapObservable(this, keySelector, elementSelector); + }; + + var SliceObservable = (function (__super__) { + inherits(SliceObservable, __super__); + function SliceObservable(source, b, e) { + this.source = source; + this._b = b; + this._e = e; + __super__.call(this); + } + + SliceObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SliceObserver(o, this._b, this._e)); + }; + + return SliceObservable; + }(ObservableBase)); + + var SliceObserver = (function (__super__) { + inherits(SliceObserver, __super__); + + function SliceObserver(o, b, e) { + this._o = o; + this._b = b; + this._e = e; + this._i = 0; + __super__.call(this); + } + + SliceObserver.prototype.next = function (x) { + if (this._i >= this._b) { + if (this._e === this._i) { + this._o.onCompleted(); + } else { + this._o.onNext(x); + } + } + this._i++; + }; + SliceObserver.prototype.error = function (e) { this._o.onError(e); }; + SliceObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SliceObserver; + }(AbstractObserver)); + + /* + * The slice() method returns a shallow copy of a portion of an Observable into a new Observable object. + * Unlike the array version, this does not support negative numbers for being or end. + * @param {Number} [begin] Zero-based index at which to begin extraction. If omitted, this will default to zero. + * @param {Number} [end] Zero-based index at which to end extraction. slice extracts up to but not including end. + * If omitted, this will emit the rest of the Observable object. + * @returns {Observable} A shallow copy of a portion of an Observable into a new Observable object. + */ + observableProto.slice = function (begin, end) { + var start = begin || 0; + if (start < 0) { throw new Rx.ArgumentOutOfRangeError(); } + if (typeof end === 'number' && end < start) { + throw new Rx.ArgumentOutOfRangeError(); + } + return new SliceObservable(this, start, end); + }; + + var LastIndexOfObservable = (function (__super__) { + inherits(LastIndexOfObservable, __super__); + function LastIndexOfObservable(source, e, n) { + this.source = source; + this._e = e; + this._n = n; + __super__.call(this); + } + + LastIndexOfObservable.prototype.subscribeCore = function (o) { + if (this._n < 0) { + o.onNext(-1); + o.onCompleted(); + return disposableEmpty; + } + + return this.source.subscribe(new LastIndexOfObserver(o, this._e, this._n)); + }; + + return LastIndexOfObservable; + }(ObservableBase)); + + var LastIndexOfObserver = (function (__super__) { + inherits(LastIndexOfObserver, __super__); + function LastIndexOfObserver(o, e, n) { + this._o = o; + this._e = e; + this._n = n; + this._v = 0; + this._hv = false; + this._i = 0; + __super__.call(this); + } + + LastIndexOfObserver.prototype.next = function (x) { + if (this._i >= this._n && x === this._e) { + this._hv = true; + this._v = this._i; + } + this._i++; + }; + LastIndexOfObserver.prototype.error = function (e) { this._o.onError(e); }; + LastIndexOfObserver.prototype.completed = function () { + if (this._hv) { + this._o.onNext(this._v); + } else { + this._o.onNext(-1); + } + this._o.onCompleted(); + }; + + return LastIndexOfObserver; + }(AbstractObserver)); + + /** + * Returns the last index at which a given element can be found in the observable sequence, or -1 if it is not present. + * @param {Any} searchElement Element to locate in the array. + * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0. + * @returns {Observable} And observable sequence containing the last index at which a given element can be found in the observable sequence, or -1 if it is not present. + */ + observableProto.lastIndexOf = function(searchElement, fromIndex) { + var n = +fromIndex || 0; + Math.abs(n) === Infinity && (n = 0); + return new LastIndexOfObservable(this, searchElement, n); + }; + + Observable.wrap = function (fn) { + createObservable.__generatorFunction__ = fn; + return createObservable; + + function createObservable() { + return Observable.spawn.call(this, fn.apply(this, arguments)); + } + }; + + var spawn = Observable.spawn = function () { + var gen = arguments[0], self = this, args = []; + for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); } + + return new AnonymousObservable(function (o) { + var g = new CompositeDisposable(); + + if (isFunction(gen)) { gen = gen.apply(self, args); } + if (!gen || !isFunction(gen.next)) { + o.onNext(gen); + return o.onCompleted(); + } + + processGenerator(); + + function processGenerator(res) { + var ret = tryCatch(gen.next).call(gen, res); + if (ret === errorObj) { return o.onError(ret.e); } + next(ret); + } + + function onError(err) { + var ret = tryCatch(gen.next).call(gen, err); + if (ret === errorObj) { return o.onError(ret.e); } + next(ret); + } + + function next(ret) { + if (ret.done) { + o.onNext(ret.value); + o.onCompleted(); + return; + } + var value = toObservable.call(self, ret.value); + if (Observable.isObservable(value)) { + g.add(value.subscribe(processGenerator, onError)); + } else { + onError(new TypeError('type not supported')); + } + } + + return g; + }); + }; + + function toObservable(obj) { + if (!obj) { return obj; } + if (Observable.isObservable(obj)) { return obj; } + if (isPromise(obj)) { return Observable.fromPromise(obj); } + if (isGeneratorFunction(obj) || isGenerator(obj)) { return spawn.call(this, obj); } + if (isFunction(obj)) { return thunkToObservable.call(this, obj); } + if (isArrayLike(obj) || isIterable(obj)) { return arrayToObservable.call(this, obj); } + if (isObject(obj)) {return objectToObservable.call(this, obj);} + return obj; + } + + function arrayToObservable (obj) { + return Observable.from(obj) + .flatMap(toObservable) + .toArray(); + } + + function objectToObservable (obj) { + var results = new obj.constructor(), keys = Object.keys(obj), observables = []; + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i]; + var observable = toObservable.call(this, obj[key]); + + if(observable && Observable.isObservable(observable)) { + defer(observable, key); + } else { + results[key] = obj[key]; + } + } + + return Observable.forkJoin.apply(Observable, observables).map(function() { + return results; + }); + + + function defer (observable, key) { + results[key] = undefined; + observables.push(observable.map(function (next) { + results[key] = next; + })); + } + } + + function thunkToObservable(fn) { + var self = this; + return new AnonymousObservable(function (o) { + fn.call(self, function () { + var err = arguments[0], res = arguments[1]; + if (err) { return o.onError(err); } + if (arguments.length > 2) { + var args = []; + for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); } + res = args; + } + o.onNext(res); + o.onCompleted(); }); }); } - - function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { - return dueTime === period ? - new AnonymousObservable(function (observer) { - return scheduler.schedulePeriodicWithState(0, period, function (count) { - observer.onNext(count); - return count + 1; - }); - }) : - observableDefer(function () { - return observableTimerDateAndPeriod(scheduler.now() + dueTime, period, scheduler); - }); + + function isGenerator(obj) { + return isFunction (obj.next) && isFunction (obj.throw); + } + + function isGeneratorFunction(obj) { + var ctor = obj.constructor; + if (!ctor) { return false; } + if (ctor.name === 'GeneratorFunction' || ctor.displayName === 'GeneratorFunction') { return true; } + return isGenerator(ctor.prototype); + } + + function isObject(val) { + return Object == val.constructor; + } + + /** + * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence. + * + * @example + * var res = Rx.Observable.start(function () { console.log('hello'); }); + * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout); + * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console); + * + * @param {Function} func Function to run asynchronously. + * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout. + * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined. + * @returns {Observable} An observable sequence exposing the function's result value, or an exception. + * + * Remarks + * * The function is called immediately, not during the subscription of the resulting sequence. + * * Multiple subscriptions to the resulting sequence can observe the function's result. + */ + Observable.start = function (func, context, scheduler) { + return observableToAsync(func, context, scheduler)(); + }; + + /** + * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler. + * @param {Function} function Function to convert to an asynchronous function. + * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout. + * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined. + * @returns {Function} Asynchronous function. + */ + var observableToAsync = Observable.toAsync = function (func, context, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return function () { + var args = arguments, + subject = new AsyncSubject(); + + scheduler.schedule(null, function () { + var result; + try { + result = func.apply(context, args); + } catch (e) { + subject.onError(e); + return; + } + subject.onNext(result); + subject.onCompleted(); + }); + return subject.asObservable(); + }; + }; + +function createCbObservable(fn, ctx, selector, args) { + var o = new AsyncSubject(); + + args.push(createCbHandler(o, ctx, selector)); + fn.apply(ctx, args); + + return o.asObservable(); +} + +function createCbHandler(o, ctx, selector) { + return function handler () { + var len = arguments.length, results = new Array(len); + for(var i = 0; i < len; i++) { results[i] = arguments[i]; } + + if (isFunction(selector)) { + results = tryCatch(selector).apply(ctx, results); + if (results === errorObj) { return o.onError(results.e); } + o.onNext(results); + } else { + if (results.length <= 1) { + o.onNext(results[0]); + } else { + o.onNext(results); + } + } + + o.onCompleted(); + }; +} + +/** + * Converts a callback function to an observable sequence. + * + * @param {Function} fn Function with a callback as the last parameter to convert to an Observable sequence. + * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined. + * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next. + * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array. + */ +Observable.fromCallback = function (fn, ctx, selector) { + return function () { + typeof ctx === 'undefined' && (ctx = this); + + var len = arguments.length, args = new Array(len) + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return createCbObservable(fn, ctx, selector, args); + }; +}; + +function createNodeObservable(fn, ctx, selector, args) { + var o = new AsyncSubject(); + + args.push(createNodeHandler(o, ctx, selector)); + fn.apply(ctx, args); + + return o.asObservable(); +} + +function createNodeHandler(o, ctx, selector) { + return function handler () { + var err = arguments[0]; + if (err) { return o.onError(err); } + + var len = arguments.length, results = []; + for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; } + + if (isFunction(selector)) { + var results = tryCatch(selector).apply(ctx, results); + if (results === errorObj) { return o.onError(results.e); } + o.onNext(results); + } else { + if (results.length <= 1) { + o.onNext(results[0]); + } else { + o.onNext(results); + } + } + + o.onCompleted(); + }; +} + +/** + * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format. + * @param {Function} fn The function to call + * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined. + * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next. + * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array. + */ +Observable.fromNodeCallback = function (fn, ctx, selector) { + return function () { + typeof ctx === 'undefined' && (ctx = this); + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return createNodeObservable(fn, ctx, selector, args); + }; +}; + + function ListenDisposable(e, n, fn) { + this._e = e; + this._n = n; + this._fn = fn; + this._e.addEventListener(this._n, this._fn, false); + this.isDisposed = false; + } + ListenDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this._e.removeEventListener(this._n, this._fn, false); + this.isDisposed = true; + } + }; + + function createEventListener (el, eventName, handler) { + var disposables = new CompositeDisposable(); + + // Asume NodeList or HTMLCollection + var elemToString = Object.prototype.toString.call(el); + if (elemToString === '[object NodeList]' || elemToString === '[object HTMLCollection]') { + for (var i = 0, len = el.length; i < len; i++) { + disposables.add(createEventListener(el.item(i), eventName, handler)); + } + } else if (el) { + disposables.add(new ListenDisposable(el, eventName, handler)); + } + + return disposables; + } + + /** + * Configuration option to determine whether to use native events only + */ + Rx.config.useNativeEvents = false; + + function eventHandler(o, selector) { + return function handler () { + var results = arguments[0]; + if (isFunction(selector)) { + results = tryCatch(selector).apply(null, arguments); + if (results === errorObj) { return o.onError(results.e); } + } + o.onNext(results); + }; + } + + /** + * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList. + * @param {Object} element The DOMElement or NodeList to attach a listener. + * @param {String} eventName The event name to attach the observable sequence. + * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next. + * @returns {Observable} An observable sequence of events from the specified element and the specified event. + */ + Observable.fromEvent = function (element, eventName, selector) { + // Node.js specific + if (element.addListener) { + return fromEventPattern( + function (h) { element.addListener(eventName, h); }, + function (h) { element.removeListener(eventName, h); }, + selector); + } + + // Use only if non-native events are allowed + if (!Rx.config.useNativeEvents) { + // Handles jq, Angular.js, Zepto, Marionette, Ember.js + if (typeof element.on === 'function' && typeof element.off === 'function') { + return fromEventPattern( + function (h) { element.on(eventName, h); }, + function (h) { element.off(eventName, h); }, + selector); + } + } + + return new AnonymousObservable(function (o) { + return createEventListener( + element, + eventName, + eventHandler(o, selector)); + }).publish().refCount(); + }; + + /** + * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair. + * @param {Function} addHandler The function to add a handler to the emitter. + * @param {Function} [removeHandler] The optional function to remove a handler from an emitter. + * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next. + * @param {Scheduler} [scheduler] A scheduler used to schedule the remove handler. + * @returns {Observable} An observable sequence which wraps an event from an event emitter + */ + var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector, scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + return new AnonymousObservable(function (o) { + function innerHandler () { + var result = arguments[0]; + if (isFunction(selector)) { + result = tryCatch(selector).apply(null, arguments); + if (result === errorObj) { return o.onError(result.e); } + } + o.onNext(result); + } + + var returnValue = addHandler(innerHandler); + return disposableCreate(function () { + isFunction(removeHandler) && removeHandler(innerHandler, returnValue); + }); + }).publish().refCount(); + }; + + /** + * Invokes the asynchronous function, surfacing the result through an observable sequence. + * @param {Function} functionAsync Asynchronous function which returns a Promise to run. + * @returns {Observable} An observable sequence exposing the function's result value, or an exception. + */ + Observable.startAsync = function (functionAsync) { + var promise = tryCatch(functionAsync)(); + if (promise === errorObj) { return observableThrow(promise.e); } + return observableFromPromise(promise); + }; + + var PausableObservable = (function (__super__) { + inherits(PausableObservable, __super__); + function PausableObservable(source, pauser) { + this.source = source; + this.controller = new Subject(); + + if (pauser && pauser.subscribe) { + this.pauser = this.controller.merge(pauser); + } else { + this.pauser = this.controller; + } + + __super__.call(this); + } + + PausableObservable.prototype._subscribe = function (o) { + var conn = this.source.publish(), + subscription = conn.subscribe(o), + connection = disposableEmpty; + + var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) { + if (b) { + connection = conn.connect(); + } else { + connection.dispose(); + connection = disposableEmpty; + } + }); + + return new NAryDisposable([subscription, connection, pausable]); + }; + + PausableObservable.prototype.pause = function () { + this.controller.onNext(false); + }; + + PausableObservable.prototype.resume = function () { + this.controller.onNext(true); + }; + + return PausableObservable; + + }(Observable)); + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausable(pauser); + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.pausable = function (pauser) { + return new PausableObservable(this, pauser); + }; + + function combineLatestSource(source, subject, resultSelector) { + return new AnonymousObservable(function (o) { + var hasValue = [false, false], + hasValueAll = false, + isDone = false, + values = new Array(2), + err; + + function next(x, i) { + values[i] = x; + hasValue[i] = true; + if (hasValueAll || (hasValueAll = hasValue.every(identity))) { + if (err) { return o.onError(err); } + var res = tryCatch(resultSelector).apply(null, values); + if (res === errorObj) { return o.onError(res.e); } + o.onNext(res); + } + isDone && values[1] && o.onCompleted(); + } + + return new BinaryDisposable( + source.subscribe( + function (x) { + next(x, 0); + }, + function (e) { + if (values[1]) { + o.onError(e); + } else { + err = e; + } + }, + function () { + isDone = true; + values[1] && o.onCompleted(); + }), + subject.subscribe( + function (x) { + next(x, 1); + }, + function (e) { o.onError(e); }, + function () { + isDone = true; + next(true, 1); + }) + ); + }, source); + } + + var PausableBufferedObservable = (function (__super__) { + inherits(PausableBufferedObservable, __super__); + function PausableBufferedObservable(source, pauser) { + this.source = source; + this.controller = new Subject(); + + if (pauser && pauser.subscribe) { + this.pauser = this.controller.merge(pauser); + } else { + this.pauser = this.controller; + } + + __super__.call(this); + } + + PausableBufferedObservable.prototype._subscribe = function (o) { + var q = [], previousShouldFire; + + function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } } + + var subscription = + combineLatestSource( + this.source, + this.pauser.startWith(false).distinctUntilChanged(), + function (data, shouldFire) { + return { data: data, shouldFire: shouldFire }; + }) + .subscribe( + function (results) { + if (previousShouldFire !== undefined && results.shouldFire !== previousShouldFire) { + previousShouldFire = results.shouldFire; + // change in shouldFire + if (results.shouldFire) { drainQueue(); } + } else { + previousShouldFire = results.shouldFire; + // new data + if (results.shouldFire) { + o.onNext(results.data); + } else { + q.push(results.data); + } + } + }, + function (err) { + drainQueue(); + o.onError(err); + }, + function () { + drainQueue(); + o.onCompleted(); + } + ); + return subscription; + }; + + PausableBufferedObservable.prototype.pause = function () { + this.controller.onNext(false); + }; + + PausableBufferedObservable.prototype.resume = function () { + this.controller.onNext(true); + }; + + return PausableBufferedObservable; + + }(Observable)); + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, + * and yields the values that were buffered while paused. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausableBuffered(pauser); + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.pausableBuffered = function (subject) { + return new PausableBufferedObservable(this, subject); + }; + + var ControlledObservable = (function (__super__) { + inherits(ControlledObservable, __super__); + function ControlledObservable (source, enableQueue, scheduler) { + __super__.call(this); + this.subject = new ControlledSubject(enableQueue, scheduler); + this.source = source.multicast(this.subject).refCount(); + } + + ControlledObservable.prototype._subscribe = function (o) { + return this.source.subscribe(o); + }; + + ControlledObservable.prototype.request = function (numberOfItems) { + return this.subject.request(numberOfItems == null ? -1 : numberOfItems); + }; + + return ControlledObservable; + + }(Observable)); + + var ControlledSubject = (function (__super__) { + inherits(ControlledSubject, __super__); + function ControlledSubject(enableQueue, scheduler) { + enableQueue == null && (enableQueue = true); + + __super__.call(this); + this.subject = new Subject(); + this.enableQueue = enableQueue; + this.queue = enableQueue ? [] : null; + this.requestedCount = 0; + this.requestedDisposable = null; + this.error = null; + this.hasFailed = false; + this.hasCompleted = false; + this.scheduler = scheduler || currentThreadScheduler; + } + + addProperties(ControlledSubject.prototype, Observer, { + _subscribe: function (o) { + return this.subject.subscribe(o); + }, + onCompleted: function () { + this.hasCompleted = true; + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onCompleted(); + this.disposeCurrentRequest(); + } else { + this.queue.push(Notification.createOnCompleted()); + } + }, + onError: function (error) { + this.hasFailed = true; + this.error = error; + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onError(error); + this.disposeCurrentRequest(); + } else { + this.queue.push(Notification.createOnError(error)); + } + }, + onNext: function (value) { + if (this.requestedCount <= 0) { + this.enableQueue && this.queue.push(Notification.createOnNext(value)); + } else { + (this.requestedCount-- === 0) && this.disposeCurrentRequest(); + this.subject.onNext(value); + } + }, + _processRequest: function (numberOfItems) { + if (this.enableQueue) { + while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) { + var first = this.queue.shift(); + first.accept(this.subject); + if (first.kind === 'N') { + numberOfItems--; + } else { + this.disposeCurrentRequest(); + this.queue = []; + } + } + } + + return numberOfItems; + }, + request: function (number) { + this.disposeCurrentRequest(); + var self = this; + + this.requestedDisposable = this.scheduler.schedule(number, + function(s, i) { + var remaining = self._processRequest(i); + var stopped = self.hasCompleted || self.hasFailed; + if (!stopped && remaining > 0) { + self.requestedCount = remaining; + + return disposableCreate(function () { + self.requestedCount = 0; + }); + // Scheduled item is still in progress. Return a new + // disposable to allow the request to be interrupted + // via dispose. + } + }); + + return this.requestedDisposable; + }, + disposeCurrentRequest: function () { + if (this.requestedDisposable) { + this.requestedDisposable.dispose(); + this.requestedDisposable = null; + } + } + }); + + return ControlledSubject; + }(Observable)); + + /** + * Attaches a controller to the observable sequence with the ability to queue. + * @example + * var source = Rx.Observable.interval(100).controlled(); + * source.request(3); // Reads 3 values + * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request + * @param {Scheduler} scheduler determines how the requests will be scheduled + * @returns {Observable} The observable sequence which only propagates values on request. + */ + observableProto.controlled = function (enableQueue, scheduler) { + + if (enableQueue && isScheduler(enableQueue)) { + scheduler = enableQueue; + enableQueue = true; + } + + if (enableQueue == null) { enableQueue = true; } + return new ControlledObservable(this, enableQueue, scheduler); + }; + + var StopAndWaitObservable = (function (__super__) { + inherits(StopAndWaitObservable, __super__); + function StopAndWaitObservable (source) { + __super__.call(this); + this.source = source; + } + + function scheduleMethod(s, self) { + self.source.request(1); + } + + StopAndWaitObservable.prototype._subscribe = function (o) { + this.subscription = this.source.subscribe(new StopAndWaitObserver(o, this, this.subscription)); + return new BinaryDisposable( + this.subscription, + defaultScheduler.schedule(this, scheduleMethod) + ); + }; + + var StopAndWaitObserver = (function (__sub__) { + inherits(StopAndWaitObserver, __sub__); + function StopAndWaitObserver (observer, observable, cancel) { + __sub__.call(this); + this.observer = observer; + this.observable = observable; + this.cancel = cancel; + this.scheduleDisposable = null; + } + + StopAndWaitObserver.prototype.completed = function () { + this.observer.onCompleted(); + this.dispose(); + }; + + StopAndWaitObserver.prototype.error = function (error) { + this.observer.onError(error); + this.dispose(); + }; + + function innerScheduleMethod(s, self) { + self.observable.source.request(1); + } + + StopAndWaitObserver.prototype.next = function (value) { + this.observer.onNext(value); + this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod); + }; + + StopAndWaitObservable.dispose = function () { + this.observer = null; + if (this.cancel) { + this.cancel.dispose(); + this.cancel = null; + } + if (this.scheduleDisposable) { + this.scheduleDisposable.dispose(); + this.scheduleDisposable = null; + } + __sub__.prototype.dispose.call(this); + }; + + return StopAndWaitObserver; + }(AbstractObserver)); + + return StopAndWaitObservable; + }(Observable)); + + + /** + * Attaches a stop and wait observable to the current observable. + * @returns {Observable} A stop and wait observable. + */ + ControlledObservable.prototype.stopAndWait = function () { + return new StopAndWaitObservable(this); + }; + + var WindowedObservable = (function (__super__) { + inherits(WindowedObservable, __super__); + function WindowedObservable(source, windowSize) { + __super__.call(this); + this.source = source; + this.windowSize = windowSize; + } + + function scheduleMethod(s, self) { + self.source.request(self.windowSize); + } + + WindowedObservable.prototype._subscribe = function (o) { + this.subscription = this.source.subscribe(new WindowedObserver(o, this, this.subscription)); + return new BinaryDisposable( + this.subscription, + defaultScheduler.schedule(this, scheduleMethod) + ); + }; + + var WindowedObserver = (function (__sub__) { + inherits(WindowedObserver, __sub__); + function WindowedObserver(observer, observable, cancel) { + this.observer = observer; + this.observable = observable; + this.cancel = cancel; + this.received = 0; + this.scheduleDisposable = null; + __sub__.call(this); + } + + WindowedObserver.prototype.completed = function () { + this.observer.onCompleted(); + this.dispose(); + }; + + WindowedObserver.prototype.error = function (error) { + this.observer.onError(error); + this.dispose(); + }; + + function innerScheduleMethod(s, self) { + self.observable.source.request(self.observable.windowSize); + } + + WindowedObserver.prototype.next = function (value) { + this.observer.onNext(value); + this.received = ++this.received % this.observable.windowSize; + this.received === 0 && (this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod)); + }; + + WindowedObserver.prototype.dispose = function () { + this.observer = null; + if (this.cancel) { + this.cancel.dispose(); + this.cancel = null; + } + if (this.scheduleDisposable) { + this.scheduleDisposable.dispose(); + this.scheduleDisposable = null; + } + __sub__.prototype.dispose.call(this); + }; + + return WindowedObserver; + }(AbstractObserver)); + + return WindowedObservable; + }(Observable)); + + /** + * Creates a sliding windowed observable based upon the window size. + * @param {Number} windowSize The number of items in the window + * @returns {Observable} A windowed observable based upon the window size. + */ + ControlledObservable.prototype.windowed = function (windowSize) { + return new WindowedObservable(this, windowSize); + }; + + /** + * Pipes the existing Observable sequence into a Node.js Stream. + * @param {Stream} dest The destination Node.js stream. + * @returns {Stream} The destination stream. + */ + observableProto.pipe = function (dest) { + var source = this.pausableBuffered(); + + function onDrain() { + source.resume(); + } + + dest.addListener('drain', onDrain); + + source.subscribe( + function (x) { + !dest.write(String(x)) && source.pause(); + }, + function (err) { + dest.emit('error', err); + }, + function () { + // Hack check because STDIO is not closable + !dest._isStdio && dest.end(); + dest.removeListener('drain', onDrain); + }); + + source.resume(); + + return dest; + }; + + var MulticastObservable = (function (__super__) { + inherits(MulticastObservable, __super__); + function MulticastObservable(source, fn1, fn2) { + this.source = source; + this._fn1 = fn1; + this._fn2 = fn2; + __super__.call(this); + } + + MulticastObservable.prototype.subscribeCore = function (o) { + var connectable = this.source.multicast(this._fn1()); + return new BinaryDisposable(this._fn2(connectable).subscribe(o), connectable.connect()); + }; + + return MulticastObservable; + }(ObservableBase)); + + /** + * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each + * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's + * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay. + * + * @example + * 1 - res = source.multicast(observable); + * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; }); + * + * @param {Function|Subject} subjectOrSubjectSelector + * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function. + * Or: + * Subject to push source elements into. + * + * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.value = null; + this.error = null; + } + }); + + return BehaviorSubject; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. + */ + var ReplaySubject = Rx.ReplaySubject = (function (__super__) { + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function createRemovableDisposable(subject, observer) { + return disposableCreate(function () { + observer.dispose(); + !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); + }); + } + + inherits(ReplaySubject, __super__); + + /** + * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. + * @param {Number} [bufferSize] Maximum element count of the replay buffer. + * @param {Number} [windowSize] Maximum time length of the replay buffer. + * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. + */ + function ReplaySubject(bufferSize, windowSize, scheduler) { + this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; + this.windowSize = windowSize == null ? maxSafeInteger : windowSize; + this.scheduler = scheduler || currentThreadScheduler; + this.q = []; + this.observers = []; + this.isStopped = false; + this.isDisposed = false; + this.hasError = false; + this.error = null; + __super__.call(this); + } + + addProperties(ReplaySubject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so); + + this._trim(this.scheduler.now()); + this.observers.push(so); + + for (var i = 0, len = this.q.length; i < len; i++) { + so.onNext(this.q[i].value); + } + + if (this.hasError) { + so.onError(this.error); + } else if (this.isStopped) { + so.onCompleted(); + } + + so.ensureActive(); + return subscription; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + return this.observers.length > 0; + }, + _trim: function (now) { + while (this.q.length > this.bufferSize) { + this.q.shift(); + } + while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { + this.q.shift(); + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + var now = this.scheduler.now(); + this.q.push({ interval: now, value: value }); + this._trim(now); + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onNext(value); + observer.ensureActive(); + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.error = error; + this.hasError = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onError(error); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onCompleted(); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + return ReplaySubject; + }(Observable)); + + var RefCountObservable = (function (__super__) { + inherits(RefCountObservable, __super__); + function RefCountObservable(source) { + this.source = source; + this._count = 0; + this._connectableSubscription = null; + __super__.call(this); + } + + RefCountObservable.prototype.subscribeCore = function (o) { + var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o); + shouldConnect && (this._connectableSubscription = this.source.connect()); + return new RefCountDisposable(this, subscription); + }; + + function RefCountDisposable(p, s) { + this._p = p; + this._s = s; + this.isDisposed = false; + } + + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.dispose(); + --this._p._count === 0 && this._p._connectableSubscription.dispose(); + } + }; + + return RefCountObservable; + }(ObservableBase)); + + var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { + inherits(ConnectableObservable, __super__); + function ConnectableObservable(source, subject) { + this.source = source; + this._hasSubscription = false; + this._subscription = null; + this._sourceObservable = source.asObservable(); + this._subject = subject; + __super__.call(this); + } + + function ConnectDisposable(parent) { + this._p = parent; + this.isDisposed = false; + } + + ConnectDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._p._hasSubscription = false; + } + }; + + ConnectableObservable.prototype.connect = function () { + if (!this._hasSubscription) { + this._hasSubscription = true; + this._subscription = new BinaryDisposable( + this._sourceObservable.subscribe(this._subject), + new ConnectDisposable(this) + ); + } + return this._subscription; + }; + + ConnectableObservable.prototype._subscribe = function (o) { + return this._subject.subscribe(o); + }; + + ConnectableObservable.prototype.refCount = function () { + return new RefCountObservable(this); + }; + + return ConnectableObservable; + }(Observable)); + + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence + * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`) + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source. + */ + observableProto.singleInstance = function() { + var source = this, hasObservable = false, observable; + + function getObservable() { + if (!hasObservable) { + hasObservable = true; + observable = source.finally(function() { hasObservable = false; }).publish().refCount(); + } + return observable; + } + + return new AnonymousObservable(function(o) { + return getObservable().subscribe(o); + }); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var leftDone = false, rightDone = false; + var leftId = 0, rightId = 0; + var leftMap = new Map(), rightMap = new Map(); + var handleError = function (e) { o.onError(e); }; + + group.add(left.subscribe( + function (value) { + var id = leftId++, md = new SingleAssignmentDisposable(); + + leftMap.set(id, value); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted(); + group.remove(md); + })); + + rightMap.forEach(function (v) { + var result = tryCatch(resultSelector)(value, v); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + leftDone = true; + (rightDone || leftMap.size === 0) && o.onCompleted(); + }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++, md = new SingleAssignmentDisposable(); + + rightMap.set(id, value); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted(); + group.remove(md); + })); + + leftMap.forEach(function (v) { + var result = tryCatch(resultSelector)(v, value); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + rightDone = true; + (leftDone || rightMap.size === 0) && o.onCompleted(); + }) + ); + return group; + }, left); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations, and groups the results. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var r = new RefCountDisposable(group); + var leftMap = new Map(), rightMap = new Map(); + var leftId = 0, rightId = 0; + var handleError = function (e) { return function (v) { v.onError(e); }; }; + + function handleError(e) { }; + + group.add(left.subscribe( + function (value) { + var s = new Subject(); + var id = leftId++; + leftMap.set(id, s); + + var result = tryCatch(resultSelector)(value, addRef(s, r)); + if (result === errorObj) { + leftMap.forEach(handleError(result.e)); + return o.onError(result.e); + } + o.onNext(result); + + rightMap.forEach(function (v) { s.onNext(v); }); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + leftMap['delete'](id) && s.onCompleted(); + group.remove(md); + })); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { o.onCompleted(); }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++; + rightMap.set(id, value); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + rightMap['delete'](id); + group.remove(md); + })); + + leftMap.forEach(function (v) { v.onNext(value); }); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }) + ); + + return r; + }, left); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers. + * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.buffer = function () { + return this.window.apply(this, arguments) + .flatMap(toArray); + }; + + /** + * Projects each element of an observable sequence into zero or more windows. + * + * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { + if (arguments.length === 1 && typeof arguments[0] !== 'function') { + return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector); + } + return typeof windowOpeningsOrClosingSelector === 'function' ? + observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) : + observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector); + }; + + function observableWindowWithOpenings(windowOpenings, windowClosingSelector) { + return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) { + return win; + }); + } + + function observableWindowWithBoundaries(windowBoundaries) { + var source = this; + return new AnonymousObservable(function (observer) { + var win = new Subject(), + d = new CompositeDisposable(), + r = new RefCountDisposable(d); + + observer.onNext(addRef(win, r)); + + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries)); + + d.add(windowBoundaries.subscribe(function (w) { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + return r; + }, source); + } + + function observableWindowWithClosingSelector(windowClosingSelector) { + var source = this; + return new AnonymousObservable(function (observer) { + var m = new SerialDisposable(), + d = new CompositeDisposable(m), + r = new RefCountDisposable(d), + win = new Subject(); + observer.onNext(addRef(win, r)); + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + function createWindowClose () { + var windowClose; + try { + windowClose = windowClosingSelector(); + } catch (e) { + observer.onError(e); + return; + } + + isPromise(windowClose) && (windowClose = observableFromPromise(windowClose)); + + var m1 = new SingleAssignmentDisposable(); + m.setDisposable(m1); + m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + createWindowClose(); + })); + } + + createWindowClose(); + return r; + }, source); + } + + /** + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. + * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array. + */ + observableProto.pairwise = function () { + var source = this; + return new AnonymousObservable(function (observer) { + var previous, hasPrevious = false; + return source.subscribe( + function (x) { + if (hasPrevious) { + observer.onNext([previous, x]); + } else { + hasPrevious = true; + } + previous = x; + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer)); + }, source); + }; + + /** + * Returns two observables which partition the observations of the source by the given function. + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes + * when the source completes. + * @param {Function} predicate + * The function to determine which output Observable will trigger a particular observation. + * @returns {Array} + * An array of observables. The first triggers when the predicate returns true, + * and the second triggers when the predicate returns false. + */ + observableProto.partition = function(predicate, thisArg) { + return [ + this.filter(predicate, thisArg), + this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); }) + ]; + }; + + var WhileEnumerable = (function(__super__) { + inherits(WhileEnumerable, __super__); + function WhileEnumerable(c, s) { + this.c = c; + this.s = s; + } + WhileEnumerable.prototype[$iterator$] = function () { + var self = this; + return { + next: function () { + return self.c() ? + { done: false, value: self.s } : + { done: true, value: void 0 }; + } + }; + }; + return WhileEnumerable; + }(Enumerable)); + + function enumerableWhile(condition, source) { + return new WhileEnumerable(condition, source); + } + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + observableProto.letBind = observableProto['let'] = function (func) { + return func(this); + }; + + /** + * Determines whether an observable collection contains values. + * + * @example + * 1 - res = Rx.Observable.if(condition, obs1); + * 2 - res = Rx.Observable.if(condition, obs1, obs2); + * 3 - res = Rx.Observable.if(condition, obs1, scheduler); + * @param {Function} condition The condition which determines if the thenSource or elseSource will be run. + * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true. + * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. + * @returns {Observable} An observable sequence which is either the thenSource or elseSource. + */ + Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) { + return observableDefer(function () { + elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty()); + + isPromise(thenSource) && (thenSource = observableFromPromise(thenSource)); + isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler)); + + // Assume a scheduler for empty only + typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler)); + return condition() ? thenSource : elseSourceOrScheduler; + }); + }; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers 0) { + isOwner = !isAcquired; + isAcquired = true; + } + if (isOwner) { + m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) { + var work; + if (q.length > 0) { + work = q.shift(); + } else { + isAcquired = false; + return; + } + var m1 = new SingleAssignmentDisposable(); + d.add(m1); + m1.setDisposable(work.subscribe(function (x) { + o.onNext(x); + var result = null; + try { + result = selector(x); + } catch (e) { + o.onError(e); + } + q.push(result); + activeCount++; + ensureActive(); + }, function (e) { o.onError(e); }, function () { + d.remove(m1); + activeCount--; + if (activeCount === 0) { + o.onCompleted(); + } + })); + self(); + })); + } + }; + + q.push(source); + activeCount++; + ensureActive(); + return d; + }, this); + }; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * 1 - res = Rx.Observable.forkJoin([obs1, obs2]); + * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences. + */ + Observable.forkJoin = function () { + var allSources = []; + if (Array.isArray(arguments[0])) { + allSources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); } + } + return new AnonymousObservable(function (subscriber) { + var count = allSources.length; + if (count === 0) { + subscriber.onCompleted(); + return disposableEmpty; + } + var group = new CompositeDisposable(), + finished = false, + hasResults = new Array(count), + hasCompleted = new Array(count), + results = new Array(count); + + for (var idx = 0; idx < count; idx++) { + (function (i) { + var source = allSources[i]; + isPromise(source) && (source = observableFromPromise(source)); + group.add( + source.subscribe( + function (value) { + if (!finished) { + hasResults[i] = true; + results[i] = value; + } + }, + function (e) { + finished = true; + subscriber.onError(e); + group.dispose(); + }, + function () { + if (!finished) { + if (!hasResults[i]) { + subscriber.onCompleted(); + return; + } + hasCompleted[i] = true; + for (var ix = 0; ix < count; ix++) { + if (!hasCompleted[ix]) { return; } + } + finished = true; + subscriber.onNext(results); + subscriber.onCompleted(); + } + })); + })(idx); + } + + return group; + }); + }; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * @param {Observable} second Second observable sequence. + * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + observableProto.forkJoin = function (second, resultSelector) { + var first = this; + return new AnonymousObservable(function (observer) { + var leftStopped = false, rightStopped = false, + hasLeft = false, hasRight = false, + lastLeft, lastRight, + leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable(); + + isPromise(second) && (second = observableFromPromise(second)); + + leftSubscription.setDisposable( + first.subscribe(function (left) { + hasLeft = true; + lastLeft = left; + }, function (err) { + rightSubscription.dispose(); + observer.onError(err); + }, function () { + leftStopped = true; + if (rightStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + rightSubscription.setDisposable( + second.subscribe(function (right) { + hasRight = true; + lastRight = right; + }, function (err) { + leftSubscription.dispose(); + observer.onError(err); + }, function () { + rightStopped = true; + if (leftStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(result.e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }, first); + }; + + /** + * Comonadic bind operator. + * @param {Function} selector A transform function to apply to each element. + * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns {Observable} An observable sequence which results from the comonadic bind operation. + */ + observableProto.manySelect = observableProto.extend = function (selector, scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + var source = this; + return observableDefer(function () { + var chain; + + return source + .map(function (x) { + var curr = new ChainObservable(x); + + chain && chain.onNext(x); + chain = curr; + + return curr; + }) + .tap( + noop, + function (e) { chain && chain.onError(e); }, + function () { chain && chain.onCompleted(); } + ) + .observeOn(scheduler) + .map(selector); + }, source); + }; + + var ChainObservable = (function (__super__) { + inherits(ChainObservable, __super__); + function ChainObservable(head) { + __super__.call(this); + this.head = head; + this.tail = new AsyncSubject(); + } + + addProperties(ChainObservable.prototype, Observer, { + _subscribe: function (o) { + var g = new CompositeDisposable(); + g.add(currentThreadScheduler.schedule(this, function (_, self) { + o.onNext(self.head); + g.add(self.tail.mergeAll().subscribe(o)); + })); + + return g; + }, + onCompleted: function () { + this.onNext(Observable.empty()); + }, + onError: function (e) { + this.onNext(Observable['throw'](e)); + }, + onNext: function (v) { + this.tail.onNext(v); + this.tail.onCompleted(); + } + }); + + return ChainObservable; + + }(Observable)); + + var Map = root.Map || (function () { + function Map() { + this.size = 0; + this._values = []; + this._keys = []; + } + + Map.prototype['delete'] = function (key) { + var i = this._keys.indexOf(key); + if (i === -1) { return false; } + this._values.splice(i, 1); + this._keys.splice(i, 1); + this.size--; + return true; + }; + + Map.prototype.get = function (key) { + var i = this._keys.indexOf(key); + return i === -1 ? undefined : this._values[i]; + }; + + Map.prototype.set = function (key, value) { + var i = this._keys.indexOf(key); + if (i === -1) { + this._keys.push(key); + this._values.push(value); + this.size++; + } else { + this._values[i] = value; + } + return this; + }; + + Map.prototype.forEach = function (cb, thisArg) { + for (var i = 0; i < this.size; i++) { + cb.call(thisArg, this._values[i], this._keys[i]); + } + }; + + return Map; + }()); + + /** + * @constructor + * Represents a join pattern over observable sequences. + */ + function Pattern(patterns) { + this.patterns = patterns; + } + + /** + * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. + * @param other Observable sequence to match in addition to the current pattern. + * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value. + */ + Pattern.prototype.and = function (other) { + return new Pattern(this.patterns.concat(other)); + }; + + /** + * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. + * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. + * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + Pattern.prototype.thenDo = function (selector) { + return new Plan(this, selector); + }; + + function Plan(expression, selector) { + this.expression = expression; + this.selector = selector; + } + + Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) { + var self = this; + var joinObservers = []; + for (var i = 0, len = this.expression.patterns.length; i < len; i++) { + joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer))); + } + var activePlan = new ActivePlan(joinObservers, function () { + var result; + try { + result = self.selector.apply(self, arguments); + } catch (e) { + observer.onError(e); + return; + } + observer.onNext(result); + }, function () { + for (var j = 0, jlen = joinObservers.length; j < jlen; j++) { + joinObservers[j].removeActivePlan(activePlan); + } + deactivate(activePlan); + }); + for (i = 0, len = joinObservers.length; i < len; i++) { + joinObservers[i].addActivePlan(activePlan); + } + return activePlan; + }; + + function planCreateObserver(externalSubscriptions, observable, onError) { + var entry = externalSubscriptions.get(observable); + if (!entry) { + var observer = new JoinObserver(observable, onError); + externalSubscriptions.set(observable, observer); + return observer; + } + return entry; + } + + function ActivePlan(joinObserverArray, onNext, onCompleted) { + this.joinObserverArray = joinObserverArray; + this.onNext = onNext; + this.onCompleted = onCompleted; + this.joinObservers = new Map(); + for (var i = 0, len = this.joinObserverArray.length; i < len; i++) { + var joinObserver = this.joinObserverArray[i]; + this.joinObservers.set(joinObserver, joinObserver); + } + } + + ActivePlan.prototype.dequeue = function () { + this.joinObservers.forEach(function (v) { v.queue.shift(); }); + }; + + ActivePlan.prototype.match = function () { + var i, len, hasValues = true; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + if (this.joinObserverArray[i].queue.length === 0) { + hasValues = false; + break; + } + } + if (hasValues) { + var firstValues = [], + isCompleted = false; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + firstValues.push(this.joinObserverArray[i].queue[0]); + this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true); + } + if (isCompleted) { + this.onCompleted(); + } else { + this.dequeue(); + var values = []; + for (i = 0, len = firstValues.length; i < firstValues.length; i++) { + values.push(firstValues[i].value); + } + this.onNext.apply(this, values); + } + } + }; + + var JoinObserver = (function (__super__) { + inherits(JoinObserver, __super__); + + function JoinObserver(source, onError) { + __super__.call(this); + this.source = source; + this.onError = onError; + this.queue = []; + this.activePlans = []; + this.subscription = new SingleAssignmentDisposable(); + this.isDisposed = false; + } + + var JoinObserverPrototype = JoinObserver.prototype; + + JoinObserverPrototype.next = function (notification) { + if (!this.isDisposed) { + if (notification.kind === 'E') { + return this.onError(notification.error); + } + this.queue.push(notification); + var activePlans = this.activePlans.slice(0); + for (var i = 0, len = activePlans.length; i < len; i++) { + activePlans[i].match(); + } + } + }; + + JoinObserverPrototype.error = noop; + JoinObserverPrototype.completed = noop; + + JoinObserverPrototype.addActivePlan = function (activePlan) { + this.activePlans.push(activePlan); + }; + + JoinObserverPrototype.subscribe = function () { + this.subscription.setDisposable(this.source.materialize().subscribe(this)); + }; + + JoinObserverPrototype.removeActivePlan = function (activePlan) { + this.activePlans.splice(this.activePlans.indexOf(activePlan), 1); + this.activePlans.length === 0 && this.dispose(); + }; + + JoinObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + if (!this.isDisposed) { + this.isDisposed = true; + this.subscription.dispose(); + } + }; + + return JoinObserver; + } (AbstractObserver)); + + /** + * Creates a pattern that matches when both observable sequences have an available value. + * + * @param right Observable sequence to match with the current sequence. + * @return {Pattern} Pattern object that matches when both observable sequences have an available value. + */ + observableProto.and = function (right) { + return new Pattern([this, right]); + }; + + /** + * Matches when the observable sequence has an available value and projects the value. + * + * @param {Function} selector Selector that will be invoked for values in the source sequence. + * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + observableProto.thenDo = function (selector) { + return new Pattern([this]).thenDo(selector); + }; + + /** + * Joins together the results from several patterns. + * + * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns. + * @returns {Observable} Observable sequence with the results form matching several patterns. + */ + Observable.when = function () { + var len = arguments.length, plans; + if (Array.isArray(arguments[0])) { + plans = arguments[0]; + } else { + plans = new Array(len); + for(var i = 0; i < len; i++) { plans[i] = arguments[i]; } + } + return new AnonymousObservable(function (o) { + var activePlans = [], + externalSubscriptions = new Map(); + var outObserver = observerCreate( + function (x) { o.onNext(x); }, + function (err) { + externalSubscriptions.forEach(function (v) { v.onError(err); }); + o.onError(err); + }, + function (x) { o.onCompleted(); } + ); + try { + for (var i = 0, len = plans.length; i < len; i++) { + activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) { + var idx = activePlans.indexOf(activePlan); + activePlans.splice(idx, 1); + activePlans.length === 0 && o.onCompleted(); + })); + } + } catch (e) { + observableThrow(e).subscribe(o); + } + var group = new CompositeDisposable(); + externalSubscriptions.forEach(function (joinObserver) { + joinObserver.subscribe(); + group.add(joinObserver); + }); + + return group; + }); + }; + + var TimerObservable = (function(__super__) { + inherits(TimerObservable, __super__); + function TimerObservable(dt, s) { + this._dt = dt; + this._s = s; + __super__.call(this); + } + + TimerObservable.prototype.subscribeCore = function (o) { + return this._s.scheduleFuture(o, this._dt, scheduleMethod); + }; + + function scheduleMethod(s, o) { + o.onNext(0); + o.onCompleted(); + } + + return TimerObservable; + }(ObservableBase)); + + function _observableTimer(dueTime, scheduler) { + return new TimerObservable(dueTime, scheduler); + } + + function observableTimerDateAndPeriod(dueTime, period, scheduler) { + return new AnonymousObservable(function (observer) { + var d = dueTime, p = normalizeTime(period); + return scheduler.scheduleRecursiveFuture(0, d, function (count, self) { + if (p > 0) { + var now = scheduler.now(); + d = d + p; + d <= now && (d = now + p); + } + observer.onNext(count); + self(count + 1, new Date(d)); + }); + }); + } + + function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { + return dueTime === period ? + new AnonymousObservable(function (observer) { + return scheduler.schedulePeriodic(0, period, function (count) { + observer.onNext(count); + return count + 1; + }); + }) : + observableDefer(function () { + return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler); + }); + } + + /** + * Returns an observable sequence that produces a value after each period. + * + * @example + * 1 - res = Rx.Observable.interval(1000); + * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); + * + * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. + * @returns {Observable} An observable sequence that produces a value after each period. + */ + var observableinterval = Observable.interval = function (period, scheduler) { + return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler); + }; + + /** + * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. + * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period. + */ + var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { + var period; + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { + period = periodOrScheduler; + } else if (isScheduler(periodOrScheduler)) { + scheduler = periodOrScheduler; + } + if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) { + return _observableTimer(dueTime, scheduler); + } + if (dueTime instanceof Date && period !== undefined) { + return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler); + } + return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); + }; + + function observableDelayRelative(source, dueTime, scheduler) { + return new AnonymousObservable(function (o) { + var active = false, + cancelable = new SerialDisposable(), + exception = null, + q = [], + running = false, + subscription; + subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) { + var d, shouldRun; + if (notification.value.kind === 'E') { + q = []; + q.push(notification); + exception = notification.value.error; + shouldRun = !running; + } else { + q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); + shouldRun = !active; + active = true; + } + if (shouldRun) { + if (exception !== null) { + o.onError(exception); + } else { + d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) { + var e, recurseDueTime, result, shouldRecurse; + if (exception !== null) { + return; + } + running = true; + do { + result = null; + if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) { + result = q.shift().value; + } + if (result !== null) { + result.accept(o); + } + } while (result !== null); + shouldRecurse = false; + recurseDueTime = 0; + if (q.length > 0) { + shouldRecurse = true; + recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now()); + } else { + active = false; + } + e = exception; + running = false; + if (e !== null) { + o.onError(e); + } else if (shouldRecurse) { + self(null, recurseDueTime); + } + })); + } + } + }); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + function observableDelayAbsolute(source, dueTime, scheduler) { + return observableDefer(function () { + return observableDelayRelative(source, dueTime - scheduler.now(), scheduler); + }); + } + + function delayWithSelector(source, subscriptionDelay, delayDurationSelector) { + var subDelay, selector; + if (isFunction(subscriptionDelay)) { + selector = subscriptionDelay; + } else { + subDelay = subscriptionDelay; + selector = delayDurationSelector; + } + return new AnonymousObservable(function (o) { + var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable(); + + function start() { + subscription.setDisposable(source.subscribe( + function (x) { + var delay = tryCatch(selector)(x); + if (delay === errorObj) { return o.onError(delay.e); } + var d = new SingleAssignmentDisposable(); + delays.add(d); + d.setDisposable(delay.subscribe( + function () { + o.onNext(x); + delays.remove(d); + done(); + }, + function (e) { o.onError(e); }, + function () { + o.onNext(x); + delays.remove(d); + done(); + } + )); + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + subscription.dispose(); + done(); + } + )); + } + + function done () { + atEnd && delays.length === 0 && o.onCompleted(); + } + + if (!subDelay) { + start(); + } else { + subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); + } + + return new BinaryDisposable(subscription, delays); + }, this); + } + + /** + * Time shifts the observable sequence by dueTime. + * The relative time intervals between the values are preserved. + * + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. + * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delay = function () { + var firstArg = arguments[0]; + if (typeof firstArg === 'number' || firstArg instanceof Date) { + var dueTime = firstArg, scheduler = arguments[1]; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return dueTime instanceof Date ? + observableDelayAbsolute(this, dueTime, scheduler) : + observableDelayRelative(this, dueTime, scheduler); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return delayWithSelector(this, firstArg, arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var DebounceObservable = (function (__super__) { + inherits(DebounceObservable, __super__); + function DebounceObservable(source, dt, s) { + isScheduler(s) || (s = defaultScheduler); + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DebounceObservable.prototype.subscribeCore = function (o) { + var cancelable = new SerialDisposable(); + return new BinaryDisposable( + this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)), + cancelable); + }; + + return DebounceObservable; + }(ObservableBase)); + + var DebounceObserver = (function (__super__) { + inherits(DebounceObserver, __super__); + function DebounceObserver(observer, source, dueTime, scheduler, cancelable) { + this._o = observer; + this._s = source; + this._d = dueTime; + this._scheduler = scheduler; + this._c = cancelable; + this._v = null; + this._hv = false; + this._id = 0; + __super__.call(this); + } + + DebounceObserver.prototype.next = function (x) { + this._hv = true; + this._v = x; + var currentId = ++this._id, d = new SingleAssignmentDisposable(); + this._c.setDisposable(d); + d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) { + self._hv && self._id === currentId && self._o.onNext(x); + self._hv = false; + })); + }; + + DebounceObserver.prototype.error = function (e) { + this._c.dispose(); + this._o.onError(e); + this._hv = false; + this._id++; + }; + + DebounceObserver.prototype.completed = function () { + this._c.dispose(); + this._hv && this._o.onNext(this._v); + this._o.onCompleted(); + this._hv = false; + this._id++; + }; + + return DebounceObserver; + }(AbstractObserver)); + + function debounceWithSelector(source, durationSelector) { + return new AnonymousObservable(function (o) { + var value, hasValue = false, cancelable = new SerialDisposable(), id = 0; + var subscription = source.subscribe( + function (x) { + var throttle = tryCatch(durationSelector)(x); + if (throttle === errorObj) { return o.onError(throttle.e); } + + isPromise(throttle) && (throttle = observableFromPromise(throttle)); + + hasValue = true; + value = x; + id++; + var currentid = id, d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(throttle.subscribe( + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + }, + function (e) { o.onError(e); }, + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + } + )); + }, + function (e) { + cancelable.dispose(); + o.onError(e); + hasValue = false; + id++; + }, + function () { + cancelable.dispose(); + hasValue && o.onNext(value); + o.onCompleted(); + hasValue = false; + id++; + } + ); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + observableProto.debounce = function () { + if (isFunction (arguments[0])) { + return debounceWithSelector(this, arguments[0]); + } else if (typeof arguments[0] === 'number') { + return new DebounceObservable(this, arguments[0], arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on timing information. + * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + var source = this, timeShift; + timeShiftOrScheduler == null && (timeShift = timeSpan); + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (typeof timeShiftOrScheduler === 'number') { + timeShift = timeShiftOrScheduler; + } else if (isScheduler(timeShiftOrScheduler)) { + timeShift = timeSpan; + scheduler = timeShiftOrScheduler; + } + return new AnonymousObservable(function (observer) { + var groupDisposable, + nextShift = timeShift, + nextSpan = timeSpan, + q = [], + refCountDisposable, + timerD = new SerialDisposable(), + totalTime = 0; + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable); + + function createTimer () { + var m = new SingleAssignmentDisposable(), + isSpan = false, + isShift = false; + timerD.setDisposable(m); + if (nextSpan === nextShift) { + isSpan = true; + isShift = true; + } else if (nextSpan < nextShift) { + isSpan = true; + } else { + isShift = true; + } + var newTotalTime = isSpan ? nextSpan : nextShift, + ts = newTotalTime - totalTime; + totalTime = newTotalTime; + if (isSpan) { + nextSpan += timeShift; + } + if (isShift) { + nextShift += timeShift; + } + m.setDisposable(scheduler.scheduleFuture(null, ts, function () { + if (isShift) { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + isSpan && q.shift().onCompleted(); + createTimer(); + })); + }; + q.push(new Subject()); + observer.onNext(addRef(q[0], refCountDisposable)); + createTimer(); + groupDisposable.add(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + }, + function (e) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); } + observer.onError(e); + }, + function () { + for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + /** + * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a window. + * @param {Number} count Maximum element count of a window. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (observer) { + var timerD = new SerialDisposable(), + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable), + n = 0, + windowId = 0, + s = new Subject(); + + function createTimer(id) { + var m = new SingleAssignmentDisposable(); + timerD.setDisposable(m); + m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () { + if (id !== windowId) { return; } + n = 0; + var newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + createTimer(newId); + })); + } + + observer.onNext(addRef(s, refCountDisposable)); + createTimer(0); + + groupDisposable.add(source.subscribe( + function (x) { + var newId = 0, newWindow = false; + s.onNext(x); + if (++n === count) { + newWindow = true; + n = 0; + newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + } + newWindow && createTimer(newId); + }, + function (e) { + s.onError(e); + observer.onError(e); + }, function () { + s.onCompleted(); + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. + * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. + * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a buffer. + * @param {Number} count Maximum element count of a buffer. + * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) { + return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray); + }; + + var TimeIntervalObservable = (function (__super__) { + inherits(TimeIntervalObservable, __super__); + function TimeIntervalObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimeIntervalObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimeIntervalObserver(o, this._s)); + }; + + return TimeIntervalObservable; + }(ObservableBase)); + + var TimeIntervalObserver = (function (__super__) { + inherits(TimeIntervalObserver, __super__); + + function TimeIntervalObserver(o, s) { + this._o = o; + this._s = s; + this._l = s.now(); + __super__.call(this); + } + + TimeIntervalObserver.prototype.next = function (x) { + var now = this._s.now(), span = now - this._l; + this._l = now; + this._o.onNext({ value: x, interval: span }); + }; + TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); }; + TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return TimeIntervalObserver; + }(AbstractObserver)); + + /** + * Records the time interval between consecutive values in an observable sequence. + * + * @example + * 1 - res = source.timeInterval(); + * 2 - res = source.timeInterval(Rx.Scheduler.timeout); + * + * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence with time interval information on values. + */ + observableProto.timeInterval = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimeIntervalObservable(this, scheduler); + }; + + var TimestampObservable = (function (__super__) { + inherits(TimestampObservable, __super__); + function TimestampObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimestampObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimestampObserver(o, this._s)); + }; + + return TimestampObservable; + }(ObservableBase)); + + var TimestampObserver = (function (__super__) { + inherits(TimestampObserver, __super__); + function TimestampObserver(o, s) { + this._o = o; + this._s = s; + __super__.call(this); + } + + TimestampObserver.prototype.next = function (x) { + this._o.onNext({ value: x, timestamp: this._s.now() }); + }; + + TimestampObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TimestampObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return TimestampObserver; + }(AbstractObserver)); + + /** + * Records the timestamp for each value in an observable sequence. + * + * @example + * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } + * 2 - res = source.timestamp(Rx.Scheduler.default); + * + * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used. + * @returns {Observable} An observable sequence with timestamp information on values. + */ + observableProto.timestamp = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimestampObservable(this, scheduler); + }; + + function sampleObservable(source, sampler) { + return new AnonymousObservable(function (o) { + var atEnd = false, value, hasValue = false; + + function sampleSubscribe() { + if (hasValue) { + hasValue = false; + o.onNext(value); + } + atEnd && o.onCompleted(); + } + + var sourceSubscription = new SingleAssignmentDisposable(); + sourceSubscription.setDisposable(source.subscribe( + function (newValue) { + hasValue = true; + value = newValue; + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + sourceSubscription.dispose(); + } + )); + + return new BinaryDisposable( + sourceSubscription, + sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe) + ); + }, source); + } + + /** + * Samples the observable sequence at each interval. + * + * @example + * 1 - res = source.sample(sampleObservable); // Sampler tick sequence + * 2 - res = source.sample(5000); // 5 seconds + * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds + * + * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable. + * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Sampled observable sequence. + */ + observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return typeof intervalOrSampler === 'number' ? + sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : + sampleObservable(this, intervalOrSampler); + }; + + var TimeoutError = Rx.TimeoutError = function(message) { + this.message = message || 'Timeout has occurred'; + this.name = 'TimeoutError'; + Error.call(this); + }; + TimeoutError.prototype = Object.create(Error.prototype); + + function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) { + if (isFunction(firstTimeout)) { + other = timeoutDurationSelector; + timeoutDurationSelector = firstTimeout; + firstTimeout = observableNever(); + } + other || (other = observableThrow(new TimeoutError())); + return new AnonymousObservable(function (o) { + var subscription = new SerialDisposable(), + timer = new SerialDisposable(), + original = new SingleAssignmentDisposable(); + + subscription.setDisposable(original); + + var id = 0, switched = false; + + function setTimer(timeout) { + var myId = id, d = new SingleAssignmentDisposable(); + + function timerWins() { + switched = (myId === id); + return switched; + } + + timer.setDisposable(d); + d.setDisposable(timeout.subscribe(function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + d.dispose(); + }, function (e) { + timerWins() && o.onError(e); + }, function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + })); + }; + + setTimer(firstTimeout); + + function oWins() { + var res = !switched; + if (res) { id++; } + return res; + } + + original.setDisposable(source.subscribe(function (x) { + if (oWins()) { + o.onNext(x); + var timeout = tryCatch(timeoutDurationSelector)(x); + if (timeout === errorObj) { return o.onError(timeout.e); } + setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout); + } + }, function (e) { + oWins() && o.onError(e); + }, function () { + oWins() && o.onCompleted(); + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + function timeout(source, dueTime, other, scheduler) { + if (isScheduler(other)) { + scheduler = other; + other = observableThrow(new TimeoutError()); + } + if (other instanceof Error) { other = observableThrow(other); } + isScheduler(scheduler) || (scheduler = defaultScheduler); + + return new AnonymousObservable(function (o) { + var id = 0, + original = new SingleAssignmentDisposable(), + subscription = new SerialDisposable(), + switched = false, + timer = new SerialDisposable(); + + subscription.setDisposable(original); + + function createTimer() { + var myId = id; + timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () { + switched = id === myId; + if (switched) { + isPromise(other) && (other = observableFromPromise(other)); + subscription.setDisposable(other.subscribe(o)); + } + })); + } + + createTimer(); + + original.setDisposable(source.subscribe(function (x) { + if (!switched) { + id++; + o.onNext(x); + createTimer(); + } + }, function (e) { + if (!switched) { + id++; + o.onError(e); + } + }, function () { + if (!switched) { + id++; + o.onCompleted(); + } + })); + return new BinaryDisposable(subscription, timer); + }, source); } - + + observableProto.timeout = function () { + var firstArg = arguments[0]; + if (firstArg instanceof Date || typeof firstArg === 'number') { + return timeout(this, firstArg, arguments[1], arguments[2]); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var GenerateAbsoluteObservable = (function (__super__) { + inherits(GenerateAbsoluteObservable, __super__); + function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateAbsoluteObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive); + }; + + return GenerateAbsoluteObservable; + }(ObservableBase)); + /** - * Returns an observable sequence that produces a value after each period. + * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails. * * @example - * 1 - res = Rx.Observable.interval(1000); - * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); + * res = source.generateWithAbsoluteTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return new Date(); } + * }); * - * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. - * @returns {Observable} An observable sequence that produces a value after each period. + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. */ - var observableinterval = Observable.interval = function (period, scheduler) { - return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : timeoutScheduler); + Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var GenerateRelativeObservable = (function (__super__) { + inherits(GenerateRelativeObservable, __super__); + function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateRelativeObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive); + }; + + return GenerateRelativeObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithRelativeTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return 500; } + * ); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var DelaySubscription = (function(__super__) { + inherits(DelaySubscription, __super__); + function DelaySubscription(source, dt, s) { + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DelaySubscription.prototype.subscribeCore = function (o) { + var d = new SerialDisposable(); + + d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod)); + + return d; + }; + + function scheduleMethod(s, state) { + var source = state[0], o = state[1], d = state[2]; + d.setDisposable(source.subscribe(o)); + } + + return DelaySubscription; + }(ObservableBase)); + + /** + * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.delaySubscription(5000); // 5s + * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds + * + * @param {Number} dueTime Relative or absolute time shift of the subscription. + * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delaySubscription = function (dueTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new DelaySubscription(this, dueTime, scheduler); }; - + + var SkipLastWithTimeObservable = (function (__super__) { + inherits(SkipLastWithTimeObservable, __super__); + function SkipLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + SkipLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastWithTimeObserver(o, this)); + }; + + return SkipLastWithTimeObservable; + }(ObservableBase)); + + var SkipLastWithTimeObserver = (function (__super__) { + inherits(SkipLastWithTimeObserver, __super__); + + function SkipLastWithTimeObserver(o, p) { + this._o = o; + this._s = p._s; + this._d = p._d; + this._q = []; + __super__.call(this); + } + + SkipLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + }; + SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + this._o.onCompleted(); + }; + + return SkipLastWithTimeObserver; + }(AbstractObserver)); + /** - * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. - * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. - * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period. + * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for skipping elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence. */ - var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { - var period; - isScheduler(scheduler) || (scheduler = timeoutScheduler); - if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { - period = periodOrScheduler; - } else if (isScheduler(periodOrScheduler)) { - scheduler = periodOrScheduler; - } - if (dueTime instanceof Date && period === undefined) { - return observableTimerDate(dueTime.getTime(), scheduler); + observableProto.skipLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipLastWithTimeObservable(this, duration, scheduler); + }; + + var TakeLastWithTimeObservable = (function (__super__) { + inherits(TakeLastWithTimeObservable, __super__); + function TakeLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); } - if (dueTime instanceof Date && period !== undefined) { - return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler); + + TakeLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s)); + }; + + return TakeLastWithTimeObservable; + }(ObservableBase)); + + var TakeLastWithTimeObserver = (function (__super__) { + inherits(TakeLastWithTimeObserver, __super__); + + function TakeLastWithTimeObserver(o, d, s) { + this._o = o; + this._d = d; + this._s = s; + this._q = []; + __super__.call(this); } - return period === undefined ? - observableTimerTimeSpan(dueTime, scheduler) : - observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); + + TakeLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._q.shift(); + } + }; + TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + TakeLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0) { + var next = this._q.shift(); + if (now - next.interval <= this._d) { this._o.onNext(next.value); } + } + this._o.onCompleted(); + }; + + return TakeLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeLastWithTimeObservable(this, duration, scheduler); }; - - function observableDelayRelative(source, dueTime, scheduler) { + + /** + * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastBufferWithTime = function (duration, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); return new AnonymousObservable(function (o) { - var active = false, - cancelable = new SerialDisposable(), - exception = null, - q = [], - running = false, - subscription; - subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) { - var d, shouldRun; - if (notification.value.kind === 'E') { - q = []; - q.push(notification); - exception = notification.value.exception; - shouldRun = !running; - } else { - q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); - shouldRun = !active; - active = true; + var q = []; + return source.subscribe(function (x) { + var now = scheduler.now(); + q.push({ interval: now, value: x }); + while (q.length > 0 && now - q[0].interval >= duration) { + q.shift(); } - if (shouldRun) { - if (exception !== null) { - o.onError(exception); - } else { - d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(scheduler.scheduleRecursiveWithRelative(dueTime, function (self) { - var e, recurseDueTime, result, shouldRecurse; - if (exception !== null) { - return; - } - running = true; - do { - result = null; - if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) { - result = q.shift().value; - } - if (result !== null) { - result.accept(o); - } - } while (result !== null); - shouldRecurse = false; - recurseDueTime = 0; - if (q.length > 0) { - shouldRecurse = true; - recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now()); - } else { - active = false; - } - e = exception; - running = false; - if (e !== null) { - o.onError(e); - } else if (shouldRecurse) { - self(recurseDueTime); - } - })); - } + }, function (e) { o.onError(e); }, function () { + var now = scheduler.now(), res = []; + while (q.length > 0) { + var next = q.shift(); + now - next.interval <= duration && res.push(next.value); } + o.onNext(res); + o.onCompleted(); }); - return new CompositeDisposable(subscription, cancelable); }, source); - } - - function observableDelayAbsolute(source, dueTime, scheduler) { - return observableDefer(function () { - return observableDelayRelative(source, dueTime - scheduler.now(), scheduler); - }); - } + }; - function delayWithSelector(source, subscriptionDelay, delayDurationSelector) { - var subDelay, selector; - if (isFunction(subscriptionDelay)) { - selector = subscriptionDelay; - } else { - subDelay = subscriptionDelay; - selector = delayDurationSelector; + var TakeWithTimeObservable = (function (__super__) { + inherits(TakeWithTimeObservable, __super__); + function TakeWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); } - return new AnonymousObservable(function (o) { - var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable(); - - function start() { - subscription.setDisposable(source.subscribe( - function (x) { - var delay = tryCatch(selector)(x); - if (delay === errorObj) { return o.onError(delay.e); } - var d = new SingleAssignmentDisposable(); - delays.add(d); - d.setDisposable(delay.subscribe( - function () { - o.onNext(x); - delays.remove(d); - done(); - }, - function (e) { o.onError(e); }, - function () { - o.onNext(x); - delays.remove(d); - done(); - } - )); - }, - function (e) { o.onError(e); }, - function () { - atEnd = true; - subscription.dispose(); - done(); - } - )); - } - function done () { - atEnd && delays.length === 0 && o.onCompleted(); - } + function scheduleMethod(s, o) { + o.onCompleted(); + } - if (!subDelay) { - start(); - } else { - subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); - } + TakeWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(o, this._d, scheduleMethod), + this.source.subscribe(o) + ); + }; - return new CompositeDisposable(subscription, delays); - }, this); - } + return TakeWithTimeObservable; + }(ObservableBase)); /** - * Time shifts the observable sequence by dueTime. - * The relative time intervals between the values are preserved. + * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. * - * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. - * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} Time-shifted sequence. + * @example + * 1 - res = source.takeWithTime(5000, [optional scheduler]); + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence. */ - observableProto.delay = function () { - if (typeof arguments[0] === 'number' || arguments[0] instanceof Date) { - var dueTime = arguments[0], scheduler = arguments[1]; - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return dueTime instanceof Date ? - observableDelayAbsolute(this, dueTime, scheduler) : - observableDelayRelative(this, dueTime, scheduler); - } else if (isFunction(arguments[0])) { - return delayWithSelector(this, arguments[0], arguments[1]); - } else { - throw new Error('Invalid arguments'); - } + observableProto.takeWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeWithTimeObservable(this, duration, scheduler); }; - - function debounce(source, dueTime, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return new AnonymousObservable(function (observer) { - var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0; - var subscription = source.subscribe( - function (x) { - hasvalue = true; - value = x; - id++; - var currentId = id, - d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () { - hasvalue && id === currentId && observer.onNext(value); - hasvalue = false; - })); - }, - function (e) { - cancelable.dispose(); - observer.onError(e); - hasvalue = false; - id++; - }, - function () { - cancelable.dispose(); - hasvalue && observer.onNext(value); - observer.onCompleted(); - hasvalue = false; - id++; - }); - return new CompositeDisposable(subscription, cancelable); - }, this); - } - function debounceWithSelector(source, durationSelector) { - return new AnonymousObservable(function (o) { - var value, hasValue = false, cancelable = new SerialDisposable(), id = 0; - var subscription = source.subscribe( - function (x) { - var throttle = tryCatch(durationSelector)(x); - if (throttle === errorObj) { return o.onError(throttle.e); } + var SkipWithTimeObservable = (function (__super__) { + inherits(SkipWithTimeObservable, __super__); + function SkipWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + this._open = false; + __super__.call(this); + } - isPromise(throttle) && (throttle = observableFromPromise(throttle)); + function scheduleMethod(s, self) { + self._open = true; + } - hasValue = true; - value = x; - id++; - var currentid = id, d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(throttle.subscribe( - function () { - hasValue && id === currentid && o.onNext(value); - hasValue = false; - d.dispose(); - }, - function (e) { o.onError(e); }, - function () { - hasValue && id === currentid && o.onNext(value); - hasValue = false; - d.dispose(); - } - )); - }, - function (e) { - cancelable.dispose(); - o.onError(e); - hasValue = false; - id++; - }, - function () { - cancelable.dispose(); - hasValue && o.onNext(value); - o.onCompleted(); - hasValue = false; - id++; - } + SkipWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(this, this._d, scheduleMethod), + this.source.subscribe(new SkipWithTimeObserver(o, this)) ); - return new CompositeDisposable(subscription, cancelable); - }, source); - } + }; - observableProto.debounce = function () { - if (isFunction (arguments[0])) { - return debounceWithSelector(this, arguments[0]); - } else if (typeof arguments[0] === 'number') { - return debounce(this, arguments[0], arguments[1]); - } else { - throw new Error('Invalid arguments'); + return SkipWithTimeObservable; + }(ObservableBase)); + + var SkipWithTimeObserver = (function (__super__) { + inherits(SkipWithTimeObserver, __super__); + + function SkipWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); } - }; - + + SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWithTimeObserver; + }(AbstractObserver)); + /** - * Records the timestamp for each value in an observable sequence. - * - * @example - * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } - * 2 - res = source.timestamp(Rx.Scheduler.default); + * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * @description + * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. + * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded + * may not execute immediately, despite the zero due time. * - * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used. - * @returns {Observable} An observable sequence with timestamp information on values. + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. + * @param {Number} duration Duration for skipping elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence. */ - observableProto.timestamp = function (scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return this.map(function (x) { - return { value: x, timestamp: scheduler.now() }; - }); + observableProto.skipWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipWithTimeObservable(this, duration, scheduler); }; - - function sampleObservable(source, sampler) { - return new AnonymousObservable(function (o) { - var atEnd = false, value, hasValue = false; - function sampleSubscribe() { - if (hasValue) { - hasValue = false; - o.onNext(value); - } - atEnd && o.onCompleted(); - } + var SkipUntilWithTimeObservable = (function (__super__) { + inherits(SkipUntilWithTimeObservable, __super__); + function SkipUntilWithTimeObservable(source, startTime, scheduler) { + this.source = source; + this._st = startTime; + this._s = scheduler; + __super__.call(this); + } - var sourceSubscription = new SingleAssignmentDisposable(); - sourceSubscription.setDisposable(source.subscribe( - function (newValue) { - hasValue = true; - value = newValue; - }, - function (e) { o.onError(e); }, - function () { - atEnd = true; - sourceSubscription.dispose(); - } - )); + function scheduleMethod(s, state) { + state._open = true; + } - return new CompositeDisposable( - sourceSubscription, - sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe) + SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) { + this._open = false; + return new BinaryDisposable( + this._s.scheduleFuture(this, this._st, scheduleMethod), + this.source.subscribe(new SkipUntilWithTimeObserver(o, this)) ); - }, source); - } + }; + + return SkipUntilWithTimeObservable; + }(ObservableBase)); + + var SkipUntilWithTimeObserver = (function (__super__) { + inherits(SkipUntilWithTimeObserver, __super__); + + function SkipUntilWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipUntilWithTimeObserver; + }(AbstractObserver)); + /** - * Samples the observable sequence at each interval. - * - * @example - * 1 - res = source.sample(sampleObservable); // Sampler tick sequence - * 2 - res = source.sample(5000); // 5 seconds - * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds + * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time. * - * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable. - * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. - * @returns {Observable} Sampled observable sequence. + * @examples + * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]); + * 2 - res = source.skipUntilWithTime(5000, [scheduler]); + * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped until the specified start time. */ - observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - return typeof intervalOrSampler === 'number' ? - sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : - sampleObservable(this, intervalOrSampler); + observableProto.skipUntilWithTime = function (startTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipUntilWithTimeObservable(this, startTime, scheduler); }; - - var TimeoutError = Rx.TimeoutError = function(message) { - this.message = message || 'Timeout has occurred'; - this.name = 'TimeoutError'; - Error.call(this); + + /** + * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. + * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. + * @returns {Observable} An observable sequence with the elements taken until the specified end time. + */ + observableProto.takeUntilWithTime = function (endTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var source = this; + return new AnonymousObservable(function (o) { + return new BinaryDisposable( + scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }), + source.subscribe(o)); + }, source); }; - TimeoutError.prototype = Object.create(Error.prototype); - function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) { - if (isFunction(firstTimeout)) { - other = timeoutDurationSelector; - timeoutDurationSelector = firstTimeout; - firstTimeout = observableNever(); - } - other || (other = observableThrow(new TimeoutError())); + /** + * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. + * @param {Number} windowDuration time to wait before emitting another item after emitting the last item + * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout. + * @returns {Observable} An Observable that performs the throttle operation. + */ + observableProto.throttle = function (windowDuration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var duration = +windowDuration || 0; + if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } + var source = this; return new AnonymousObservable(function (o) { - var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable(); + var lastOnNext = 0; + return source.subscribe( + function (x) { + var now = scheduler.now(); + if (lastOnNext === 0 || now - lastOnNext >= duration) { + lastOnNext = now; + o.onNext(x); + } + },function (e) { o.onError(e); }, function () { o.onCompleted(); } + ); + }, source); + }; - subscription.setDisposable(original); + var TransduceObserver = (function (__super__) { + inherits(TransduceObserver, __super__); + function TransduceObserver(o, xform) { + this._o = o; + this._xform = xform; + __super__.call(this); + } - var id = 0, switched = false; + TransduceObserver.prototype.next = function (x) { + var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x); + if (res === errorObj) { this._o.onError(res.e); } + }; - function setTimer(timeout) { - var myId = id, d = new SingleAssignmentDisposable(); - timer.setDisposable(d); - d.setDisposable(timeout.subscribe(function () { - id === myId && subscription.setDisposable(other.subscribe(o)); - d.dispose(); - }, function (e) { - id === myId && o.onError(e); - }, function () { - id === myId && subscription.setDisposable(other.subscribe(o)); - })); - }; + TransduceObserver.prototype.error = function (e) { this._o.onError(e); }; - setTimer(firstTimeout); + TransduceObserver.prototype.completed = function () { + this._xform['@@transducer/result'](this._o); + }; - function oWins() { - var res = !switched; - if (res) { id++; } - return res; + return TransduceObserver; + }(AbstractObserver)); + + function transformForObserver(o) { + return { + '@@transducer/init': function() { + return o; + }, + '@@transducer/step': function(obs, input) { + return obs.onNext(input); + }, + '@@transducer/result': function(obs) { + return obs.onCompleted(); } + }; + } - original.setDisposable(source.subscribe(function (x) { - if (oWins()) { - o.onNext(x); - var timeout = tryCatch(timeoutDurationSelector)(x); - if (timeout === errorObj) { return o.onError(timeout.e); } - setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout); - } - }, function (e) { - oWins() && o.onError(e); - }, function () { - oWins() && o.onCompleted(); - })); - return new CompositeDisposable(subscription, timer); + /** + * Executes a transducer to transform the observable sequence + * @param {Transducer} transducer A transducer to execute + * @returns {Observable} An Observable sequence containing the results from the transducer. + */ + observableProto.transduce = function(transducer) { + var source = this; + return new AnonymousObservable(function(o) { + var xform = transducer(transformForObserver(o)); + return source.subscribe(new TransduceObserver(o, xform)); }, source); - } + }; - function timeout(source, dueTime, other, scheduler) { - if (other == null) { throw new Error('other or scheduler must be specified'); } - if (isScheduler(other)) { - scheduler = other; - other = observableThrow(new TimeoutError()); + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * @returns {Observable} A exclusive observable with only the results that happen when subscribed. + */ + observableProto.switchFirst = function () { + var sources = this; + return new AnonymousObservable(function (o) { + var hasCurrent = false, + isStopped = false, + m = new SingleAssignmentDisposable(), + g = new CompositeDisposable(); + + g.add(m); + + m.setDisposable(sources.subscribe( + function (innerSource) { + if (!hasCurrent) { + hasCurrent = true; + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + var innerSubscription = new SingleAssignmentDisposable(); + g.add(innerSubscription); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { o.onError(e); }, + function () { + g.remove(innerSubscription); + hasCurrent = false; + isStopped && g.length === 1 && o.onCompleted(); + })); + } + }, + function (e) { o.onError(e); }, + function () { + isStopped = true; + !hasCurrent && g.length === 1 && o.onCompleted(); + })); + + return g; + }, this); + }; + +observableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst(); +}; + +Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +}; + /** Provides a set of extension methods for virtual time scheduling. */ + var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) { + inherits(VirtualTimeScheduler, __super__); + + /** + * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer. + * + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function VirtualTimeScheduler(initialClock, comparer) { + this.clock = initialClock; + this.comparer = comparer; + this.isEnabled = false; + this.queue = new PriorityQueue(1024); + __super__.call(this); } - if (other instanceof Error) { other = observableThrow(other); } - isScheduler(scheduler) || (scheduler = timeoutScheduler); - var schedulerMethod = dueTime instanceof Date ? - 'scheduleWithAbsolute' : - 'scheduleWithRelative'; + var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype; - return new AnonymousObservable(function (o) { - var id = 0, - original = new SingleAssignmentDisposable(), - subscription = new SerialDisposable(), - switched = false, - timer = new SerialDisposable(); + VirtualTimeSchedulerPrototype.now = function () { + return this.toAbsoluteTime(this.clock); + }; + + VirtualTimeSchedulerPrototype.schedule = function (state, action) { + return this.scheduleAbsolute(state, this.clock, action); + }; + + VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime instanceof Date ? + this.toRelativeTime(dueTime - this.now()) : + this.toRelativeTime(dueTime); + + return this.scheduleRelative(state, dt, action); + }; + + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + VirtualTimeSchedulerPrototype.add = notImplemented; + + /** + * Converts an absolute time to a number + * @param {Any} The absolute time. + * @returns {Number} The absolute time in ms + */ + VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented; + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) { + var s = new SchedulePeriodicRecursive(this, state, period, action); + return s.start(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) { + var runAt = this.add(this.clock, dueTime); + return this.scheduleAbsolute(state, runAt, action); + }; + + /** + * Starts the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.start = function () { + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + } + }; - subscription.setDisposable(original); + /** + * Stops the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.stop = function () { + this.isEnabled = false; + }; - function createTimer() { - var myId = id; - timer.setDisposable(scheduler[schedulerMethod](dueTime, function () { - if (id === myId) { - isPromise(other) && (other = observableFromPromise(other)); - subscription.setDisposable(other.subscribe(o)); + /** + * Advances the scheduler's clock to the specified time, running all work till that point. + * @param {Number} time Absolute time to advance the scheduler's clock to. + */ + VirtualTimeSchedulerPrototype.advanceTo = function (time) { + var dueToClock = this.comparer(this.clock, time); + if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null && this.comparer(next.dueTime, time) <= 0) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; } - })); + } while (this.isEnabled); + this.clock = time; } + }; - createTimer(); - - original.setDisposable(source.subscribe(function (x) { - if (!switched) { - id++; - o.onNext(x); - createTimer(); - } - }, function (e) { - if (!switched) { - id++; - o.onError(e); - } - }, function () { - if (!switched) { - id++; - o.onCompleted(); - } - })); - return new CompositeDisposable(subscription, timer); - }, source); - } + /** + * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.advanceBy = function (time) { + var dt = this.add(this.clock, time), + dueToClock = this.comparer(this.clock, dt); + if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } - observableProto.timeout = function () { - var firstArg = arguments[0]; - if (firstArg instanceof Date || typeof firstArg === 'number') { - return timeout(this, firstArg, arguments[1], arguments[2]); - } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { - return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); - } else { - throw new Error('Invalid arguments'); - } - }; - - /** - * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. - * @param {Number} windowDuration time to wait before emitting another item after emitting the last item - * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout. - * @returns {Observable} An Observable that performs the throttle operation. - */ - observableProto.throttle = function (windowDuration, scheduler) { - isScheduler(scheduler) || (scheduler = timeoutScheduler); - var duration = +windowDuration || 0; - if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } - var source = this; - return new AnonymousObservable(function (o) { - var lastOnNext = 0; - return source.subscribe( - function (x) { - var now = scheduler.now(); - if (lastOnNext === 0 || now - lastOnNext >= duration) { - lastOnNext = now; - o.onNext(x); - } - },function (e) { o.onError(e); }, function () { o.onCompleted(); } - ); - }, source); - }; - - var PausableObservable = (function (__super__) { + this.advanceTo(dt); + }; - inherits(PausableObservable, __super__); + /** + * Advances the scheduler's clock by the specified relative time. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.sleep = function (time) { + var dt = this.add(this.clock, time); + if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); } - function subscribe(observer) { - var conn = this.source.publish(), - subscription = conn.subscribe(observer), - connection = disposableEmpty; + this.clock = dt; + }; - var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) { - if (b) { - connection = conn.connect(); + /** + * Gets the next scheduled item to be executed. + * @returns {ScheduledItem} The next scheduled item. + */ + VirtualTimeSchedulerPrototype.getNext = function () { + while (this.queue.length > 0) { + var next = this.queue.peek(); + if (next.isCancelled()) { + this.queue.dequeue(); } else { - connection.dispose(); - connection = disposableEmpty; + return next; } - }); - - return new CompositeDisposable(subscription, connection, pausable); - } + } + return null; + }; - function PausableObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); + /** + * Schedules an action to be executed at dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Absolute time at which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) { + var self = this; - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; + function run(scheduler, state1) { + self.queue.remove(si); + return action(scheduler, state1); } - __super__.call(this, subscribe, source); - } + var si = new ScheduledItem(this, state, run, dueTime, this.comparer); + this.queue.enqueue(si); - PausableObservable.prototype.pause = function () { - this.controller.onNext(false); + return si.disposable; }; - PausableObservable.prototype.resume = function () { - this.controller.onNext(true); - }; + return VirtualTimeScheduler; + }(Scheduler)); - return PausableObservable; + /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */ + Rx.HistoricalScheduler = (function (__super__) { + inherits(HistoricalScheduler, __super__); - }(Observable)); + /** + * Creates a new historical scheduler with the specified initial clock value. + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function HistoricalScheduler(initialClock, comparer) { + var clock = initialClock == null ? 0 : initialClock; + var cmp = comparer || defaultSubComparer; + __super__.call(this, clock, cmp); + } - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausable(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. - */ - observableProto.pausable = function (pauser) { - return new PausableObservable(this, pauser); - }; - - function combineLatestSource(source, subject, resultSelector) { - return new AnonymousObservable(function (o) { - var hasValue = [false, false], - hasValueAll = false, - isDone = false, - values = new Array(2), - err; + var HistoricalSchedulerProto = HistoricalScheduler.prototype; - function next(x, i) { - values[i] = x; - hasValue[i] = true; - if (hasValueAll || (hasValueAll = hasValue.every(identity))) { - if (err) { return o.onError(err); } - var res = tryCatch(resultSelector).apply(null, values); - if (res === errorObj) { return o.onError(res.e); } - o.onNext(res); - } - isDone && values[1] && o.onCompleted(); - } + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + HistoricalSchedulerProto.add = function (absolute, relative) { + return absolute + relative; + }; - return new CompositeDisposable( - source.subscribe( - function (x) { - next(x, 0); - }, - function (e) { - if (values[1]) { - o.onError(e); - } else { - err = e; - } - }, - function () { - isDone = true; - values[1] && o.onCompleted(); - }), - subject.subscribe( - function (x) { - next(x, 1); - }, - function (e) { o.onError(e); }, - function () { - isDone = true; - next(true, 1); - }) - ); - }, source); - } + HistoricalSchedulerProto.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; - var PausableBufferedObservable = (function (__super__) { + /** + * Converts the TimeSpan value to a relative virtual time value. + * @memberOf HistoricalScheduler + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + HistoricalSchedulerProto.toRelativeTime = function (timeSpan) { + return timeSpan; + }; - inherits(PausableBufferedObservable, __super__); + return HistoricalScheduler; + }(Rx.VirtualTimeScheduler)); - function subscribe(o) { - var q = [], previousShouldFire; +function OnNextPredicate(predicate) { + this.predicate = predicate; +} - function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } } +OnNextPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'N') { return false; } + return this.predicate(other.value); +}; - var subscription = - combineLatestSource( - this.source, - this.pauser.startWith(false).distinctUntilChanged(), - function (data, shouldFire) { - return { data: data, shouldFire: shouldFire }; - }) - .subscribe( - function (results) { - if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) { - previousShouldFire = results.shouldFire; - // change in shouldFire - if (results.shouldFire) { drainQueue(); } - } else { - previousShouldFire = results.shouldFire; - // new data - if (results.shouldFire) { - o.onNext(results.data); - } else { - q.push(results.data); - } - } - }, - function (err) { - drainQueue(); - o.onError(err); - }, - function () { - drainQueue(); - o.onCompleted(); - } - ); - return subscription; - } +function OnErrorPredicate(predicate) { + this.predicate = predicate; +} - function PausableBufferedObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); +OnErrorPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'E') { return false; } + return this.predicate(other.error); +}; - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; - } +var ReactiveTest = Rx.ReactiveTest = { + /** Default virtual time used for creation of observable sequences in unit tests. */ + created: 100, + /** Default virtual time used to subscribe to observable sequences in unit tests. */ + subscribed: 200, + /** Default virtual time used to dispose subscriptions in unit tests. */ + disposed: 1000, - __super__.call(this, subscribe, source); - } + /** + * Factory method for an OnNext notification record at a given time with a given value or a predicate function. + * + * 1 - ReactiveTest.onNext(200, 42); + * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); + * + * @param ticks Recorded virtual time the OnNext notification occurs. + * @param value Recorded value stored in the OnNext notification or a predicate. + * @return Recorded OnNext notification. + */ + onNext: function (ticks, value) { + return typeof value === 'function' ? + new Recorded(ticks, new OnNextPredicate(value)) : + new Recorded(ticks, Notification.createOnNext(value)); + }, + /** + * Factory method for an OnError notification record at a given time with a given error. + * + * 1 - ReactiveTest.onNext(200, new Error('error')); + * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); + * + * @param ticks Recorded virtual time the OnError notification occurs. + * @param exception Recorded exception stored in the OnError notification. + * @return Recorded OnError notification. + */ + onError: function (ticks, error) { + return typeof error === 'function' ? + new Recorded(ticks, new OnErrorPredicate(error)) : + new Recorded(ticks, Notification.createOnError(error)); + }, + /** + * Factory method for an OnCompleted notification record at a given time. + * + * @param ticks Recorded virtual time the OnCompleted notification occurs. + * @return Recorded OnCompleted notification. + */ + onCompleted: function (ticks) { + return new Recorded(ticks, Notification.createOnCompleted()); + }, + /** + * Factory method for a subscription record based on a given subscription and disposal time. + * + * @param start Virtual time indicating when the subscription was created. + * @param end Virtual time indicating when the subscription was disposed. + * @return Subscription object. + */ + subscribe: function (start, end) { + return new Subscription(start, end); + } +}; + + /** + * Creates a new object recording the production of the specified value at the given virtual time. + * + * @constructor + * @param {Number} time Virtual time the value was produced on. + * @param {Mixed} value Value that was produced. + * @param {Function} comparer An optional comparer. + */ + var Recorded = Rx.Recorded = function (time, value, comparer) { + this.time = time; + this.value = value; + this.comparer = comparer || defaultComparer; + }; - PausableBufferedObservable.prototype.pause = function () { - this.controller.onNext(false); - }; + /** + * Checks whether the given recorded object is equal to the current instance. + * + * @param {Recorded} other Recorded object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Recorded.prototype.equals = function (other) { + return this.time === other.time && this.comparer(this.value, other.value); + }; - PausableBufferedObservable.prototype.resume = function () { - this.controller.onNext(true); - }; + /** + * Returns a string representation of the current Recorded value. + * + * @returns {String} String representation of the current Recorded value. + */ + Recorded.prototype.toString = function () { + return this.value.toString() + '@' + this.time; + }; - return PausableBufferedObservable; + /** + * Creates a new subscription object with the given virtual subscription and unsubscription time. + * + * @constructor + * @param {Number} subscribe Virtual time at which the subscription occurred. + * @param {Number} unsubscribe Virtual time at which the unsubscription occurred. + */ + var Subscription = Rx.Subscription = function (start, end) { + this.subscribe = start; + this.unsubscribe = end || Number.MAX_VALUE; + }; - }(Observable)); + /** + * Checks whether the given subscription is equal to the current instance. + * @param other Subscription object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Subscription.prototype.equals = function (other) { + return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; + }; /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, - * and yields the values that were buffered while paused. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausableBuffered(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. + * Returns a string representation of the current Subscription value. + * @returns {String} String representation of the current Subscription value. */ - observableProto.pausableBuffered = function (subject) { - return new PausableBufferedObservable(this, subject); + Subscription.prototype.toString = function () { + return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')'; }; - -var ControlledObservable = (function (__super__) { - inherits(ControlledObservable, __super__); + var MockDisposable = Rx.MockDisposable = function (scheduler) { + this.scheduler = scheduler; + this.disposes = []; + this.disposes.push(this.scheduler.clock); + }; - function subscribe (observer) { - return this.source.subscribe(observer); - } + MockDisposable.prototype.dispose = function () { + this.disposes.push(this.scheduler.clock); + }; - function ControlledObservable (source, enableQueue, scheduler) { - __super__.call(this, subscribe, source); - this.subject = new ControlledSubject(enableQueue, scheduler); - this.source = source.multicast(this.subject).refCount(); - } + var MockObserver = (function (__super__) { + inherits(MockObserver, __super__); - ControlledObservable.prototype.request = function (numberOfItems) { - return this.subject.request(numberOfItems == null ? -1 : numberOfItems); - }; + function MockObserver(scheduler) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = []; + } - return ControlledObservable; + var MockObserverPrototype = MockObserver.prototype; -}(Observable)); + MockObserverPrototype.onNext = function (value) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value))); + }; -var ControlledSubject = (function (__super__) { + MockObserverPrototype.onError = function (e) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e))); + }; - function subscribe (observer) { - return this.subject.subscribe(observer); - } + MockObserverPrototype.onCompleted = function () { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted())); + }; - inherits(ControlledSubject, __super__); - - function ControlledSubject(enableQueue, scheduler) { - enableQueue == null && (enableQueue = true); - - __super__.call(this, subscribe); - this.subject = new Subject(); - this.enableQueue = enableQueue; - this.queue = enableQueue ? [] : null; - this.requestedCount = 0; - this.requestedDisposable = null; - this.error = null; - this.hasFailed = false; - this.hasCompleted = false; - this.scheduler = scheduler || currentThreadScheduler; - } + return MockObserver; + })(Observer); - addProperties(ControlledSubject.prototype, Observer, { - onCompleted: function () { - this.hasCompleted = true; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onCompleted(); - this.disposeCurrentRequest() - } else { - this.queue.push(Notification.createOnCompleted()); - } - }, - onError: function (error) { - this.hasFailed = true; - this.error = error; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onError(error); - this.disposeCurrentRequest() - } else { - this.queue.push(Notification.createOnError(error)); - } - }, - onNext: function (value) { - if (this.requestedCount <= 0) { - this.enableQueue && this.queue.push(Notification.createOnNext(value)); - } else { - (this.requestedCount-- === 0) && this.disposeCurrentRequest(); - this.subject.onNext(value); - } - }, - _processRequest: function (numberOfItems) { - if (this.enableQueue) { - while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) { - var first = this.queue.shift(); - first.accept(this.subject); - if (first.kind === 'N') { - numberOfItems--; - } else { - this.disposeCurrentRequest(); - this.queue = []; + function MockPromise(scheduler, messages) { + var self = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + var message = this.messages[i], + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = self.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); } + return disposableEmpty; + }); + })(notification); + } + } + + MockPromise.prototype.then = function (onResolved, onRejected) { + var self = this; + + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + + var newPromise; + + var observer = Rx.Observer.create( + function (x) { + var retValue = onResolved(x); + if (retValue && typeof retValue.then === 'function') { + newPromise = retValue; + } else { + var ticks = self.scheduler.clock; + newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]); } + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + }, + function (err) { + onRejected(err); + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); } + ); + this.observers.push(observer); - return numberOfItems; - }, - request: function (number) { - this.disposeCurrentRequest(); - var self = this; + return newPromise || new MockPromise(this.scheduler, this.messages); + }; - this.requestedDisposable = this.scheduler.scheduleWithState(number, - function(s, i) { - var remaining = self._processRequest(i); - var stopped = self.hasCompleted || self.hasFailed - if (!stopped && remaining > 0) { - self.requestedCount = remaining; + var HotObservable = (function (__super__) { + inherits(HotObservable, __super__); - return disposableCreate(function () { - self.requestedCount = 0; + function HotObservable(scheduler, messages) { + __super__.call(this); + var message, notification, observable = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = observable.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; }); - // Scheduled item is still in progress. Return a new - // disposable to allow the request to be interrupted - // via dispose. - } - }); - - return this.requestedDisposable; - }, - disposeCurrentRequest: function () { - if (this.requestedDisposable) { - this.requestedDisposable.dispose(); - this.requestedDisposable = null; + })(notification); } } - }); - return ControlledSubject; -}(Observable)); + HotObservable.prototype._subscribe = function (o) { + var observable = this; + this.observers.push(o); + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + return disposableCreate(function () { + var idx = observable.observers.indexOf(o); + observable.observers.splice(idx, 1); + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + }); + }; -/** - * Attaches a controller to the observable sequence with the ability to queue. - * @example - * var source = Rx.Observable.interval(100).controlled(); - * source.request(3); // Reads 3 values - * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request - * @param {Scheduler} scheduler determines how the requests will be scheduled - * @returns {Observable} The observable sequence which only propagates values on request. - */ -observableProto.controlled = function (enableQueue, scheduler) { + return HotObservable; + })(Observable); - if (enableQueue && isScheduler(enableQueue)) { - scheduler = enableQueue; - enableQueue = true; - } + var ColdObservable = (function (__super__) { + inherits(ColdObservable, __super__); - if (enableQueue == null) { enableQueue = true; } - return new ControlledObservable(this, enableQueue, scheduler); -}; - - /** - * Pipes the existing Observable sequence into a Node.js Stream. - * @param {Stream} dest The destination Node.js stream. - * @returns {Stream} The destination stream. - */ - observableProto.pipe = function (dest) { - var source = this.pausableBuffered(); + function ColdObservable(scheduler, messages) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + } + + ColdObservable.prototype._subscribe = function (o) { + var message, notification, observable = this; + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + var d = new CompositeDisposable(); + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + d.add(observable.scheduler.scheduleRelative(null, message.time, function () { + innerNotification.accept(o); + return disposableEmpty; + })); + })(notification); + } + return disposableCreate(function () { + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + d.dispose(); + }); + }; - function onDrain() { - source.resume(); + return ColdObservable; + })(Observable); + + /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ + Rx.TestScheduler = (function (__super__) { + inherits(TestScheduler, __super__); + + function baseComparer(x, y) { + return x > y ? 1 : (x < y ? -1 : 0); } - dest.addListener('drain', onDrain); + function TestScheduler() { + __super__.call(this, 0, baseComparer); + } - source.subscribe( - function (x) { - !dest.write(String(x)) && source.pause(); - }, - function (err) { - dest.emit('error', err); - }, - function () { - // Hack check because STDIO is not closable - !dest._isStdio && dest.end(); - dest.removeListener('drain', onDrain); + /** + * Schedules an action to be executed at the specified virtual time. + * + * @param state State passed to the action to be executed. + * @param dueTime Absolute virtual time at which to execute the action. + * @param action Action to be executed. + * @return Disposable object used to cancel the scheduled action (best effort). + */ + TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) { + dueTime <= this.clock && (dueTime = this.clock + 1); + return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action); + }; + /** + * Adds a relative virtual time to an absolute virtual time value. + * + * @param absolute Absolute virtual time value. + * @param relative Relative virtual time value to add. + * @return Resulting absolute virtual time sum value. + */ + TestScheduler.prototype.add = function (absolute, relative) { + return absolute + relative; + }; + /** + * Converts the absolute virtual time value to a DateTimeOffset value. + * + * @param absolute Absolute virtual time value to convert. + * @return Corresponding DateTimeOffset value. + */ + TestScheduler.prototype.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + /** + * Converts the TimeSpan value to a relative virtual time value. + * + * @param timeSpan TimeSpan value to convert. + * @return Corresponding relative virtual time value. + */ + TestScheduler.prototype.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + /** + * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. + * + * @param create Factory method to create an observable sequence. + * @param created Virtual time at which to invoke the factory to create an observable sequence. + * @param subscribed Virtual time at which to subscribe to the created observable sequence. + * @param disposed Virtual time at which to dispose the subscription. + * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. + */ + TestScheduler.prototype.startScheduler = function (createFn, settings) { + settings || (settings = {}); + settings.created == null && (settings.created = ReactiveTest.created); + settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed); + settings.disposed == null && (settings.disposed = ReactiveTest.disposed); + + var observer = this.createObserver(), source, subscription; + + this.scheduleAbsolute(null, settings.created, function () { + source = createFn(); + return disposableEmpty; }); - source.resume(); + this.scheduleAbsolute(null, settings.subscribed, function () { + subscription = source.subscribe(observer); + return disposableEmpty; + }); - return dest; - }; - - /** - * Executes a transducer to transform the observable sequence - * @param {Transducer} transducer A transducer to execute - * @returns {Observable} An Observable sequence containing the results from the transducer. - */ - observableProto.transduce = function(transducer) { - var source = this; + this.scheduleAbsolute(null, settings.disposed, function () { + subscription.dispose(); + return disposableEmpty; + }); - function transformForObserver(o) { - return { - '@@transducer/init': function() { - return o; - }, - '@@transducer/step': function(obs, input) { - return obs.onNext(input); - }, - '@@transducer/result': function(obs) { - return obs.onCompleted(); - } - }; - } + this.start(); + + return observer; + }; + + /** + * Creates a hot observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified absolute virtual times. + * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createHotObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new HotObservable(this, args); + }; + + /** + * Creates a cold observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. + * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createColdObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new ColdObservable(this, args); + }; + + /** + * Creates a resolved promise with the given value and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} value The value to yield at the given tick. + * @returns {MockPromise} A mock Promise which fulfills with the given value. + */ + TestScheduler.prototype.createResolvedPromise = function (ticks, value) { + return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]); + }; + + /** + * Creates a rejected promise with the given reason and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} reason The reason for rejection to yield at the given tick. + * @returns {MockPromise} A mock Promise which rejects with the given reason. + */ + TestScheduler.prototype.createRejectedPromise = function (ticks, reason) { + return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]); + }; + + /** + * Creates an observer that records received notification messages and timestamps those. + * @return Observer that can be used to assert the timing of received notifications. + */ + TestScheduler.prototype.createObserver = function () { + return new MockObserver(this); + }; + + return TestScheduler; + })(VirtualTimeScheduler); - return new AnonymousObservable(function(o) { - var xform = transducer(transformForObserver(o)); - return source.subscribe( - function(v) { - var res = tryCatch(xform['@@transducer/step']).call(xform, o, v); - if (res === errorObj) { o.onError(res.e); } - }, - function (e) { o.onError(e); }, - function() { xform['@@transducer/result'](o); } - ); - }, source); - }; - var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) { inherits(AnonymousObservable, __super__); @@ -5869,34 +11750,31 @@ observableProto.controlled = function (enableQueue, scheduler) { function setDisposable(s, state) { var ado = state[0], self = state[1]; var sub = tryCatch(self.__subscribe).call(self, ado); - - if (sub === errorObj) { - if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); } - } + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } ado.setDisposable(fixSubscriber(sub)); } - function innerSubscribe(observer) { - var ado = new AutoDetachObserver(observer), state = [ado, this]; + function AnonymousObservable(subscribe, parent) { + this.source = parent; + this.__subscribe = subscribe; + __super__.call(this); + } + + AnonymousObservable.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; if (currentThreadScheduler.scheduleRequired()) { - currentThreadScheduler.scheduleWithState(state, setDisposable); + currentThreadScheduler.schedule(state, setDisposable); } else { setDisposable(null, state); } return ado; - } - - function AnonymousObservable(subscribe, parent) { - this.source = parent; - this.__subscribe = subscribe; - __super__.call(this, innerSubscribe); - } + }; return AnonymousObservable; }(Observable)); - + var AutoDetachObserver = (function (__super__) { inherits(AutoDetachObserver, __super__); @@ -5938,53 +11816,67 @@ observableProto.controlled = function (enableQueue, scheduler) { return AutoDetachObserver; }(AbstractObserver)); - - var InnerSubscription = function (subject, observer) { - this.subject = subject; - this.observer = observer; - }; - InnerSubscription.prototype.dispose = function () { - if (!this.subject.isDisposed && this.observer !== null) { - var idx = this.subject.observers.indexOf(this.observer); - this.subject.observers.splice(idx, 1); - this.observer = null; + var UnderlyingObservable = (function (__super__) { + inherits(UnderlyingObservable, __super__); + function UnderlyingObservable(m, u) { + this._m = m; + this._u = u; + __super__.call(this); } - }; - + + UnderlyingObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o)); + }; + + return UnderlyingObservable; + }(ObservableBase)); + + var GroupedObservable = (function (__super__) { + inherits(GroupedObservable, __super__); + function GroupedObservable(key, underlyingObservable, mergedDisposable) { + __super__.call(this); + this.key = key; + this.underlyingObservable = !mergedDisposable ? + underlyingObservable : + new UnderlyingObservable(mergedDisposable, underlyingObservable); + } + + GroupedObservable.prototype._subscribe = function (o) { + return this.underlyingObservable.subscribe(o); + }; + + return GroupedObservable; + }(Observable)); + /** * Represents an object that is both an observable sequence as well as an observer. * Each notification is broadcasted to all subscribed observers. */ var Subject = Rx.Subject = (function (__super__) { - function subscribe(observer) { - checkDisposed(this); - if (!this.isStopped) { - this.observers.push(observer); - return new InnerSubscription(this, observer); - } - if (this.hasError) { - observer.onError(this.error); - return disposableEmpty; - } - observer.onCompleted(); - return disposableEmpty; - } - inherits(Subject, __super__); - - /** - * Creates a subject. - */ function Subject() { - __super__.call(this, subscribe); - this.isDisposed = false, - this.isStopped = false, + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; this.observers = []; this.hasError = false; } addProperties(Subject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + if (this.hasError) { + o.onError(this.error); + return disposableEmpty; + } + o.onCompleted(); + return disposableEmpty; + }, /** * Indicates whether the subject has observers subscribed to it. * @returns {Boolean} Indicates whether the subject has observers subscribed to it. @@ -6054,33 +11946,12 @@ observableProto.controlled = function (enableQueue, scheduler) { return Subject; }(Observable)); - + /** * Represents the result of an asynchronous operation. * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers. */ var AsyncSubject = Rx.AsyncSubject = (function (__super__) { - - function subscribe(observer) { - checkDisposed(this); - - if (!this.isStopped) { - this.observers.push(observer); - return new InnerSubscription(this, observer); - } - - if (this.hasError) { - observer.onError(this.error); - } else if (this.hasValue) { - observer.onNext(this.value); - observer.onCompleted(); - } else { - observer.onCompleted(); - } - - return disposableEmpty; - } - inherits(AsyncSubject, __super__); /** @@ -6088,8 +11959,7 @@ observableProto.controlled = function (enableQueue, scheduler) { * @constructor */ function AsyncSubject() { - __super__.call(this, subscribe); - + __super__.call(this); this.isDisposed = false; this.isStopped = false; this.hasValue = false; @@ -6098,6 +11968,25 @@ observableProto.controlled = function (enableQueue, scheduler) { } addProperties(AsyncSubject.prototype, Observer, { + _subscribe: function (o) { + checkDisposed(this); + + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + + if (this.hasError) { + o.onError(this.error); + } else if (this.hasValue) { + o.onNext(this.value); + o.onCompleted(); + } else { + o.onCompleted(); + } + + return disposableEmpty; + }, /** * Indicates whether the subject has observers subscribed to it. * @returns {Boolean} Indicates whether the subject has observers subscribed to it. @@ -6165,28 +12054,26 @@ observableProto.controlled = function (enableQueue, scheduler) { dispose: function () { this.isDisposed = true; this.observers = null; - this.exception = null; + this.error = null; this.value = null; } }); return AsyncSubject; }(Observable)); - + var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) { inherits(AnonymousSubject, __super__); - - function subscribe(observer) { - return this.observable.subscribe(observer); - } - function AnonymousSubject(observer, observable) { this.observer = observer; this.observable = observable; - __super__.call(this, subscribe); + __super__.call(this); } addProperties(AnonymousSubject.prototype, Observer.prototype, { + _subscribe: function (o) { + return this.observable.subscribe(o); + }, onCompleted: function () { this.observer.onCompleted(); }, @@ -6200,261 +12087,12 @@ observableProto.controlled = function (enableQueue, scheduler) { return AnonymousSubject; }(Observable)); - - /** - * Represents a value that changes over time. - * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications. - */ - var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) { - function subscribe(observer) { - checkDisposed(this); - if (!this.isStopped) { - this.observers.push(observer); - observer.onNext(this.value); - return new InnerSubscription(this, observer); - } - if (this.hasError) { - observer.onError(this.error); - } else { - observer.onCompleted(); - } - return disposableEmpty; - } - - inherits(BehaviorSubject, __super__); - - /** - * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value. - * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet. - */ - function BehaviorSubject(value) { - __super__.call(this, subscribe); - this.value = value, - this.observers = [], - this.isDisposed = false, - this.isStopped = false, - this.hasError = false; - } - - addProperties(BehaviorSubject.prototype, Observer, { - /** - * Gets the current value or throws an exception. - * Value is frozen after onCompleted is called. - * After onError is called always throws the specified exception. - * An exception is always thrown after dispose is called. - * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext. - */ - getValue: function () { - checkDisposed(this); - if (this.hasError) { - throw this.error; - } - return this.value; - }, - /** - * Indicates whether the subject has observers subscribed to it. - * @returns {Boolean} Indicates whether the subject has observers subscribed to it. - */ - hasObservers: function () { return this.observers.length > 0; }, - /** - * Notifies all subscribed observers about the end of the sequence. - */ - onCompleted: function () { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onCompleted(); - } - - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.hasError = true; - this.error = error; - - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onError(error); - } - - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. - */ - onNext: function (value) { - checkDisposed(this); - if (this.isStopped) { return; } - this.value = value; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onNext(value); - } - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - this.value = null; - this.exception = null; - } - }); - - return BehaviorSubject; - }(Observable)); - - /** - * Represents an object that is both an observable sequence as well as an observer. - * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. - */ - var ReplaySubject = Rx.ReplaySubject = (function (__super__) { - - var maxSafeInteger = Math.pow(2, 53) - 1; - - function createRemovableDisposable(subject, observer) { - return disposableCreate(function () { - observer.dispose(); - !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); - }); - } - - function subscribe(observer) { - var so = new ScheduledObserver(this.scheduler, observer), - subscription = createRemovableDisposable(this, so); - checkDisposed(this); - this._trim(this.scheduler.now()); - this.observers.push(so); - - for (var i = 0, len = this.q.length; i < len; i++) { - so.onNext(this.q[i].value); - } - - if (this.hasError) { - so.onError(this.error); - } else if (this.isStopped) { - so.onCompleted(); - } - - so.ensureActive(); - return subscription; - } - - inherits(ReplaySubject, __super__); - - /** - * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. - * @param {Number} [bufferSize] Maximum element count of the replay buffer. - * @param {Number} [windowSize] Maximum time length of the replay buffer. - * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. - */ - function ReplaySubject(bufferSize, windowSize, scheduler) { - this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; - this.windowSize = windowSize == null ? maxSafeInteger : windowSize; - this.scheduler = scheduler || currentThreadScheduler; - this.q = []; - this.observers = []; - this.isStopped = false; - this.isDisposed = false; - this.hasError = false; - this.error = null; - __super__.call(this, subscribe); - } - - addProperties(ReplaySubject.prototype, Observer.prototype, { - /** - * Indicates whether the subject has observers subscribed to it. - * @returns {Boolean} Indicates whether the subject has observers subscribed to it. - */ - hasObservers: function () { - return this.observers.length > 0; - }, - _trim: function (now) { - while (this.q.length > this.bufferSize) { - this.q.shift(); - } - while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { - this.q.shift(); - } - }, - /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. - */ - onNext: function (value) { - checkDisposed(this); - if (this.isStopped) { return; } - var now = this.scheduler.now(); - this.q.push({ interval: now, value: value }); - this._trim(now); - - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onNext(value); - observer.ensureActive(); - } - }, - /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.error = error; - this.hasError = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onError(error); - observer.ensureActive(); - } - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the end of the sequence. - */ - onCompleted: function () { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onCompleted(); - observer.ensureActive(); - } - this.observers.length = 0; - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - } - }); - return ReplaySubject; - }(Observable)); - /** * Used to pause and resume streams. */ Rx.Pauser = (function (__super__) { inherits(Pauser, __super__); - function Pauser() { __super__.call(this); } @@ -6471,7 +12109,7 @@ observableProto.controlled = function (enableQueue, scheduler) { return Pauser; }(Subject)); - + if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { root.Rx = Rx; @@ -6489,18 +12127,21 @@ observableProto.controlled = function (enableQueue, scheduler) { // in a browser or Rhino root.Rx = Rx; } - + // All code before this point will be filtered from stack traces. var rEndingLine = captureLine(); - + }.call(this)); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":2}],4:[function(require,module,exports){ -"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var n=0;n=200&&i.status<300){var t=JSON.parse(i.responseText);try{e.push(t),a&&a.call(s,e.find(t.data.type,t.data.id))}catch(n){o&&o.call(s,n)}}else o&&o.call(s)},i.send(JSON.stringify({data:e.convert(t,n)}))}()}}},{key:"destroy",value:function(e,t,n,a,o,s){var l=this;if(o&&"[object Function]"!=={}.toString.call(o))this.destroy(e,t,n,a,null,o);else{if(!e._types[t])throw new Error("Unknown type '"+t+"'");!function(){var i=new XMLHttpRequest;i.open("DELETE",l._base+"/"+t+"/"+n,!0),i.setRequestHeader("Content-Type","application/vnd.api+json"),i.onload=function(){if(i.status>=200&&i.status<300)try{e.remove(t,n),a&&a.call(s)}catch(l){o.call(s,l)}else o&&o.call(s)},i.send()}()}}},{key:"load",value:function(e,t,n,a,o,s,l){var i=this;if(n&&"[object Function]"==={}.toString.call(n))this.load(e,t,null,null,n,a,o);else if(n&&"object"==typeof n)this.load(e,t,null,n,a,o,s);else if(a&&"[object Function]"==={}.toString.call(a))this.load(e,t,n,{},a,o,s);else if(s&&"[object Function]"!=={}.toString.call(s))this.load(e,t,n,a,o,null,s);else{if(!e._types[t])throw new Error("Unknown type '"+t+"'");!function(){var r=new XMLHttpRequest,c=void 0;if(a=a||{},c=n?i._base+"/"+t+"/"+n:i._base+"/"+t,a){var u=[];a.fields&&(Object.keys(a.fields).forEach(function(e){a["fields["+e+"]"]=a.fields[e]}),delete a.fields),u=Object.keys(a).map(function(e){return e+"="+encodeURIComponent(a[e])}).sort(),u.length&&(c=c+"?"+u.join("&"))}r.open("GET",c,!0),r.setRequestHeader("Content-Type","application/vnd.api+json"),r.onload=function(){if(r.status>=200&&r.status<300)try{e.push(JSON.parse(r.responseText)),o&&o.call(l,n?e.find(t,n):e.find(t))}catch(a){s.call({},a)}else s&&s.call(l)},r.send()}()}}},{key:"update",value:function(e,t,n,a,o,s,l){var i=this;if(s&&"[object Function]"!=={}.toString.call(s))this.update(e,t,n,a,o,null,s);else{if(!e._types[t])throw new Error("Unknown type '"+t+"'");!function(){var r=new XMLHttpRequest,c=e.convert(t,n,a);r.open("PATCH",i._base+"/"+t+"/"+n,!0),r.setRequestHeader("Content-Type","application/vnd.api+json"),r.onload=function(){if(r.status>=200&&r.status<300)try{e.add(c),o&&o.call(l,e.find(c.type,c.id))}catch(t){s&&s.call(l,t)}else s&&s.call(l)},r.send(JSON.stringify({data:c}))}()}}}]),e}();exports["default"]=AjaxAdapter,module.exports=exports["default"]; +"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,n){for(var t=0;tt;t++)try{if(e=r[t],new root.ActiveXObject(e))break}catch(o){}return new root.ActiveXObject(e)}catch(o){throw new Error("XMLHttpRequest is not supported by your browser")}}function getCORSRequest(){var e=new root.XMLHttpRequest;if("withCredentials"in e)return e;if(root.XDomainRequest)return new XDomainRequest;throw new Error("CORS is not supported by your browser")}function normalizeAjaxSuccessEvent(e,r,t){var o="response"in r?r.response:r.responseText;if("auto"===t.responseType)try{o=JSON.parse(o)}catch(e){}else o="json"===t.responseType?JSON.parse(o):o;return{response:o,status:r.status,responseType:r.responseType,xhr:r,originalEvent:e}}function normalizeAjaxErrorEvent(e,r,t){return{type:t,status:r.status,xhr:r,originalEvent:e}}Object.defineProperty(exports,"__esModule",{value:!0});var _rx=require("rx"),_rx2=_interopRequireDefault(_rx),root="undefined"!=typeof window&&window||void 0;exports["default"]=function(e){var r={method:"GET",crossDomain:!1,async:!0,headers:{},responseType:"text",createXHR:function(){return this.crossDomain?getCORSRequest():getXMLHttpRequest()},normalizeError:normalizeAjaxErrorEvent,normalizeSuccess:normalizeAjaxSuccessEvent};if("string"==typeof e)r.url=e;else for(var t in e)hasOwnProperty.call(e,t)&&(r[t]=e[t]);var o=r.normalizeError,s=r.normalizeSuccess;return r.crossDomain||r.headers["X-Requested-With"]||(r.headers["X-Requested-With"]="XMLHttpRequest"),r.hasContent=void 0!==r.body,new _rx2["default"].AnonymousObservable(function(e){var t,n=!1,a=function(t,a){var u=1223===t.status?204:t.status;u>=200&&300>=u||0===u||""===u?(e.onNext(s(a,t,r)),e.onCompleted()):e.onError(o(a,t,"error")),n=!0};try{t=r.createXHR()}catch(u){e.onError(u)}try{r.user?t.open(r.method,r.url,r.async,r.user,r.password):t.open(r.method,r.url,r.async);var i=r.headers;for(var p in i)hasOwnProperty.call(i,p)&&t.setRequestHeader(p,i[p]);t.upload||!("withCredentials"in t)&&root.XDomainRequest?(t.onload=function(e){r.progressObserver&&(r.progressObserver.onNext(e),r.progressObserver.onCompleted()),a(t,e)},r.progressObserver&&(t.onprogress=function(e){r.progressObserver.onNext(e)}),t.onerror=function(s){r.progressObserver&&r.progressObserver.onError(s),e.onError(o(s,t,"error")),n=!0},t.onabort=function(s){r.progressObserver&&r.progressObserver.onError(s),e.onError(o(s,t,"abort")),n=!0}):t.onreadystatechange=function(e){4===t.readyState&&a(t,e)},t.send(r.hasContent&&r.body||null)}catch(c){e.onError(c)}return function(){n||4===t.readyState||t.abort()}})},module.exports=exports["default"]; -},{}],5:[function(require,module,exports){ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r=", + "left": { + "type": "Identifier", + "name": "status", + "range": [ + 4080, + 4086 + ], + "loc": { + "start": { + "line": 148, + "column": 11 + }, + "end": { + "line": 148, + "column": 17 + } + } + }, + "right": { + "type": "Literal", + "value": 200, + "raw": "200", + "range": [ + 4090, + 4093 + ], + "loc": { + "start": { + "line": 148, + "column": 21 + }, + "end": { + "line": 148, + "column": 24 + } + } + }, + "range": [ + 4080, + 4093 + ], + "loc": { + "start": { + "line": 148, + "column": 11 + }, + "end": { + "line": 148, + "column": 24 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "<=", + "left": { + "type": "Identifier", + "name": "status", + "range": [ + 4097, + 4103 + ], + "loc": { + "start": { + "line": 148, + "column": 28 + }, + "end": { + "line": 148, + "column": 34 + } + } + }, + "right": { + "type": "Literal", + "value": 300, + "raw": "300", + "range": [ + 4107, + 4110 + ], + "loc": { + "start": { + "line": 148, + "column": 38 + }, + "end": { + "line": 148, + "column": 41 + } + } + }, + "range": [ + 4097, + 4110 + ], + "loc": { + "start": { + "line": 148, + "column": 28 + }, + "end": { + "line": 148, + "column": 41 + } + } + }, + "range": [ + 4080, + 4110 + ], + "loc": { + "start": { + "line": 148, + "column": 11 + }, + "end": { + "line": 148, + "column": 41 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "status", + "range": [ + 4115, + 4121 + ], + "loc": { + "start": { + "line": 148, + "column": 46 + }, + "end": { + "line": 148, + "column": 52 + } + } + }, + "right": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 4126, + 4127 + ], + "loc": { + "start": { + "line": 148, + "column": 57 + }, + "end": { + "line": 148, + "column": 58 + } + } + }, + "range": [ + 4115, + 4127 + ], + "loc": { + "start": { + "line": 148, + "column": 46 + }, + "end": { + "line": 148, + "column": 58 + } + } + }, + "range": [ + 4079, + 4127 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 58 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "status", + "range": [ + 4131, + 4137 + ], + "loc": { + "start": { + "line": 148, + "column": 62 + }, + "end": { + "line": 148, + "column": 68 + } + } + }, + "right": { + "type": "Literal", + "value": "", + "raw": "''", + "range": [ + 4142, + 4144 + ], + "loc": { + "start": { + "line": 148, + "column": 73 + }, + "end": { + "line": 148, + "column": 75 + } + } + }, + "range": [ + 4131, + 4144 + ], + "loc": { + "start": { + "line": 148, + "column": 62 + }, + "end": { + "line": 148, + "column": 75 + } + } + }, + "range": [ + 4079, + 4144 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 75 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 4156, + 4164 + ], + "loc": { + "start": { + "line": 149, + "column": 8 + }, + "end": { + "line": 149, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "onNext", + "range": [ + 4165, + 4171 + ], + "loc": { + "start": { + "line": 149, + "column": 17 + }, + "end": { + "line": 149, + "column": 23 + } + } + }, + "range": [ + 4156, + 4171 + ], + "loc": { + "start": { + "line": 149, + "column": 8 + }, + "end": { + "line": 149, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "normalizeSuccess", + "range": [ + 4172, + 4188 + ], + "loc": { + "start": { + "line": 149, + "column": 24 + }, + "end": { + "line": 149, + "column": 40 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 4189, + 4190 + ], + "loc": { + "start": { + "line": 149, + "column": 41 + }, + "end": { + "line": 149, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "xhr", + "range": [ + 4192, + 4195 + ], + "loc": { + "start": { + "line": 149, + "column": 44 + }, + "end": { + "line": 149, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "settings", + "range": [ + 4197, + 4205 + ], + "loc": { + "start": { + "line": 149, + "column": 49 + }, + "end": { + "line": 149, + "column": 57 + } + } + } + ], + "range": [ + 4172, + 4206 + ], + "loc": { + "start": { + "line": 149, + "column": 24 + }, + "end": { + "line": 149, + "column": 58 + } + } + } + ], + "range": [ + 4156, + 4207 + ], + "loc": { + "start": { + "line": 149, + "column": 8 + }, + "end": { + "line": 149, + "column": 59 + } + } + }, + "range": [ + 4156, + 4208 + ], + "loc": { + "start": { + "line": 149, + "column": 8 + }, + "end": { + "line": 149, + "column": 60 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 4217, + 4225 + ], + "loc": { + "start": { + "line": 150, + "column": 8 + }, + "end": { + "line": 150, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "onCompleted", + "range": [ + 4226, + 4237 + ], + "loc": { + "start": { + "line": 150, + "column": 17 + }, + "end": { + "line": 150, + "column": 28 + } + } + }, + "range": [ + 4217, + 4237 + ], + "loc": { + "start": { + "line": 150, + "column": 8 + }, + "end": { + "line": 150, + "column": 28 + } + } + }, + "arguments": [], + "range": [ + 4217, + 4239 + ], + "loc": { + "start": { + "line": 150, + "column": 8 + }, + "end": { + "line": 150, + "column": 30 + } + } + }, + "range": [ + 4217, + 4240 + ], + "loc": { + "start": { + "line": 150, + "column": 8 + }, + "end": { + "line": 150, + "column": 31 + } + } + } + ], + "range": [ + 4146, + 4248 + ], + "loc": { + "start": { + "line": 148, + "column": 77 + }, + "end": { + "line": 151, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 4264, + 4272 + ], + "loc": { + "start": { + "line": 152, + "column": 8 + }, + "end": { + "line": 152, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 4273, + 4280 + ], + "loc": { + "start": { + "line": 152, + "column": 17 + }, + "end": { + "line": 152, + "column": 24 + } + } + }, + "range": [ + 4264, + 4280 + ], + "loc": { + "start": { + "line": 152, + "column": 8 + }, + "end": { + "line": 152, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "normalizeError", + "range": [ + 4281, + 4295 + ], + "loc": { + "start": { + "line": 152, + "column": 25 + }, + "end": { + "line": 152, + "column": 39 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 4296, + 4297 + ], + "loc": { + "start": { + "line": 152, + "column": 40 + }, + "end": { + "line": 152, + "column": 41 + } + } + }, + { + "type": "Identifier", + "name": "xhr", + "range": [ + 4299, + 4302 + ], + "loc": { + "start": { + "line": 152, + "column": 43 + }, + "end": { + "line": 152, + "column": 46 + } + } + }, + { + "type": "Literal", + "value": "error", + "raw": "'error'", + "range": [ + 4304, + 4311 + ], + "loc": { + "start": { + "line": 152, + "column": 48 + }, + "end": { + "line": 152, + "column": 55 + } + } + } + ], + "range": [ + 4281, + 4312 + ], + "loc": { + "start": { + "line": 152, + "column": 25 + }, + "end": { + "line": 152, + "column": 56 + } + } + } + ], + "range": [ + 4264, + 4313 + ], + "loc": { + "start": { + "line": 152, + "column": 8 + }, + "end": { + "line": 152, + "column": 57 + } + } + }, + "range": [ + 4264, + 4314 + ], + "loc": { + "start": { + "line": 152, + "column": 8 + }, + "end": { + "line": 152, + "column": 58 + } + } + } + ], + "range": [ + 4254, + 4322 + ], + "loc": { + "start": { + "line": 151, + "column": 13 + }, + "end": { + "line": 153, + "column": 7 + } + } + }, + "range": [ + 4075, + 4322 + ], + "loc": { + "start": { + "line": 148, + "column": 6 + }, + "end": { + "line": 153, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "isDone", + "range": [ + 4329, + 4335 + ], + "loc": { + "start": { + "line": 154, + "column": 6 + }, + "end": { + "line": 154, + "column": 12 + } + } + }, + "right": { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 4338, + 4342 + ], + "loc": { + "start": { + "line": 154, + "column": 15 + }, + "end": { + "line": 154, + "column": 19 + } + } + }, + "range": [ + 4329, + 4342 + ], + "loc": { + "start": { + "line": 154, + "column": 6 + }, + "end": { + "line": 154, + "column": 19 + } + } + }, + "range": [ + 4329, + 4343 + ], + "loc": { + "start": { + "line": 154, + "column": 6 + }, + "end": { + "line": 154, + "column": 20 + } + } + } + ], + "range": [ + 4008, + 4349 + ], + "loc": { + "start": { + "line": 146, + "column": 42 + }, + "end": { + "line": 155, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3992, + 4349 + ], + "loc": { + "start": { + "line": 146, + "column": 26 + }, + "end": { + "line": 155, + "column": 5 + } + } + }, + "range": [ + 3974, + 4349 + ], + "loc": { + "start": { + "line": 146, + "column": 8 + }, + "end": { + "line": 155, + "column": 5 + } + } + } + ], + "kind": "var", + "range": [ + 3970, + 4350 + ], + "loc": { + "start": { + "line": 146, + "column": 4 + }, + "end": { + "line": 155, + "column": 6 + } + } + }, + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4368, + 4371 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 9 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4374, + 4382 + ], + "loc": { + "start": { + "line": 158, + "column": 12 + }, + "end": { + "line": 158, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "createXHR", + "range": [ + 4383, + 4392 + ], + "loc": { + "start": { + "line": 158, + "column": 21 + }, + "end": { + "line": 158, + "column": 30 + } + } + }, + "range": [ + 4374, + 4392 + ], + "loc": { + "start": { + "line": 158, + "column": 12 + }, + "end": { + "line": 158, + "column": 30 + } + } + }, + "arguments": [], + "range": [ + 4374, + 4394 + ], + "loc": { + "start": { + "line": 158, + "column": 12 + }, + "end": { + "line": 158, + "column": 32 + } + } + }, + "range": [ + 4368, + 4394 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 32 + } + } + }, + "range": [ + 4368, + 4395 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 33 + } + } + }, + { + "type": "EmptyStatement", + "range": [ + 4395, + 4396 + ], + "loc": { + "start": { + "line": 158, + "column": 33 + }, + "end": { + "line": 158, + "column": 34 + } + } + } + ], + "range": [ + 4360, + 4402 + ], + "loc": { + "start": { + "line": 157, + "column": 8 + }, + "end": { + "line": 159, + "column": 5 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "err", + "range": [ + 4410, + 4413 + ], + "loc": { + "start": { + "line": 159, + "column": 13 + }, + "end": { + "line": 159, + "column": 16 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 4423, + 4431 + ], + "loc": { + "start": { + "line": 160, + "column": 6 + }, + "end": { + "line": 160, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 4432, + 4439 + ], + "loc": { + "start": { + "line": 160, + "column": 15 + }, + "end": { + "line": 160, + "column": 22 + } + } + }, + "range": [ + 4423, + 4439 + ], + "loc": { + "start": { + "line": 160, + "column": 6 + }, + "end": { + "line": 160, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "err", + "range": [ + 4440, + 4443 + ], + "loc": { + "start": { + "line": 160, + "column": 23 + }, + "end": { + "line": 160, + "column": 26 + } + } + } + ], + "range": [ + 4423, + 4444 + ], + "loc": { + "start": { + "line": 160, + "column": 6 + }, + "end": { + "line": 160, + "column": 27 + } + } + }, + "range": [ + 4423, + 4445 + ], + "loc": { + "start": { + "line": 160, + "column": 6 + }, + "end": { + "line": 160, + "column": 28 + } + } + } + ], + "range": [ + 4415, + 4451 + ], + "loc": { + "start": { + "line": 159, + "column": 18 + }, + "end": { + "line": 161, + "column": 5 + } + } + }, + "range": [ + 4403, + 4451 + ], + "loc": { + "start": { + "line": 159, + "column": 6 + }, + "end": { + "line": 161, + "column": 5 + } + } + }, + "finalizer": null, + "range": [ + 4356, + 4451 + ], + "loc": { + "start": { + "line": 157, + "column": 4 + }, + "end": { + "line": 161, + "column": 5 + } + } + }, + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4473, + 4481 + ], + "loc": { + "start": { + "line": 164, + "column": 10 + }, + "end": { + "line": 164, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "user", + "range": [ + 4482, + 4486 + ], + "loc": { + "start": { + "line": 164, + "column": 19 + }, + "end": { + "line": 164, + "column": 23 + } + } + }, + "range": [ + 4473, + 4486 + ], + "loc": { + "start": { + "line": 164, + "column": 10 + }, + "end": { + "line": 164, + "column": 23 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4498, + 4501 + ], + "loc": { + "start": { + "line": 165, + "column": 8 + }, + "end": { + "line": 165, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 4502, + 4506 + ], + "loc": { + "start": { + "line": 165, + "column": 12 + }, + "end": { + "line": 165, + "column": 16 + } + } + }, + "range": [ + 4498, + 4506 + ], + "loc": { + "start": { + "line": 165, + "column": 8 + }, + "end": { + "line": 165, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4507, + 4515 + ], + "loc": { + "start": { + "line": 165, + "column": 17 + }, + "end": { + "line": 165, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "method", + "range": [ + 4516, + 4522 + ], + "loc": { + "start": { + "line": 165, + "column": 26 + }, + "end": { + "line": 165, + "column": 32 + } + } + }, + "range": [ + 4507, + 4522 + ], + "loc": { + "start": { + "line": 165, + "column": 17 + }, + "end": { + "line": 165, + "column": 32 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4524, + 4532 + ], + "loc": { + "start": { + "line": 165, + "column": 34 + }, + "end": { + "line": 165, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "url", + "range": [ + 4533, + 4536 + ], + "loc": { + "start": { + "line": 165, + "column": 43 + }, + "end": { + "line": 165, + "column": 46 + } + } + }, + "range": [ + 4524, + 4536 + ], + "loc": { + "start": { + "line": 165, + "column": 34 + }, + "end": { + "line": 165, + "column": 46 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4538, + 4546 + ], + "loc": { + "start": { + "line": 165, + "column": 48 + }, + "end": { + "line": 165, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "async", + "range": [ + 4547, + 4552 + ], + "loc": { + "start": { + "line": 165, + "column": 57 + }, + "end": { + "line": 165, + "column": 62 + } + } + }, + "range": [ + 4538, + 4552 + ], + "loc": { + "start": { + "line": 165, + "column": 48 + }, + "end": { + "line": 165, + "column": 62 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4554, + 4562 + ], + "loc": { + "start": { + "line": 165, + "column": 64 + }, + "end": { + "line": 165, + "column": 72 + } + } + }, + "property": { + "type": "Identifier", + "name": "user", + "range": [ + 4563, + 4567 + ], + "loc": { + "start": { + "line": 165, + "column": 73 + }, + "end": { + "line": 165, + "column": 77 + } + } + }, + "range": [ + 4554, + 4567 + ], + "loc": { + "start": { + "line": 165, + "column": 64 + }, + "end": { + "line": 165, + "column": 77 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4569, + 4577 + ], + "loc": { + "start": { + "line": 165, + "column": 79 + }, + "end": { + "line": 165, + "column": 87 + } + } + }, + "property": { + "type": "Identifier", + "name": "password", + "range": [ + 4578, + 4586 + ], + "loc": { + "start": { + "line": 165, + "column": 88 + }, + "end": { + "line": 165, + "column": 96 + } + } + }, + "range": [ + 4569, + 4586 + ], + "loc": { + "start": { + "line": 165, + "column": 79 + }, + "end": { + "line": 165, + "column": 96 + } + } + } + ], + "range": [ + 4498, + 4587 + ], + "loc": { + "start": { + "line": 165, + "column": 8 + }, + "end": { + "line": 165, + "column": 97 + } + } + }, + "range": [ + 4498, + 4588 + ], + "loc": { + "start": { + "line": 165, + "column": 8 + }, + "end": { + "line": 165, + "column": 98 + } + } + } + ], + "range": [ + 4488, + 4596 + ], + "loc": { + "start": { + "line": 164, + "column": 25 + }, + "end": { + "line": 166, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4612, + 4615 + ], + "loc": { + "start": { + "line": 167, + "column": 8 + }, + "end": { + "line": 167, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 4616, + 4620 + ], + "loc": { + "start": { + "line": 167, + "column": 12 + }, + "end": { + "line": 167, + "column": 16 + } + } + }, + "range": [ + 4612, + 4620 + ], + "loc": { + "start": { + "line": 167, + "column": 8 + }, + "end": { + "line": 167, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4621, + 4629 + ], + "loc": { + "start": { + "line": 167, + "column": 17 + }, + "end": { + "line": 167, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "method", + "range": [ + 4630, + 4636 + ], + "loc": { + "start": { + "line": 167, + "column": 26 + }, + "end": { + "line": 167, + "column": 32 + } + } + }, + "range": [ + 4621, + 4636 + ], + "loc": { + "start": { + "line": 167, + "column": 17 + }, + "end": { + "line": 167, + "column": 32 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4638, + 4646 + ], + "loc": { + "start": { + "line": 167, + "column": 34 + }, + "end": { + "line": 167, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "url", + "range": [ + 4647, + 4650 + ], + "loc": { + "start": { + "line": 167, + "column": 43 + }, + "end": { + "line": 167, + "column": 46 + } + } + }, + "range": [ + 4638, + 4650 + ], + "loc": { + "start": { + "line": 167, + "column": 34 + }, + "end": { + "line": 167, + "column": 46 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4652, + 4660 + ], + "loc": { + "start": { + "line": 167, + "column": 48 + }, + "end": { + "line": 167, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "async", + "range": [ + 4661, + 4666 + ], + "loc": { + "start": { + "line": 167, + "column": 57 + }, + "end": { + "line": 167, + "column": 62 + } + } + }, + "range": [ + 4652, + 4666 + ], + "loc": { + "start": { + "line": 167, + "column": 48 + }, + "end": { + "line": 167, + "column": 62 + } + } + } + ], + "range": [ + 4612, + 4667 + ], + "loc": { + "start": { + "line": 167, + "column": 8 + }, + "end": { + "line": 167, + "column": 63 + } + } + }, + "range": [ + 4612, + 4668 + ], + "loc": { + "start": { + "line": 167, + "column": 8 + }, + "end": { + "line": 167, + "column": 64 + } + } + } + ], + "range": [ + 4602, + 4676 + ], + "loc": { + "start": { + "line": 166, + "column": 13 + }, + "end": { + "line": 168, + "column": 7 + } + } + }, + "range": [ + 4469, + 4676 + ], + "loc": { + "start": { + "line": 164, + "column": 6 + }, + "end": { + "line": 168, + "column": 7 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "headers", + "range": [ + 4688, + 4695 + ], + "loc": { + "start": { + "line": 170, + "column": 10 + }, + "end": { + "line": 170, + "column": 17 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 4698, + 4706 + ], + "loc": { + "start": { + "line": 170, + "column": 20 + }, + "end": { + "line": 170, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "headers", + "range": [ + 4707, + 4714 + ], + "loc": { + "start": { + "line": 170, + "column": 29 + }, + "end": { + "line": 170, + "column": 36 + } + } + }, + "range": [ + 4698, + 4714 + ], + "loc": { + "start": { + "line": 170, + "column": 20 + }, + "end": { + "line": 170, + "column": 36 + } + } + }, + "range": [ + 4688, + 4714 + ], + "loc": { + "start": { + "line": 170, + "column": 10 + }, + "end": { + "line": 170, + "column": 36 + } + } + } + ], + "kind": "let", + "range": [ + 4684, + 4715 + ], + "loc": { + "start": { + "line": 170, + "column": 6 + }, + "end": { + "line": 170, + "column": 37 + } + } + }, + { + "type": "ForInStatement", + "left": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "header", + "range": [ + 4731, + 4737 + ], + "loc": { + "start": { + "line": 171, + "column": 15 + }, + "end": { + "line": 171, + "column": 21 + } + } + }, + "init": null, + "range": [ + 4731, + 4737 + ], + "loc": { + "start": { + "line": 171, + "column": 15 + }, + "end": { + "line": 171, + "column": 21 + } + } + } + ], + "kind": "let", + "range": [ + 4727, + 4737 + ], + "loc": { + "start": { + "line": 171, + "column": 11 + }, + "end": { + "line": 171, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "headers", + "range": [ + 4741, + 4748 + ], + "loc": { + "start": { + "line": 171, + "column": 25 + }, + "end": { + "line": 171, + "column": 32 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "hasOwnProperty", + "range": [ + 4764, + 4778 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4779, + 4783 + ], + "loc": { + "start": { + "line": 172, + "column": 27 + }, + "end": { + "line": 172, + "column": 31 + } + } + }, + "range": [ + 4764, + 4783 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 31 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "headers", + "range": [ + 4784, + 4791 + ], + "loc": { + "start": { + "line": 172, + "column": 32 + }, + "end": { + "line": 172, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "header", + "range": [ + 4793, + 4799 + ], + "loc": { + "start": { + "line": 172, + "column": 41 + }, + "end": { + "line": 172, + "column": 47 + } + } + } + ], + "range": [ + 4764, + 4800 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 48 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4814, + 4817 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 173, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "setRequestHeader", + "range": [ + 4818, + 4834 + ], + "loc": { + "start": { + "line": 173, + "column": 14 + }, + "end": { + "line": 173, + "column": 30 + } + } + }, + "range": [ + 4814, + 4834 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 173, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "header", + "range": [ + 4835, + 4841 + ], + "loc": { + "start": { + "line": 173, + "column": 31 + }, + "end": { + "line": 173, + "column": 37 + } + } + }, + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "headers", + "range": [ + 4843, + 4850 + ], + "loc": { + "start": { + "line": 173, + "column": 39 + }, + "end": { + "line": 173, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "header", + "range": [ + 4851, + 4857 + ], + "loc": { + "start": { + "line": 173, + "column": 47 + }, + "end": { + "line": 173, + "column": 53 + } + } + }, + "range": [ + 4843, + 4858 + ], + "loc": { + "start": { + "line": 173, + "column": 39 + }, + "end": { + "line": 173, + "column": 54 + } + } + } + ], + "range": [ + 4814, + 4859 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 173, + "column": 55 + } + } + }, + "range": [ + 4814, + 4860 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 173, + "column": 56 + } + } + } + ], + "range": [ + 4802, + 4870 + ], + "loc": { + "start": { + "line": 172, + "column": 50 + }, + "end": { + "line": 174, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 4760, + 4870 + ], + "loc": { + "start": { + "line": 172, + "column": 8 + }, + "end": { + "line": 174, + "column": 9 + } + } + } + ], + "range": [ + 4750, + 4878 + ], + "loc": { + "start": { + "line": 171, + "column": 34 + }, + "end": { + "line": 175, + "column": 7 + } + } + }, + "each": false, + "range": [ + 4722, + 4878 + ], + "loc": { + "start": { + "line": 171, + "column": 6 + }, + "end": { + "line": 175, + "column": 7 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4891, + 4894 + ], + "loc": { + "start": { + "line": 177, + "column": 11 + }, + "end": { + "line": 177, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "upload", + "range": [ + 4895, + 4901 + ], + "loc": { + "start": { + "line": 177, + "column": 15 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "range": [ + 4891, + 4901 + ], + "loc": { + "start": { + "line": 177, + "column": 11 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "prefix": true, + "range": [ + 4890, + 4901 + ], + "loc": { + "start": { + "line": 177, + "column": 10 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "prefix": true, + "range": [ + 4889, + 4901 + ], + "loc": { + "start": { + "line": 177, + "column": 9 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "BinaryExpression", + "operator": "in", + "left": { + "type": "Literal", + "value": "withCredentials", + "raw": "'withCredentials'", + "range": [ + 4908, + 4925 + ], + "loc": { + "start": { + "line": 177, + "column": 28 + }, + "end": { + "line": 177, + "column": 45 + } + } + }, + "right": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4929, + 4932 + ], + "loc": { + "start": { + "line": 177, + "column": 49 + }, + "end": { + "line": 177, + "column": 52 + } + } + }, + "range": [ + 4908, + 4932 + ], + "loc": { + "start": { + "line": 177, + "column": 28 + }, + "end": { + "line": 177, + "column": 52 + } + } + }, + "prefix": true, + "range": [ + 4906, + 4933 + ], + "loc": { + "start": { + "line": 177, + "column": 26 + }, + "end": { + "line": 177, + "column": 53 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 4939, + 4943 + ], + "loc": { + "start": { + "line": 177, + "column": 59 + }, + "end": { + "line": 177, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "XDomainRequest", + "range": [ + 4944, + 4958 + ], + "loc": { + "start": { + "line": 177, + "column": 64 + }, + "end": { + "line": 177, + "column": 78 + } + } + }, + "range": [ + 4939, + 4958 + ], + "loc": { + "start": { + "line": 177, + "column": 59 + }, + "end": { + "line": 177, + "column": 78 + } + } + }, + "prefix": true, + "range": [ + 4938, + 4958 + ], + "loc": { + "start": { + "line": 177, + "column": 58 + }, + "end": { + "line": 177, + "column": 78 + } + } + }, + "prefix": true, + "range": [ + 4937, + 4958 + ], + "loc": { + "start": { + "line": 177, + "column": 57 + }, + "end": { + "line": 177, + "column": 78 + } + } + }, + "range": [ + 4906, + 4958 + ], + "loc": { + "start": { + "line": 177, + "column": 26 + }, + "end": { + "line": 177, + "column": 78 + } + } + }, + "range": [ + 4889, + 4959 + ], + "loc": { + "start": { + "line": 177, + "column": 9 + }, + "end": { + "line": 177, + "column": 79 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 4971, + 4974 + ], + "loc": { + "start": { + "line": 178, + "column": 8 + }, + "end": { + "line": 178, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "onload", + "range": [ + 4975, + 4981 + ], + "loc": { + "start": { + "line": 178, + "column": 12 + }, + "end": { + "line": 178, + "column": 18 + } + } + }, + "range": [ + 4971, + 4981 + ], + "loc": { + "start": { + "line": 178, + "column": 8 + }, + "end": { + "line": 178, + "column": 18 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 4993, + 4994 + ], + "loc": { + "start": { + "line": 178, + "column": 30 + }, + "end": { + "line": 178, + "column": 31 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5011, + 5019 + ], + "loc": { + "start": { + "line": 179, + "column": 13 + }, + "end": { + "line": 179, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5020, + 5036 + ], + "loc": { + "start": { + "line": 179, + "column": 22 + }, + "end": { + "line": 179, + "column": 38 + } + } + }, + "range": [ + 5011, + 5036 + ], + "loc": { + "start": { + "line": 179, + "column": 13 + }, + "end": { + "line": 179, + "column": 38 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5052, + 5060 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5061, + 5077 + ], + "loc": { + "start": { + "line": 180, + "column": 21 + }, + "end": { + "line": 180, + "column": 37 + } + } + }, + "range": [ + 5052, + 5077 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "onNext", + "range": [ + 5078, + 5084 + ], + "loc": { + "start": { + "line": 180, + "column": 38 + }, + "end": { + "line": 180, + "column": 44 + } + } + }, + "range": [ + 5052, + 5084 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 44 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5085, + 5086 + ], + "loc": { + "start": { + "line": 180, + "column": 45 + }, + "end": { + "line": 180, + "column": 46 + } + } + } + ], + "range": [ + 5052, + 5087 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 47 + } + } + }, + "range": [ + 5052, + 5088 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 48 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5101, + 5109 + ], + "loc": { + "start": { + "line": 181, + "column": 12 + }, + "end": { + "line": 181, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5110, + 5126 + ], + "loc": { + "start": { + "line": 181, + "column": 21 + }, + "end": { + "line": 181, + "column": 37 + } + } + }, + "range": [ + 5101, + 5126 + ], + "loc": { + "start": { + "line": 181, + "column": 12 + }, + "end": { + "line": 181, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "onCompleted", + "range": [ + 5127, + 5138 + ], + "loc": { + "start": { + "line": 181, + "column": 38 + }, + "end": { + "line": 181, + "column": 49 + } + } + }, + "range": [ + 5101, + 5138 + ], + "loc": { + "start": { + "line": 181, + "column": 12 + }, + "end": { + "line": 181, + "column": 49 + } + } + }, + "arguments": [], + "range": [ + 5101, + 5140 + ], + "loc": { + "start": { + "line": 181, + "column": 12 + }, + "end": { + "line": 181, + "column": 51 + } + } + }, + "range": [ + 5101, + 5141 + ], + "loc": { + "start": { + "line": 181, + "column": 12 + }, + "end": { + "line": 181, + "column": 52 + } + } + } + ], + "range": [ + 5038, + 5153 + ], + "loc": { + "start": { + "line": 179, + "column": 40 + }, + "end": { + "line": 182, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 5008, + 5153 + ], + "loc": { + "start": { + "line": 179, + "column": 10 + }, + "end": { + "line": 182, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "processResponse", + "range": [ + 5164, + 5179 + ], + "loc": { + "start": { + "line": 183, + "column": 10 + }, + "end": { + "line": 183, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "xhr", + "range": [ + 5180, + 5183 + ], + "loc": { + "start": { + "line": 183, + "column": 26 + }, + "end": { + "line": 183, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 5185, + 5186 + ], + "loc": { + "start": { + "line": 183, + "column": 31 + }, + "end": { + "line": 183, + "column": 32 + } + } + } + ], + "range": [ + 5164, + 5187 + ], + "loc": { + "start": { + "line": 183, + "column": 10 + }, + "end": { + "line": 183, + "column": 33 + } + } + }, + "range": [ + 5164, + 5188 + ], + "loc": { + "start": { + "line": 183, + "column": 10 + }, + "end": { + "line": 183, + "column": 34 + } + } + } + ], + "range": [ + 4996, + 5198 + ], + "loc": { + "start": { + "line": 178, + "column": 33 + }, + "end": { + "line": 184, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 4984, + 5198 + ], + "loc": { + "start": { + "line": 178, + "column": 21 + }, + "end": { + "line": 184, + "column": 9 + } + } + }, + "range": [ + 4971, + 5198 + ], + "loc": { + "start": { + "line": 178, + "column": 8 + }, + "end": { + "line": 184, + "column": 9 + } + } + }, + "range": [ + 4971, + 5199 + ], + "loc": { + "start": { + "line": 178, + "column": 8 + }, + "end": { + "line": 184, + "column": 10 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5212, + 5220 + ], + "loc": { + "start": { + "line": 186, + "column": 11 + }, + "end": { + "line": 186, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5221, + 5237 + ], + "loc": { + "start": { + "line": 186, + "column": 20 + }, + "end": { + "line": 186, + "column": 36 + } + } + }, + "range": [ + 5212, + 5237 + ], + "loc": { + "start": { + "line": 186, + "column": 11 + }, + "end": { + "line": 186, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 5251, + 5254 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 187, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "onprogress", + "range": [ + 5255, + 5265 + ], + "loc": { + "start": { + "line": 187, + "column": 14 + }, + "end": { + "line": 187, + "column": 24 + } + } + }, + "range": [ + 5251, + 5265 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 187, + "column": 24 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5277, + 5278 + ], + "loc": { + "start": { + "line": 187, + "column": 36 + }, + "end": { + "line": 187, + "column": 37 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5294, + 5302 + ], + "loc": { + "start": { + "line": 188, + "column": 12 + }, + "end": { + "line": 188, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5303, + 5319 + ], + "loc": { + "start": { + "line": 188, + "column": 21 + }, + "end": { + "line": 188, + "column": 37 + } + } + }, + "range": [ + 5294, + 5319 + ], + "loc": { + "start": { + "line": 188, + "column": 12 + }, + "end": { + "line": 188, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "onNext", + "range": [ + 5320, + 5326 + ], + "loc": { + "start": { + "line": 188, + "column": 38 + }, + "end": { + "line": 188, + "column": 44 + } + } + }, + "range": [ + 5294, + 5326 + ], + "loc": { + "start": { + "line": 188, + "column": 12 + }, + "end": { + "line": 188, + "column": 44 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5327, + 5328 + ], + "loc": { + "start": { + "line": 188, + "column": 45 + }, + "end": { + "line": 188, + "column": 46 + } + } + } + ], + "range": [ + 5294, + 5329 + ], + "loc": { + "start": { + "line": 188, + "column": 12 + }, + "end": { + "line": 188, + "column": 47 + } + } + }, + "range": [ + 5294, + 5330 + ], + "loc": { + "start": { + "line": 188, + "column": 12 + }, + "end": { + "line": 188, + "column": 48 + } + } + } + ], + "range": [ + 5280, + 5342 + ], + "loc": { + "start": { + "line": 187, + "column": 39 + }, + "end": { + "line": 189, + "column": 11 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5268, + 5342 + ], + "loc": { + "start": { + "line": 187, + "column": 27 + }, + "end": { + "line": 189, + "column": 11 + } + } + }, + "range": [ + 5251, + 5342 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 189, + "column": 11 + } + } + }, + "range": [ + 5251, + 5343 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 189, + "column": 12 + } + } + } + ], + "range": [ + 5239, + 5353 + ], + "loc": { + "start": { + "line": 186, + "column": 38 + }, + "end": { + "line": 190, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 5209, + 5353 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 190, + "column": 9 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 5363, + 5366 + ], + "loc": { + "start": { + "line": 192, + "column": 8 + }, + "end": { + "line": 192, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "onerror", + "range": [ + 5367, + 5374 + ], + "loc": { + "start": { + "line": 192, + "column": 12 + }, + "end": { + "line": 192, + "column": 19 + } + } + }, + "range": [ + 5363, + 5374 + ], + "loc": { + "start": { + "line": 192, + "column": 8 + }, + "end": { + "line": 192, + "column": 19 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5386, + 5387 + ], + "loc": { + "start": { + "line": 192, + "column": 31 + }, + "end": { + "line": 192, + "column": 32 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5405, + 5413 + ], + "loc": { + "start": { + "line": 193, + "column": 14 + }, + "end": { + "line": 193, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5414, + 5430 + ], + "loc": { + "start": { + "line": 193, + "column": 23 + }, + "end": { + "line": 193, + "column": 39 + } + } + }, + "range": [ + 5405, + 5430 + ], + "loc": { + "start": { + "line": 193, + "column": 14 + }, + "end": { + "line": 193, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5446, + 5454 + ], + "loc": { + "start": { + "line": 194, + "column": 12 + }, + "end": { + "line": 194, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5455, + 5471 + ], + "loc": { + "start": { + "line": 194, + "column": 21 + }, + "end": { + "line": 194, + "column": 37 + } + } + }, + "range": [ + 5446, + 5471 + ], + "loc": { + "start": { + "line": 194, + "column": 12 + }, + "end": { + "line": 194, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 5472, + 5479 + ], + "loc": { + "start": { + "line": 194, + "column": 38 + }, + "end": { + "line": 194, + "column": 45 + } + } + }, + "range": [ + 5446, + 5479 + ], + "loc": { + "start": { + "line": 194, + "column": 12 + }, + "end": { + "line": 194, + "column": 45 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5480, + 5481 + ], + "loc": { + "start": { + "line": 194, + "column": 46 + }, + "end": { + "line": 194, + "column": 47 + } + } + } + ], + "range": [ + 5446, + 5482 + ], + "loc": { + "start": { + "line": 194, + "column": 12 + }, + "end": { + "line": 194, + "column": 48 + } + } + }, + "range": [ + 5446, + 5483 + ], + "loc": { + "start": { + "line": 194, + "column": 12 + }, + "end": { + "line": 194, + "column": 49 + } + } + } + ], + "range": [ + 5432, + 5495 + ], + "loc": { + "start": { + "line": 193, + "column": 41 + }, + "end": { + "line": 195, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 5401, + 5495 + ], + "loc": { + "start": { + "line": 193, + "column": 10 + }, + "end": { + "line": 195, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 5506, + 5514 + ], + "loc": { + "start": { + "line": 196, + "column": 10 + }, + "end": { + "line": 196, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 5515, + 5522 + ], + "loc": { + "start": { + "line": 196, + "column": 19 + }, + "end": { + "line": 196, + "column": 26 + } + } + }, + "range": [ + 5506, + 5522 + ], + "loc": { + "start": { + "line": 196, + "column": 10 + }, + "end": { + "line": 196, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "normalizeError", + "range": [ + 5523, + 5537 + ], + "loc": { + "start": { + "line": 196, + "column": 27 + }, + "end": { + "line": 196, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5538, + 5539 + ], + "loc": { + "start": { + "line": 196, + "column": 42 + }, + "end": { + "line": 196, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "xhr", + "range": [ + 5541, + 5544 + ], + "loc": { + "start": { + "line": 196, + "column": 45 + }, + "end": { + "line": 196, + "column": 48 + } + } + }, + { + "type": "Literal", + "value": "error", + "raw": "'error'", + "range": [ + 5546, + 5553 + ], + "loc": { + "start": { + "line": 196, + "column": 50 + }, + "end": { + "line": 196, + "column": 57 + } + } + } + ], + "range": [ + 5523, + 5554 + ], + "loc": { + "start": { + "line": 196, + "column": 27 + }, + "end": { + "line": 196, + "column": 58 + } + } + } + ], + "range": [ + 5506, + 5555 + ], + "loc": { + "start": { + "line": 196, + "column": 10 + }, + "end": { + "line": 196, + "column": 59 + } + } + }, + "range": [ + 5506, + 5556 + ], + "loc": { + "start": { + "line": 196, + "column": 10 + }, + "end": { + "line": 196, + "column": 60 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "isDone", + "range": [ + 5567, + 5573 + ], + "loc": { + "start": { + "line": 197, + "column": 10 + }, + "end": { + "line": 197, + "column": 16 + } + } + }, + "right": { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 5576, + 5580 + ], + "loc": { + "start": { + "line": 197, + "column": 19 + }, + "end": { + "line": 197, + "column": 23 + } + } + }, + "range": [ + 5567, + 5580 + ], + "loc": { + "start": { + "line": 197, + "column": 10 + }, + "end": { + "line": 197, + "column": 23 + } + } + }, + "range": [ + 5567, + 5581 + ], + "loc": { + "start": { + "line": 197, + "column": 10 + }, + "end": { + "line": 197, + "column": 24 + } + } + } + ], + "range": [ + 5389, + 5591 + ], + "loc": { + "start": { + "line": 192, + "column": 34 + }, + "end": { + "line": 198, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5377, + 5591 + ], + "loc": { + "start": { + "line": 192, + "column": 22 + }, + "end": { + "line": 198, + "column": 9 + } + } + }, + "range": [ + 5363, + 5591 + ], + "loc": { + "start": { + "line": 192, + "column": 8 + }, + "end": { + "line": 198, + "column": 9 + } + } + }, + "range": [ + 5363, + 5592 + ], + "loc": { + "start": { + "line": 192, + "column": 8 + }, + "end": { + "line": 198, + "column": 10 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 5602, + 5605 + ], + "loc": { + "start": { + "line": 200, + "column": 8 + }, + "end": { + "line": 200, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "onabort", + "range": [ + 5606, + 5613 + ], + "loc": { + "start": { + "line": 200, + "column": 12 + }, + "end": { + "line": 200, + "column": 19 + } + } + }, + "range": [ + 5602, + 5613 + ], + "loc": { + "start": { + "line": 200, + "column": 8 + }, + "end": { + "line": 200, + "column": 19 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5625, + 5626 + ], + "loc": { + "start": { + "line": 200, + "column": 31 + }, + "end": { + "line": 200, + "column": 32 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5644, + 5652 + ], + "loc": { + "start": { + "line": 201, + "column": 14 + }, + "end": { + "line": 201, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5653, + 5669 + ], + "loc": { + "start": { + "line": 201, + "column": 23 + }, + "end": { + "line": 201, + "column": 39 + } + } + }, + "range": [ + 5644, + 5669 + ], + "loc": { + "start": { + "line": 201, + "column": 14 + }, + "end": { + "line": 201, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 5685, + 5693 + ], + "loc": { + "start": { + "line": 202, + "column": 12 + }, + "end": { + "line": 202, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "progressObserver", + "range": [ + 5694, + 5710 + ], + "loc": { + "start": { + "line": 202, + "column": 21 + }, + "end": { + "line": 202, + "column": 37 + } + } + }, + "range": [ + 5685, + 5710 + ], + "loc": { + "start": { + "line": 202, + "column": 12 + }, + "end": { + "line": 202, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 5711, + 5718 + ], + "loc": { + "start": { + "line": 202, + "column": 38 + }, + "end": { + "line": 202, + "column": 45 + } + } + }, + "range": [ + 5685, + 5718 + ], + "loc": { + "start": { + "line": 202, + "column": 12 + }, + "end": { + "line": 202, + "column": 45 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5719, + 5720 + ], + "loc": { + "start": { + "line": 202, + "column": 46 + }, + "end": { + "line": 202, + "column": 47 + } + } + } + ], + "range": [ + 5685, + 5721 + ], + "loc": { + "start": { + "line": 202, + "column": 12 + }, + "end": { + "line": 202, + "column": 48 + } + } + }, + "range": [ + 5685, + 5722 + ], + "loc": { + "start": { + "line": 202, + "column": 12 + }, + "end": { + "line": 202, + "column": 49 + } + } + } + ], + "range": [ + 5671, + 5734 + ], + "loc": { + "start": { + "line": 201, + "column": 41 + }, + "end": { + "line": 203, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 5640, + 5734 + ], + "loc": { + "start": { + "line": 201, + "column": 10 + }, + "end": { + "line": 203, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 5745, + 5753 + ], + "loc": { + "start": { + "line": 204, + "column": 10 + }, + "end": { + "line": 204, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 5754, + 5761 + ], + "loc": { + "start": { + "line": 204, + "column": 19 + }, + "end": { + "line": 204, + "column": 26 + } + } + }, + "range": [ + 5745, + 5761 + ], + "loc": { + "start": { + "line": 204, + "column": 10 + }, + "end": { + "line": 204, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "normalizeError", + "range": [ + 5762, + 5776 + ], + "loc": { + "start": { + "line": 204, + "column": 27 + }, + "end": { + "line": 204, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5777, + 5778 + ], + "loc": { + "start": { + "line": 204, + "column": 42 + }, + "end": { + "line": 204, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "xhr", + "range": [ + 5780, + 5783 + ], + "loc": { + "start": { + "line": 204, + "column": 45 + }, + "end": { + "line": 204, + "column": 48 + } + } + }, + { + "type": "Literal", + "value": "abort", + "raw": "'abort'", + "range": [ + 5785, + 5792 + ], + "loc": { + "start": { + "line": 204, + "column": 50 + }, + "end": { + "line": 204, + "column": 57 + } + } + } + ], + "range": [ + 5762, + 5793 + ], + "loc": { + "start": { + "line": 204, + "column": 27 + }, + "end": { + "line": 204, + "column": 58 + } + } + } + ], + "range": [ + 5745, + 5794 + ], + "loc": { + "start": { + "line": 204, + "column": 10 + }, + "end": { + "line": 204, + "column": 59 + } + } + }, + "range": [ + 5745, + 5795 + ], + "loc": { + "start": { + "line": 204, + "column": 10 + }, + "end": { + "line": 204, + "column": 60 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "isDone", + "range": [ + 5806, + 5812 + ], + "loc": { + "start": { + "line": 205, + "column": 10 + }, + "end": { + "line": 205, + "column": 16 + } + } + }, + "right": { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 5815, + 5819 + ], + "loc": { + "start": { + "line": 205, + "column": 19 + }, + "end": { + "line": 205, + "column": 23 + } + } + }, + "range": [ + 5806, + 5819 + ], + "loc": { + "start": { + "line": 205, + "column": 10 + }, + "end": { + "line": 205, + "column": 23 + } + } + }, + "range": [ + 5806, + 5820 + ], + "loc": { + "start": { + "line": 205, + "column": 10 + }, + "end": { + "line": 205, + "column": 24 + } + } + } + ], + "range": [ + 5628, + 5830 + ], + "loc": { + "start": { + "line": 200, + "column": 34 + }, + "end": { + "line": 206, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5616, + 5830 + ], + "loc": { + "start": { + "line": 200, + "column": 22 + }, + "end": { + "line": 206, + "column": 9 + } + } + }, + "range": [ + 5602, + 5830 + ], + "loc": { + "start": { + "line": 200, + "column": 8 + }, + "end": { + "line": 206, + "column": 9 + } + } + }, + "range": [ + 5602, + 5831 + ], + "loc": { + "start": { + "line": 200, + "column": 8 + }, + "end": { + "line": 206, + "column": 10 + } + } + } + ], + "range": [ + 4961, + 5839 + ], + "loc": { + "start": { + "line": 177, + "column": 81 + }, + "end": { + "line": 207, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 5856, + 5859 + ], + "loc": { + "start": { + "line": 209, + "column": 8 + }, + "end": { + "line": 209, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "onreadystatechange", + "range": [ + 5860, + 5878 + ], + "loc": { + "start": { + "line": 209, + "column": 12 + }, + "end": { + "line": 209, + "column": 30 + } + } + }, + "range": [ + 5856, + 5878 + ], + "loc": { + "start": { + "line": 209, + "column": 8 + }, + "end": { + "line": 209, + "column": 30 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 5891, + 5892 + ], + "loc": { + "start": { + "line": 209, + "column": 43 + }, + "end": { + "line": 209, + "column": 44 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 5910, + 5913 + ], + "loc": { + "start": { + "line": 210, + "column": 14 + }, + "end": { + "line": 210, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "readyState", + "range": [ + 5914, + 5924 + ], + "loc": { + "start": { + "line": 210, + "column": 18 + }, + "end": { + "line": 210, + "column": 28 + } + } + }, + "range": [ + 5910, + 5924 + ], + "loc": { + "start": { + "line": 210, + "column": 14 + }, + "end": { + "line": 210, + "column": 28 + } + } + }, + "right": { + "type": "Literal", + "value": 4, + "raw": "4", + "range": [ + 5929, + 5930 + ], + "loc": { + "start": { + "line": 210, + "column": 33 + }, + "end": { + "line": 210, + "column": 34 + } + } + }, + "range": [ + 5910, + 5930 + ], + "loc": { + "start": { + "line": 210, + "column": 14 + }, + "end": { + "line": 210, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "processResponse", + "range": [ + 5946, + 5961 + ], + "loc": { + "start": { + "line": 211, + "column": 12 + }, + "end": { + "line": 211, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "xhr", + "range": [ + 5962, + 5965 + ], + "loc": { + "start": { + "line": 211, + "column": 28 + }, + "end": { + "line": 211, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 5967, + 5968 + ], + "loc": { + "start": { + "line": 211, + "column": 33 + }, + "end": { + "line": 211, + "column": 34 + } + } + } + ], + "range": [ + 5946, + 5969 + ], + "loc": { + "start": { + "line": 211, + "column": 12 + }, + "end": { + "line": 211, + "column": 35 + } + } + }, + "range": [ + 5946, + 5970 + ], + "loc": { + "start": { + "line": 211, + "column": 12 + }, + "end": { + "line": 211, + "column": 36 + } + } + } + ], + "range": [ + 5932, + 5982 + ], + "loc": { + "start": { + "line": 210, + "column": 36 + }, + "end": { + "line": 212, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 5906, + 5982 + ], + "loc": { + "start": { + "line": 210, + "column": 10 + }, + "end": { + "line": 212, + "column": 11 + } + } + } + ], + "range": [ + 5894, + 5992 + ], + "loc": { + "start": { + "line": 209, + "column": 46 + }, + "end": { + "line": 213, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5881, + 5992 + ], + "loc": { + "start": { + "line": 209, + "column": 33 + }, + "end": { + "line": 213, + "column": 9 + } + } + }, + "range": [ + 5856, + 5992 + ], + "loc": { + "start": { + "line": 209, + "column": 8 + }, + "end": { + "line": 213, + "column": 9 + } + } + }, + "range": [ + 5856, + 5993 + ], + "loc": { + "start": { + "line": 209, + "column": 8 + }, + "end": { + "line": 213, + "column": 10 + } + } + } + ], + "range": [ + 5845, + 6001 + ], + "loc": { + "start": { + "line": 207, + "column": 13 + }, + "end": { + "line": 214, + "column": 7 + } + } + }, + "range": [ + 4886, + 6001 + ], + "loc": { + "start": { + "line": 177, + "column": 6 + }, + "end": { + "line": 214, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 6009, + 6012 + ], + "loc": { + "start": { + "line": 216, + "column": 6 + }, + "end": { + "line": 216, + "column": 9 + } + } + }, + "property": { + "type": "Identifier", + "name": "send", + "range": [ + 6013, + 6017 + ], + "loc": { + "start": { + "line": 216, + "column": 10 + }, + "end": { + "line": 216, + "column": 14 + } + } + }, + "range": [ + 6009, + 6017 + ], + "loc": { + "start": { + "line": 216, + "column": 6 + }, + "end": { + "line": 216, + "column": 14 + } + } + }, + "arguments": [ + { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 6018, + 6026 + ], + "loc": { + "start": { + "line": 216, + "column": 15 + }, + "end": { + "line": 216, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasContent", + "range": [ + 6027, + 6037 + ], + "loc": { + "start": { + "line": 216, + "column": 24 + }, + "end": { + "line": 216, + "column": 34 + } + } + }, + "range": [ + 6018, + 6037 + ], + "loc": { + "start": { + "line": 216, + "column": 15 + }, + "end": { + "line": 216, + "column": 34 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "settings", + "range": [ + 6041, + 6049 + ], + "loc": { + "start": { + "line": 216, + "column": 38 + }, + "end": { + "line": 216, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "body", + "range": [ + 6050, + 6054 + ], + "loc": { + "start": { + "line": 216, + "column": 47 + }, + "end": { + "line": 216, + "column": 51 + } + } + }, + "range": [ + 6041, + 6054 + ], + "loc": { + "start": { + "line": 216, + "column": 38 + }, + "end": { + "line": 216, + "column": 51 + } + } + }, + "range": [ + 6018, + 6054 + ], + "loc": { + "start": { + "line": 216, + "column": 15 + }, + "end": { + "line": 216, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 6058, + 6062 + ], + "loc": { + "start": { + "line": 216, + "column": 55 + }, + "end": { + "line": 216, + "column": 59 + } + } + }, + "range": [ + 6018, + 6062 + ], + "loc": { + "start": { + "line": 216, + "column": 15 + }, + "end": { + "line": 216, + "column": 59 + } + } + } + ], + "range": [ + 6009, + 6063 + ], + "loc": { + "start": { + "line": 216, + "column": 6 + }, + "end": { + "line": 216, + "column": 60 + } + } + }, + "range": [ + 6009, + 6064 + ], + "loc": { + "start": { + "line": 216, + "column": 6 + }, + "end": { + "line": 216, + "column": 61 + } + } + } + ], + "range": [ + 4461, + 6070 + ], + "loc": { + "start": { + "line": 163, + "column": 8 + }, + "end": { + "line": 217, + "column": 5 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "e", + "range": [ + 6078, + 6079 + ], + "loc": { + "start": { + "line": 217, + "column": 13 + }, + "end": { + "line": 217, + "column": 14 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "observer", + "range": [ + 6089, + 6097 + ], + "loc": { + "start": { + "line": 218, + "column": 6 + }, + "end": { + "line": 218, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "onError", + "range": [ + 6098, + 6105 + ], + "loc": { + "start": { + "line": 218, + "column": 15 + }, + "end": { + "line": 218, + "column": 22 + } + } + }, + "range": [ + 6089, + 6105 + ], + "loc": { + "start": { + "line": 218, + "column": 6 + }, + "end": { + "line": 218, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 6106, + 6107 + ], + "loc": { + "start": { + "line": 218, + "column": 23 + }, + "end": { + "line": 218, + "column": 24 + } + } + } + ], + "range": [ + 6089, + 6108 + ], + "loc": { + "start": { + "line": 218, + "column": 6 + }, + "end": { + "line": 218, + "column": 25 + } + } + }, + "range": [ + 6089, + 6109 + ], + "loc": { + "start": { + "line": 218, + "column": 6 + }, + "end": { + "line": 218, + "column": 26 + } + } + } + ], + "range": [ + 6081, + 6115 + ], + "loc": { + "start": { + "line": 217, + "column": 16 + }, + "end": { + "line": 219, + "column": 5 + } + } + }, + "range": [ + 6071, + 6115 + ], + "loc": { + "start": { + "line": 217, + "column": 6 + }, + "end": { + "line": 219, + "column": 5 + } + } + }, + "finalizer": null, + "range": [ + 4457, + 6115 + ], + "loc": { + "start": { + "line": 163, + "column": 4 + }, + "end": { + "line": 219, + "column": 5 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "Identifier", + "name": "isDone", + "range": [ + 6153, + 6159 + ], + "loc": { + "start": { + "line": 222, + "column": 11 + }, + "end": { + "line": 222, + "column": 17 + } + } + }, + "prefix": true, + "range": [ + 6152, + 6159 + ], + "loc": { + "start": { + "line": 222, + "column": 10 + }, + "end": { + "line": 222, + "column": 17 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 6163, + 6166 + ], + "loc": { + "start": { + "line": 222, + "column": 21 + }, + "end": { + "line": 222, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "readyState", + "range": [ + 6167, + 6177 + ], + "loc": { + "start": { + "line": 222, + "column": 25 + }, + "end": { + "line": 222, + "column": 35 + } + } + }, + "range": [ + 6163, + 6177 + ], + "loc": { + "start": { + "line": 222, + "column": 21 + }, + "end": { + "line": 222, + "column": 35 + } + } + }, + "right": { + "type": "Literal", + "value": 4, + "raw": "4", + "range": [ + 6182, + 6183 + ], + "loc": { + "start": { + "line": 222, + "column": 40 + }, + "end": { + "line": 222, + "column": 41 + } + } + }, + "range": [ + 6163, + 6183 + ], + "loc": { + "start": { + "line": 222, + "column": 21 + }, + "end": { + "line": 222, + "column": 41 + } + } + }, + "range": [ + 6152, + 6183 + ], + "loc": { + "start": { + "line": 222, + "column": 10 + }, + "end": { + "line": 222, + "column": 41 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "xhr", + "range": [ + 6187, + 6190 + ], + "loc": { + "start": { + "line": 222, + "column": 45 + }, + "end": { + "line": 222, + "column": 48 + } + } + }, + "property": { + "type": "Identifier", + "name": "abort", + "range": [ + 6191, + 6196 + ], + "loc": { + "start": { + "line": 222, + "column": 49 + }, + "end": { + "line": 222, + "column": 54 + } + } + }, + "range": [ + 6187, + 6196 + ], + "loc": { + "start": { + "line": 222, + "column": 45 + }, + "end": { + "line": 222, + "column": 54 + } + } + }, + "arguments": [], + "range": [ + 6187, + 6198 + ], + "loc": { + "start": { + "line": 222, + "column": 45 + }, + "end": { + "line": 222, + "column": 56 + } + } + }, + "range": [ + 6187, + 6199 + ], + "loc": { + "start": { + "line": 222, + "column": 45 + }, + "end": { + "line": 222, + "column": 57 + } + } + } + ], + "range": [ + 6185, + 6201 + ], + "loc": { + "start": { + "line": 222, + "column": 43 + }, + "end": { + "line": 222, + "column": 59 + } + } + }, + "alternate": null, + "range": [ + 6148, + 6201 + ], + "loc": { + "start": { + "line": 222, + "column": 6 + }, + "end": { + "line": 222, + "column": 59 + } + } + } + ], + "range": [ + 6140, + 6207 + ], + "loc": { + "start": { + "line": 221, + "column": 23 + }, + "end": { + "line": 223, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 6128, + 6207 + ], + "loc": { + "start": { + "line": 221, + "column": 11 + }, + "end": { + "line": 223, + "column": 5 + } + } + }, + "range": [ + 6121, + 6208 + ], + "loc": { + "start": { + "line": 221, + "column": 4 + }, + "end": { + "line": 223, + "column": 6 + } + } + } + ], + "range": [ + 3926, + 6212 + ], + "loc": { + "start": { + "line": 142, + "column": 56 + }, + "end": { + "line": 224, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3906, + 6212 + ], + "loc": { + "start": { + "line": 142, + "column": 36 + }, + "end": { + "line": 224, + "column": 3 + } + } + } + ], + "range": [ + 3879, + 6213 + ], + "loc": { + "start": { + "line": 142, + "column": 9 + }, + "end": { + "line": 224, + "column": 4 + } + } + }, + "range": [ + 3872, + 6214 + ], + "loc": { + "start": { + "line": 142, + "column": 2 + }, + "end": { + "line": 224, + "column": 5 + } + } + } + ], + "range": [ + 3037, + 6216 + ], + "loc": { + "start": { + "line": 110, + "column": 34 + }, + "end": { + "line": 225, + "column": 1 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3018, + 6216 + ], + "loc": { + "start": { + "line": 110, + "column": 15 + }, + "end": { + "line": 225, + "column": 1 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n", + "range": [ + 2196, + 3002 + ], + "loc": { + "start": { + "line": 89, + "column": 0 + }, + "end": { + "line": 109, + "column": 2 + } + } + } + ], + "trailingComments": [] + }, + "range": [ + 3003, + 6216 + ], + "loc": { + "start": { + "line": 110, + "column": 0 + }, + "end": { + "line": 225, + "column": 1 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n", + "range": [ + 2196, + 3002 + ], + "loc": { + "start": { + "line": 89, + "column": 0 + }, + "end": { + "line": 109, + "column": 2 + } + } + } + ] + }, + { + "type": "EmptyStatement", + "range": [ + 6216, + 6217 + ], + "loc": { + "start": { + "line": 225, + "column": 1 + }, + "end": { + "line": 225, + "column": 2 + } + } + } + ], + "sourceType": "module", + "range": [ + 0, + 6217 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 225, + "column": 2 + } + }, + "comments": [ + { + "type": "Block", + "value": "*\n *\n * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM\n *\n * The original source file can be viewed here:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js\n *\n * Licensed under the Apache License, Version 2.0:\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Modifications from original:\n *\n * - extracted from \"Rx.DOM\" namespace\n * - minor eslinter cleanup (\"var\" to \"let\" etc)\n * - addition of \"auto\" responseType\n *\n ", + "range": [ + 22, + 592 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 23, + "column": 3 + } + } + }, + { + "type": "Line", + "value": " Gets the proper XMLHttpRequest for support for older IE", + "range": [ + 657, + 715 + ], + "loc": { + "start": { + "line": 27, + "column": 0 + }, + "end": { + "line": 27, + "column": 58 + } + } + }, + { + "type": "Line", + "value": " Get CORS support even for older IE", + "range": [ + 1274, + 1311 + ], + "loc": { + "start": { + "line": 50, + "column": 0 + }, + "end": { + "line": 50, + "column": 37 + } + } + }, + { + "type": "Block", + "value": "*\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n", + "range": [ + 2196, + 3002 + ], + "loc": { + "start": { + "line": 89, + "column": 0 + }, + "end": { + "line": 109, + "column": 2 + } + } + } + ] +} \ No newline at end of file diff --git a/docs/v0.7.0/ast/source/src/ajax-adapter.js.json b/docs/v0.7.0/ast/source/src/ajax-adapter.js.json new file mode 100644 index 0000000..fc480ac --- /dev/null +++ b/docs/v0.7.0/ast/source/src/ajax-adapter.js.json @@ -0,0 +1,15669 @@ +{ + "type": "Program", + "body": [ + { + "type": "ExportDefaultDeclaration", + "declaration": { + "type": "ClassDeclaration", + "id": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 21, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + "superClass": null, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 38, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "options", + "range": [ + 50, + 57 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 70, + 75 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "range": [ + 65, + 75 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 79, + 86 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 25 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 4, + "column": 29 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "base", + "range": [ + 98, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 37 + }, + "end": { + "line": 4, + "column": 41 + } + } + }, + "range": [ + 90, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 29 + }, + "end": { + "line": 4, + "column": 41 + } + } + }, + "range": [ + 79, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 41 + } + } + }, + "right": { + "type": "Literal", + "value": "", + "raw": "\"\"", + "range": [ + 107, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 48 + } + } + }, + "range": [ + 78, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 48 + } + } + }, + "range": [ + 65, + 109 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 48 + } + } + }, + "range": [ + 65, + 110 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 49 + } + } + } + ], + "range": [ + 59, + 114 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 49, + 114 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + "kind": "constructor", + "computed": false, + "range": [ + 38, + 114 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "create", + "range": [ + 119, + 125 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 126, + 131 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 133, + 137 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 7, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 139, + 146 + ], + "loc": { + "start": { + "line": 7, + "column": 22 + }, + "end": { + "line": 7, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 148, + 155 + ], + "loc": { + "start": { + "line": 7, + "column": 31 + }, + "end": { + "line": 7, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 157, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 40 + }, + "end": { + "line": 7, + "column": 45 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 164, + 171 + ], + "loc": { + "start": { + "line": 7, + "column": 47 + }, + "end": { + "line": 7, + "column": 54 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "error", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 193, + 195 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 196, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "range": [ + 193, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 33 + } + } + }, + "range": [ + 193, + 209 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "error", + "range": [ + 210, + 215 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 39 + } + } + } + ], + "range": [ + 193, + 216 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 221, + 240 + ], + "loc": { + "start": { + "line": 9, + "column": 45 + }, + "end": { + "line": 9, + "column": 64 + } + } + }, + "range": [ + 193, + 240 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 64 + } + } + }, + "range": [ + 184, + 240 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 251, + 255 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "create", + "range": [ + 256, + 262 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 17 + } + } + }, + "range": [ + 251, + 262 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 17 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 263, + 268 + ], + "loc": { + "start": { + "line": 11, + "column": 18 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 270, + 274 + ], + "loc": { + "start": { + "line": 11, + "column": 25 + }, + "end": { + "line": 11, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 276, + 283 + ], + "loc": { + "start": { + "line": 11, + "column": 31 + }, + "end": { + "line": 11, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 285, + 292 + ], + "loc": { + "start": { + "line": 11, + "column": 40 + }, + "end": { + "line": 11, + "column": 47 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 294, + 298 + ], + "loc": { + "start": { + "line": 11, + "column": 49 + }, + "end": { + "line": 11, + "column": 53 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 300, + 305 + ], + "loc": { + "start": { + "line": 11, + "column": 55 + }, + "end": { + "line": 11, + "column": 60 + } + } + } + ], + "range": [ + 251, + 306 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 61 + } + } + }, + "range": [ + 251, + 307 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 62 + } + } + } + ], + "range": [ + 242, + 314 + ], + "loc": { + "start": { + "line": 9, + "column": 66 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 324, + 329 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 330, + 336 + ], + "loc": { + "start": { + "line": 13, + "column": 21 + }, + "end": { + "line": 13, + "column": 27 + } + } + }, + "range": [ + 324, + 336 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 337, + 341 + ], + "loc": { + "start": { + "line": 13, + "column": 28 + }, + "end": { + "line": 13, + "column": 32 + } + } + }, + "range": [ + 324, + 342 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 33 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "request", + "range": [ + 357, + 364 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 17 + } + } + }, + "init": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "XMLHttpRequest", + "range": [ + 371, + 385 + ], + "loc": { + "start": { + "line": 15, + "column": 24 + }, + "end": { + "line": 15, + "column": 38 + } + } + }, + "arguments": [], + "range": [ + 367, + 387 + ], + "loc": { + "start": { + "line": 15, + "column": 20 + }, + "end": { + "line": 15, + "column": 40 + } + } + }, + "range": [ + 357, + 387 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 353, + 388 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 396, + 403 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 404, + 408 + ], + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "range": [ + 396, + 408 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "POST", + "raw": "'POST'", + "range": [ + 409, + 415 + ], + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 417, + 420 + ], + "loc": { + "start": { + "line": 17, + "column": 27 + }, + "end": { + "line": 17, + "column": 30 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 430, + 434 + ], + "loc": { + "start": { + "line": 17, + "column": 40 + }, + "end": { + "line": 17, + "column": 44 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 438, + 440 + ], + "loc": { + "start": { + "line": 17, + "column": 48 + }, + "end": { + "line": 17, + "column": 50 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 420, + 424 + ], + "loc": { + "start": { + "line": 17, + "column": 30 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 425, + 430 + ], + "loc": { + "start": { + "line": 17, + "column": 35 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "range": [ + 420, + 430 + ], + "loc": { + "start": { + "line": 17, + "column": 30 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 434, + 438 + ], + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 48 + } + } + } + ], + "range": [ + 417, + 440 + ], + "loc": { + "start": { + "line": 17, + "column": 27 + }, + "end": { + "line": 17, + "column": 50 + } + } + }, + { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 442, + 446 + ], + "loc": { + "start": { + "line": 17, + "column": 52 + }, + "end": { + "line": 17, + "column": 56 + } + } + } + ], + "range": [ + 396, + 447 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 57 + } + } + }, + "range": [ + 396, + 448 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 58 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 456, + 463 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "setRequestHeader", + "range": [ + 464, + 480 + ], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 30 + } + } + }, + "range": [ + 456, + 480 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Content-Type", + "raw": "\"Content-Type\"", + "range": [ + 481, + 495 + ], + "loc": { + "start": { + "line": 19, + "column": 31 + }, + "end": { + "line": 19, + "column": 45 + } + } + }, + { + "type": "Literal", + "value": "application/vnd.api+json", + "raw": "\"application/vnd.api+json\"", + "range": [ + 497, + 523 + ], + "loc": { + "start": { + "line": 19, + "column": 47 + }, + "end": { + "line": 19, + "column": 73 + } + } + } + ], + "range": [ + 456, + 524 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 74 + } + } + }, + "range": [ + 456, + 525 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 75 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 533, + 540 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "onload", + "range": [ + 541, + 547 + ], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 20 + } + } + }, + "range": [ + 533, + 547 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 20 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": ">=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 576, + 583 + ], + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 584, + 590 + ], + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 26 + } + } + }, + "range": [ + 576, + 590 + ], + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": 200, + "raw": "200", + "range": [ + 594, + 597 + ], + "loc": { + "start": { + "line": 22, + "column": 30 + }, + "end": { + "line": 22, + "column": 33 + } + } + }, + "range": [ + 576, + 597 + ], + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 33 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 601, + 608 + ], + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 609, + 615 + ], + "loc": { + "start": { + "line": 22, + "column": 45 + }, + "end": { + "line": 22, + "column": 51 + } + } + }, + "range": [ + 601, + 615 + ], + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": 300, + "raw": "300", + "range": [ + 618, + 621 + ], + "loc": { + "start": { + "line": 22, + "column": 54 + }, + "end": { + "line": 22, + "column": 57 + } + } + }, + "range": [ + 601, + 621 + ], + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 57 + } + } + }, + "range": [ + 576, + 621 + ], + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 57 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "response", + "range": [ + 639, + 647 + ], + "loc": { + "start": { + "line": 23, + "column": 14 + }, + "end": { + "line": 23, + "column": 22 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "JSON", + "range": [ + 650, + 654 + ], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "parse", + "range": [ + 655, + 660 + ], + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 35 + } + } + }, + "range": [ + 650, + 660 + ], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 661, + 668 + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "responseText", + "range": [ + 669, + 681 + ], + "loc": { + "start": { + "line": 23, + "column": 44 + }, + "end": { + "line": 23, + "column": 56 + } + } + }, + "range": [ + 661, + 681 + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 56 + } + } + } + ], + "range": [ + 650, + 682 + ], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 57 + } + } + }, + "range": [ + 639, + 682 + ], + "loc": { + "start": { + "line": 23, + "column": 14 + }, + "end": { + "line": 23, + "column": 57 + } + } + } + ], + "kind": "let", + "range": [ + 635, + 683 + ], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 58 + } + } + }, + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 712, + 717 + ], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 718, + 722 + ], + "loc": { + "start": { + "line": 25, + "column": 18 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + "range": [ + 712, + 722 + ], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "response", + "range": [ + 723, + 731 + ], + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 31 + } + } + } + ], + "range": [ + 712, + 732 + ], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 32 + } + } + }, + "range": [ + 712, + 733 + ], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 33 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "success", + "range": [ + 750, + 757 + ], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 23 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "success", + "range": [ + 775, + 782 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 783, + 787 + ], + "loc": { + "start": { + "line": 27, + "column": 22 + }, + "end": { + "line": 27, + "column": 26 + } + } + }, + "range": [ + 775, + 787 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 788, + 795 + ], + "loc": { + "start": { + "line": 27, + "column": 27 + }, + "end": { + "line": 27, + "column": 34 + } + } + }, + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 797, + 802 + ], + "loc": { + "start": { + "line": 27, + "column": 36 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 803, + 807 + ], + "loc": { + "start": { + "line": 27, + "column": 42 + }, + "end": { + "line": 27, + "column": 46 + } + } + }, + "range": [ + 797, + 807 + ], + "loc": { + "start": { + "line": 27, + "column": 36 + }, + "end": { + "line": 27, + "column": 46 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "response", + "range": [ + 808, + 816 + ], + "loc": { + "start": { + "line": 27, + "column": 47 + }, + "end": { + "line": 27, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 817, + 821 + ], + "loc": { + "start": { + "line": 27, + "column": 56 + }, + "end": { + "line": 27, + "column": 60 + } + } + }, + "range": [ + 808, + 821 + ], + "loc": { + "start": { + "line": 27, + "column": 47 + }, + "end": { + "line": 27, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 822, + 826 + ], + "loc": { + "start": { + "line": 27, + "column": 61 + }, + "end": { + "line": 27, + "column": 65 + } + } + }, + "range": [ + 808, + 826 + ], + "loc": { + "start": { + "line": 27, + "column": 47 + }, + "end": { + "line": 27, + "column": 65 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "response", + "range": [ + 828, + 836 + ], + "loc": { + "start": { + "line": 27, + "column": 67 + }, + "end": { + "line": 27, + "column": 75 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 837, + 841 + ], + "loc": { + "start": { + "line": 27, + "column": 76 + }, + "end": { + "line": 27, + "column": 80 + } + } + }, + "range": [ + 828, + 841 + ], + "loc": { + "start": { + "line": 27, + "column": 67 + }, + "end": { + "line": 27, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 842, + 844 + ], + "loc": { + "start": { + "line": 27, + "column": 81 + }, + "end": { + "line": 27, + "column": 83 + } + } + }, + "range": [ + 828, + 844 + ], + "loc": { + "start": { + "line": 27, + "column": 67 + }, + "end": { + "line": 27, + "column": 83 + } + } + } + ], + "range": [ + 797, + 845 + ], + "loc": { + "start": { + "line": 27, + "column": 36 + }, + "end": { + "line": 27, + "column": 84 + } + } + } + ], + "range": [ + 775, + 846 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 85 + } + } + }, + "range": [ + 775, + 847 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 86 + } + } + } + ], + "range": [ + 759, + 861 + ], + "loc": { + "start": { + "line": 26, + "column": 25 + }, + "end": { + "line": 28, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 746, + 861 + ], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 28, + "column": 13 + } + } + } + ], + "range": [ + 698, + 873 + ], + "loc": { + "start": { + "line": 24, + "column": 14 + }, + "end": { + "line": 29, + "column": 11 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "e", + "range": [ + 881, + 882 + ], + "loc": { + "start": { + "line": 29, + "column": 19 + }, + "end": { + "line": 29, + "column": 20 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 902, + 907 + ], + "loc": { + "start": { + "line": 30, + "column": 16 + }, + "end": { + "line": 30, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 925, + 930 + ], + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 931, + 935 + ], + "loc": { + "start": { + "line": 31, + "column": 20 + }, + "end": { + "line": 31, + "column": 24 + } + } + }, + "range": [ + 925, + 935 + ], + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 936, + 943 + ], + "loc": { + "start": { + "line": 31, + "column": 25 + }, + "end": { + "line": 31, + "column": 32 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 945, + 946 + ], + "loc": { + "start": { + "line": 31, + "column": 34 + }, + "end": { + "line": 31, + "column": 35 + } + } + } + ], + "range": [ + 925, + 947 + ], + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 36 + } + } + }, + "range": [ + 925, + 948 + ], + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 37 + } + } + } + ], + "range": [ + 909, + 962 + ], + "loc": { + "start": { + "line": 30, + "column": 23 + }, + "end": { + "line": 32, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 898, + 962 + ], + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 32, + "column": 13 + } + } + } + ], + "range": [ + 884, + 974 + ], + "loc": { + "start": { + "line": 29, + "column": 22 + }, + "end": { + "line": 33, + "column": 11 + } + } + }, + "range": [ + 874, + 974 + ], + "loc": { + "start": { + "line": 29, + "column": 12 + }, + "end": { + "line": 33, + "column": 11 + } + } + }, + "finalizer": null, + "range": [ + 694, + 974 + ], + "loc": { + "start": { + "line": 24, + "column": 10 + }, + "end": { + "line": 33, + "column": 11 + } + } + } + ], + "range": [ + 623, + 984 + ], + "loc": { + "start": { + "line": 22, + "column": 59 + }, + "end": { + "line": 34, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 1006, + 1011 + ], + "loc": { + "start": { + "line": 35, + "column": 14 + }, + "end": { + "line": 35, + "column": 19 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 1027, + 1032 + ], + "loc": { + "start": { + "line": 36, + "column": 12 + }, + "end": { + "line": 36, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 1033, + 1037 + ], + "loc": { + "start": { + "line": 36, + "column": 18 + }, + "end": { + "line": 36, + "column": 22 + } + } + }, + "range": [ + 1027, + 1037 + ], + "loc": { + "start": { + "line": 36, + "column": 12 + }, + "end": { + "line": 36, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 1038, + 1045 + ], + "loc": { + "start": { + "line": 36, + "column": 23 + }, + "end": { + "line": 36, + "column": 30 + } + } + } + ], + "range": [ + 1027, + 1046 + ], + "loc": { + "start": { + "line": 36, + "column": 12 + }, + "end": { + "line": 36, + "column": 31 + } + } + }, + "range": [ + 1027, + 1047 + ], + "loc": { + "start": { + "line": 36, + "column": 12 + }, + "end": { + "line": 36, + "column": 32 + } + } + } + ], + "range": [ + 1013, + 1059 + ], + "loc": { + "start": { + "line": 35, + "column": 21 + }, + "end": { + "line": 37, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 1002, + 1059 + ], + "loc": { + "start": { + "line": 35, + "column": 10 + }, + "end": { + "line": 37, + "column": 11 + } + } + } + ], + "range": [ + 990, + 1069 + ], + "loc": { + "start": { + "line": 34, + "column": 15 + }, + "end": { + "line": 38, + "column": 9 + } + } + }, + "range": [ + 572, + 1069 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 38, + "column": 9 + } + } + } + ], + "range": [ + 562, + 1077 + ], + "loc": { + "start": { + "line": 21, + "column": 35 + }, + "end": { + "line": 39, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 550, + 1077 + ], + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 39, + "column": 7 + } + } + }, + "range": [ + 533, + 1077 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 39, + "column": 7 + } + } + }, + "range": [ + 533, + 1078 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 39, + "column": 8 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1086, + 1093 + ], + "loc": { + "start": { + "line": 41, + "column": 6 + }, + "end": { + "line": 41, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "send", + "range": [ + 1094, + 1098 + ], + "loc": { + "start": { + "line": 41, + "column": 14 + }, + "end": { + "line": 41, + "column": 18 + } + } + }, + "range": [ + 1086, + 1098 + ], + "loc": { + "start": { + "line": 41, + "column": 6 + }, + "end": { + "line": 41, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "JSON", + "range": [ + 1099, + 1103 + ], + "loc": { + "start": { + "line": 41, + "column": 19 + }, + "end": { + "line": 41, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "stringify", + "range": [ + 1104, + 1113 + ], + "loc": { + "start": { + "line": 41, + "column": 24 + }, + "end": { + "line": 41, + "column": 33 + } + } + }, + "range": [ + 1099, + 1113 + ], + "loc": { + "start": { + "line": 41, + "column": 19 + }, + "end": { + "line": 41, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 1124, + 1128 + ], + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 12 + } + } + }, + "value": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 1130, + 1135 + ], + "loc": { + "start": { + "line": 42, + "column": 14 + }, + "end": { + "line": 42, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 1136, + 1143 + ], + "loc": { + "start": { + "line": 42, + "column": 20 + }, + "end": { + "line": 42, + "column": 27 + } + } + }, + "range": [ + 1130, + 1143 + ], + "loc": { + "start": { + "line": 42, + "column": 14 + }, + "end": { + "line": 42, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 1144, + 1148 + ], + "loc": { + "start": { + "line": 42, + "column": 28 + }, + "end": { + "line": 42, + "column": 32 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 1150, + 1157 + ], + "loc": { + "start": { + "line": 42, + "column": 34 + }, + "end": { + "line": 42, + "column": 41 + } + } + } + ], + "range": [ + 1130, + 1158 + ], + "loc": { + "start": { + "line": 42, + "column": 14 + }, + "end": { + "line": 42, + "column": 42 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1124, + 1158 + ], + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 42 + } + } + } + ], + "range": [ + 1114, + 1166 + ], + "loc": { + "start": { + "line": 41, + "column": 34 + }, + "end": { + "line": 43, + "column": 7 + } + } + } + ], + "range": [ + 1099, + 1167 + ], + "loc": { + "start": { + "line": 41, + "column": 19 + }, + "end": { + "line": 43, + "column": 8 + } + } + } + ], + "range": [ + 1086, + 1168 + ], + "loc": { + "start": { + "line": 41, + "column": 6 + }, + "end": { + "line": 43, + "column": 9 + } + } + }, + "range": [ + 1086, + 1169 + ], + "loc": { + "start": { + "line": 41, + "column": 6 + }, + "end": { + "line": 43, + "column": 10 + } + } + } + ], + "range": [ + 344, + 1176 + ], + "loc": { + "start": { + "line": 13, + "column": 35 + }, + "end": { + "line": 45, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 1200, + 1205 + ], + "loc": { + "start": { + "line": 46, + "column": 16 + }, + "end": { + "line": 46, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 1206, + 1223 + ], + "loc": { + "start": { + "line": 46, + "column": 22 + }, + "end": { + "line": 46, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 1227, + 1230 + ], + "loc": { + "start": { + "line": 46, + "column": 43 + }, + "end": { + "line": 46, + "column": 46 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 1223, + 1227 + ], + "loc": { + "start": { + "line": 46, + "column": 39 + }, + "end": { + "line": 46, + "column": 43 + } + } + } + ], + "range": [ + 1206, + 1230 + ], + "loc": { + "start": { + "line": 46, + "column": 22 + }, + "end": { + "line": 46, + "column": 46 + } + } + } + ], + "range": [ + 1196, + 1231 + ], + "loc": { + "start": { + "line": 46, + "column": 12 + }, + "end": { + "line": 46, + "column": 47 + } + } + }, + "range": [ + 1190, + 1232 + ], + "loc": { + "start": { + "line": 46, + "column": 6 + }, + "end": { + "line": 46, + "column": 48 + } + } + } + ], + "range": [ + 1182, + 1238 + ], + "loc": { + "start": { + "line": 45, + "column": 11 + }, + "end": { + "line": 47, + "column": 5 + } + } + }, + "range": [ + 320, + 1238 + ], + "loc": { + "start": { + "line": 13, + "column": 11 + }, + "end": { + "line": 47, + "column": 5 + } + } + }, + "range": [ + 180, + 1238 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 47, + "column": 5 + } + } + } + ], + "range": [ + 173, + 1243 + ], + "loc": { + "start": { + "line": 7, + "column": 56 + }, + "end": { + "line": 49, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 125, + 1243 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 49, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 119, + 1243 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 49, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "destroy", + "range": [ + 1247, + 1254 + ], + "loc": { + "start": { + "line": 51, + "column": 2 + }, + "end": { + "line": 51, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 1255, + 1260 + ], + "loc": { + "start": { + "line": 51, + "column": 10 + }, + "end": { + "line": 51, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 1262, + 1266 + ], + "loc": { + "start": { + "line": 51, + "column": 17 + }, + "end": { + "line": 51, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 1268, + 1270 + ], + "loc": { + "start": { + "line": 51, + "column": 23 + }, + "end": { + "line": 51, + "column": 25 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 1272, + 1279 + ], + "loc": { + "start": { + "line": 51, + "column": 27 + }, + "end": { + "line": 51, + "column": 34 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 1281, + 1286 + ], + "loc": { + "start": { + "line": 51, + "column": 36 + }, + "end": { + "line": 51, + "column": 41 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 1288, + 1295 + ], + "loc": { + "start": { + "line": 51, + "column": 43 + }, + "end": { + "line": 51, + "column": 50 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "error", + "range": [ + 1308, + 1313 + ], + "loc": { + "start": { + "line": 53, + "column": 8 + }, + "end": { + "line": 53, + "column": 13 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 1317, + 1319 + ], + "loc": { + "start": { + "line": 53, + "column": 17 + }, + "end": { + "line": 53, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 1320, + 1328 + ], + "loc": { + "start": { + "line": 53, + "column": 20 + }, + "end": { + "line": 53, + "column": 28 + } + } + }, + "range": [ + 1317, + 1328 + ], + "loc": { + "start": { + "line": 53, + "column": 17 + }, + "end": { + "line": 53, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 1329, + 1333 + ], + "loc": { + "start": { + "line": 53, + "column": 29 + }, + "end": { + "line": 53, + "column": 33 + } + } + }, + "range": [ + 1317, + 1333 + ], + "loc": { + "start": { + "line": 53, + "column": 17 + }, + "end": { + "line": 53, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "error", + "range": [ + 1334, + 1339 + ], + "loc": { + "start": { + "line": 53, + "column": 34 + }, + "end": { + "line": 53, + "column": 39 + } + } + } + ], + "range": [ + 1317, + 1340 + ], + "loc": { + "start": { + "line": 53, + "column": 17 + }, + "end": { + "line": 53, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 1345, + 1364 + ], + "loc": { + "start": { + "line": 53, + "column": 45 + }, + "end": { + "line": 53, + "column": 64 + } + } + }, + "range": [ + 1317, + 1364 + ], + "loc": { + "start": { + "line": 53, + "column": 17 + }, + "end": { + "line": 53, + "column": 64 + } + } + }, + "range": [ + 1308, + 1364 + ], + "loc": { + "start": { + "line": 53, + "column": 8 + }, + "end": { + "line": 53, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 1375, + 1379 + ], + "loc": { + "start": { + "line": 55, + "column": 6 + }, + "end": { + "line": 55, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "destroy", + "range": [ + 1380, + 1387 + ], + "loc": { + "start": { + "line": 55, + "column": 11 + }, + "end": { + "line": 55, + "column": 18 + } + } + }, + "range": [ + 1375, + 1387 + ], + "loc": { + "start": { + "line": 55, + "column": 6 + }, + "end": { + "line": 55, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 1388, + 1393 + ], + "loc": { + "start": { + "line": 55, + "column": 19 + }, + "end": { + "line": 55, + "column": 24 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 1395, + 1399 + ], + "loc": { + "start": { + "line": 55, + "column": 26 + }, + "end": { + "line": 55, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 1401, + 1403 + ], + "loc": { + "start": { + "line": 55, + "column": 32 + }, + "end": { + "line": 55, + "column": 34 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 1405, + 1412 + ], + "loc": { + "start": { + "line": 55, + "column": 36 + }, + "end": { + "line": 55, + "column": 43 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1414, + 1418 + ], + "loc": { + "start": { + "line": 55, + "column": 45 + }, + "end": { + "line": 55, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 1420, + 1425 + ], + "loc": { + "start": { + "line": 55, + "column": 51 + }, + "end": { + "line": 55, + "column": 56 + } + } + } + ], + "range": [ + 1375, + 1426 + ], + "loc": { + "start": { + "line": 55, + "column": 6 + }, + "end": { + "line": 55, + "column": 57 + } + } + }, + "range": [ + 1375, + 1427 + ], + "loc": { + "start": { + "line": 55, + "column": 6 + }, + "end": { + "line": 55, + "column": 58 + } + } + } + ], + "range": [ + 1366, + 1434 + ], + "loc": { + "start": { + "line": 53, + "column": 66 + }, + "end": { + "line": 57, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 1444, + 1449 + ], + "loc": { + "start": { + "line": 57, + "column": 15 + }, + "end": { + "line": 57, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 1450, + 1456 + ], + "loc": { + "start": { + "line": 57, + "column": 21 + }, + "end": { + "line": 57, + "column": 27 + } + } + }, + "range": [ + 1444, + 1456 + ], + "loc": { + "start": { + "line": 57, + "column": 15 + }, + "end": { + "line": 57, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 1457, + 1461 + ], + "loc": { + "start": { + "line": 57, + "column": 28 + }, + "end": { + "line": 57, + "column": 32 + } + } + }, + "range": [ + 1444, + 1462 + ], + "loc": { + "start": { + "line": 57, + "column": 15 + }, + "end": { + "line": 57, + "column": 33 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "request", + "range": [ + 1477, + 1484 + ], + "loc": { + "start": { + "line": 59, + "column": 10 + }, + "end": { + "line": 59, + "column": 17 + } + } + }, + "init": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "XMLHttpRequest", + "range": [ + 1491, + 1505 + ], + "loc": { + "start": { + "line": 59, + "column": 24 + }, + "end": { + "line": 59, + "column": 38 + } + } + }, + "arguments": [], + "range": [ + 1487, + 1507 + ], + "loc": { + "start": { + "line": 59, + "column": 20 + }, + "end": { + "line": 59, + "column": 40 + } + } + }, + "range": [ + 1477, + 1507 + ], + "loc": { + "start": { + "line": 59, + "column": 10 + }, + "end": { + "line": 59, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 1473, + 1508 + ], + "loc": { + "start": { + "line": 59, + "column": 6 + }, + "end": { + "line": 59, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1516, + 1523 + ], + "loc": { + "start": { + "line": 61, + "column": 6 + }, + "end": { + "line": 61, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 1524, + 1528 + ], + "loc": { + "start": { + "line": 61, + "column": 14 + }, + "end": { + "line": 61, + "column": 18 + } + } + }, + "range": [ + 1516, + 1528 + ], + "loc": { + "start": { + "line": 61, + "column": 6 + }, + "end": { + "line": 61, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "DELETE", + "raw": "'DELETE'", + "range": [ + 1529, + 1537 + ], + "loc": { + "start": { + "line": 61, + "column": 19 + }, + "end": { + "line": 61, + "column": 27 + } + } + }, + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 1539, + 1542 + ], + "loc": { + "start": { + "line": 61, + "column": 29 + }, + "end": { + "line": 61, + "column": 32 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 1552, + 1556 + ], + "loc": { + "start": { + "line": 61, + "column": 42 + }, + "end": { + "line": 61, + "column": 46 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 1560, + 1564 + ], + "loc": { + "start": { + "line": 61, + "column": 50 + }, + "end": { + "line": 61, + "column": 54 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 1566, + 1568 + ], + "loc": { + "start": { + "line": 61, + "column": 56 + }, + "end": { + "line": 61, + "column": 58 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 1542, + 1546 + ], + "loc": { + "start": { + "line": 61, + "column": 32 + }, + "end": { + "line": 61, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 1547, + 1552 + ], + "loc": { + "start": { + "line": 61, + "column": 37 + }, + "end": { + "line": 61, + "column": 42 + } + } + }, + "range": [ + 1542, + 1552 + ], + "loc": { + "start": { + "line": 61, + "column": 32 + }, + "end": { + "line": 61, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 1556, + 1560 + ], + "loc": { + "start": { + "line": 61, + "column": 46 + }, + "end": { + "line": 61, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 1564, + 1566 + ], + "loc": { + "start": { + "line": 61, + "column": 54 + }, + "end": { + "line": 61, + "column": 56 + } + } + } + ], + "range": [ + 1539, + 1568 + ], + "loc": { + "start": { + "line": 61, + "column": 29 + }, + "end": { + "line": 61, + "column": 58 + } + } + }, + { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 1570, + 1574 + ], + "loc": { + "start": { + "line": 61, + "column": 60 + }, + "end": { + "line": 61, + "column": 64 + } + } + } + ], + "range": [ + 1516, + 1575 + ], + "loc": { + "start": { + "line": 61, + "column": 6 + }, + "end": { + "line": 61, + "column": 65 + } + } + }, + "range": [ + 1516, + 1576 + ], + "loc": { + "start": { + "line": 61, + "column": 6 + }, + "end": { + "line": 61, + "column": 66 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1584, + 1591 + ], + "loc": { + "start": { + "line": 63, + "column": 6 + }, + "end": { + "line": 63, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "setRequestHeader", + "range": [ + 1592, + 1608 + ], + "loc": { + "start": { + "line": 63, + "column": 14 + }, + "end": { + "line": 63, + "column": 30 + } + } + }, + "range": [ + 1584, + 1608 + ], + "loc": { + "start": { + "line": 63, + "column": 6 + }, + "end": { + "line": 63, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Content-Type", + "raw": "\"Content-Type\"", + "range": [ + 1609, + 1623 + ], + "loc": { + "start": { + "line": 63, + "column": 31 + }, + "end": { + "line": 63, + "column": 45 + } + } + }, + { + "type": "Literal", + "value": "application/vnd.api+json", + "raw": "\"application/vnd.api+json\"", + "range": [ + 1625, + 1651 + ], + "loc": { + "start": { + "line": 63, + "column": 47 + }, + "end": { + "line": 63, + "column": 73 + } + } + } + ], + "range": [ + 1584, + 1652 + ], + "loc": { + "start": { + "line": 63, + "column": 6 + }, + "end": { + "line": 63, + "column": 74 + } + } + }, + "range": [ + 1584, + 1653 + ], + "loc": { + "start": { + "line": 63, + "column": 6 + }, + "end": { + "line": 63, + "column": 75 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1661, + 1668 + ], + "loc": { + "start": { + "line": 65, + "column": 6 + }, + "end": { + "line": 65, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "onload", + "range": [ + 1669, + 1675 + ], + "loc": { + "start": { + "line": 65, + "column": 14 + }, + "end": { + "line": 65, + "column": 20 + } + } + }, + "range": [ + 1661, + 1675 + ], + "loc": { + "start": { + "line": 65, + "column": 6 + }, + "end": { + "line": 65, + "column": 20 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": ">=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1704, + 1711 + ], + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 66, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 1712, + 1718 + ], + "loc": { + "start": { + "line": 66, + "column": 20 + }, + "end": { + "line": 66, + "column": 26 + } + } + }, + "range": [ + 1704, + 1718 + ], + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 66, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": 200, + "raw": "200", + "range": [ + 1722, + 1725 + ], + "loc": { + "start": { + "line": 66, + "column": 30 + }, + "end": { + "line": 66, + "column": 33 + } + } + }, + "range": [ + 1704, + 1725 + ], + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 66, + "column": 33 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 1729, + 1736 + ], + "loc": { + "start": { + "line": 66, + "column": 37 + }, + "end": { + "line": 66, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 1737, + 1743 + ], + "loc": { + "start": { + "line": 66, + "column": 45 + }, + "end": { + "line": 66, + "column": 51 + } + } + }, + "range": [ + 1729, + 1743 + ], + "loc": { + "start": { + "line": 66, + "column": 37 + }, + "end": { + "line": 66, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": 300, + "raw": "300", + "range": [ + 1746, + 1749 + ], + "loc": { + "start": { + "line": 66, + "column": 54 + }, + "end": { + "line": 66, + "column": 57 + } + } + }, + "range": [ + 1729, + 1749 + ], + "loc": { + "start": { + "line": 66, + "column": 37 + }, + "end": { + "line": 66, + "column": 57 + } + } + }, + "range": [ + 1704, + 1749 + ], + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 66, + "column": 57 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 1781, + 1786 + ], + "loc": { + "start": { + "line": 68, + "column": 12 + }, + "end": { + "line": 68, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "remove", + "range": [ + 1787, + 1793 + ], + "loc": { + "start": { + "line": 68, + "column": 18 + }, + "end": { + "line": 68, + "column": 24 + } + } + }, + "range": [ + 1781, + 1793 + ], + "loc": { + "start": { + "line": 68, + "column": 12 + }, + "end": { + "line": 68, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 1794, + 1798 + ], + "loc": { + "start": { + "line": 68, + "column": 25 + }, + "end": { + "line": 68, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 1800, + 1802 + ], + "loc": { + "start": { + "line": 68, + "column": 31 + }, + "end": { + "line": 68, + "column": 33 + } + } + } + ], + "range": [ + 1781, + 1803 + ], + "loc": { + "start": { + "line": 68, + "column": 12 + }, + "end": { + "line": 68, + "column": 34 + } + } + }, + "range": [ + 1781, + 1804 + ], + "loc": { + "start": { + "line": 68, + "column": 12 + }, + "end": { + "line": 68, + "column": 35 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "success", + "range": [ + 1821, + 1828 + ], + "loc": { + "start": { + "line": 69, + "column": 16 + }, + "end": { + "line": 69, + "column": 23 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "success", + "range": [ + 1846, + 1853 + ], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 1854, + 1858 + ], + "loc": { + "start": { + "line": 70, + "column": 22 + }, + "end": { + "line": 70, + "column": 26 + } + } + }, + "range": [ + 1846, + 1858 + ], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 1859, + 1866 + ], + "loc": { + "start": { + "line": 70, + "column": 27 + }, + "end": { + "line": 70, + "column": 34 + } + } + } + ], + "range": [ + 1846, + 1867 + ], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 35 + } + } + }, + "range": [ + 1846, + 1868 + ], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 36 + } + } + } + ], + "range": [ + 1830, + 1882 + ], + "loc": { + "start": { + "line": 69, + "column": 25 + }, + "end": { + "line": 71, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 1817, + 1882 + ], + "loc": { + "start": { + "line": 69, + "column": 12 + }, + "end": { + "line": 71, + "column": 13 + } + } + } + ], + "range": [ + 1767, + 1894 + ], + "loc": { + "start": { + "line": 67, + "column": 14 + }, + "end": { + "line": 72, + "column": 11 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "e", + "range": [ + 1902, + 1903 + ], + "loc": { + "start": { + "line": 72, + "column": 19 + }, + "end": { + "line": 72, + "column": 20 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 1919, + 1924 + ], + "loc": { + "start": { + "line": 73, + "column": 12 + }, + "end": { + "line": 73, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 1925, + 1929 + ], + "loc": { + "start": { + "line": 73, + "column": 18 + }, + "end": { + "line": 73, + "column": 22 + } + } + }, + "range": [ + 1919, + 1929 + ], + "loc": { + "start": { + "line": 73, + "column": 12 + }, + "end": { + "line": 73, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 1930, + 1937 + ], + "loc": { + "start": { + "line": 73, + "column": 23 + }, + "end": { + "line": 73, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 1939, + 1940 + ], + "loc": { + "start": { + "line": 73, + "column": 32 + }, + "end": { + "line": 73, + "column": 33 + } + } + } + ], + "range": [ + 1919, + 1941 + ], + "loc": { + "start": { + "line": 73, + "column": 12 + }, + "end": { + "line": 73, + "column": 34 + } + } + }, + "range": [ + 1919, + 1942 + ], + "loc": { + "start": { + "line": 73, + "column": 12 + }, + "end": { + "line": 73, + "column": 35 + } + } + } + ], + "range": [ + 1905, + 1954 + ], + "loc": { + "start": { + "line": 72, + "column": 22 + }, + "end": { + "line": 74, + "column": 11 + } + } + }, + "range": [ + 1895, + 1954 + ], + "loc": { + "start": { + "line": 72, + "column": 12 + }, + "end": { + "line": 74, + "column": 11 + } + } + }, + "finalizer": null, + "range": [ + 1763, + 1954 + ], + "loc": { + "start": { + "line": 67, + "column": 10 + }, + "end": { + "line": 74, + "column": 11 + } + } + } + ], + "range": [ + 1751, + 1964 + ], + "loc": { + "start": { + "line": 66, + "column": 59 + }, + "end": { + "line": 75, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 1974, + 1979 + ], + "loc": { + "start": { + "line": 75, + "column": 19 + }, + "end": { + "line": 75, + "column": 24 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 1993, + 1998 + ], + "loc": { + "start": { + "line": 76, + "column": 10 + }, + "end": { + "line": 76, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 1999, + 2003 + ], + "loc": { + "start": { + "line": 76, + "column": 16 + }, + "end": { + "line": 76, + "column": 20 + } + } + }, + "range": [ + 1993, + 2003 + ], + "loc": { + "start": { + "line": 76, + "column": 10 + }, + "end": { + "line": 76, + "column": 20 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 2004, + 2011 + ], + "loc": { + "start": { + "line": 76, + "column": 21 + }, + "end": { + "line": 76, + "column": 28 + } + } + } + ], + "range": [ + 1993, + 2012 + ], + "loc": { + "start": { + "line": 76, + "column": 10 + }, + "end": { + "line": 76, + "column": 29 + } + } + }, + "range": [ + 1993, + 2013 + ], + "loc": { + "start": { + "line": 76, + "column": 10 + }, + "end": { + "line": 76, + "column": 30 + } + } + } + ], + "range": [ + 1981, + 2023 + ], + "loc": { + "start": { + "line": 75, + "column": 26 + }, + "end": { + "line": 77, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 1970, + 2023 + ], + "loc": { + "start": { + "line": 75, + "column": 15 + }, + "end": { + "line": 77, + "column": 9 + } + } + }, + "range": [ + 1700, + 2023 + ], + "loc": { + "start": { + "line": 66, + "column": 8 + }, + "end": { + "line": 77, + "column": 9 + } + } + } + ], + "range": [ + 1690, + 2031 + ], + "loc": { + "start": { + "line": 65, + "column": 35 + }, + "end": { + "line": 78, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1678, + 2031 + ], + "loc": { + "start": { + "line": 65, + "column": 23 + }, + "end": { + "line": 78, + "column": 7 + } + } + }, + "range": [ + 1661, + 2031 + ], + "loc": { + "start": { + "line": 65, + "column": 6 + }, + "end": { + "line": 78, + "column": 7 + } + } + }, + "range": [ + 1661, + 2032 + ], + "loc": { + "start": { + "line": 65, + "column": 6 + }, + "end": { + "line": 78, + "column": 8 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 2040, + 2047 + ], + "loc": { + "start": { + "line": 80, + "column": 6 + }, + "end": { + "line": 80, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "send", + "range": [ + 2048, + 2052 + ], + "loc": { + "start": { + "line": 80, + "column": 14 + }, + "end": { + "line": 80, + "column": 18 + } + } + }, + "range": [ + 2040, + 2052 + ], + "loc": { + "start": { + "line": 80, + "column": 6 + }, + "end": { + "line": 80, + "column": 18 + } + } + }, + "arguments": [], + "range": [ + 2040, + 2054 + ], + "loc": { + "start": { + "line": 80, + "column": 6 + }, + "end": { + "line": 80, + "column": 20 + } + } + }, + "range": [ + 2040, + 2055 + ], + "loc": { + "start": { + "line": 80, + "column": 6 + }, + "end": { + "line": 80, + "column": 21 + } + } + } + ], + "range": [ + 1464, + 2062 + ], + "loc": { + "start": { + "line": 57, + "column": 35 + }, + "end": { + "line": 82, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 2086, + 2091 + ], + "loc": { + "start": { + "line": 83, + "column": 16 + }, + "end": { + "line": 83, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 2092, + 2109 + ], + "loc": { + "start": { + "line": 83, + "column": 22 + }, + "end": { + "line": 83, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 2113, + 2116 + ], + "loc": { + "start": { + "line": 83, + "column": 43 + }, + "end": { + "line": 83, + "column": 46 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 2109, + 2113 + ], + "loc": { + "start": { + "line": 83, + "column": 39 + }, + "end": { + "line": 83, + "column": 43 + } + } + } + ], + "range": [ + 2092, + 2116 + ], + "loc": { + "start": { + "line": 83, + "column": 22 + }, + "end": { + "line": 83, + "column": 46 + } + } + } + ], + "range": [ + 2082, + 2117 + ], + "loc": { + "start": { + "line": 83, + "column": 12 + }, + "end": { + "line": 83, + "column": 47 + } + } + }, + "range": [ + 2076, + 2118 + ], + "loc": { + "start": { + "line": 83, + "column": 6 + }, + "end": { + "line": 83, + "column": 48 + } + } + } + ], + "range": [ + 2068, + 2124 + ], + "loc": { + "start": { + "line": 82, + "column": 11 + }, + "end": { + "line": 84, + "column": 5 + } + } + }, + "range": [ + 1440, + 2124 + ], + "loc": { + "start": { + "line": 57, + "column": 11 + }, + "end": { + "line": 84, + "column": 5 + } + } + }, + "range": [ + 1304, + 2124 + ], + "loc": { + "start": { + "line": 53, + "column": 4 + }, + "end": { + "line": 84, + "column": 5 + } + } + } + ], + "range": [ + 1297, + 2129 + ], + "loc": { + "start": { + "line": 51, + "column": 52 + }, + "end": { + "line": 86, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1254, + 2129 + ], + "loc": { + "start": { + "line": 51, + "column": 9 + }, + "end": { + "line": 86, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 1247, + 2129 + ], + "loc": { + "start": { + "line": 51, + "column": 2 + }, + "end": { + "line": 86, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "load", + "range": [ + 2133, + 2137 + ], + "loc": { + "start": { + "line": 88, + "column": 2 + }, + "end": { + "line": 88, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 2138, + 2143 + ], + "loc": { + "start": { + "line": 88, + "column": 7 + }, + "end": { + "line": 88, + "column": 12 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2145, + 2149 + ], + "loc": { + "start": { + "line": 88, + "column": 14 + }, + "end": { + "line": 88, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2151, + 2153 + ], + "loc": { + "start": { + "line": 88, + "column": 20 + }, + "end": { + "line": 88, + "column": 22 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2155, + 2162 + ], + "loc": { + "start": { + "line": 88, + "column": 24 + }, + "end": { + "line": 88, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 2164, + 2171 + ], + "loc": { + "start": { + "line": 88, + "column": 33 + }, + "end": { + "line": 88, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 2173, + 2178 + ], + "loc": { + "start": { + "line": 88, + "column": 42 + }, + "end": { + "line": 88, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 2180, + 2187 + ], + "loc": { + "start": { + "line": 88, + "column": 49 + }, + "end": { + "line": 88, + "column": 56 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 2200, + 2202 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 10 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 2206, + 2208 + ], + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 2209, + 2217 + ], + "loc": { + "start": { + "line": 90, + "column": 17 + }, + "end": { + "line": 90, + "column": 25 + } + } + }, + "range": [ + 2206, + 2217 + ], + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 2218, + 2222 + ], + "loc": { + "start": { + "line": 90, + "column": 26 + }, + "end": { + "line": 90, + "column": 30 + } + } + }, + "range": [ + 2206, + 2222 + ], + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 2223, + 2225 + ], + "loc": { + "start": { + "line": 90, + "column": 31 + }, + "end": { + "line": 90, + "column": 33 + } + } + } + ], + "range": [ + 2206, + 2226 + ], + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 34 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 2231, + 2250 + ], + "loc": { + "start": { + "line": 90, + "column": 39 + }, + "end": { + "line": 90, + "column": 58 + } + } + }, + "range": [ + 2206, + 2250 + ], + "loc": { + "start": { + "line": 90, + "column": 14 + }, + "end": { + "line": 90, + "column": 58 + } + } + }, + "range": [ + 2200, + 2250 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 58 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2260, + 2264 + ], + "loc": { + "start": { + "line": 91, + "column": 6 + }, + "end": { + "line": 91, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 2265, + 2269 + ], + "loc": { + "start": { + "line": 91, + "column": 11 + }, + "end": { + "line": 91, + "column": 15 + } + } + }, + "range": [ + 2260, + 2269 + ], + "loc": { + "start": { + "line": 91, + "column": 6 + }, + "end": { + "line": 91, + "column": 15 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 2270, + 2275 + ], + "loc": { + "start": { + "line": 91, + "column": 16 + }, + "end": { + "line": 91, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2277, + 2281 + ], + "loc": { + "start": { + "line": 91, + "column": 23 + }, + "end": { + "line": 91, + "column": 27 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2283, + 2287 + ], + "loc": { + "start": { + "line": 91, + "column": 29 + }, + "end": { + "line": 91, + "column": 33 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2289, + 2293 + ], + "loc": { + "start": { + "line": 91, + "column": 35 + }, + "end": { + "line": 91, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2295, + 2297 + ], + "loc": { + "start": { + "line": 91, + "column": 41 + }, + "end": { + "line": 91, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2299, + 2306 + ], + "loc": { + "start": { + "line": 91, + "column": 45 + }, + "end": { + "line": 91, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 2308, + 2315 + ], + "loc": { + "start": { + "line": 91, + "column": 54 + }, + "end": { + "line": 91, + "column": 61 + } + } + } + ], + "range": [ + 2260, + 2316 + ], + "loc": { + "start": { + "line": 91, + "column": 6 + }, + "end": { + "line": 91, + "column": 62 + } + } + }, + "range": [ + 2260, + 2317 + ], + "loc": { + "start": { + "line": 91, + "column": 6 + }, + "end": { + "line": 91, + "column": 63 + } + } + } + ], + "range": [ + 2252, + 2323 + ], + "loc": { + "start": { + "line": 90, + "column": 60 + }, + "end": { + "line": 92, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 2333, + 2335 + ], + "loc": { + "start": { + "line": 92, + "column": 15 + }, + "end": { + "line": 92, + "column": 17 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "id", + "range": [ + 2346, + 2348 + ], + "loc": { + "start": { + "line": 92, + "column": 28 + }, + "end": { + "line": 92, + "column": 30 + } + } + }, + "prefix": true, + "range": [ + 2339, + 2348 + ], + "loc": { + "start": { + "line": 92, + "column": 21 + }, + "end": { + "line": 92, + "column": 30 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 2353, + 2361 + ], + "loc": { + "start": { + "line": 92, + "column": 35 + }, + "end": { + "line": 92, + "column": 43 + } + } + }, + "range": [ + 2339, + 2361 + ], + "loc": { + "start": { + "line": 92, + "column": 21 + }, + "end": { + "line": 92, + "column": 43 + } + } + }, + "range": [ + 2333, + 2361 + ], + "loc": { + "start": { + "line": 92, + "column": 15 + }, + "end": { + "line": 92, + "column": 43 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2371, + 2375 + ], + "loc": { + "start": { + "line": 93, + "column": 6 + }, + "end": { + "line": 93, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 2376, + 2380 + ], + "loc": { + "start": { + "line": 93, + "column": 11 + }, + "end": { + "line": 93, + "column": 15 + } + } + }, + "range": [ + 2371, + 2380 + ], + "loc": { + "start": { + "line": 93, + "column": 6 + }, + "end": { + "line": 93, + "column": 15 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 2381, + 2386 + ], + "loc": { + "start": { + "line": 93, + "column": 16 + }, + "end": { + "line": 93, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2388, + 2392 + ], + "loc": { + "start": { + "line": 93, + "column": 23 + }, + "end": { + "line": 93, + "column": 27 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2394, + 2398 + ], + "loc": { + "start": { + "line": 93, + "column": 29 + }, + "end": { + "line": 93, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2400, + 2402 + ], + "loc": { + "start": { + "line": 93, + "column": 35 + }, + "end": { + "line": 93, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2404, + 2411 + ], + "loc": { + "start": { + "line": 93, + "column": 39 + }, + "end": { + "line": 93, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 2413, + 2420 + ], + "loc": { + "start": { + "line": 93, + "column": 48 + }, + "end": { + "line": 93, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 2422, + 2427 + ], + "loc": { + "start": { + "line": 93, + "column": 57 + }, + "end": { + "line": 93, + "column": 62 + } + } + } + ], + "range": [ + 2371, + 2428 + ], + "loc": { + "start": { + "line": 93, + "column": 6 + }, + "end": { + "line": 93, + "column": 63 + } + } + }, + "range": [ + 2371, + 2429 + ], + "loc": { + "start": { + "line": 93, + "column": 6 + }, + "end": { + "line": 93, + "column": 64 + } + } + } + ], + "range": [ + 2363, + 2435 + ], + "loc": { + "start": { + "line": 92, + "column": 45 + }, + "end": { + "line": 94, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 2445, + 2452 + ], + "loc": { + "start": { + "line": 94, + "column": 15 + }, + "end": { + "line": 94, + "column": 22 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 2456, + 2458 + ], + "loc": { + "start": { + "line": 94, + "column": 26 + }, + "end": { + "line": 94, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 2459, + 2467 + ], + "loc": { + "start": { + "line": 94, + "column": 29 + }, + "end": { + "line": 94, + "column": 37 + } + } + }, + "range": [ + 2456, + 2467 + ], + "loc": { + "start": { + "line": 94, + "column": 26 + }, + "end": { + "line": 94, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 2468, + 2472 + ], + "loc": { + "start": { + "line": 94, + "column": 38 + }, + "end": { + "line": 94, + "column": 42 + } + } + }, + "range": [ + 2456, + 2472 + ], + "loc": { + "start": { + "line": 94, + "column": 26 + }, + "end": { + "line": 94, + "column": 42 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "options", + "range": [ + 2473, + 2480 + ], + "loc": { + "start": { + "line": 94, + "column": 43 + }, + "end": { + "line": 94, + "column": 50 + } + } + } + ], + "range": [ + 2456, + 2481 + ], + "loc": { + "start": { + "line": 94, + "column": 26 + }, + "end": { + "line": 94, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 2486, + 2505 + ], + "loc": { + "start": { + "line": 94, + "column": 56 + }, + "end": { + "line": 94, + "column": 75 + } + } + }, + "range": [ + 2456, + 2505 + ], + "loc": { + "start": { + "line": 94, + "column": 26 + }, + "end": { + "line": 94, + "column": 75 + } + } + }, + "range": [ + 2445, + 2505 + ], + "loc": { + "start": { + "line": 94, + "column": 15 + }, + "end": { + "line": 94, + "column": 75 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2515, + 2519 + ], + "loc": { + "start": { + "line": 95, + "column": 6 + }, + "end": { + "line": 95, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 2520, + 2524 + ], + "loc": { + "start": { + "line": 95, + "column": 11 + }, + "end": { + "line": 95, + "column": 15 + } + } + }, + "range": [ + 2515, + 2524 + ], + "loc": { + "start": { + "line": 95, + "column": 6 + }, + "end": { + "line": 95, + "column": 15 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 2525, + 2530 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2532, + 2536 + ], + "loc": { + "start": { + "line": 95, + "column": 23 + }, + "end": { + "line": 95, + "column": 27 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2538, + 2540 + ], + "loc": { + "start": { + "line": 95, + "column": 29 + }, + "end": { + "line": 95, + "column": 31 + } + } + }, + { + "type": "ObjectExpression", + "properties": [], + "range": [ + 2542, + 2544 + ], + "loc": { + "start": { + "line": 95, + "column": 33 + }, + "end": { + "line": 95, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2546, + 2553 + ], + "loc": { + "start": { + "line": 95, + "column": 37 + }, + "end": { + "line": 95, + "column": 44 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 2555, + 2562 + ], + "loc": { + "start": { + "line": 95, + "column": 46 + }, + "end": { + "line": 95, + "column": 53 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 2564, + 2569 + ], + "loc": { + "start": { + "line": 95, + "column": 55 + }, + "end": { + "line": 95, + "column": 60 + } + } + } + ], + "range": [ + 2515, + 2570 + ], + "loc": { + "start": { + "line": 95, + "column": 6 + }, + "end": { + "line": 95, + "column": 61 + } + } + }, + "range": [ + 2515, + 2571 + ], + "loc": { + "start": { + "line": 95, + "column": 6 + }, + "end": { + "line": 95, + "column": 62 + } + } + } + ], + "range": [ + 2507, + 2577 + ], + "loc": { + "start": { + "line": 94, + "column": 77 + }, + "end": { + "line": 96, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "error", + "range": [ + 2587, + 2592 + ], + "loc": { + "start": { + "line": 96, + "column": 15 + }, + "end": { + "line": 96, + "column": 20 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 2596, + 2598 + ], + "loc": { + "start": { + "line": 96, + "column": 24 + }, + "end": { + "line": 96, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 2599, + 2607 + ], + "loc": { + "start": { + "line": 96, + "column": 27 + }, + "end": { + "line": 96, + "column": 35 + } + } + }, + "range": [ + 2596, + 2607 + ], + "loc": { + "start": { + "line": 96, + "column": 24 + }, + "end": { + "line": 96, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 2608, + 2612 + ], + "loc": { + "start": { + "line": 96, + "column": 36 + }, + "end": { + "line": 96, + "column": 40 + } + } + }, + "range": [ + 2596, + 2612 + ], + "loc": { + "start": { + "line": 96, + "column": 24 + }, + "end": { + "line": 96, + "column": 40 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "error", + "range": [ + 2613, + 2618 + ], + "loc": { + "start": { + "line": 96, + "column": 41 + }, + "end": { + "line": 96, + "column": 46 + } + } + } + ], + "range": [ + 2596, + 2619 + ], + "loc": { + "start": { + "line": 96, + "column": 24 + }, + "end": { + "line": 96, + "column": 47 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 2624, + 2643 + ], + "loc": { + "start": { + "line": 96, + "column": 52 + }, + "end": { + "line": 96, + "column": 71 + } + } + }, + "range": [ + 2596, + 2643 + ], + "loc": { + "start": { + "line": 96, + "column": 24 + }, + "end": { + "line": 96, + "column": 71 + } + } + }, + "range": [ + 2587, + 2643 + ], + "loc": { + "start": { + "line": 96, + "column": 15 + }, + "end": { + "line": 96, + "column": 71 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2653, + 2657 + ], + "loc": { + "start": { + "line": 97, + "column": 6 + }, + "end": { + "line": 97, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 2658, + 2662 + ], + "loc": { + "start": { + "line": 97, + "column": 11 + }, + "end": { + "line": 97, + "column": 15 + } + } + }, + "range": [ + 2653, + 2662 + ], + "loc": { + "start": { + "line": 97, + "column": 6 + }, + "end": { + "line": 97, + "column": 15 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 2663, + 2668 + ], + "loc": { + "start": { + "line": 97, + "column": 16 + }, + "end": { + "line": 97, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2670, + 2674 + ], + "loc": { + "start": { + "line": 97, + "column": 23 + }, + "end": { + "line": 97, + "column": 27 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2676, + 2678 + ], + "loc": { + "start": { + "line": 97, + "column": 29 + }, + "end": { + "line": 97, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2680, + 2687 + ], + "loc": { + "start": { + "line": 97, + "column": 33 + }, + "end": { + "line": 97, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 2689, + 2696 + ], + "loc": { + "start": { + "line": 97, + "column": 42 + }, + "end": { + "line": 97, + "column": 49 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2698, + 2702 + ], + "loc": { + "start": { + "line": 97, + "column": 51 + }, + "end": { + "line": 97, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 2704, + 2709 + ], + "loc": { + "start": { + "line": 97, + "column": 57 + }, + "end": { + "line": 97, + "column": 62 + } + } + } + ], + "range": [ + 2653, + 2710 + ], + "loc": { + "start": { + "line": 97, + "column": 6 + }, + "end": { + "line": 97, + "column": 63 + } + } + }, + "range": [ + 2653, + 2711 + ], + "loc": { + "start": { + "line": 97, + "column": 6 + }, + "end": { + "line": 97, + "column": 64 + } + } + } + ], + "range": [ + 2645, + 2717 + ], + "loc": { + "start": { + "line": 96, + "column": 73 + }, + "end": { + "line": 98, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 2727, + 2732 + ], + "loc": { + "start": { + "line": 98, + "column": 15 + }, + "end": { + "line": 98, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 2733, + 2739 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 27 + } + } + }, + "range": [ + 2727, + 2739 + ], + "loc": { + "start": { + "line": 98, + "column": 15 + }, + "end": { + "line": 98, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 2740, + 2744 + ], + "loc": { + "start": { + "line": 98, + "column": 28 + }, + "end": { + "line": 98, + "column": 32 + } + } + }, + "range": [ + 2727, + 2745 + ], + "loc": { + "start": { + "line": 98, + "column": 15 + }, + "end": { + "line": 98, + "column": 33 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "request", + "range": [ + 2760, + 2767 + ], + "loc": { + "start": { + "line": 100, + "column": 10 + }, + "end": { + "line": 100, + "column": 17 + } + } + }, + "init": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "XMLHttpRequest", + "range": [ + 2774, + 2788 + ], + "loc": { + "start": { + "line": 100, + "column": 24 + }, + "end": { + "line": 100, + "column": 38 + } + } + }, + "arguments": [], + "range": [ + 2770, + 2790 + ], + "loc": { + "start": { + "line": 100, + "column": 20 + }, + "end": { + "line": 100, + "column": 40 + } + } + }, + "range": [ + 2760, + 2790 + ], + "loc": { + "start": { + "line": 100, + "column": 10 + }, + "end": { + "line": 100, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 2756, + 2791 + ], + "loc": { + "start": { + "line": 100, + "column": 6 + }, + "end": { + "line": 100, + "column": 41 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "url", + "range": [ + 2802, + 2805 + ], + "loc": { + "start": { + "line": 101, + "column": 10 + }, + "end": { + "line": 101, + "column": 13 + } + } + }, + "init": null, + "range": [ + 2802, + 2805 + ], + "loc": { + "start": { + "line": 101, + "column": 10 + }, + "end": { + "line": 101, + "column": 13 + } + } + } + ], + "kind": "let", + "range": [ + 2798, + 2806 + ], + "loc": { + "start": { + "line": 101, + "column": 6 + }, + "end": { + "line": 101, + "column": 14 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 2814, + 2821 + ], + "loc": { + "start": { + "line": 103, + "column": 6 + }, + "end": { + "line": 103, + "column": 13 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 2824, + 2831 + ], + "loc": { + "start": { + "line": 103, + "column": 16 + }, + "end": { + "line": 103, + "column": 23 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 2835, + 2837 + ], + "loc": { + "start": { + "line": 103, + "column": 27 + }, + "end": { + "line": 103, + "column": 29 + } + } + }, + "range": [ + 2824, + 2837 + ], + "loc": { + "start": { + "line": 103, + "column": 16 + }, + "end": { + "line": 103, + "column": 29 + } + } + }, + "range": [ + 2814, + 2837 + ], + "loc": { + "start": { + "line": 103, + "column": 6 + }, + "end": { + "line": 103, + "column": 29 + } + } + }, + "range": [ + 2814, + 2838 + ], + "loc": { + "start": { + "line": 103, + "column": 6 + }, + "end": { + "line": 103, + "column": 30 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "url", + "range": [ + 2845, + 2848 + ], + "loc": { + "start": { + "line": 104, + "column": 6 + }, + "end": { + "line": 104, + "column": 9 + } + } + }, + "right": { + "type": "ConditionalExpression", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 2851, + 2853 + ], + "loc": { + "start": { + "line": 104, + "column": 12 + }, + "end": { + "line": 104, + "column": 14 + } + } + }, + "consequent": { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 2856, + 2859 + ], + "loc": { + "start": { + "line": 104, + "column": 17 + }, + "end": { + "line": 104, + "column": 20 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 2869, + 2873 + ], + "loc": { + "start": { + "line": 104, + "column": 30 + }, + "end": { + "line": 104, + "column": 34 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 2877, + 2881 + ], + "loc": { + "start": { + "line": 104, + "column": 38 + }, + "end": { + "line": 104, + "column": 42 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 2883, + 2885 + ], + "loc": { + "start": { + "line": 104, + "column": 44 + }, + "end": { + "line": 104, + "column": 46 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2859, + 2863 + ], + "loc": { + "start": { + "line": 104, + "column": 20 + }, + "end": { + "line": 104, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 2864, + 2869 + ], + "loc": { + "start": { + "line": 104, + "column": 25 + }, + "end": { + "line": 104, + "column": 30 + } + } + }, + "range": [ + 2859, + 2869 + ], + "loc": { + "start": { + "line": 104, + "column": 20 + }, + "end": { + "line": 104, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2873, + 2877 + ], + "loc": { + "start": { + "line": 104, + "column": 34 + }, + "end": { + "line": 104, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 2881, + 2883 + ], + "loc": { + "start": { + "line": 104, + "column": 42 + }, + "end": { + "line": 104, + "column": 44 + } + } + } + ], + "range": [ + 2856, + 2885 + ], + "loc": { + "start": { + "line": 104, + "column": 17 + }, + "end": { + "line": 104, + "column": 46 + } + } + }, + "alternate": { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 2888, + 2891 + ], + "loc": { + "start": { + "line": 104, + "column": 49 + }, + "end": { + "line": 104, + "column": 52 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 2901, + 2905 + ], + "loc": { + "start": { + "line": 104, + "column": 62 + }, + "end": { + "line": 104, + "column": 66 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 2909, + 2911 + ], + "loc": { + "start": { + "line": 104, + "column": 70 + }, + "end": { + "line": 104, + "column": 72 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 2891, + 2895 + ], + "loc": { + "start": { + "line": 104, + "column": 52 + }, + "end": { + "line": 104, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 2896, + 2901 + ], + "loc": { + "start": { + "line": 104, + "column": 57 + }, + "end": { + "line": 104, + "column": 62 + } + } + }, + "range": [ + 2891, + 2901 + ], + "loc": { + "start": { + "line": 104, + "column": 52 + }, + "end": { + "line": 104, + "column": 62 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 2905, + 2909 + ], + "loc": { + "start": { + "line": 104, + "column": 66 + }, + "end": { + "line": 104, + "column": 70 + } + } + } + ], + "range": [ + 2888, + 2911 + ], + "loc": { + "start": { + "line": 104, + "column": 49 + }, + "end": { + "line": 104, + "column": 72 + } + } + }, + "range": [ + 2851, + 2911 + ], + "loc": { + "start": { + "line": 104, + "column": 12 + }, + "end": { + "line": 104, + "column": 72 + } + } + }, + "range": [ + 2845, + 2911 + ], + "loc": { + "start": { + "line": 104, + "column": 6 + }, + "end": { + "line": 104, + "column": 72 + } + } + }, + "range": [ + 2845, + 2912 + ], + "loc": { + "start": { + "line": 104, + "column": 6 + }, + "end": { + "line": 104, + "column": 73 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "options", + "range": [ + 2924, + 2931 + ], + "loc": { + "start": { + "line": 106, + "column": 10 + }, + "end": { + "line": 106, + "column": 17 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "params", + "range": [ + 2948, + 2954 + ], + "loc": { + "start": { + "line": 108, + "column": 12 + }, + "end": { + "line": 108, + "column": 18 + } + } + }, + "init": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 2957, + 2959 + ], + "loc": { + "start": { + "line": 108, + "column": 21 + }, + "end": { + "line": 108, + "column": 23 + } + } + }, + "range": [ + 2948, + 2959 + ], + "loc": { + "start": { + "line": 108, + "column": 12 + }, + "end": { + "line": 108, + "column": 23 + } + } + } + ], + "kind": "let", + "range": [ + 2944, + 2960 + ], + "loc": { + "start": { + "line": 108, + "column": 8 + }, + "end": { + "line": 108, + "column": 24 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 2974, + 2981 + ], + "loc": { + "start": { + "line": 110, + "column": 12 + }, + "end": { + "line": 110, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "fields", + "range": [ + 2982, + 2988 + ], + "loc": { + "start": { + "line": 110, + "column": 20 + }, + "end": { + "line": 110, + "column": 26 + } + } + }, + "range": [ + 2974, + 2988 + ], + "loc": { + "start": { + "line": 110, + "column": 12 + }, + "end": { + "line": 110, + "column": 26 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 3002, + 3008 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 111, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 3009, + 3013 + ], + "loc": { + "start": { + "line": 111, + "column": 17 + }, + "end": { + "line": 111, + "column": 21 + } + } + }, + "range": [ + 3002, + 3013 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 111, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 3014, + 3021 + ], + "loc": { + "start": { + "line": 111, + "column": 22 + }, + "end": { + "line": 111, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "fields", + "range": [ + 3022, + 3028 + ], + "loc": { + "start": { + "line": 111, + "column": 30 + }, + "end": { + "line": 111, + "column": 36 + } + } + }, + "range": [ + 3014, + 3028 + ], + "loc": { + "start": { + "line": 111, + "column": 22 + }, + "end": { + "line": 111, + "column": 36 + } + } + } + ], + "range": [ + 3002, + 3029 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 111, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 3030, + 3037 + ], + "loc": { + "start": { + "line": 111, + "column": 38 + }, + "end": { + "line": 111, + "column": 45 + } + } + }, + "range": [ + 3002, + 3037 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 111, + "column": 45 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "field", + "range": [ + 3038, + 3043 + ], + "loc": { + "start": { + "line": 111, + "column": 46 + }, + "end": { + "line": 111, + "column": 51 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 3061, + 3068 + ], + "loc": { + "start": { + "line": 112, + "column": 12 + }, + "end": { + "line": 112, + "column": 19 + } + } + }, + "property": { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "fields[", + "cooked": "fields[" + }, + "tail": false, + "range": [ + 3069, + 3079 + ], + "loc": { + "start": { + "line": 112, + "column": 20 + }, + "end": { + "line": 112, + "column": 30 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "]", + "cooked": "]" + }, + "tail": true, + "range": [ + 3084, + 3087 + ], + "loc": { + "start": { + "line": 112, + "column": 35 + }, + "end": { + "line": 112, + "column": 38 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "field", + "range": [ + 3079, + 3084 + ], + "loc": { + "start": { + "line": 112, + "column": 30 + }, + "end": { + "line": 112, + "column": 35 + } + } + } + ], + "range": [ + 3069, + 3087 + ], + "loc": { + "start": { + "line": 112, + "column": 20 + }, + "end": { + "line": 112, + "column": 38 + } + } + }, + "range": [ + 3061, + 3088 + ], + "loc": { + "start": { + "line": 112, + "column": 12 + }, + "end": { + "line": 112, + "column": 39 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 3091, + 3098 + ], + "loc": { + "start": { + "line": 112, + "column": 42 + }, + "end": { + "line": 112, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "fields", + "range": [ + 3099, + 3105 + ], + "loc": { + "start": { + "line": 112, + "column": 50 + }, + "end": { + "line": 112, + "column": 56 + } + } + }, + "range": [ + 3091, + 3105 + ], + "loc": { + "start": { + "line": 112, + "column": 42 + }, + "end": { + "line": 112, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "field", + "range": [ + 3106, + 3111 + ], + "loc": { + "start": { + "line": 112, + "column": 57 + }, + "end": { + "line": 112, + "column": 62 + } + } + }, + "range": [ + 3091, + 3112 + ], + "loc": { + "start": { + "line": 112, + "column": 42 + }, + "end": { + "line": 112, + "column": 63 + } + } + }, + "range": [ + 3061, + 3112 + ], + "loc": { + "start": { + "line": 112, + "column": 12 + }, + "end": { + "line": 112, + "column": 63 + } + } + }, + "range": [ + 3061, + 3113 + ], + "loc": { + "start": { + "line": 112, + "column": 12 + }, + "end": { + "line": 112, + "column": 64 + } + } + } + ], + "range": [ + 3047, + 3125 + ], + "loc": { + "start": { + "line": 111, + "column": 55 + }, + "end": { + "line": 113, + "column": 11 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3038, + 3125 + ], + "loc": { + "start": { + "line": 111, + "column": 46 + }, + "end": { + "line": 113, + "column": 11 + } + } + } + ], + "range": [ + 3002, + 3126 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 113, + "column": 12 + } + } + }, + "range": [ + 3002, + 3127 + ], + "loc": { + "start": { + "line": 111, + "column": 10 + }, + "end": { + "line": 113, + "column": 13 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UnaryExpression", + "operator": "delete", + "argument": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 3145, + 3152 + ], + "loc": { + "start": { + "line": 114, + "column": 17 + }, + "end": { + "line": 114, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "fields", + "range": [ + 3153, + 3159 + ], + "loc": { + "start": { + "line": 114, + "column": 25 + }, + "end": { + "line": 114, + "column": 31 + } + } + }, + "range": [ + 3145, + 3159 + ], + "loc": { + "start": { + "line": 114, + "column": 17 + }, + "end": { + "line": 114, + "column": 31 + } + } + }, + "prefix": true, + "range": [ + 3138, + 3159 + ], + "loc": { + "start": { + "line": 114, + "column": 10 + }, + "end": { + "line": 114, + "column": 31 + } + } + }, + "range": [ + 3138, + 3160 + ], + "loc": { + "start": { + "line": 114, + "column": 10 + }, + "end": { + "line": 114, + "column": 32 + } + } + } + ], + "range": [ + 2990, + 3170 + ], + "loc": { + "start": { + "line": 110, + "column": 28 + }, + "end": { + "line": 115, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 2970, + 3170 + ], + "loc": { + "start": { + "line": 110, + "column": 8 + }, + "end": { + "line": 115, + "column": 9 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "params", + "range": [ + 3180, + 3186 + ], + "loc": { + "start": { + "line": 117, + "column": 8 + }, + "end": { + "line": 117, + "column": 14 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 3189, + 3195 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 117, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 3196, + 3200 + ], + "loc": { + "start": { + "line": 117, + "column": 24 + }, + "end": { + "line": 117, + "column": 28 + } + } + }, + "range": [ + 3189, + 3200 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 117, + "column": 28 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "options", + "range": [ + 3201, + 3208 + ], + "loc": { + "start": { + "line": 117, + "column": 29 + }, + "end": { + "line": 117, + "column": 36 + } + } + } + ], + "range": [ + 3189, + 3209 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 117, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 3210, + 3213 + ], + "loc": { + "start": { + "line": 117, + "column": 38 + }, + "end": { + "line": 117, + "column": 41 + } + } + }, + "range": [ + 3189, + 3213 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 117, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "key", + "range": [ + 3214, + 3217 + ], + "loc": { + "start": { + "line": 117, + "column": 42 + }, + "end": { + "line": 117, + "column": 45 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "key", + "range": [ + 3240, + 3243 + ], + "loc": { + "start": { + "line": 118, + "column": 17 + }, + "end": { + "line": 118, + "column": 20 + } + } + }, + "right": { + "type": "Literal", + "value": "=", + "raw": "\"=\"", + "range": [ + 3246, + 3249 + ], + "loc": { + "start": { + "line": 118, + "column": 23 + }, + "end": { + "line": 118, + "column": 26 + } + } + }, + "range": [ + 3240, + 3249 + ], + "loc": { + "start": { + "line": 118, + "column": 17 + }, + "end": { + "line": 118, + "column": 26 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "encodeURIComponent", + "range": [ + 3252, + 3270 + ], + "loc": { + "start": { + "line": 118, + "column": 29 + }, + "end": { + "line": 118, + "column": 47 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 3271, + 3278 + ], + "loc": { + "start": { + "line": 118, + "column": 48 + }, + "end": { + "line": 118, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 3279, + 3282 + ], + "loc": { + "start": { + "line": 118, + "column": 56 + }, + "end": { + "line": 118, + "column": 59 + } + } + }, + "range": [ + 3271, + 3283 + ], + "loc": { + "start": { + "line": 118, + "column": 48 + }, + "end": { + "line": 118, + "column": 60 + } + } + } + ], + "range": [ + 3252, + 3284 + ], + "loc": { + "start": { + "line": 118, + "column": 29 + }, + "end": { + "line": 118, + "column": 61 + } + } + }, + "range": [ + 3240, + 3284 + ], + "loc": { + "start": { + "line": 118, + "column": 17 + }, + "end": { + "line": 118, + "column": 61 + } + } + }, + "range": [ + 3233, + 3285 + ], + "loc": { + "start": { + "line": 118, + "column": 10 + }, + "end": { + "line": 118, + "column": 62 + } + } + } + ], + "range": [ + 3221, + 3295 + ], + "loc": { + "start": { + "line": 117, + "column": 49 + }, + "end": { + "line": 119, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3214, + 3295 + ], + "loc": { + "start": { + "line": 117, + "column": 42 + }, + "end": { + "line": 119, + "column": 9 + } + } + } + ], + "range": [ + 3189, + 3296 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 119, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "sort", + "range": [ + 3297, + 3301 + ], + "loc": { + "start": { + "line": 119, + "column": 11 + }, + "end": { + "line": 119, + "column": 15 + } + } + }, + "range": [ + 3189, + 3301 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 119, + "column": 15 + } + } + }, + "arguments": [], + "range": [ + 3189, + 3303 + ], + "loc": { + "start": { + "line": 117, + "column": 17 + }, + "end": { + "line": 119, + "column": 17 + } + } + }, + "range": [ + 3180, + 3303 + ], + "loc": { + "start": { + "line": 117, + "column": 8 + }, + "end": { + "line": 119, + "column": 17 + } + } + }, + "range": [ + 3180, + 3304 + ], + "loc": { + "start": { + "line": 117, + "column": 8 + }, + "end": { + "line": 119, + "column": 18 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "params", + "range": [ + 3318, + 3324 + ], + "loc": { + "start": { + "line": 121, + "column": 12 + }, + "end": { + "line": 121, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "range": [ + 3325, + 3331 + ], + "loc": { + "start": { + "line": 121, + "column": 19 + }, + "end": { + "line": 121, + "column": 25 + } + } + }, + "range": [ + 3318, + 3331 + ], + "loc": { + "start": { + "line": 121, + "column": 12 + }, + "end": { + "line": 121, + "column": 25 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "url", + "range": [ + 3345, + 3348 + ], + "loc": { + "start": { + "line": 122, + "column": 10 + }, + "end": { + "line": 122, + "column": 13 + } + } + }, + "right": { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 3351, + 3354 + ], + "loc": { + "start": { + "line": 122, + "column": 16 + }, + "end": { + "line": 122, + "column": 19 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "?", + "cooked": "?" + }, + "tail": false, + "range": [ + 3357, + 3361 + ], + "loc": { + "start": { + "line": 122, + "column": 22 + }, + "end": { + "line": 122, + "column": 26 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 3377, + 3379 + ], + "loc": { + "start": { + "line": 122, + "column": 42 + }, + "end": { + "line": 122, + "column": 44 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "url", + "range": [ + 3354, + 3357 + ], + "loc": { + "start": { + "line": 122, + "column": 19 + }, + "end": { + "line": 122, + "column": 22 + } + } + }, + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "params", + "range": [ + 3361, + 3367 + ], + "loc": { + "start": { + "line": 122, + "column": 26 + }, + "end": { + "line": 122, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "join", + "range": [ + 3368, + 3372 + ], + "loc": { + "start": { + "line": 122, + "column": 33 + }, + "end": { + "line": 122, + "column": 37 + } + } + }, + "range": [ + 3361, + 3372 + ], + "loc": { + "start": { + "line": 122, + "column": 26 + }, + "end": { + "line": 122, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "&", + "raw": "\"&\"", + "range": [ + 3373, + 3376 + ], + "loc": { + "start": { + "line": 122, + "column": 38 + }, + "end": { + "line": 122, + "column": 41 + } + } + } + ], + "range": [ + 3361, + 3377 + ], + "loc": { + "start": { + "line": 122, + "column": 26 + }, + "end": { + "line": 122, + "column": 42 + } + } + } + ], + "range": [ + 3351, + 3379 + ], + "loc": { + "start": { + "line": 122, + "column": 16 + }, + "end": { + "line": 122, + "column": 44 + } + } + }, + "range": [ + 3345, + 3379 + ], + "loc": { + "start": { + "line": 122, + "column": 10 + }, + "end": { + "line": 122, + "column": 44 + } + } + }, + "range": [ + 3345, + 3380 + ], + "loc": { + "start": { + "line": 122, + "column": 10 + }, + "end": { + "line": 122, + "column": 45 + } + } + } + ], + "range": [ + 3333, + 3390 + ], + "loc": { + "start": { + "line": 121, + "column": 27 + }, + "end": { + "line": 123, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 3314, + 3390 + ], + "loc": { + "start": { + "line": 121, + "column": 8 + }, + "end": { + "line": 123, + "column": 9 + } + } + } + ], + "range": [ + 2933, + 3399 + ], + "loc": { + "start": { + "line": 106, + "column": 19 + }, + "end": { + "line": 125, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 2920, + 3399 + ], + "loc": { + "start": { + "line": 106, + "column": 6 + }, + "end": { + "line": 125, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3407, + 3414 + ], + "loc": { + "start": { + "line": 127, + "column": 6 + }, + "end": { + "line": 127, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 3415, + 3419 + ], + "loc": { + "start": { + "line": 127, + "column": 14 + }, + "end": { + "line": 127, + "column": 18 + } + } + }, + "range": [ + 3407, + 3419 + ], + "loc": { + "start": { + "line": 127, + "column": 6 + }, + "end": { + "line": 127, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "GET", + "raw": "'GET'", + "range": [ + 3420, + 3425 + ], + "loc": { + "start": { + "line": 127, + "column": 19 + }, + "end": { + "line": 127, + "column": 24 + } + } + }, + { + "type": "Identifier", + "name": "url", + "range": [ + 3427, + 3430 + ], + "loc": { + "start": { + "line": 127, + "column": 26 + }, + "end": { + "line": 127, + "column": 29 + } + } + }, + { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 3432, + 3436 + ], + "loc": { + "start": { + "line": 127, + "column": 31 + }, + "end": { + "line": 127, + "column": 35 + } + } + } + ], + "range": [ + 3407, + 3437 + ], + "loc": { + "start": { + "line": 127, + "column": 6 + }, + "end": { + "line": 127, + "column": 36 + } + } + }, + "range": [ + 3407, + 3438 + ], + "loc": { + "start": { + "line": 127, + "column": 6 + }, + "end": { + "line": 127, + "column": 37 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3446, + 3453 + ], + "loc": { + "start": { + "line": 129, + "column": 6 + }, + "end": { + "line": 129, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "setRequestHeader", + "range": [ + 3454, + 3470 + ], + "loc": { + "start": { + "line": 129, + "column": 14 + }, + "end": { + "line": 129, + "column": 30 + } + } + }, + "range": [ + 3446, + 3470 + ], + "loc": { + "start": { + "line": 129, + "column": 6 + }, + "end": { + "line": 129, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Content-Type", + "raw": "\"Content-Type\"", + "range": [ + 3471, + 3485 + ], + "loc": { + "start": { + "line": 129, + "column": 31 + }, + "end": { + "line": 129, + "column": 45 + } + } + }, + { + "type": "Literal", + "value": "application/vnd.api+json", + "raw": "\"application/vnd.api+json\"", + "range": [ + 3487, + 3513 + ], + "loc": { + "start": { + "line": 129, + "column": 47 + }, + "end": { + "line": 129, + "column": 73 + } + } + } + ], + "range": [ + 3446, + 3514 + ], + "loc": { + "start": { + "line": 129, + "column": 6 + }, + "end": { + "line": 129, + "column": 74 + } + } + }, + "range": [ + 3446, + 3515 + ], + "loc": { + "start": { + "line": 129, + "column": 6 + }, + "end": { + "line": 129, + "column": 75 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3523, + 3530 + ], + "loc": { + "start": { + "line": 131, + "column": 6 + }, + "end": { + "line": 131, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "onload", + "range": [ + 3531, + 3537 + ], + "loc": { + "start": { + "line": 131, + "column": 14 + }, + "end": { + "line": 131, + "column": 20 + } + } + }, + "range": [ + 3523, + 3537 + ], + "loc": { + "start": { + "line": 131, + "column": 6 + }, + "end": { + "line": 131, + "column": 20 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": ">=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3566, + 3573 + ], + "loc": { + "start": { + "line": 132, + "column": 12 + }, + "end": { + "line": 132, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 3574, + 3580 + ], + "loc": { + "start": { + "line": 132, + "column": 20 + }, + "end": { + "line": 132, + "column": 26 + } + } + }, + "range": [ + 3566, + 3580 + ], + "loc": { + "start": { + "line": 132, + "column": 12 + }, + "end": { + "line": 132, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": 200, + "raw": "200", + "range": [ + 3584, + 3587 + ], + "loc": { + "start": { + "line": 132, + "column": 30 + }, + "end": { + "line": 132, + "column": 33 + } + } + }, + "range": [ + 3566, + 3587 + ], + "loc": { + "start": { + "line": 132, + "column": 12 + }, + "end": { + "line": 132, + "column": 33 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3591, + 3598 + ], + "loc": { + "start": { + "line": 132, + "column": 37 + }, + "end": { + "line": 132, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 3599, + 3605 + ], + "loc": { + "start": { + "line": 132, + "column": 45 + }, + "end": { + "line": 132, + "column": 51 + } + } + }, + "range": [ + 3591, + 3605 + ], + "loc": { + "start": { + "line": 132, + "column": 37 + }, + "end": { + "line": 132, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": 300, + "raw": "300", + "range": [ + 3608, + 3611 + ], + "loc": { + "start": { + "line": 132, + "column": 54 + }, + "end": { + "line": 132, + "column": 57 + } + } + }, + "range": [ + 3591, + 3611 + ], + "loc": { + "start": { + "line": 132, + "column": 37 + }, + "end": { + "line": 132, + "column": 57 + } + } + }, + "range": [ + 3566, + 3611 + ], + "loc": { + "start": { + "line": 132, + "column": 12 + }, + "end": { + "line": 132, + "column": 57 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 3643, + 3648 + ], + "loc": { + "start": { + "line": 134, + "column": 12 + }, + "end": { + "line": 134, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 3649, + 3653 + ], + "loc": { + "start": { + "line": 134, + "column": 18 + }, + "end": { + "line": 134, + "column": 22 + } + } + }, + "range": [ + 3643, + 3653 + ], + "loc": { + "start": { + "line": 134, + "column": 12 + }, + "end": { + "line": 134, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "JSON", + "range": [ + 3654, + 3658 + ], + "loc": { + "start": { + "line": 134, + "column": 23 + }, + "end": { + "line": 134, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "parse", + "range": [ + 3659, + 3664 + ], + "loc": { + "start": { + "line": 134, + "column": 28 + }, + "end": { + "line": 134, + "column": 33 + } + } + }, + "range": [ + 3654, + 3664 + ], + "loc": { + "start": { + "line": 134, + "column": 23 + }, + "end": { + "line": 134, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3665, + 3672 + ], + "loc": { + "start": { + "line": 134, + "column": 34 + }, + "end": { + "line": 134, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "responseText", + "range": [ + 3673, + 3685 + ], + "loc": { + "start": { + "line": 134, + "column": 42 + }, + "end": { + "line": 134, + "column": 54 + } + } + }, + "range": [ + 3665, + 3685 + ], + "loc": { + "start": { + "line": 134, + "column": 34 + }, + "end": { + "line": 134, + "column": 54 + } + } + } + ], + "range": [ + 3654, + 3686 + ], + "loc": { + "start": { + "line": 134, + "column": 23 + }, + "end": { + "line": 134, + "column": 55 + } + } + } + ], + "range": [ + 3643, + 3687 + ], + "loc": { + "start": { + "line": 134, + "column": 12 + }, + "end": { + "line": 134, + "column": 56 + } + } + }, + "range": [ + 3643, + 3688 + ], + "loc": { + "start": { + "line": 134, + "column": 12 + }, + "end": { + "line": 134, + "column": 57 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "success", + "range": [ + 3705, + 3712 + ], + "loc": { + "start": { + "line": 135, + "column": 16 + }, + "end": { + "line": 135, + "column": 23 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "success", + "range": [ + 3730, + 3737 + ], + "loc": { + "start": { + "line": 136, + "column": 14 + }, + "end": { + "line": 136, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 3738, + 3742 + ], + "loc": { + "start": { + "line": 136, + "column": 22 + }, + "end": { + "line": 136, + "column": 26 + } + } + }, + "range": [ + 3730, + 3742 + ], + "loc": { + "start": { + "line": 136, + "column": 14 + }, + "end": { + "line": 136, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 3743, + 3750 + ], + "loc": { + "start": { + "line": 136, + "column": 27 + }, + "end": { + "line": 136, + "column": 34 + } + } + }, + { + "type": "ConditionalExpression", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 3752, + 3754 + ], + "loc": { + "start": { + "line": 136, + "column": 36 + }, + "end": { + "line": 136, + "column": 38 + } + } + }, + "consequent": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 3757, + 3762 + ], + "loc": { + "start": { + "line": 136, + "column": 41 + }, + "end": { + "line": 136, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 3763, + 3767 + ], + "loc": { + "start": { + "line": 136, + "column": 47 + }, + "end": { + "line": 136, + "column": 51 + } + } + }, + "range": [ + 3757, + 3767 + ], + "loc": { + "start": { + "line": 136, + "column": 41 + }, + "end": { + "line": 136, + "column": 51 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 3768, + 3772 + ], + "loc": { + "start": { + "line": 136, + "column": 52 + }, + "end": { + "line": 136, + "column": 56 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 3774, + 3776 + ], + "loc": { + "start": { + "line": 136, + "column": 58 + }, + "end": { + "line": 136, + "column": 60 + } + } + } + ], + "range": [ + 3757, + 3777 + ], + "loc": { + "start": { + "line": 136, + "column": 41 + }, + "end": { + "line": 136, + "column": 61 + } + } + }, + "alternate": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 3780, + 3785 + ], + "loc": { + "start": { + "line": 136, + "column": 64 + }, + "end": { + "line": 136, + "column": 69 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 3786, + 3790 + ], + "loc": { + "start": { + "line": 136, + "column": 70 + }, + "end": { + "line": 136, + "column": 74 + } + } + }, + "range": [ + 3780, + 3790 + ], + "loc": { + "start": { + "line": 136, + "column": 64 + }, + "end": { + "line": 136, + "column": 74 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 3791, + 3795 + ], + "loc": { + "start": { + "line": 136, + "column": 75 + }, + "end": { + "line": 136, + "column": 79 + } + } + } + ], + "range": [ + 3780, + 3796 + ], + "loc": { + "start": { + "line": 136, + "column": 64 + }, + "end": { + "line": 136, + "column": 80 + } + } + }, + "range": [ + 3752, + 3796 + ], + "loc": { + "start": { + "line": 136, + "column": 36 + }, + "end": { + "line": 136, + "column": 80 + } + } + } + ], + "range": [ + 3730, + 3797 + ], + "loc": { + "start": { + "line": 136, + "column": 14 + }, + "end": { + "line": 136, + "column": 81 + } + } + }, + "range": [ + 3730, + 3798 + ], + "loc": { + "start": { + "line": 136, + "column": 14 + }, + "end": { + "line": 136, + "column": 82 + } + } + } + ], + "range": [ + 3714, + 3812 + ], + "loc": { + "start": { + "line": 135, + "column": 25 + }, + "end": { + "line": 137, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 3701, + 3812 + ], + "loc": { + "start": { + "line": 135, + "column": 12 + }, + "end": { + "line": 137, + "column": 13 + } + } + } + ], + "range": [ + 3629, + 3824 + ], + "loc": { + "start": { + "line": 133, + "column": 14 + }, + "end": { + "line": 138, + "column": 11 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "e", + "range": [ + 3832, + 3833 + ], + "loc": { + "start": { + "line": 138, + "column": 19 + }, + "end": { + "line": 138, + "column": 20 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 3849, + 3854 + ], + "loc": { + "start": { + "line": 139, + "column": 12 + }, + "end": { + "line": 139, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 3855, + 3859 + ], + "loc": { + "start": { + "line": 139, + "column": 18 + }, + "end": { + "line": 139, + "column": 22 + } + } + }, + "range": [ + 3849, + 3859 + ], + "loc": { + "start": { + "line": 139, + "column": 12 + }, + "end": { + "line": 139, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3860, + 3862 + ], + "loc": { + "start": { + "line": 139, + "column": 23 + }, + "end": { + "line": 139, + "column": 25 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 3864, + 3865 + ], + "loc": { + "start": { + "line": 139, + "column": 27 + }, + "end": { + "line": 139, + "column": 28 + } + } + } + ], + "range": [ + 3849, + 3866 + ], + "loc": { + "start": { + "line": 139, + "column": 12 + }, + "end": { + "line": 139, + "column": 29 + } + } + }, + "range": [ + 3849, + 3867 + ], + "loc": { + "start": { + "line": 139, + "column": 12 + }, + "end": { + "line": 139, + "column": 30 + } + } + } + ], + "range": [ + 3835, + 3879 + ], + "loc": { + "start": { + "line": 138, + "column": 22 + }, + "end": { + "line": 140, + "column": 11 + } + } + }, + "range": [ + 3825, + 3879 + ], + "loc": { + "start": { + "line": 138, + "column": 12 + }, + "end": { + "line": 140, + "column": 11 + } + } + }, + "finalizer": null, + "range": [ + 3625, + 3879 + ], + "loc": { + "start": { + "line": 133, + "column": 10 + }, + "end": { + "line": 140, + "column": 11 + } + } + } + ], + "range": [ + 3613, + 3889 + ], + "loc": { + "start": { + "line": 132, + "column": 59 + }, + "end": { + "line": 141, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 3899, + 3904 + ], + "loc": { + "start": { + "line": 141, + "column": 19 + }, + "end": { + "line": 141, + "column": 24 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 3918, + 3923 + ], + "loc": { + "start": { + "line": 142, + "column": 10 + }, + "end": { + "line": 142, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 3924, + 3928 + ], + "loc": { + "start": { + "line": 142, + "column": 16 + }, + "end": { + "line": 142, + "column": 20 + } + } + }, + "range": [ + 3918, + 3928 + ], + "loc": { + "start": { + "line": 142, + "column": 10 + }, + "end": { + "line": 142, + "column": 20 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 3929, + 3936 + ], + "loc": { + "start": { + "line": 142, + "column": 21 + }, + "end": { + "line": 142, + "column": 28 + } + } + } + ], + "range": [ + 3918, + 3937 + ], + "loc": { + "start": { + "line": 142, + "column": 10 + }, + "end": { + "line": 142, + "column": 29 + } + } + }, + "range": [ + 3918, + 3938 + ], + "loc": { + "start": { + "line": 142, + "column": 10 + }, + "end": { + "line": 142, + "column": 30 + } + } + } + ], + "range": [ + 3906, + 3948 + ], + "loc": { + "start": { + "line": 141, + "column": 26 + }, + "end": { + "line": 143, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 3895, + 3948 + ], + "loc": { + "start": { + "line": 141, + "column": 15 + }, + "end": { + "line": 143, + "column": 9 + } + } + }, + "range": [ + 3562, + 3948 + ], + "loc": { + "start": { + "line": 132, + "column": 8 + }, + "end": { + "line": 143, + "column": 9 + } + } + } + ], + "range": [ + 3552, + 3956 + ], + "loc": { + "start": { + "line": 131, + "column": 35 + }, + "end": { + "line": 144, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3540, + 3956 + ], + "loc": { + "start": { + "line": 131, + "column": 23 + }, + "end": { + "line": 144, + "column": 7 + } + } + }, + "range": [ + 3523, + 3956 + ], + "loc": { + "start": { + "line": 131, + "column": 6 + }, + "end": { + "line": 144, + "column": 7 + } + } + }, + "range": [ + 3523, + 3957 + ], + "loc": { + "start": { + "line": 131, + "column": 6 + }, + "end": { + "line": 144, + "column": 8 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 3965, + 3972 + ], + "loc": { + "start": { + "line": 146, + "column": 6 + }, + "end": { + "line": 146, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "send", + "range": [ + 3973, + 3977 + ], + "loc": { + "start": { + "line": 146, + "column": 14 + }, + "end": { + "line": 146, + "column": 18 + } + } + }, + "range": [ + 3965, + 3977 + ], + "loc": { + "start": { + "line": 146, + "column": 6 + }, + "end": { + "line": 146, + "column": 18 + } + } + }, + "arguments": [], + "range": [ + 3965, + 3979 + ], + "loc": { + "start": { + "line": 146, + "column": 6 + }, + "end": { + "line": 146, + "column": 20 + } + } + }, + "range": [ + 3965, + 3980 + ], + "loc": { + "start": { + "line": 146, + "column": 6 + }, + "end": { + "line": 146, + "column": 21 + } + } + } + ], + "range": [ + 2747, + 3987 + ], + "loc": { + "start": { + "line": 98, + "column": 35 + }, + "end": { + "line": 148, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 4011, + 4016 + ], + "loc": { + "start": { + "line": 149, + "column": 16 + }, + "end": { + "line": 149, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 4017, + 4034 + ], + "loc": { + "start": { + "line": 149, + "column": 22 + }, + "end": { + "line": 149, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 4038, + 4041 + ], + "loc": { + "start": { + "line": 149, + "column": 43 + }, + "end": { + "line": 149, + "column": 46 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 4034, + 4038 + ], + "loc": { + "start": { + "line": 149, + "column": 39 + }, + "end": { + "line": 149, + "column": 43 + } + } + } + ], + "range": [ + 4017, + 4041 + ], + "loc": { + "start": { + "line": 149, + "column": 22 + }, + "end": { + "line": 149, + "column": 46 + } + } + } + ], + "range": [ + 4007, + 4042 + ], + "loc": { + "start": { + "line": 149, + "column": 12 + }, + "end": { + "line": 149, + "column": 47 + } + } + }, + "range": [ + 4001, + 4043 + ], + "loc": { + "start": { + "line": 149, + "column": 6 + }, + "end": { + "line": 149, + "column": 48 + } + } + } + ], + "range": [ + 3993, + 4049 + ], + "loc": { + "start": { + "line": 148, + "column": 11 + }, + "end": { + "line": 150, + "column": 5 + } + } + }, + "range": [ + 2723, + 4049 + ], + "loc": { + "start": { + "line": 98, + "column": 11 + }, + "end": { + "line": 150, + "column": 5 + } + } + }, + "range": [ + 2583, + 4049 + ], + "loc": { + "start": { + "line": 96, + "column": 11 + }, + "end": { + "line": 150, + "column": 5 + } + } + }, + "range": [ + 2441, + 4049 + ], + "loc": { + "start": { + "line": 94, + "column": 11 + }, + "end": { + "line": 150, + "column": 5 + } + } + }, + "range": [ + 2329, + 4049 + ], + "loc": { + "start": { + "line": 92, + "column": 11 + }, + "end": { + "line": 150, + "column": 5 + } + } + }, + "range": [ + 2196, + 4049 + ], + "loc": { + "start": { + "line": 90, + "column": 4 + }, + "end": { + "line": 150, + "column": 5 + } + } + } + ], + "range": [ + 2189, + 4054 + ], + "loc": { + "start": { + "line": 88, + "column": 58 + }, + "end": { + "line": 152, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 2137, + 4054 + ], + "loc": { + "start": { + "line": 88, + "column": 6 + }, + "end": { + "line": 152, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 2133, + 4054 + ], + "loc": { + "start": { + "line": 88, + "column": 2 + }, + "end": { + "line": 152, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "update", + "range": [ + 4058, + 4064 + ], + "loc": { + "start": { + "line": 154, + "column": 2 + }, + "end": { + "line": 154, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 4065, + 4070 + ], + "loc": { + "start": { + "line": 154, + "column": 9 + }, + "end": { + "line": 154, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 4072, + 4076 + ], + "loc": { + "start": { + "line": 154, + "column": 16 + }, + "end": { + "line": 154, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 4078, + 4080 + ], + "loc": { + "start": { + "line": 154, + "column": 22 + }, + "end": { + "line": 154, + "column": 24 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 4082, + 4089 + ], + "loc": { + "start": { + "line": 154, + "column": 26 + }, + "end": { + "line": 154, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 4091, + 4098 + ], + "loc": { + "start": { + "line": 154, + "column": 35 + }, + "end": { + "line": 154, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 4100, + 4105 + ], + "loc": { + "start": { + "line": 154, + "column": 44 + }, + "end": { + "line": 154, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 4107, + 4114 + ], + "loc": { + "start": { + "line": 154, + "column": 51 + }, + "end": { + "line": 154, + "column": 58 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "error", + "range": [ + 4127, + 4132 + ], + "loc": { + "start": { + "line": 156, + "column": 8 + }, + "end": { + "line": 156, + "column": 13 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 4136, + 4138 + ], + "loc": { + "start": { + "line": 156, + "column": 17 + }, + "end": { + "line": 156, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 4139, + 4147 + ], + "loc": { + "start": { + "line": 156, + "column": 20 + }, + "end": { + "line": 156, + "column": 28 + } + } + }, + "range": [ + 4136, + 4147 + ], + "loc": { + "start": { + "line": 156, + "column": 17 + }, + "end": { + "line": 156, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4148, + 4152 + ], + "loc": { + "start": { + "line": 156, + "column": 29 + }, + "end": { + "line": 156, + "column": 33 + } + } + }, + "range": [ + 4136, + 4152 + ], + "loc": { + "start": { + "line": 156, + "column": 17 + }, + "end": { + "line": 156, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "error", + "range": [ + 4153, + 4158 + ], + "loc": { + "start": { + "line": 156, + "column": 34 + }, + "end": { + "line": 156, + "column": 39 + } + } + } + ], + "range": [ + 4136, + 4159 + ], + "loc": { + "start": { + "line": 156, + "column": 17 + }, + "end": { + "line": 156, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 4164, + 4183 + ], + "loc": { + "start": { + "line": 156, + "column": 45 + }, + "end": { + "line": 156, + "column": 64 + } + } + }, + "range": [ + 4136, + 4183 + ], + "loc": { + "start": { + "line": 156, + "column": 17 + }, + "end": { + "line": 156, + "column": 64 + } + } + }, + "range": [ + 4127, + 4183 + ], + "loc": { + "start": { + "line": 156, + "column": 8 + }, + "end": { + "line": 156, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4194, + 4198 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "update", + "range": [ + 4199, + 4205 + ], + "loc": { + "start": { + "line": 158, + "column": 11 + }, + "end": { + "line": 158, + "column": 17 + } + } + }, + "range": [ + 4194, + 4205 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 17 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "store", + "range": [ + 4206, + 4211 + ], + "loc": { + "start": { + "line": 158, + "column": 18 + }, + "end": { + "line": 158, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 4213, + 4217 + ], + "loc": { + "start": { + "line": 158, + "column": 25 + }, + "end": { + "line": 158, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 4219, + 4221 + ], + "loc": { + "start": { + "line": 158, + "column": 31 + }, + "end": { + "line": 158, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 4223, + 4230 + ], + "loc": { + "start": { + "line": 158, + "column": 35 + }, + "end": { + "line": 158, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 4232, + 4239 + ], + "loc": { + "start": { + "line": 158, + "column": 44 + }, + "end": { + "line": 158, + "column": 51 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 4241, + 4245 + ], + "loc": { + "start": { + "line": 158, + "column": 53 + }, + "end": { + "line": 158, + "column": 57 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 4247, + 4252 + ], + "loc": { + "start": { + "line": 158, + "column": 59 + }, + "end": { + "line": 158, + "column": 64 + } + } + } + ], + "range": [ + 4194, + 4253 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 65 + } + } + }, + "range": [ + 4194, + 4254 + ], + "loc": { + "start": { + "line": 158, + "column": 6 + }, + "end": { + "line": 158, + "column": 66 + } + } + } + ], + "range": [ + 4185, + 4261 + ], + "loc": { + "start": { + "line": 156, + "column": 66 + }, + "end": { + "line": 160, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 4271, + 4276 + ], + "loc": { + "start": { + "line": 160, + "column": 15 + }, + "end": { + "line": 160, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 4277, + 4283 + ], + "loc": { + "start": { + "line": 160, + "column": 21 + }, + "end": { + "line": 160, + "column": 27 + } + } + }, + "range": [ + 4271, + 4283 + ], + "loc": { + "start": { + "line": 160, + "column": 15 + }, + "end": { + "line": 160, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4284, + 4288 + ], + "loc": { + "start": { + "line": 160, + "column": 28 + }, + "end": { + "line": 160, + "column": 32 + } + } + }, + "range": [ + 4271, + 4289 + ], + "loc": { + "start": { + "line": 160, + "column": 15 + }, + "end": { + "line": 160, + "column": 33 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "request", + "range": [ + 4304, + 4311 + ], + "loc": { + "start": { + "line": 162, + "column": 10 + }, + "end": { + "line": 162, + "column": 17 + } + } + }, + "init": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "XMLHttpRequest", + "range": [ + 4318, + 4332 + ], + "loc": { + "start": { + "line": 162, + "column": 24 + }, + "end": { + "line": 162, + "column": 38 + } + } + }, + "arguments": [], + "range": [ + 4314, + 4334 + ], + "loc": { + "start": { + "line": 162, + "column": 20 + }, + "end": { + "line": 162, + "column": 40 + } + } + }, + "range": [ + 4304, + 4334 + ], + "loc": { + "start": { + "line": 162, + "column": 10 + }, + "end": { + "line": 162, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 4300, + 4335 + ], + "loc": { + "start": { + "line": 162, + "column": 6 + }, + "end": { + "line": 162, + "column": 41 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "data", + "range": [ + 4346, + 4350 + ], + "loc": { + "start": { + "line": 163, + "column": 10 + }, + "end": { + "line": 163, + "column": 14 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 4353, + 4358 + ], + "loc": { + "start": { + "line": 163, + "column": 17 + }, + "end": { + "line": 163, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 4359, + 4366 + ], + "loc": { + "start": { + "line": 163, + "column": 23 + }, + "end": { + "line": 163, + "column": 30 + } + } + }, + "range": [ + 4353, + 4366 + ], + "loc": { + "start": { + "line": 163, + "column": 17 + }, + "end": { + "line": 163, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 4367, + 4371 + ], + "loc": { + "start": { + "line": 163, + "column": 31 + }, + "end": { + "line": 163, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 4373, + 4375 + ], + "loc": { + "start": { + "line": 163, + "column": 37 + }, + "end": { + "line": 163, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 4377, + 4384 + ], + "loc": { + "start": { + "line": 163, + "column": 41 + }, + "end": { + "line": 163, + "column": 48 + } + } + } + ], + "range": [ + 4353, + 4385 + ], + "loc": { + "start": { + "line": 163, + "column": 17 + }, + "end": { + "line": 163, + "column": 49 + } + } + }, + "range": [ + 4346, + 4385 + ], + "loc": { + "start": { + "line": 163, + "column": 10 + }, + "end": { + "line": 163, + "column": 49 + } + } + } + ], + "kind": "let", + "range": [ + 4342, + 4386 + ], + "loc": { + "start": { + "line": 163, + "column": 6 + }, + "end": { + "line": 163, + "column": 50 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4394, + 4401 + ], + "loc": { + "start": { + "line": 165, + "column": 6 + }, + "end": { + "line": 165, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "open", + "range": [ + 4402, + 4406 + ], + "loc": { + "start": { + "line": 165, + "column": 14 + }, + "end": { + "line": 165, + "column": 18 + } + } + }, + "range": [ + 4394, + 4406 + ], + "loc": { + "start": { + "line": 165, + "column": 6 + }, + "end": { + "line": 165, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "PATCH", + "raw": "'PATCH'", + "range": [ + 4407, + 4414 + ], + "loc": { + "start": { + "line": 165, + "column": 19 + }, + "end": { + "line": 165, + "column": 26 + } + } + }, + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": false, + "range": [ + 4416, + 4419 + ], + "loc": { + "start": { + "line": 165, + "column": 28 + }, + "end": { + "line": 165, + "column": 31 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 4429, + 4433 + ], + "loc": { + "start": { + "line": 165, + "column": 41 + }, + "end": { + "line": 165, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "/", + "cooked": "/" + }, + "tail": false, + "range": [ + 4437, + 4441 + ], + "loc": { + "start": { + "line": 165, + "column": 49 + }, + "end": { + "line": 165, + "column": 53 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "", + "cooked": "" + }, + "tail": true, + "range": [ + 4443, + 4445 + ], + "loc": { + "start": { + "line": 165, + "column": 55 + }, + "end": { + "line": 165, + "column": 57 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4419, + 4423 + ], + "loc": { + "start": { + "line": 165, + "column": 31 + }, + "end": { + "line": 165, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "_base", + "range": [ + 4424, + 4429 + ], + "loc": { + "start": { + "line": 165, + "column": 36 + }, + "end": { + "line": 165, + "column": 41 + } + } + }, + "range": [ + 4419, + 4429 + ], + "loc": { + "start": { + "line": 165, + "column": 31 + }, + "end": { + "line": 165, + "column": 41 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 4433, + 4437 + ], + "loc": { + "start": { + "line": 165, + "column": 45 + }, + "end": { + "line": 165, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 4441, + 4443 + ], + "loc": { + "start": { + "line": 165, + "column": 53 + }, + "end": { + "line": 165, + "column": 55 + } + } + } + ], + "range": [ + 4416, + 4445 + ], + "loc": { + "start": { + "line": 165, + "column": 28 + }, + "end": { + "line": 165, + "column": 57 + } + } + }, + { + "type": "Literal", + "value": true, + "raw": "true", + "range": [ + 4447, + 4451 + ], + "loc": { + "start": { + "line": 165, + "column": 59 + }, + "end": { + "line": 165, + "column": 63 + } + } + } + ], + "range": [ + 4394, + 4452 + ], + "loc": { + "start": { + "line": 165, + "column": 6 + }, + "end": { + "line": 165, + "column": 64 + } + } + }, + "range": [ + 4394, + 4453 + ], + "loc": { + "start": { + "line": 165, + "column": 6 + }, + "end": { + "line": 165, + "column": 65 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4461, + 4468 + ], + "loc": { + "start": { + "line": 167, + "column": 6 + }, + "end": { + "line": 167, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "setRequestHeader", + "range": [ + 4469, + 4485 + ], + "loc": { + "start": { + "line": 167, + "column": 14 + }, + "end": { + "line": 167, + "column": 30 + } + } + }, + "range": [ + 4461, + 4485 + ], + "loc": { + "start": { + "line": 167, + "column": 6 + }, + "end": { + "line": 167, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Content-Type", + "raw": "\"Content-Type\"", + "range": [ + 4486, + 4500 + ], + "loc": { + "start": { + "line": 167, + "column": 31 + }, + "end": { + "line": 167, + "column": 45 + } + } + }, + { + "type": "Literal", + "value": "application/vnd.api+json", + "raw": "\"application/vnd.api+json\"", + "range": [ + 4502, + 4528 + ], + "loc": { + "start": { + "line": 167, + "column": 47 + }, + "end": { + "line": 167, + "column": 73 + } + } + } + ], + "range": [ + 4461, + 4529 + ], + "loc": { + "start": { + "line": 167, + "column": 6 + }, + "end": { + "line": 167, + "column": 74 + } + } + }, + "range": [ + 4461, + 4530 + ], + "loc": { + "start": { + "line": 167, + "column": 6 + }, + "end": { + "line": 167, + "column": 75 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4538, + 4545 + ], + "loc": { + "start": { + "line": 169, + "column": 6 + }, + "end": { + "line": 169, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "onload", + "range": [ + 4546, + 4552 + ], + "loc": { + "start": { + "line": 169, + "column": 14 + }, + "end": { + "line": 169, + "column": 20 + } + } + }, + "range": [ + 4538, + 4552 + ], + "loc": { + "start": { + "line": 169, + "column": 6 + }, + "end": { + "line": 169, + "column": 20 + } + } + }, + "right": { + "type": "FunctionExpression", + "id": null, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": ">=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4581, + 4588 + ], + "loc": { + "start": { + "line": 170, + "column": 12 + }, + "end": { + "line": 170, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 4589, + 4595 + ], + "loc": { + "start": { + "line": 170, + "column": 20 + }, + "end": { + "line": 170, + "column": 26 + } + } + }, + "range": [ + 4581, + 4595 + ], + "loc": { + "start": { + "line": 170, + "column": 12 + }, + "end": { + "line": 170, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": 200, + "raw": "200", + "range": [ + 4599, + 4602 + ], + "loc": { + "start": { + "line": 170, + "column": 30 + }, + "end": { + "line": 170, + "column": 33 + } + } + }, + "range": [ + 4581, + 4602 + ], + "loc": { + "start": { + "line": 170, + "column": 12 + }, + "end": { + "line": 170, + "column": 33 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4606, + 4613 + ], + "loc": { + "start": { + "line": 170, + "column": 37 + }, + "end": { + "line": 170, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "status", + "range": [ + 4614, + 4620 + ], + "loc": { + "start": { + "line": 170, + "column": 45 + }, + "end": { + "line": 170, + "column": 51 + } + } + }, + "range": [ + 4606, + 4620 + ], + "loc": { + "start": { + "line": 170, + "column": 37 + }, + "end": { + "line": 170, + "column": 51 + } + } + }, + "right": { + "type": "Literal", + "value": 300, + "raw": "300", + "range": [ + 4623, + 4626 + ], + "loc": { + "start": { + "line": 170, + "column": 54 + }, + "end": { + "line": 170, + "column": 57 + } + } + }, + "range": [ + 4606, + 4626 + ], + "loc": { + "start": { + "line": 170, + "column": 37 + }, + "end": { + "line": 170, + "column": 57 + } + } + }, + "range": [ + 4581, + 4626 + ], + "loc": { + "start": { + "line": 170, + "column": 12 + }, + "end": { + "line": 170, + "column": 57 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "TryStatement", + "block": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 4658, + 4663 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 4664, + 4667 + ], + "loc": { + "start": { + "line": 172, + "column": 18 + }, + "end": { + "line": 172, + "column": 21 + } + } + }, + "range": [ + 4658, + 4667 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 4668, + 4672 + ], + "loc": { + "start": { + "line": 172, + "column": 22 + }, + "end": { + "line": 172, + "column": 26 + } + } + } + ], + "range": [ + 4658, + 4673 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 27 + } + } + }, + "range": [ + 4658, + 4674 + ], + "loc": { + "start": { + "line": 172, + "column": 12 + }, + "end": { + "line": 172, + "column": 28 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "success", + "range": [ + 4691, + 4698 + ], + "loc": { + "start": { + "line": 173, + "column": 16 + }, + "end": { + "line": 173, + "column": 23 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "success", + "range": [ + 4716, + 4723 + ], + "loc": { + "start": { + "line": 174, + "column": 14 + }, + "end": { + "line": 174, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4724, + 4728 + ], + "loc": { + "start": { + "line": 174, + "column": 22 + }, + "end": { + "line": 174, + "column": 26 + } + } + }, + "range": [ + 4716, + 4728 + ], + "loc": { + "start": { + "line": 174, + "column": 14 + }, + "end": { + "line": 174, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 4729, + 4736 + ], + "loc": { + "start": { + "line": 174, + "column": 27 + }, + "end": { + "line": 174, + "column": 34 + } + } + }, + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "store", + "range": [ + 4738, + 4743 + ], + "loc": { + "start": { + "line": 174, + "column": 36 + }, + "end": { + "line": 174, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 4744, + 4748 + ], + "loc": { + "start": { + "line": 174, + "column": 42 + }, + "end": { + "line": 174, + "column": 46 + } + } + }, + "range": [ + 4738, + 4748 + ], + "loc": { + "start": { + "line": 174, + "column": 36 + }, + "end": { + "line": 174, + "column": 46 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 4749, + 4753 + ], + "loc": { + "start": { + "line": 174, + "column": 47 + }, + "end": { + "line": 174, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4754, + 4758 + ], + "loc": { + "start": { + "line": 174, + "column": 52 + }, + "end": { + "line": 174, + "column": 56 + } + } + }, + "range": [ + 4749, + 4758 + ], + "loc": { + "start": { + "line": 174, + "column": 47 + }, + "end": { + "line": 174, + "column": 56 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 4760, + 4764 + ], + "loc": { + "start": { + "line": 174, + "column": 58 + }, + "end": { + "line": 174, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4765, + 4767 + ], + "loc": { + "start": { + "line": 174, + "column": 63 + }, + "end": { + "line": 174, + "column": 65 + } + } + }, + "range": [ + 4760, + 4767 + ], + "loc": { + "start": { + "line": 174, + "column": 58 + }, + "end": { + "line": 174, + "column": 65 + } + } + } + ], + "range": [ + 4738, + 4768 + ], + "loc": { + "start": { + "line": 174, + "column": 36 + }, + "end": { + "line": 174, + "column": 66 + } + } + } + ], + "range": [ + 4716, + 4769 + ], + "loc": { + "start": { + "line": 174, + "column": 14 + }, + "end": { + "line": 174, + "column": 67 + } + } + }, + "range": [ + 4716, + 4770 + ], + "loc": { + "start": { + "line": 174, + "column": 14 + }, + "end": { + "line": 174, + "column": 68 + } + } + } + ], + "range": [ + 4700, + 4784 + ], + "loc": { + "start": { + "line": 173, + "column": 25 + }, + "end": { + "line": 175, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 4687, + 4784 + ], + "loc": { + "start": { + "line": 173, + "column": 12 + }, + "end": { + "line": 175, + "column": 13 + } + } + } + ], + "range": [ + 4644, + 4796 + ], + "loc": { + "start": { + "line": 171, + "column": 14 + }, + "end": { + "line": 176, + "column": 11 + } + } + }, + "handler": { + "type": "CatchClause", + "param": { + "type": "Identifier", + "name": "e", + "range": [ + 4804, + 4805 + ], + "loc": { + "start": { + "line": 176, + "column": 19 + }, + "end": { + "line": 176, + "column": 20 + } + } + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 4825, + 4830 + ], + "loc": { + "start": { + "line": 177, + "column": 16 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 4848, + 4853 + ], + "loc": { + "start": { + "line": 178, + "column": 14 + }, + "end": { + "line": 178, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4854, + 4858 + ], + "loc": { + "start": { + "line": 178, + "column": 20 + }, + "end": { + "line": 178, + "column": 24 + } + } + }, + "range": [ + 4848, + 4858 + ], + "loc": { + "start": { + "line": 178, + "column": 14 + }, + "end": { + "line": 178, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 4859, + 4866 + ], + "loc": { + "start": { + "line": 178, + "column": 25 + }, + "end": { + "line": 178, + "column": 32 + } + } + }, + { + "type": "Identifier", + "name": "e", + "range": [ + 4868, + 4869 + ], + "loc": { + "start": { + "line": 178, + "column": 34 + }, + "end": { + "line": 178, + "column": 35 + } + } + } + ], + "range": [ + 4848, + 4870 + ], + "loc": { + "start": { + "line": 178, + "column": 14 + }, + "end": { + "line": 178, + "column": 36 + } + } + }, + "range": [ + 4848, + 4871 + ], + "loc": { + "start": { + "line": 178, + "column": 14 + }, + "end": { + "line": 178, + "column": 37 + } + } + } + ], + "range": [ + 4832, + 4885 + ], + "loc": { + "start": { + "line": 177, + "column": 23 + }, + "end": { + "line": 179, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 4821, + 4885 + ], + "loc": { + "start": { + "line": 177, + "column": 12 + }, + "end": { + "line": 179, + "column": 13 + } + } + } + ], + "range": [ + 4807, + 4897 + ], + "loc": { + "start": { + "line": 176, + "column": 22 + }, + "end": { + "line": 180, + "column": 11 + } + } + }, + "range": [ + 4797, + 4897 + ], + "loc": { + "start": { + "line": 176, + "column": 12 + }, + "end": { + "line": 180, + "column": 11 + } + } + }, + "finalizer": null, + "range": [ + 4640, + 4897 + ], + "loc": { + "start": { + "line": 171, + "column": 10 + }, + "end": { + "line": 180, + "column": 11 + } + } + } + ], + "range": [ + 4628, + 4907 + ], + "loc": { + "start": { + "line": 170, + "column": 59 + }, + "end": { + "line": 181, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "error", + "range": [ + 4917, + 4922 + ], + "loc": { + "start": { + "line": 181, + "column": 19 + }, + "end": { + "line": 181, + "column": 24 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "error", + "range": [ + 4936, + 4941 + ], + "loc": { + "start": { + "line": 182, + "column": 10 + }, + "end": { + "line": 182, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4942, + 4946 + ], + "loc": { + "start": { + "line": 182, + "column": 16 + }, + "end": { + "line": 182, + "column": 20 + } + } + }, + "range": [ + 4936, + 4946 + ], + "loc": { + "start": { + "line": 182, + "column": 10 + }, + "end": { + "line": 182, + "column": 20 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 4947, + 4954 + ], + "loc": { + "start": { + "line": 182, + "column": 21 + }, + "end": { + "line": 182, + "column": 28 + } + } + } + ], + "range": [ + 4936, + 4955 + ], + "loc": { + "start": { + "line": 182, + "column": 10 + }, + "end": { + "line": 182, + "column": 29 + } + } + }, + "range": [ + 4936, + 4956 + ], + "loc": { + "start": { + "line": 182, + "column": 10 + }, + "end": { + "line": 182, + "column": 30 + } + } + } + ], + "range": [ + 4924, + 4966 + ], + "loc": { + "start": { + "line": 181, + "column": 26 + }, + "end": { + "line": 183, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 4913, + 4966 + ], + "loc": { + "start": { + "line": 181, + "column": 15 + }, + "end": { + "line": 183, + "column": 9 + } + } + }, + "range": [ + 4577, + 4966 + ], + "loc": { + "start": { + "line": 170, + "column": 8 + }, + "end": { + "line": 183, + "column": 9 + } + } + } + ], + "range": [ + 4567, + 4974 + ], + "loc": { + "start": { + "line": 169, + "column": 35 + }, + "end": { + "line": 184, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 4555, + 4974 + ], + "loc": { + "start": { + "line": 169, + "column": 23 + }, + "end": { + "line": 184, + "column": 7 + } + } + }, + "range": [ + 4538, + 4974 + ], + "loc": { + "start": { + "line": 169, + "column": 6 + }, + "end": { + "line": 184, + "column": 7 + } + } + }, + "range": [ + 4538, + 4975 + ], + "loc": { + "start": { + "line": 169, + "column": 6 + }, + "end": { + "line": 184, + "column": 8 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "request", + "range": [ + 4983, + 4990 + ], + "loc": { + "start": { + "line": 186, + "column": 6 + }, + "end": { + "line": 186, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "send", + "range": [ + 4991, + 4995 + ], + "loc": { + "start": { + "line": 186, + "column": 14 + }, + "end": { + "line": 186, + "column": 18 + } + } + }, + "range": [ + 4983, + 4995 + ], + "loc": { + "start": { + "line": 186, + "column": 6 + }, + "end": { + "line": 186, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "JSON", + "range": [ + 4996, + 5000 + ], + "loc": { + "start": { + "line": 186, + "column": 19 + }, + "end": { + "line": 186, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "stringify", + "range": [ + 5001, + 5010 + ], + "loc": { + "start": { + "line": 186, + "column": 24 + }, + "end": { + "line": 186, + "column": 33 + } + } + }, + "range": [ + 4996, + 5010 + ], + "loc": { + "start": { + "line": 186, + "column": 19 + }, + "end": { + "line": 186, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 5021, + 5025 + ], + "loc": { + "start": { + "line": 187, + "column": 8 + }, + "end": { + "line": 187, + "column": 12 + } + } + }, + "value": { + "type": "Identifier", + "name": "data", + "range": [ + 5027, + 5031 + ], + "loc": { + "start": { + "line": 187, + "column": 14 + }, + "end": { + "line": 187, + "column": 18 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 5021, + 5031 + ], + "loc": { + "start": { + "line": 187, + "column": 8 + }, + "end": { + "line": 187, + "column": 18 + } + } + } + ], + "range": [ + 5011, + 5039 + ], + "loc": { + "start": { + "line": 186, + "column": 34 + }, + "end": { + "line": 188, + "column": 7 + } + } + } + ], + "range": [ + 4996, + 5040 + ], + "loc": { + "start": { + "line": 186, + "column": 19 + }, + "end": { + "line": 188, + "column": 8 + } + } + } + ], + "range": [ + 4983, + 5041 + ], + "loc": { + "start": { + "line": 186, + "column": 6 + }, + "end": { + "line": 188, + "column": 9 + } + } + }, + "range": [ + 4983, + 5042 + ], + "loc": { + "start": { + "line": 186, + "column": 6 + }, + "end": { + "line": 188, + "column": 10 + } + } + } + ], + "range": [ + 4291, + 5049 + ], + "loc": { + "start": { + "line": 160, + "column": 35 + }, + "end": { + "line": 190, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 5073, + 5078 + ], + "loc": { + "start": { + "line": 191, + "column": 16 + }, + "end": { + "line": 191, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 5079, + 5096 + ], + "loc": { + "start": { + "line": 191, + "column": 22 + }, + "end": { + "line": 191, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 5100, + 5103 + ], + "loc": { + "start": { + "line": 191, + "column": 43 + }, + "end": { + "line": 191, + "column": 46 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 5096, + 5100 + ], + "loc": { + "start": { + "line": 191, + "column": 39 + }, + "end": { + "line": 191, + "column": 43 + } + } + } + ], + "range": [ + 5079, + 5103 + ], + "loc": { + "start": { + "line": 191, + "column": 22 + }, + "end": { + "line": 191, + "column": 46 + } + } + } + ], + "range": [ + 5069, + 5104 + ], + "loc": { + "start": { + "line": 191, + "column": 12 + }, + "end": { + "line": 191, + "column": 47 + } + } + }, + "range": [ + 5063, + 5105 + ], + "loc": { + "start": { + "line": 191, + "column": 6 + }, + "end": { + "line": 191, + "column": 48 + } + } + } + ], + "range": [ + 5055, + 5111 + ], + "loc": { + "start": { + "line": 190, + "column": 11 + }, + "end": { + "line": 192, + "column": 5 + } + } + }, + "range": [ + 4267, + 5111 + ], + "loc": { + "start": { + "line": 160, + "column": 11 + }, + "end": { + "line": 192, + "column": 5 + } + } + }, + "range": [ + 4123, + 5111 + ], + "loc": { + "start": { + "line": 156, + "column": 4 + }, + "end": { + "line": 192, + "column": 5 + } + } + } + ], + "range": [ + 4116, + 5116 + ], + "loc": { + "start": { + "line": 154, + "column": 60 + }, + "end": { + "line": 194, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 4064, + 5116 + ], + "loc": { + "start": { + "line": 154, + "column": 8 + }, + "end": { + "line": 194, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 4058, + 5116 + ], + "loc": { + "start": { + "line": 154, + "column": 2 + }, + "end": { + "line": 194, + "column": 3 + } + }, + "static": false + } + ], + "range": [ + 33, + 5119 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 196, + "column": 1 + } + } + }, + "range": [ + 15, + 5119 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 196, + "column": 1 + } + }, + "leadingComments": [], + "trailingComments": [] + }, + "range": [ + 0, + 5119 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 196, + "column": 1 + } + } + } + ], + "sourceType": "module", + "range": [ + 0, + 5119 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 196, + "column": 1 + } + }, + "comments": [] +} \ No newline at end of file diff --git a/docs/v0.7.0/ast/source/src/store.js.json b/docs/v0.7.0/ast/source/src/store.js.json new file mode 100644 index 0000000..eb2d4d4 --- /dev/null +++ b/docs/v0.7.0/ast/source/src/store.js.json @@ -0,0 +1,44996 @@ +{ + "type": "Program", + "body": [ + { + "type": "ImportDeclaration", + "specifiers": [], + "source": { + "type": "Literal", + "value": "array.prototype.find", + "raw": "\"array.prototype.find\"", + "range": [ + 7, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 29 + } + } + }, + "range": [ + 0, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "ImportDeclaration", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 38, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + "range": [ + 38, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 18 + } + } + } + ], + "source": { + "type": "Literal", + "value": "./ajax-adapter", + "raw": "\"./ajax-adapter\"", + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 40 + } + } + }, + "range": [ + 31, + 72 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 41 + } + } + }, + { + "type": "ExportDefaultDeclaration", + "declaration": { + "type": "ClassDeclaration", + "id": { + "type": "Identifier", + "name": "Store", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 26 + } + } + }, + "superClass": null, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "attr", + "range": [ + 438, + 442 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 13 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 443, + 447 + ], + "loc": { + "start": { + "line": 15, + "column": 14 + }, + "end": { + "line": 15, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 449, + 456 + ], + "loc": { + "start": { + "line": 15, + "column": 20 + }, + "end": { + "line": 15, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 468, + 472 + ], + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 483, + 487 + ], + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 476, + 487 + ], + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 492, + 500 + ], + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "range": [ + 476, + 500 + ], + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "range": [ + 468, + 500 + ], + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 517, + 522 + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "attr", + "range": [ + 523, + 527 + ], + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 23 + } + } + }, + "range": [ + 517, + 527 + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 528, + 532 + ], + "loc": { + "start": { + "line": 17, + "column": 24 + }, + "end": { + "line": 17, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 534, + 538 + ], + "loc": { + "start": { + "line": 17, + "column": 30 + }, + "end": { + "line": 17, + "column": 34 + } + } + } + ], + "range": [ + 517, + 539 + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 35 + } + } + }, + "range": [ + 510, + 540 + ], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 36 + } + } + } + ], + "range": [ + 502, + 546 + ], + "loc": { + "start": { + "line": 16, + "column": 42 + }, + "end": { + "line": 18, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 577, + 581 + ], + "loc": { + "start": { + "line": 20, + "column": 8 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 583, + 589 + ], + "loc": { + "start": { + "line": 20, + "column": 14 + }, + "end": { + "line": 20, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 577, + 589 + ], + "loc": { + "start": { + "line": 20, + "column": 8 + }, + "end": { + "line": 20, + "column": 20 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "default", + "range": [ + 599, + 606 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 608, + 615 + ], + "loc": { + "start": { + "line": 21, + "column": 17 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 619, + 626 + ], + "loc": { + "start": { + "line": 21, + "column": 28 + }, + "end": { + "line": 21, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "default", + "range": [ + 627, + 634 + ], + "loc": { + "start": { + "line": 21, + "column": 36 + }, + "end": { + "line": 21, + "column": 43 + } + } + }, + "range": [ + 619, + 634 + ], + "loc": { + "start": { + "line": 21, + "column": 28 + }, + "end": { + "line": 21, + "column": 43 + } + } + }, + "range": [ + 608, + 634 + ], + "loc": { + "start": { + "line": 21, + "column": 17 + }, + "end": { + "line": 21, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 599, + 634 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 644, + 655 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 667, + 671 + ], + "loc": { + "start": { + "line": 22, + "column": 31 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 673, + 676 + ], + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 697, + 701 + ], + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 702, + 712 + ], + "loc": { + "start": { + "line": 23, + "column": 22 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "range": [ + 697, + 712 + ], + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 716, + 720 + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 721, + 731 + ], + "loc": { + "start": { + "line": 23, + "column": 41 + }, + "end": { + "line": 23, + "column": 51 + } + } + }, + "range": [ + 716, + 731 + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 51 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 732, + 736 + ], + "loc": { + "start": { + "line": 23, + "column": 52 + }, + "end": { + "line": 23, + "column": 56 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 740, + 743 + ], + "loc": { + "start": { + "line": 23, + "column": 60 + }, + "end": { + "line": 23, + "column": 63 + } + } + }, + "range": [ + 732, + 743 + ], + "loc": { + "start": { + "line": 23, + "column": 52 + }, + "end": { + "line": 23, + "column": 63 + } + } + }, + "range": [ + 716, + 744 + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 64 + } + } + }, + "range": [ + 697, + 744 + ], + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 64 + } + } + }, + "range": [ + 690, + 745 + ], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 65 + } + } + } + ], + "range": [ + 678, + 755 + ], + "loc": { + "start": { + "line": 22, + "column": 42 + }, + "end": { + "line": 24, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 657, + 755 + ], + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 24, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 644, + 755 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 24, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 765, + 774 + ], + "loc": { + "start": { + "line": 25, + "column": 8 + }, + "end": { + "line": 25, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 786, + 794 + ], + "loc": { + "start": { + "line": 25, + "column": 29 + }, + "end": { + "line": 25, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 796, + 800 + ], + "loc": { + "start": { + "line": 25, + "column": 39 + }, + "end": { + "line": 25, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 802, + 805 + ], + "loc": { + "start": { + "line": 25, + "column": 45 + }, + "end": { + "line": 25, + "column": 48 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 819, + 823 + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 824, + 834 + ], + "loc": { + "start": { + "line": 26, + "column": 15 + }, + "end": { + "line": 26, + "column": 25 + } + } + }, + "range": [ + 819, + 834 + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 25 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 835, + 839 + ], + "loc": { + "start": { + "line": 26, + "column": 26 + }, + "end": { + "line": 26, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 843, + 846 + ], + "loc": { + "start": { + "line": 26, + "column": 34 + }, + "end": { + "line": 26, + "column": 37 + } + } + }, + "range": [ + 835, + 846 + ], + "loc": { + "start": { + "line": 26, + "column": 26 + }, + "end": { + "line": 26, + "column": 37 + } + } + }, + "range": [ + 819, + 847 + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 850, + 858 + ], + "loc": { + "start": { + "line": 26, + "column": 41 + }, + "end": { + "line": 26, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 859, + 862 + ], + "loc": { + "start": { + "line": 26, + "column": 50 + }, + "end": { + "line": 26, + "column": 53 + } + } + }, + "range": [ + 850, + 863 + ], + "loc": { + "start": { + "line": 26, + "column": 41 + }, + "end": { + "line": 26, + "column": 54 + } + } + }, + "range": [ + 819, + 863 + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 54 + } + } + }, + "range": [ + 819, + 864 + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 55 + } + } + } + ], + "range": [ + 807, + 874 + ], + "loc": { + "start": { + "line": 25, + "column": 50 + }, + "end": { + "line": 27, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 776, + 874 + ], + "loc": { + "start": { + "line": 25, + "column": 19 + }, + "end": { + "line": 27, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 765, + 874 + ], + "loc": { + "start": { + "line": 25, + "column": 8 + }, + "end": { + "line": 27, + "column": 9 + } + } + } + ], + "range": [ + 567, + 882 + ], + "loc": { + "start": { + "line": 19, + "column": 13 + }, + "end": { + "line": 28, + "column": 7 + } + } + }, + "range": [ + 560, + 883 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 28, + "column": 8 + } + } + } + ], + "range": [ + 552, + 889 + ], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 29, + "column": 5 + } + } + }, + "range": [ + 464, + 889 + ], + "loc": { + "start": { + "line": 16, + "column": 4 + }, + "end": { + "line": 29, + "column": 5 + } + } + } + ], + "range": [ + 458, + 893 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 30, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 442, + 893 + ], + "loc": { + "start": { + "line": 15, + "column": 13 + }, + "end": { + "line": 30, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 431, + 893 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 30, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n ", + "range": [ + 106, + 428 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 897, + 1234 + ], + "loc": { + "start": { + "line": 32, + "column": 2 + }, + "end": { + "line": 40, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "hasOne", + "range": [ + 1244, + 1250 + ], + "loc": { + "start": { + "line": 41, + "column": 9 + }, + "end": { + "line": 41, + "column": 15 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 1251, + 1255 + ], + "loc": { + "start": { + "line": 41, + "column": 16 + }, + "end": { + "line": 41, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 1257, + 1264 + ], + "loc": { + "start": { + "line": 41, + "column": 22 + }, + "end": { + "line": 41, + "column": 29 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1276, + 1280 + ], + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 1291, + 1295 + ], + "loc": { + "start": { + "line": 42, + "column": 23 + }, + "end": { + "line": 42, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 1284, + 1295 + ], + "loc": { + "start": { + "line": 42, + "column": 16 + }, + "end": { + "line": 42, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 1300, + 1308 + ], + "loc": { + "start": { + "line": 42, + "column": 32 + }, + "end": { + "line": 42, + "column": 40 + } + } + }, + "range": [ + 1284, + 1308 + ], + "loc": { + "start": { + "line": 42, + "column": 16 + }, + "end": { + "line": 42, + "column": 40 + } + } + }, + "range": [ + 1276, + 1308 + ], + "loc": { + "start": { + "line": 42, + "column": 8 + }, + "end": { + "line": 42, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 1325, + 1330 + ], + "loc": { + "start": { + "line": 43, + "column": 13 + }, + "end": { + "line": 43, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasOne", + "range": [ + 1331, + 1337 + ], + "loc": { + "start": { + "line": 43, + "column": 19 + }, + "end": { + "line": 43, + "column": 25 + } + } + }, + "range": [ + 1325, + 1337 + ], + "loc": { + "start": { + "line": 43, + "column": 13 + }, + "end": { + "line": 43, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1338, + 1342 + ], + "loc": { + "start": { + "line": 43, + "column": 26 + }, + "end": { + "line": 43, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 1344, + 1348 + ], + "loc": { + "start": { + "line": 43, + "column": 32 + }, + "end": { + "line": 43, + "column": 36 + } + } + } + ], + "range": [ + 1325, + 1349 + ], + "loc": { + "start": { + "line": 43, + "column": 13 + }, + "end": { + "line": 43, + "column": 37 + } + } + }, + "range": [ + 1318, + 1350 + ], + "loc": { + "start": { + "line": 43, + "column": 6 + }, + "end": { + "line": 43, + "column": 38 + } + } + } + ], + "range": [ + 1310, + 1356 + ], + "loc": { + "start": { + "line": 42, + "column": 42 + }, + "end": { + "line": 44, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 1387, + 1391 + ], + "loc": { + "start": { + "line": 46, + "column": 8 + }, + "end": { + "line": 46, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 1393, + 1402 + ], + "loc": { + "start": { + "line": 46, + "column": 14 + }, + "end": { + "line": 46, + "column": 23 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1387, + 1402 + ], + "loc": { + "start": { + "line": 46, + "column": 8 + }, + "end": { + "line": 46, + "column": 23 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "inverse", + "range": [ + 1412, + 1419 + ], + "loc": { + "start": { + "line": 47, + "column": 8 + }, + "end": { + "line": 47, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 1421, + 1428 + ], + "loc": { + "start": { + "line": 47, + "column": 17 + }, + "end": { + "line": 47, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 1432, + 1439 + ], + "loc": { + "start": { + "line": 47, + "column": 28 + }, + "end": { + "line": 47, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 1440, + 1447 + ], + "loc": { + "start": { + "line": 47, + "column": 36 + }, + "end": { + "line": 47, + "column": 43 + } + } + }, + "range": [ + 1432, + 1447 + ], + "loc": { + "start": { + "line": 47, + "column": 28 + }, + "end": { + "line": 47, + "column": 43 + } + } + }, + "range": [ + 1421, + 1447 + ], + "loc": { + "start": { + "line": 47, + "column": 17 + }, + "end": { + "line": 47, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1412, + 1447 + ], + "loc": { + "start": { + "line": 47, + "column": 8 + }, + "end": { + "line": 47, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 1457, + 1468 + ], + "loc": { + "start": { + "line": 48, + "column": 8 + }, + "end": { + "line": 48, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 1480, + 1484 + ], + "loc": { + "start": { + "line": 48, + "column": 31 + }, + "end": { + "line": 48, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 1486, + 1489 + ], + "loc": { + "start": { + "line": 48, + "column": 37 + }, + "end": { + "line": 48, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1503, + 1507 + ], + "loc": { + "start": { + "line": 49, + "column": 10 + }, + "end": { + "line": 49, + "column": 14 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1510, + 1514 + ], + "loc": { + "start": { + "line": 49, + "column": 17 + }, + "end": { + "line": 49, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 1518, + 1521 + ], + "loc": { + "start": { + "line": 49, + "column": 25 + }, + "end": { + "line": 49, + "column": 28 + } + } + }, + "range": [ + 1510, + 1521 + ], + "loc": { + "start": { + "line": 49, + "column": 17 + }, + "end": { + "line": 49, + "column": 28 + } + } + }, + "range": [ + 1503, + 1521 + ], + "loc": { + "start": { + "line": 49, + "column": 10 + }, + "end": { + "line": 49, + "column": 28 + } + } + }, + "range": [ + 1503, + 1522 + ], + "loc": { + "start": { + "line": 49, + "column": 10 + }, + "end": { + "line": 49, + "column": 29 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1537, + 1541 + ], + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1542, + 1555 + ], + "loc": { + "start": { + "line": 50, + "column": 19 + }, + "end": { + "line": 50, + "column": 32 + } + } + }, + "range": [ + 1537, + 1555 + ], + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1559, + 1563 + ], + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1564, + 1577 + ], + "loc": { + "start": { + "line": 50, + "column": 41 + }, + "end": { + "line": 50, + "column": 54 + } + } + }, + "range": [ + 1559, + 1577 + ], + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1578, + 1582 + ], + "loc": { + "start": { + "line": 50, + "column": 55 + }, + "end": { + "line": 50, + "column": 59 + } + } + }, + "range": [ + 1559, + 1583 + ], + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 60 + } + } + }, + "range": [ + 1537, + 1583 + ], + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 60 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1603, + 1607 + ], + "loc": { + "start": { + "line": 51, + "column": 16 + }, + "end": { + "line": 51, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1608, + 1621 + ], + "loc": { + "start": { + "line": 51, + "column": 21 + }, + "end": { + "line": 51, + "column": 34 + } + } + }, + "range": [ + 1603, + 1621 + ], + "loc": { + "start": { + "line": 51, + "column": 16 + }, + "end": { + "line": 51, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1622, + 1626 + ], + "loc": { + "start": { + "line": 51, + "column": 35 + }, + "end": { + "line": 51, + "column": 39 + } + } + }, + "range": [ + 1603, + 1627 + ], + "loc": { + "start": { + "line": 51, + "column": 16 + }, + "end": { + "line": 51, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1628, + 1632 + ], + "loc": { + "start": { + "line": 51, + "column": 41 + }, + "end": { + "line": 51, + "column": 45 + } + } + }, + "range": [ + 1603, + 1632 + ], + "loc": { + "start": { + "line": 51, + "column": 16 + }, + "end": { + "line": 51, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1637, + 1641 + ], + "loc": { + "start": { + "line": 51, + "column": 50 + }, + "end": { + "line": 51, + "column": 54 + } + } + }, + "range": [ + 1603, + 1641 + ], + "loc": { + "start": { + "line": 51, + "column": 16 + }, + "end": { + "line": 51, + "column": 54 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1666, + 1670 + ], + "loc": { + "start": { + "line": 52, + "column": 21 + }, + "end": { + "line": 52, + "column": 25 + } + } + }, + "range": [ + 1659, + 1671 + ], + "loc": { + "start": { + "line": 52, + "column": 14 + }, + "end": { + "line": 52, + "column": 26 + } + } + } + ], + "range": [ + 1643, + 1685 + ], + "loc": { + "start": { + "line": 51, + "column": 56 + }, + "end": { + "line": 53, + "column": 13 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1695, + 1699 + ], + "loc": { + "start": { + "line": 53, + "column": 23 + }, + "end": { + "line": 53, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1700, + 1713 + ], + "loc": { + "start": { + "line": 53, + "column": 28 + }, + "end": { + "line": 53, + "column": 41 + } + } + }, + "range": [ + 1695, + 1713 + ], + "loc": { + "start": { + "line": 53, + "column": 23 + }, + "end": { + "line": 53, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1714, + 1718 + ], + "loc": { + "start": { + "line": 53, + "column": 42 + }, + "end": { + "line": 53, + "column": 46 + } + } + }, + "range": [ + 1695, + 1719 + ], + "loc": { + "start": { + "line": 53, + "column": 23 + }, + "end": { + "line": 53, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1720, + 1724 + ], + "loc": { + "start": { + "line": 53, + "column": 48 + }, + "end": { + "line": 53, + "column": 52 + } + } + }, + "range": [ + 1695, + 1724 + ], + "loc": { + "start": { + "line": 53, + "column": 23 + }, + "end": { + "line": 53, + "column": 52 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 1749, + 1753 + ], + "loc": { + "start": { + "line": 54, + "column": 21 + }, + "end": { + "line": 54, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 1754, + 1758 + ], + "loc": { + "start": { + "line": 54, + "column": 26 + }, + "end": { + "line": 54, + "column": 30 + } + } + }, + "range": [ + 1749, + 1758 + ], + "loc": { + "start": { + "line": 54, + "column": 21 + }, + "end": { + "line": 54, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1759, + 1763 + ], + "loc": { + "start": { + "line": 54, + "column": 31 + }, + "end": { + "line": 54, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1764, + 1777 + ], + "loc": { + "start": { + "line": 54, + "column": 36 + }, + "end": { + "line": 54, + "column": 49 + } + } + }, + "range": [ + 1759, + 1777 + ], + "loc": { + "start": { + "line": 54, + "column": 31 + }, + "end": { + "line": 54, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1778, + 1782 + ], + "loc": { + "start": { + "line": 54, + "column": 50 + }, + "end": { + "line": 54, + "column": 54 + } + } + }, + "range": [ + 1759, + 1783 + ], + "loc": { + "start": { + "line": 54, + "column": 31 + }, + "end": { + "line": 54, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1784, + 1788 + ], + "loc": { + "start": { + "line": 54, + "column": 56 + }, + "end": { + "line": 54, + "column": 60 + } + } + }, + "range": [ + 1759, + 1788 + ], + "loc": { + "start": { + "line": 54, + "column": 31 + }, + "end": { + "line": 54, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 1789, + 1793 + ], + "loc": { + "start": { + "line": 54, + "column": 61 + }, + "end": { + "line": 54, + "column": 65 + } + } + }, + "range": [ + 1759, + 1793 + ], + "loc": { + "start": { + "line": 54, + "column": 31 + }, + "end": { + "line": 54, + "column": 65 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1795, + 1799 + ], + "loc": { + "start": { + "line": 54, + "column": 67 + }, + "end": { + "line": 54, + "column": 71 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1800, + 1813 + ], + "loc": { + "start": { + "line": 54, + "column": 72 + }, + "end": { + "line": 54, + "column": 85 + } + } + }, + "range": [ + 1795, + 1813 + ], + "loc": { + "start": { + "line": 54, + "column": 67 + }, + "end": { + "line": 54, + "column": 85 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1814, + 1818 + ], + "loc": { + "start": { + "line": 54, + "column": 86 + }, + "end": { + "line": 54, + "column": 90 + } + } + }, + "range": [ + 1795, + 1819 + ], + "loc": { + "start": { + "line": 54, + "column": 67 + }, + "end": { + "line": 54, + "column": 91 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1820, + 1824 + ], + "loc": { + "start": { + "line": 54, + "column": 92 + }, + "end": { + "line": 54, + "column": 96 + } + } + }, + "range": [ + 1795, + 1824 + ], + "loc": { + "start": { + "line": 54, + "column": 67 + }, + "end": { + "line": 54, + "column": 96 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 1825, + 1827 + ], + "loc": { + "start": { + "line": 54, + "column": 97 + }, + "end": { + "line": 54, + "column": 99 + } + } + }, + "range": [ + 1795, + 1827 + ], + "loc": { + "start": { + "line": 54, + "column": 67 + }, + "end": { + "line": 54, + "column": 99 + } + } + } + ], + "range": [ + 1749, + 1828 + ], + "loc": { + "start": { + "line": 54, + "column": 21 + }, + "end": { + "line": 54, + "column": 100 + } + } + }, + "range": [ + 1742, + 1829 + ], + "loc": { + "start": { + "line": 54, + "column": 14 + }, + "end": { + "line": 54, + "column": 101 + } + } + } + ], + "range": [ + 1726, + 1843 + ], + "loc": { + "start": { + "line": 53, + "column": 54 + }, + "end": { + "line": 55, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 1691, + 1843 + ], + "loc": { + "start": { + "line": 53, + "column": 19 + }, + "end": { + "line": 55, + "column": 13 + } + } + }, + "range": [ + 1599, + 1843 + ], + "loc": { + "start": { + "line": 51, + "column": 12 + }, + "end": { + "line": 55, + "column": 13 + } + } + } + ], + "range": [ + 1585, + 1855 + ], + "loc": { + "start": { + "line": 50, + "column": 62 + }, + "end": { + "line": 56, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 1533, + 1855 + ], + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 56, + "column": 11 + } + } + } + ], + "range": [ + 1491, + 1865 + ], + "loc": { + "start": { + "line": 48, + "column": 42 + }, + "end": { + "line": 57, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1470, + 1865 + ], + "loc": { + "start": { + "line": 48, + "column": 21 + }, + "end": { + "line": 57, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1457, + 1865 + ], + "loc": { + "start": { + "line": 48, + "column": 8 + }, + "end": { + "line": 57, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 1875, + 1884 + ], + "loc": { + "start": { + "line": 58, + "column": 8 + }, + "end": { + "line": 58, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": { + "type": "Identifier", + "name": "serialize", + "range": [ + 1895, + 1904 + ], + "loc": { + "start": { + "line": 58, + "column": 28 + }, + "end": { + "line": 58, + "column": 37 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 1905, + 1913 + ], + "loc": { + "start": { + "line": 58, + "column": 38 + }, + "end": { + "line": 58, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 1915, + 1919 + ], + "loc": { + "start": { + "line": 58, + "column": 48 + }, + "end": { + "line": 58, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 1921, + 1924 + ], + "loc": { + "start": { + "line": 58, + "column": 54 + }, + "end": { + "line": 58, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 1942, + 1950 + ], + "loc": { + "start": { + "line": 59, + "column": 14 + }, + "end": { + "line": 59, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 1951, + 1954 + ], + "loc": { + "start": { + "line": 59, + "column": 23 + }, + "end": { + "line": 59, + "column": 26 + } + } + }, + "range": [ + 1942, + 1955 + ], + "loc": { + "start": { + "line": 59, + "column": 14 + }, + "end": { + "line": 59, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1960, + 1964 + ], + "loc": { + "start": { + "line": 59, + "column": 32 + }, + "end": { + "line": 59, + "column": 36 + } + } + }, + "range": [ + 1942, + 1964 + ], + "loc": { + "start": { + "line": 59, + "column": 14 + }, + "end": { + "line": 59, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1980, + 1984 + ], + "loc": { + "start": { + "line": 60, + "column": 12 + }, + "end": { + "line": 60, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1985, + 1998 + ], + "loc": { + "start": { + "line": 60, + "column": 17 + }, + "end": { + "line": 60, + "column": 30 + } + } + }, + "range": [ + 1980, + 1998 + ], + "loc": { + "start": { + "line": 60, + "column": 12 + }, + "end": { + "line": 60, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1999, + 2003 + ], + "loc": { + "start": { + "line": 60, + "column": 31 + }, + "end": { + "line": 60, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2007, + 2010 + ], + "loc": { + "start": { + "line": 60, + "column": 39 + }, + "end": { + "line": 60, + "column": 42 + } + } + }, + "range": [ + 1999, + 2010 + ], + "loc": { + "start": { + "line": 60, + "column": 31 + }, + "end": { + "line": 60, + "column": 42 + } + } + }, + "range": [ + 1980, + 2011 + ], + "loc": { + "start": { + "line": 60, + "column": 12 + }, + "end": { + "line": 60, + "column": 43 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2014, + 2018 + ], + "loc": { + "start": { + "line": 60, + "column": 46 + }, + "end": { + "line": 60, + "column": 50 + } + } + }, + "range": [ + 1980, + 2018 + ], + "loc": { + "start": { + "line": 60, + "column": 12 + }, + "end": { + "line": 60, + "column": 50 + } + } + }, + "range": [ + 1980, + 2019 + ], + "loc": { + "start": { + "line": 60, + "column": 12 + }, + "end": { + "line": 60, + "column": 51 + } + } + } + ], + "range": [ + 1966, + 2031 + ], + "loc": { + "start": { + "line": 59, + "column": 38 + }, + "end": { + "line": 61, + "column": 11 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2041, + 2049 + ], + "loc": { + "start": { + "line": 61, + "column": 21 + }, + "end": { + "line": 61, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2050, + 2053 + ], + "loc": { + "start": { + "line": 61, + "column": 30 + }, + "end": { + "line": 61, + "column": 33 + } + } + }, + "range": [ + 2041, + 2054 + ], + "loc": { + "start": { + "line": 61, + "column": 21 + }, + "end": { + "line": 61, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2070, + 2074 + ], + "loc": { + "start": { + "line": 62, + "column": 12 + }, + "end": { + "line": 62, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2075, + 2088 + ], + "loc": { + "start": { + "line": 62, + "column": 17 + }, + "end": { + "line": 62, + "column": 30 + } + } + }, + "range": [ + 2070, + 2088 + ], + "loc": { + "start": { + "line": 62, + "column": 12 + }, + "end": { + "line": 62, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2089, + 2093 + ], + "loc": { + "start": { + "line": 62, + "column": 31 + }, + "end": { + "line": 62, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2097, + 2100 + ], + "loc": { + "start": { + "line": 62, + "column": 39 + }, + "end": { + "line": 62, + "column": 42 + } + } + }, + "range": [ + 2089, + 2100 + ], + "loc": { + "start": { + "line": 62, + "column": 31 + }, + "end": { + "line": 62, + "column": 42 + } + } + }, + "range": [ + 2070, + 2101 + ], + "loc": { + "start": { + "line": 62, + "column": 12 + }, + "end": { + "line": 62, + "column": 43 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 2120, + 2124 + ], + "loc": { + "start": { + "line": 63, + "column": 14 + }, + "end": { + "line": 63, + "column": 18 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 2144, + 2148 + ], + "loc": { + "start": { + "line": 64, + "column": 16 + }, + "end": { + "line": 64, + "column": 20 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2150, + 2158 + ], + "loc": { + "start": { + "line": 64, + "column": 22 + }, + "end": { + "line": 64, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2159, + 2162 + ], + "loc": { + "start": { + "line": 64, + "column": 31 + }, + "end": { + "line": 64, + "column": 34 + } + } + }, + "range": [ + 2150, + 2163 + ], + "loc": { + "start": { + "line": 64, + "column": 22 + }, + "end": { + "line": 64, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 2164, + 2168 + ], + "loc": { + "start": { + "line": 64, + "column": 36 + }, + "end": { + "line": 64, + "column": 40 + } + } + }, + "range": [ + 2150, + 2168 + ], + "loc": { + "start": { + "line": 64, + "column": 22 + }, + "end": { + "line": 64, + "column": 40 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2144, + 2168 + ], + "loc": { + "start": { + "line": 64, + "column": 16 + }, + "end": { + "line": 64, + "column": 40 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 2186, + 2188 + ], + "loc": { + "start": { + "line": 65, + "column": 16 + }, + "end": { + "line": 65, + "column": 18 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2190, + 2198 + ], + "loc": { + "start": { + "line": 65, + "column": 20 + }, + "end": { + "line": 65, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2199, + 2202 + ], + "loc": { + "start": { + "line": 65, + "column": 29 + }, + "end": { + "line": 65, + "column": 32 + } + } + }, + "range": [ + 2190, + 2203 + ], + "loc": { + "start": { + "line": 65, + "column": 20 + }, + "end": { + "line": 65, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 2204, + 2206 + ], + "loc": { + "start": { + "line": 65, + "column": 34 + }, + "end": { + "line": 65, + "column": 36 + } + } + }, + "range": [ + 2190, + 2206 + ], + "loc": { + "start": { + "line": 65, + "column": 20 + }, + "end": { + "line": 65, + "column": 36 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2186, + 2206 + ], + "loc": { + "start": { + "line": 65, + "column": 16 + }, + "end": { + "line": 65, + "column": 36 + } + } + } + ], + "range": [ + 2126, + 2222 + ], + "loc": { + "start": { + "line": 63, + "column": 20 + }, + "end": { + "line": 66, + "column": 15 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2120, + 2222 + ], + "loc": { + "start": { + "line": 63, + "column": 14 + }, + "end": { + "line": 66, + "column": 15 + } + } + } + ], + "range": [ + 2104, + 2236 + ], + "loc": { + "start": { + "line": 62, + "column": 46 + }, + "end": { + "line": 67, + "column": 13 + } + } + }, + "range": [ + 2070, + 2236 + ], + "loc": { + "start": { + "line": 62, + "column": 12 + }, + "end": { + "line": 67, + "column": 13 + } + } + }, + "range": [ + 2070, + 2237 + ], + "loc": { + "start": { + "line": 62, + "column": 12 + }, + "end": { + "line": 67, + "column": 14 + } + } + } + ], + "range": [ + 2056, + 2249 + ], + "loc": { + "start": { + "line": 61, + "column": 36 + }, + "end": { + "line": 68, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 2037, + 2249 + ], + "loc": { + "start": { + "line": 61, + "column": 17 + }, + "end": { + "line": 68, + "column": 11 + } + } + }, + "range": [ + 1938, + 2249 + ], + "loc": { + "start": { + "line": 59, + "column": 10 + }, + "end": { + "line": 68, + "column": 11 + } + } + } + ], + "range": [ + 1926, + 2259 + ], + "loc": { + "start": { + "line": 58, + "column": 59 + }, + "end": { + "line": 69, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1886, + 2259 + ], + "loc": { + "start": { + "line": 58, + "column": 19 + }, + "end": { + "line": 69, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1875, + 2259 + ], + "loc": { + "start": { + "line": 58, + "column": 8 + }, + "end": { + "line": 69, + "column": 9 + } + } + } + ], + "range": [ + 1377, + 2267 + ], + "loc": { + "start": { + "line": 45, + "column": 13 + }, + "end": { + "line": 70, + "column": 7 + } + } + }, + "range": [ + 1370, + 2268 + ], + "loc": { + "start": { + "line": 45, + "column": 6 + }, + "end": { + "line": 70, + "column": 8 + } + } + } + ], + "range": [ + 1362, + 2274 + ], + "loc": { + "start": { + "line": 44, + "column": 11 + }, + "end": { + "line": 71, + "column": 5 + } + } + }, + "range": [ + 1272, + 2274 + ], + "loc": { + "start": { + "line": 42, + "column": 4 + }, + "end": { + "line": 71, + "column": 5 + } + } + } + ], + "range": [ + 1266, + 2278 + ], + "loc": { + "start": { + "line": 41, + "column": 31 + }, + "end": { + "line": 72, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1250, + 2278 + ], + "loc": { + "start": { + "line": 41, + "column": 15 + }, + "end": { + "line": 72, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 1237, + 2278 + ], + "loc": { + "start": { + "line": 41, + "column": 2 + }, + "end": { + "line": 72, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 897, + 1234 + ], + "loc": { + "start": { + "line": 32, + "column": 2 + }, + "end": { + "line": 40, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2282, + 2620 + ], + "loc": { + "start": { + "line": 74, + "column": 2 + }, + "end": { + "line": 82, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "hasMany", + "range": [ + 2630, + 2637 + ], + "loc": { + "start": { + "line": 83, + "column": 9 + }, + "end": { + "line": 83, + "column": 16 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 2638, + 2642 + ], + "loc": { + "start": { + "line": 83, + "column": 17 + }, + "end": { + "line": 83, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2644, + 2651 + ], + "loc": { + "start": { + "line": 83, + "column": 23 + }, + "end": { + "line": 83, + "column": 30 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2663, + 2667 + ], + "loc": { + "start": { + "line": 84, + "column": 8 + }, + "end": { + "line": 84, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 2678, + 2682 + ], + "loc": { + "start": { + "line": 84, + "column": 23 + }, + "end": { + "line": 84, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 2671, + 2682 + ], + "loc": { + "start": { + "line": 84, + "column": 16 + }, + "end": { + "line": 84, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 2687, + 2695 + ], + "loc": { + "start": { + "line": 84, + "column": 32 + }, + "end": { + "line": 84, + "column": 40 + } + } + }, + "range": [ + 2671, + 2695 + ], + "loc": { + "start": { + "line": 84, + "column": 16 + }, + "end": { + "line": 84, + "column": 40 + } + } + }, + "range": [ + 2663, + 2695 + ], + "loc": { + "start": { + "line": 84, + "column": 8 + }, + "end": { + "line": 84, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 2712, + 2717 + ], + "loc": { + "start": { + "line": 85, + "column": 13 + }, + "end": { + "line": 85, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasMany", + "range": [ + 2718, + 2725 + ], + "loc": { + "start": { + "line": 85, + "column": 19 + }, + "end": { + "line": 85, + "column": 26 + } + } + }, + "range": [ + 2712, + 2725 + ], + "loc": { + "start": { + "line": 85, + "column": 13 + }, + "end": { + "line": 85, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2726, + 2730 + ], + "loc": { + "start": { + "line": 85, + "column": 27 + }, + "end": { + "line": 85, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 2732, + 2736 + ], + "loc": { + "start": { + "line": 85, + "column": 33 + }, + "end": { + "line": 85, + "column": 37 + } + } + } + ], + "range": [ + 2712, + 2737 + ], + "loc": { + "start": { + "line": 85, + "column": 13 + }, + "end": { + "line": 85, + "column": 38 + } + } + }, + "range": [ + 2705, + 2738 + ], + "loc": { + "start": { + "line": 85, + "column": 6 + }, + "end": { + "line": 85, + "column": 39 + } + } + } + ], + "range": [ + 2697, + 2744 + ], + "loc": { + "start": { + "line": 84, + "column": 42 + }, + "end": { + "line": 86, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 2775, + 2779 + ], + "loc": { + "start": { + "line": 88, + "column": 8 + }, + "end": { + "line": 88, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 2781, + 2791 + ], + "loc": { + "start": { + "line": 88, + "column": 14 + }, + "end": { + "line": 88, + "column": 24 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2775, + 2791 + ], + "loc": { + "start": { + "line": 88, + "column": 8 + }, + "end": { + "line": 88, + "column": 24 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "default", + "range": [ + 2801, + 2808 + ], + "loc": { + "start": { + "line": 89, + "column": 8 + }, + "end": { + "line": 89, + "column": 15 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 2810, + 2812 + ], + "loc": { + "start": { + "line": 89, + "column": 17 + }, + "end": { + "line": 89, + "column": 19 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2801, + 2812 + ], + "loc": { + "start": { + "line": 89, + "column": 8 + }, + "end": { + "line": 89, + "column": 19 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "inverse", + "range": [ + 2822, + 2829 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 2831, + 2838 + ], + "loc": { + "start": { + "line": 90, + "column": 17 + }, + "end": { + "line": 90, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 2842, + 2849 + ], + "loc": { + "start": { + "line": 90, + "column": 28 + }, + "end": { + "line": 90, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 2850, + 2857 + ], + "loc": { + "start": { + "line": 90, + "column": 36 + }, + "end": { + "line": 90, + "column": 43 + } + } + }, + "range": [ + 2842, + 2857 + ], + "loc": { + "start": { + "line": 90, + "column": 28 + }, + "end": { + "line": 90, + "column": 43 + } + } + }, + "range": [ + 2831, + 2857 + ], + "loc": { + "start": { + "line": 90, + "column": 17 + }, + "end": { + "line": 90, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2822, + 2857 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 2867, + 2878 + ], + "loc": { + "start": { + "line": 91, + "column": 8 + }, + "end": { + "line": 91, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 2890, + 2894 + ], + "loc": { + "start": { + "line": 91, + "column": 31 + }, + "end": { + "line": 91, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 2896, + 2899 + ], + "loc": { + "start": { + "line": 91, + "column": 37 + }, + "end": { + "line": 91, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2913, + 2917 + ], + "loc": { + "start": { + "line": 92, + "column": 10 + }, + "end": { + "line": 92, + "column": 14 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2920, + 2924 + ], + "loc": { + "start": { + "line": 92, + "column": 17 + }, + "end": { + "line": 92, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2928, + 2931 + ], + "loc": { + "start": { + "line": 92, + "column": 25 + }, + "end": { + "line": 92, + "column": 28 + } + } + }, + "range": [ + 2920, + 2931 + ], + "loc": { + "start": { + "line": 92, + "column": 17 + }, + "end": { + "line": 92, + "column": 28 + } + } + }, + "range": [ + 2913, + 2931 + ], + "loc": { + "start": { + "line": 92, + "column": 10 + }, + "end": { + "line": 92, + "column": 28 + } + } + }, + "range": [ + 2913, + 2932 + ], + "loc": { + "start": { + "line": 92, + "column": 10 + }, + "end": { + "line": 92, + "column": 29 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2947, + 2951 + ], + "loc": { + "start": { + "line": 93, + "column": 14 + }, + "end": { + "line": 93, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2952, + 2965 + ], + "loc": { + "start": { + "line": 93, + "column": 19 + }, + "end": { + "line": 93, + "column": 32 + } + } + }, + "range": [ + 2947, + 2965 + ], + "loc": { + "start": { + "line": 93, + "column": 14 + }, + "end": { + "line": 93, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2969, + 2973 + ], + "loc": { + "start": { + "line": 93, + "column": 36 + }, + "end": { + "line": 93, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2974, + 2987 + ], + "loc": { + "start": { + "line": 93, + "column": 41 + }, + "end": { + "line": 93, + "column": 54 + } + } + }, + "range": [ + 2969, + 2987 + ], + "loc": { + "start": { + "line": 93, + "column": 36 + }, + "end": { + "line": 93, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 2988, + 2992 + ], + "loc": { + "start": { + "line": 93, + "column": 55 + }, + "end": { + "line": 93, + "column": 59 + } + } + }, + "range": [ + 2969, + 2993 + ], + "loc": { + "start": { + "line": 93, + "column": 36 + }, + "end": { + "line": 93, + "column": 60 + } + } + }, + "range": [ + 2947, + 2993 + ], + "loc": { + "start": { + "line": 93, + "column": 14 + }, + "end": { + "line": 93, + "column": 60 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3013, + 3017 + ], + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3018, + 3031 + ], + "loc": { + "start": { + "line": 94, + "column": 21 + }, + "end": { + "line": 94, + "column": 34 + } + } + }, + "range": [ + 3013, + 3031 + ], + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3032, + 3036 + ], + "loc": { + "start": { + "line": 94, + "column": 35 + }, + "end": { + "line": 94, + "column": 39 + } + } + }, + "range": [ + 3013, + 3037 + ], + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3038, + 3042 + ], + "loc": { + "start": { + "line": 94, + "column": 41 + }, + "end": { + "line": 94, + "column": 45 + } + } + }, + "range": [ + 3013, + 3042 + ], + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 3047, + 3051 + ], + "loc": { + "start": { + "line": 94, + "column": 50 + }, + "end": { + "line": 94, + "column": 54 + } + } + }, + "range": [ + 3013, + 3051 + ], + "loc": { + "start": { + "line": 94, + "column": 16 + }, + "end": { + "line": 94, + "column": 54 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 3076, + 3078 + ], + "loc": { + "start": { + "line": 95, + "column": 21 + }, + "end": { + "line": 95, + "column": 23 + } + } + }, + "range": [ + 3069, + 3079 + ], + "loc": { + "start": { + "line": 95, + "column": 14 + }, + "end": { + "line": 95, + "column": 24 + } + } + } + ], + "range": [ + 3053, + 3093 + ], + "loc": { + "start": { + "line": 94, + "column": 56 + }, + "end": { + "line": 96, + "column": 13 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3103, + 3107 + ], + "loc": { + "start": { + "line": 96, + "column": 23 + }, + "end": { + "line": 96, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3108, + 3121 + ], + "loc": { + "start": { + "line": 96, + "column": 28 + }, + "end": { + "line": 96, + "column": 41 + } + } + }, + "range": [ + 3103, + 3121 + ], + "loc": { + "start": { + "line": 96, + "column": 23 + }, + "end": { + "line": 96, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3122, + 3126 + ], + "loc": { + "start": { + "line": 96, + "column": 42 + }, + "end": { + "line": 96, + "column": 46 + } + } + }, + "range": [ + 3103, + 3127 + ], + "loc": { + "start": { + "line": 96, + "column": 23 + }, + "end": { + "line": 96, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3128, + 3132 + ], + "loc": { + "start": { + "line": 96, + "column": 48 + }, + "end": { + "line": 96, + "column": 52 + } + } + }, + "range": [ + 3103, + 3132 + ], + "loc": { + "start": { + "line": 96, + "column": 23 + }, + "end": { + "line": 96, + "column": 52 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3157, + 3161 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 97, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3162, + 3175 + ], + "loc": { + "start": { + "line": 97, + "column": 26 + }, + "end": { + "line": 97, + "column": 39 + } + } + }, + "range": [ + 3157, + 3175 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 97, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3176, + 3180 + ], + "loc": { + "start": { + "line": 97, + "column": 40 + }, + "end": { + "line": 97, + "column": 44 + } + } + }, + "range": [ + 3157, + 3181 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 97, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3182, + 3186 + ], + "loc": { + "start": { + "line": 97, + "column": 46 + }, + "end": { + "line": 97, + "column": 50 + } + } + }, + "range": [ + 3157, + 3186 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 97, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 3187, + 3190 + ], + "loc": { + "start": { + "line": 97, + "column": 51 + }, + "end": { + "line": 97, + "column": 54 + } + } + }, + "range": [ + 3157, + 3190 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 97, + "column": 54 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "c", + "range": [ + 3192, + 3193 + ], + "loc": { + "start": { + "line": 97, + "column": 56 + }, + "end": { + "line": 97, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3223, + 3227 + ], + "loc": { + "start": { + "line": 98, + "column": 23 + }, + "end": { + "line": 98, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 3228, + 3232 + ], + "loc": { + "start": { + "line": 98, + "column": 28 + }, + "end": { + "line": 98, + "column": 32 + } + } + }, + "range": [ + 3223, + 3232 + ], + "loc": { + "start": { + "line": 98, + "column": 23 + }, + "end": { + "line": 98, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "c", + "range": [ + 3233, + 3234 + ], + "loc": { + "start": { + "line": 98, + "column": 33 + }, + "end": { + "line": 98, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 3235, + 3239 + ], + "loc": { + "start": { + "line": 98, + "column": 35 + }, + "end": { + "line": 98, + "column": 39 + } + } + }, + "range": [ + 3233, + 3239 + ], + "loc": { + "start": { + "line": 98, + "column": 33 + }, + "end": { + "line": 98, + "column": 39 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "c", + "range": [ + 3241, + 3242 + ], + "loc": { + "start": { + "line": 98, + "column": 41 + }, + "end": { + "line": 98, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 3243, + 3245 + ], + "loc": { + "start": { + "line": 98, + "column": 43 + }, + "end": { + "line": 98, + "column": 45 + } + } + }, + "range": [ + 3241, + 3245 + ], + "loc": { + "start": { + "line": 98, + "column": 41 + }, + "end": { + "line": 98, + "column": 45 + } + } + } + ], + "range": [ + 3223, + 3246 + ], + "loc": { + "start": { + "line": 98, + "column": 23 + }, + "end": { + "line": 98, + "column": 46 + } + } + }, + "range": [ + 3216, + 3247 + ], + "loc": { + "start": { + "line": 98, + "column": 16 + }, + "end": { + "line": 98, + "column": 47 + } + } + } + ], + "range": [ + 3198, + 3263 + ], + "loc": { + "start": { + "line": 97, + "column": 62 + }, + "end": { + "line": 99, + "column": 15 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3191, + 3263 + ], + "loc": { + "start": { + "line": 97, + "column": 55 + }, + "end": { + "line": 99, + "column": 15 + } + } + } + ], + "range": [ + 3157, + 3264 + ], + "loc": { + "start": { + "line": 97, + "column": 21 + }, + "end": { + "line": 99, + "column": 16 + } + } + }, + "range": [ + 3150, + 3265 + ], + "loc": { + "start": { + "line": 97, + "column": 14 + }, + "end": { + "line": 99, + "column": 17 + } + } + } + ], + "range": [ + 3134, + 3279 + ], + "loc": { + "start": { + "line": 96, + "column": 54 + }, + "end": { + "line": 100, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 3099, + 3279 + ], + "loc": { + "start": { + "line": 96, + "column": 19 + }, + "end": { + "line": 100, + "column": 13 + } + } + }, + "range": [ + 3009, + 3279 + ], + "loc": { + "start": { + "line": 94, + "column": 12 + }, + "end": { + "line": 100, + "column": 13 + } + } + } + ], + "range": [ + 2995, + 3291 + ], + "loc": { + "start": { + "line": 93, + "column": 62 + }, + "end": { + "line": 101, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 2943, + 3291 + ], + "loc": { + "start": { + "line": 93, + "column": 10 + }, + "end": { + "line": 101, + "column": 11 + } + } + } + ], + "range": [ + 2901, + 3301 + ], + "loc": { + "start": { + "line": 91, + "column": 42 + }, + "end": { + "line": 102, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 2880, + 3301 + ], + "loc": { + "start": { + "line": 91, + "column": 21 + }, + "end": { + "line": 102, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2867, + 3301 + ], + "loc": { + "start": { + "line": 91, + "column": 8 + }, + "end": { + "line": 102, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 3311, + 3320 + ], + "loc": { + "start": { + "line": 103, + "column": 8 + }, + "end": { + "line": 103, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": { + "type": "Identifier", + "name": "serialize", + "range": [ + 3331, + 3340 + ], + "loc": { + "start": { + "line": 103, + "column": 28 + }, + "end": { + "line": 103, + "column": 37 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 3341, + 3349 + ], + "loc": { + "start": { + "line": 103, + "column": 38 + }, + "end": { + "line": 103, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 3351, + 3355 + ], + "loc": { + "start": { + "line": 103, + "column": 48 + }, + "end": { + "line": 103, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 3357, + 3360 + ], + "loc": { + "start": { + "line": 103, + "column": 54 + }, + "end": { + "line": 103, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 3378, + 3386 + ], + "loc": { + "start": { + "line": 104, + "column": 14 + }, + "end": { + "line": 104, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 3387, + 3390 + ], + "loc": { + "start": { + "line": 104, + "column": 23 + }, + "end": { + "line": 104, + "column": 26 + } + } + }, + "range": [ + 3378, + 3391 + ], + "loc": { + "start": { + "line": 104, + "column": 14 + }, + "end": { + "line": 104, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3407, + 3411 + ], + "loc": { + "start": { + "line": 105, + "column": 12 + }, + "end": { + "line": 105, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3412, + 3425 + ], + "loc": { + "start": { + "line": 105, + "column": 17 + }, + "end": { + "line": 105, + "column": 30 + } + } + }, + "range": [ + 3407, + 3425 + ], + "loc": { + "start": { + "line": 105, + "column": 12 + }, + "end": { + "line": 105, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 3426, + 3430 + ], + "loc": { + "start": { + "line": 105, + "column": 31 + }, + "end": { + "line": 105, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 3434, + 3437 + ], + "loc": { + "start": { + "line": 105, + "column": 39 + }, + "end": { + "line": 105, + "column": 42 + } + } + }, + "range": [ + 3426, + 3437 + ], + "loc": { + "start": { + "line": 105, + "column": 31 + }, + "end": { + "line": 105, + "column": 42 + } + } + }, + "range": [ + 3407, + 3438 + ], + "loc": { + "start": { + "line": 105, + "column": 12 + }, + "end": { + "line": 105, + "column": 43 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 3457, + 3461 + ], + "loc": { + "start": { + "line": 106, + "column": 14 + }, + "end": { + "line": 106, + "column": 18 + } + } + }, + "value": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 3463, + 3471 + ], + "loc": { + "start": { + "line": 106, + "column": 20 + }, + "end": { + "line": 106, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 3472, + 3475 + ], + "loc": { + "start": { + "line": 106, + "column": 29 + }, + "end": { + "line": 106, + "column": 32 + } + } + }, + "range": [ + 3463, + 3476 + ], + "loc": { + "start": { + "line": 106, + "column": 20 + }, + "end": { + "line": 106, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 3477, + 3480 + ], + "loc": { + "start": { + "line": 106, + "column": 34 + }, + "end": { + "line": 106, + "column": 37 + } + } + }, + "range": [ + 3463, + 3480 + ], + "loc": { + "start": { + "line": 106, + "column": 20 + }, + "end": { + "line": 106, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 3481, + 3482 + ], + "loc": { + "start": { + "line": 106, + "column": 38 + }, + "end": { + "line": 106, + "column": 39 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 3513, + 3517 + ], + "loc": { + "start": { + "line": 107, + "column": 25 + }, + "end": { + "line": 107, + "column": 29 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 3519, + 3520 + ], + "loc": { + "start": { + "line": 107, + "column": 31 + }, + "end": { + "line": 107, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 3521, + 3525 + ], + "loc": { + "start": { + "line": 107, + "column": 33 + }, + "end": { + "line": 107, + "column": 37 + } + } + }, + "range": [ + 3519, + 3525 + ], + "loc": { + "start": { + "line": 107, + "column": 31 + }, + "end": { + "line": 107, + "column": 37 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3513, + 3525 + ], + "loc": { + "start": { + "line": 107, + "column": 25 + }, + "end": { + "line": 107, + "column": 37 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 3527, + 3529 + ], + "loc": { + "start": { + "line": 107, + "column": 39 + }, + "end": { + "line": 107, + "column": 41 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 3531, + 3532 + ], + "loc": { + "start": { + "line": 107, + "column": 43 + }, + "end": { + "line": 107, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 3533, + 3535 + ], + "loc": { + "start": { + "line": 107, + "column": 45 + }, + "end": { + "line": 107, + "column": 47 + } + } + }, + "range": [ + 3531, + 3535 + ], + "loc": { + "start": { + "line": 107, + "column": 43 + }, + "end": { + "line": 107, + "column": 47 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3527, + 3535 + ], + "loc": { + "start": { + "line": 107, + "column": 39 + }, + "end": { + "line": 107, + "column": 47 + } + } + } + ], + "range": [ + 3511, + 3537 + ], + "loc": { + "start": { + "line": 107, + "column": 23 + }, + "end": { + "line": 107, + "column": 49 + } + } + }, + "range": [ + 3504, + 3538 + ], + "loc": { + "start": { + "line": 107, + "column": 16 + }, + "end": { + "line": 107, + "column": 50 + } + } + } + ], + "range": [ + 3486, + 3554 + ], + "loc": { + "start": { + "line": 106, + "column": 43 + }, + "end": { + "line": 108, + "column": 15 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3481, + 3554 + ], + "loc": { + "start": { + "line": 106, + "column": 38 + }, + "end": { + "line": 108, + "column": 15 + } + } + } + ], + "range": [ + 3463, + 3555 + ], + "loc": { + "start": { + "line": 106, + "column": 20 + }, + "end": { + "line": 108, + "column": 16 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3457, + 3555 + ], + "loc": { + "start": { + "line": 106, + "column": 14 + }, + "end": { + "line": 108, + "column": 16 + } + } + } + ], + "range": [ + 3441, + 3569 + ], + "loc": { + "start": { + "line": 105, + "column": 46 + }, + "end": { + "line": 109, + "column": 13 + } + } + }, + "range": [ + 3407, + 3569 + ], + "loc": { + "start": { + "line": 105, + "column": 12 + }, + "end": { + "line": 109, + "column": 13 + } + } + }, + "range": [ + 3407, + 3570 + ], + "loc": { + "start": { + "line": 105, + "column": 12 + }, + "end": { + "line": 109, + "column": 14 + } + } + } + ], + "range": [ + 3393, + 3582 + ], + "loc": { + "start": { + "line": 104, + "column": 29 + }, + "end": { + "line": 110, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 3374, + 3582 + ], + "loc": { + "start": { + "line": 104, + "column": 10 + }, + "end": { + "line": 110, + "column": 11 + } + } + } + ], + "range": [ + 3362, + 3592 + ], + "loc": { + "start": { + "line": 103, + "column": 59 + }, + "end": { + "line": 111, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3322, + 3592 + ], + "loc": { + "start": { + "line": 103, + "column": 19 + }, + "end": { + "line": 111, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3311, + 3592 + ], + "loc": { + "start": { + "line": 103, + "column": 8 + }, + "end": { + "line": 111, + "column": 9 + } + } + } + ], + "range": [ + 2765, + 3600 + ], + "loc": { + "start": { + "line": 87, + "column": 13 + }, + "end": { + "line": 112, + "column": 7 + } + } + }, + "range": [ + 2758, + 3601 + ], + "loc": { + "start": { + "line": 87, + "column": 6 + }, + "end": { + "line": 112, + "column": 8 + } + } + } + ], + "range": [ + 2750, + 3607 + ], + "loc": { + "start": { + "line": 86, + "column": 11 + }, + "end": { + "line": 113, + "column": 5 + } + } + }, + "range": [ + 2659, + 3607 + ], + "loc": { + "start": { + "line": 84, + "column": 4 + }, + "end": { + "line": 113, + "column": 5 + } + } + } + ], + "range": [ + 2653, + 3611 + ], + "loc": { + "start": { + "line": 83, + "column": 32 + }, + "end": { + "line": 114, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 2637, + 3611 + ], + "loc": { + "start": { + "line": 83, + "column": 16 + }, + "end": { + "line": 114, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 2623, + 3611 + ], + "loc": { + "start": { + "line": 83, + "column": 2 + }, + "end": { + "line": 114, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2282, + 2620 + ], + "loc": { + "start": { + "line": 74, + "column": 2 + }, + "end": { + "line": 82, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 3615, + 3626 + ], + "loc": { + "start": { + "line": 116, + "column": 2 + }, + "end": { + "line": 116, + "column": 13 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "adapter", + "range": [ + 3627, + 3634 + ], + "loc": { + "start": { + "line": 116, + "column": 14 + }, + "end": { + "line": 116, + "column": 21 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3642, + 3646 + ], + "loc": { + "start": { + "line": 117, + "column": 4 + }, + "end": { + "line": 117, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 3647, + 3655 + ], + "loc": { + "start": { + "line": 117, + "column": 9 + }, + "end": { + "line": 117, + "column": 17 + } + } + }, + "range": [ + 3642, + 3655 + ], + "loc": { + "start": { + "line": 117, + "column": 4 + }, + "end": { + "line": 117, + "column": 17 + } + } + }, + "right": { + "type": "Identifier", + "name": "adapter", + "range": [ + 3658, + 3665 + ], + "loc": { + "start": { + "line": 117, + "column": 20 + }, + "end": { + "line": 117, + "column": 27 + } + } + }, + "range": [ + 3642, + 3665 + ], + "loc": { + "start": { + "line": 117, + "column": 4 + }, + "end": { + "line": 117, + "column": 27 + } + } + }, + "range": [ + 3642, + 3666 + ], + "loc": { + "start": { + "line": 117, + "column": 4 + }, + "end": { + "line": 117, + "column": 28 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3671, + 3675 + ], + "loc": { + "start": { + "line": 118, + "column": 4 + }, + "end": { + "line": 118, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 3676, + 3696 + ], + "loc": { + "start": { + "line": 118, + "column": 9 + }, + "end": { + "line": 118, + "column": 29 + } + } + }, + "range": [ + 3671, + 3696 + ], + "loc": { + "start": { + "line": 118, + "column": 4 + }, + "end": { + "line": 118, + "column": 29 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 3701, + 3708 + ], + "loc": { + "start": { + "line": 118, + "column": 34 + }, + "end": { + "line": 118, + "column": 41 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3710, + 3712 + ], + "loc": { + "start": { + "line": 118, + "column": 43 + }, + "end": { + "line": 118, + "column": 45 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3701, + 3712 + ], + "loc": { + "start": { + "line": 118, + "column": 34 + }, + "end": { + "line": 118, + "column": 45 + } + } + }, + { + "type": "Property", + "key": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 3714, + 3723 + ], + "loc": { + "start": { + "line": 118, + "column": 47 + }, + "end": { + "line": 118, + "column": 56 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3725, + 3727 + ], + "loc": { + "start": { + "line": 118, + "column": 58 + }, + "end": { + "line": 118, + "column": 60 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3714, + 3727 + ], + "loc": { + "start": { + "line": 118, + "column": 47 + }, + "end": { + "line": 118, + "column": 60 + } + } + }, + { + "type": "Property", + "key": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 3729, + 3738 + ], + "loc": { + "start": { + "line": 118, + "column": 62 + }, + "end": { + "line": 118, + "column": 71 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3740, + 3742 + ], + "loc": { + "start": { + "line": 118, + "column": 73 + }, + "end": { + "line": 118, + "column": 75 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3729, + 3742 + ], + "loc": { + "start": { + "line": 118, + "column": 62 + }, + "end": { + "line": 118, + "column": 75 + } + } + } + ], + "range": [ + 3699, + 3744 + ], + "loc": { + "start": { + "line": 118, + "column": 32 + }, + "end": { + "line": 118, + "column": 77 + } + } + }, + "range": [ + 3671, + 3744 + ], + "loc": { + "start": { + "line": 118, + "column": 4 + }, + "end": { + "line": 118, + "column": 77 + } + } + }, + "range": [ + 3671, + 3745 + ], + "loc": { + "start": { + "line": 118, + "column": 4 + }, + "end": { + "line": 118, + "column": 78 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3750, + 3754 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 3755, + 3760 + ], + "loc": { + "start": { + "line": 119, + "column": 9 + }, + "end": { + "line": 119, + "column": 14 + } + } + }, + "range": [ + 3750, + 3760 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 14 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3763, + 3765 + ], + "loc": { + "start": { + "line": 119, + "column": 17 + }, + "end": { + "line": 119, + "column": 19 + } + } + }, + "range": [ + 3750, + 3765 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 19 + } + } + }, + "range": [ + 3750, + 3766 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 20 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3771, + 3775 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 3776, + 3794 + ], + "loc": { + "start": { + "line": 120, + "column": 9 + }, + "end": { + "line": 120, + "column": 27 + } + } + }, + "range": [ + 3771, + 3794 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 27 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 3799, + 3806 + ], + "loc": { + "start": { + "line": 120, + "column": 32 + }, + "end": { + "line": 120, + "column": 39 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3808, + 3810 + ], + "loc": { + "start": { + "line": 120, + "column": 41 + }, + "end": { + "line": 120, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3799, + 3810 + ], + "loc": { + "start": { + "line": 120, + "column": 32 + }, + "end": { + "line": 120, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 3812, + 3821 + ], + "loc": { + "start": { + "line": 120, + "column": 45 + }, + "end": { + "line": 120, + "column": 54 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3823, + 3825 + ], + "loc": { + "start": { + "line": 120, + "column": 56 + }, + "end": { + "line": 120, + "column": 58 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3812, + 3825 + ], + "loc": { + "start": { + "line": 120, + "column": 45 + }, + "end": { + "line": 120, + "column": 58 + } + } + }, + { + "type": "Property", + "key": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 3827, + 3836 + ], + "loc": { + "start": { + "line": 120, + "column": 60 + }, + "end": { + "line": 120, + "column": 69 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3838, + 3840 + ], + "loc": { + "start": { + "line": 120, + "column": 71 + }, + "end": { + "line": 120, + "column": 73 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3827, + 3840 + ], + "loc": { + "start": { + "line": 120, + "column": 60 + }, + "end": { + "line": 120, + "column": 73 + } + } + } + ], + "range": [ + 3797, + 3842 + ], + "loc": { + "start": { + "line": 120, + "column": 30 + }, + "end": { + "line": 120, + "column": 75 + } + } + }, + "range": [ + 3771, + 3842 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 75 + } + } + }, + "range": [ + 3771, + 3843 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 76 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3848, + 3852 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 3853, + 3859 + ], + "loc": { + "start": { + "line": 121, + "column": 9 + }, + "end": { + "line": 121, + "column": 15 + } + } + }, + "range": [ + 3848, + 3859 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 15 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3862, + 3864 + ], + "loc": { + "start": { + "line": 121, + "column": 18 + }, + "end": { + "line": 121, + "column": 20 + } + } + }, + "range": [ + 3848, + 3864 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 20 + } + } + }, + "range": [ + 3848, + 3865 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 21 + } + } + } + ], + "range": [ + 3636, + 3869 + ], + "loc": { + "start": { + "line": 116, + "column": 23 + }, + "end": { + "line": 122, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3626, + 3869 + ], + "loc": { + "start": { + "line": 116, + "column": 13 + }, + "end": { + "line": 122, + "column": 3 + } + } + }, + "kind": "constructor", + "computed": false, + "range": [ + 3615, + 3869 + ], + "loc": { + "start": { + "line": 116, + "column": 2 + }, + "end": { + "line": 122, + "column": 3 + } + }, + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - Resource Object to add. See:\n http://jsonapi.org/format/#document-resource-objects\n * @return {undefined} - Nothing.\n ", + "range": [ + 3873, + 4165 + ], + "loc": { + "start": { + "line": 124, + "column": 2 + }, + "end": { + "line": 132, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "add", + "range": [ + 4168, + 4171 + ], + "loc": { + "start": { + "line": 133, + "column": 2 + }, + "end": { + "line": 133, + "column": 5 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 4172, + 4178 + ], + "loc": { + "start": { + "line": 133, + "column": 6 + }, + "end": { + "line": 133, + "column": 12 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "object", + "range": [ + 4190, + 4196 + ], + "loc": { + "start": { + "line": 134, + "column": 8 + }, + "end": { + "line": 134, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4210, + 4216 + ], + "loc": { + "start": { + "line": 135, + "column": 10 + }, + "end": { + "line": 135, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4217, + 4221 + ], + "loc": { + "start": { + "line": 135, + "column": 17 + }, + "end": { + "line": 135, + "column": 21 + } + } + }, + "range": [ + 4210, + 4221 + ], + "loc": { + "start": { + "line": 135, + "column": 10 + }, + "end": { + "line": 135, + "column": 21 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4225, + 4231 + ], + "loc": { + "start": { + "line": 135, + "column": 25 + }, + "end": { + "line": 135, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4232, + 4234 + ], + "loc": { + "start": { + "line": 135, + "column": 32 + }, + "end": { + "line": 135, + "column": 34 + } + } + }, + "range": [ + 4225, + 4234 + ], + "loc": { + "start": { + "line": 135, + "column": 25 + }, + "end": { + "line": 135, + "column": 34 + } + } + }, + "range": [ + 4210, + 4234 + ], + "loc": { + "start": { + "line": 135, + "column": 10 + }, + "end": { + "line": 135, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "event", + "range": [ + 4250, + 4255 + ], + "loc": { + "start": { + "line": 136, + "column": 12 + }, + "end": { + "line": 136, + "column": 17 + } + } + }, + "init": { + "type": "ConditionalExpression", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4258, + 4262 + ], + "loc": { + "start": { + "line": 136, + "column": 20 + }, + "end": { + "line": 136, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 4263, + 4268 + ], + "loc": { + "start": { + "line": 136, + "column": 25 + }, + "end": { + "line": 136, + "column": 30 + } + } + }, + "range": [ + 4258, + 4268 + ], + "loc": { + "start": { + "line": 136, + "column": 20 + }, + "end": { + "line": 136, + "column": 30 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4269, + 4275 + ], + "loc": { + "start": { + "line": 136, + "column": 31 + }, + "end": { + "line": 136, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4276, + 4280 + ], + "loc": { + "start": { + "line": 136, + "column": 38 + }, + "end": { + "line": 136, + "column": 42 + } + } + }, + "range": [ + 4269, + 4280 + ], + "loc": { + "start": { + "line": 136, + "column": 31 + }, + "end": { + "line": 136, + "column": 42 + } + } + }, + "range": [ + 4258, + 4281 + ], + "loc": { + "start": { + "line": 136, + "column": 20 + }, + "end": { + "line": 136, + "column": 43 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4285, + 4289 + ], + "loc": { + "start": { + "line": 136, + "column": 47 + }, + "end": { + "line": 136, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 4290, + 4295 + ], + "loc": { + "start": { + "line": 136, + "column": 52 + }, + "end": { + "line": 136, + "column": 57 + } + } + }, + "range": [ + 4285, + 4295 + ], + "loc": { + "start": { + "line": 136, + "column": 47 + }, + "end": { + "line": 136, + "column": 57 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4296, + 4302 + ], + "loc": { + "start": { + "line": 136, + "column": 58 + }, + "end": { + "line": 136, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4303, + 4307 + ], + "loc": { + "start": { + "line": 136, + "column": 65 + }, + "end": { + "line": 136, + "column": 69 + } + } + }, + "range": [ + 4296, + 4307 + ], + "loc": { + "start": { + "line": 136, + "column": 58 + }, + "end": { + "line": 136, + "column": 69 + } + } + }, + "range": [ + 4285, + 4308 + ], + "loc": { + "start": { + "line": 136, + "column": 47 + }, + "end": { + "line": 136, + "column": 70 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4309, + 4315 + ], + "loc": { + "start": { + "line": 136, + "column": 71 + }, + "end": { + "line": 136, + "column": 77 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4316, + 4318 + ], + "loc": { + "start": { + "line": 136, + "column": 78 + }, + "end": { + "line": 136, + "column": 80 + } + } + }, + "range": [ + 4309, + 4318 + ], + "loc": { + "start": { + "line": 136, + "column": 71 + }, + "end": { + "line": 136, + "column": 80 + } + } + }, + "range": [ + 4285, + 4319 + ], + "loc": { + "start": { + "line": 136, + "column": 47 + }, + "end": { + "line": 136, + "column": 81 + } + } + }, + "range": [ + 4258, + 4319 + ], + "loc": { + "start": { + "line": 136, + "column": 20 + }, + "end": { + "line": 136, + "column": 81 + } + } + }, + "consequent": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 4322, + 4331 + ], + "loc": { + "start": { + "line": 136, + "column": 84 + }, + "end": { + "line": 136, + "column": 93 + } + } + }, + "alternate": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 4334, + 4341 + ], + "loc": { + "start": { + "line": 136, + "column": 96 + }, + "end": { + "line": 136, + "column": 103 + } + } + }, + "range": [ + 4258, + 4341 + ], + "loc": { + "start": { + "line": 136, + "column": 20 + }, + "end": { + "line": 136, + "column": 103 + } + } + }, + "range": [ + 4250, + 4341 + ], + "loc": { + "start": { + "line": 136, + "column": 12 + }, + "end": { + "line": 136, + "column": 103 + } + } + } + ], + "kind": "let", + "range": [ + 4246, + 4342 + ], + "loc": { + "start": { + "line": 136, + "column": 8 + }, + "end": { + "line": 136, + "column": 104 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "resource", + "range": [ + 4355, + 4363 + ], + "loc": { + "start": { + "line": 137, + "column": 12 + }, + "end": { + "line": 137, + "column": 20 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4366, + 4370 + ], + "loc": { + "start": { + "line": 137, + "column": 23 + }, + "end": { + "line": 137, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 4371, + 4375 + ], + "loc": { + "start": { + "line": 137, + "column": 28 + }, + "end": { + "line": 137, + "column": 32 + } + } + }, + "range": [ + 4366, + 4375 + ], + "loc": { + "start": { + "line": 137, + "column": 23 + }, + "end": { + "line": 137, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4376, + 4382 + ], + "loc": { + "start": { + "line": 137, + "column": 33 + }, + "end": { + "line": 137, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4383, + 4387 + ], + "loc": { + "start": { + "line": 137, + "column": 40 + }, + "end": { + "line": 137, + "column": 44 + } + } + }, + "range": [ + 4376, + 4387 + ], + "loc": { + "start": { + "line": 137, + "column": 33 + }, + "end": { + "line": 137, + "column": 44 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4389, + 4395 + ], + "loc": { + "start": { + "line": 137, + "column": 46 + }, + "end": { + "line": 137, + "column": 52 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4396, + 4398 + ], + "loc": { + "start": { + "line": 137, + "column": 53 + }, + "end": { + "line": 137, + "column": 55 + } + } + }, + "range": [ + 4389, + 4398 + ], + "loc": { + "start": { + "line": 137, + "column": 46 + }, + "end": { + "line": 137, + "column": 55 + } + } + } + ], + "range": [ + 4366, + 4399 + ], + "loc": { + "start": { + "line": 137, + "column": 23 + }, + "end": { + "line": 137, + "column": 56 + } + } + }, + "range": [ + 4355, + 4399 + ], + "loc": { + "start": { + "line": 137, + "column": 12 + }, + "end": { + "line": 137, + "column": 56 + } + } + } + ], + "kind": "let", + "range": [ + 4351, + 4400 + ], + "loc": { + "start": { + "line": 137, + "column": 8 + }, + "end": { + "line": 137, + "column": 57 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 4413, + 4423 + ], + "loc": { + "start": { + "line": 138, + "column": 12 + }, + "end": { + "line": 138, + "column": 22 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4426, + 4430 + ], + "loc": { + "start": { + "line": 138, + "column": 25 + }, + "end": { + "line": 138, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 4431, + 4437 + ], + "loc": { + "start": { + "line": 138, + "column": 30 + }, + "end": { + "line": 138, + "column": 36 + } + } + }, + "range": [ + 4426, + 4437 + ], + "loc": { + "start": { + "line": 138, + "column": 25 + }, + "end": { + "line": 138, + "column": 36 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4438, + 4444 + ], + "loc": { + "start": { + "line": 138, + "column": 37 + }, + "end": { + "line": 138, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4445, + 4449 + ], + "loc": { + "start": { + "line": 138, + "column": 44 + }, + "end": { + "line": 138, + "column": 48 + } + } + }, + "range": [ + 4438, + 4449 + ], + "loc": { + "start": { + "line": 138, + "column": 37 + }, + "end": { + "line": 138, + "column": 48 + } + } + }, + "range": [ + 4426, + 4450 + ], + "loc": { + "start": { + "line": 138, + "column": 25 + }, + "end": { + "line": 138, + "column": 49 + } + } + }, + "range": [ + 4413, + 4450 + ], + "loc": { + "start": { + "line": 138, + "column": 12 + }, + "end": { + "line": 138, + "column": 49 + } + } + } + ], + "kind": "let", + "range": [ + 4409, + 4451 + ], + "loc": { + "start": { + "line": 138, + "column": 8 + }, + "end": { + "line": 138, + "column": 50 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 4460, + 4466 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 139, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 4467, + 4471 + ], + "loc": { + "start": { + "line": 139, + "column": 15 + }, + "end": { + "line": 139, + "column": 19 + } + } + }, + "range": [ + 4460, + 4471 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 139, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 4472, + 4482 + ], + "loc": { + "start": { + "line": 139, + "column": 20 + }, + "end": { + "line": 139, + "column": 30 + } + } + } + ], + "range": [ + 4460, + 4483 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 139, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 4484, + 4491 + ], + "loc": { + "start": { + "line": 139, + "column": 32 + }, + "end": { + "line": 139, + "column": 39 + } + } + }, + "range": [ + 4460, + 4491 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 139, + "column": 39 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 4492, + 4501 + ], + "loc": { + "start": { + "line": 139, + "column": 40 + }, + "end": { + "line": 139, + "column": 49 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 4521, + 4530 + ], + "loc": { + "start": { + "line": 140, + "column": 14 + }, + "end": { + "line": 140, + "column": 23 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 4531, + 4532 + ], + "loc": { + "start": { + "line": 140, + "column": 24 + }, + "end": { + "line": 140, + "column": 25 + } + } + }, + "range": [ + 4521, + 4533 + ], + "loc": { + "start": { + "line": 140, + "column": 14 + }, + "end": { + "line": 140, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 4538, + 4541 + ], + "loc": { + "start": { + "line": 140, + "column": 31 + }, + "end": { + "line": 140, + "column": 34 + } + } + }, + "range": [ + 4521, + 4541 + ], + "loc": { + "start": { + "line": 140, + "column": 14 + }, + "end": { + "line": 140, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4557, + 4561 + ], + "loc": { + "start": { + "line": 141, + "column": 12 + }, + "end": { + "line": 141, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addField", + "range": [ + 4562, + 4571 + ], + "loc": { + "start": { + "line": 141, + "column": 17 + }, + "end": { + "line": 141, + "column": 26 + } + } + }, + "range": [ + 4557, + 4571 + ], + "loc": { + "start": { + "line": 141, + "column": 12 + }, + "end": { + "line": 141, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 4572, + 4578 + ], + "loc": { + "start": { + "line": 141, + "column": 27 + }, + "end": { + "line": 141, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 4580, + 4588 + ], + "loc": { + "start": { + "line": 141, + "column": 35 + }, + "end": { + "line": 141, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 4590, + 4600 + ], + "loc": { + "start": { + "line": 141, + "column": 45 + }, + "end": { + "line": 141, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 4602, + 4611 + ], + "loc": { + "start": { + "line": 141, + "column": 57 + }, + "end": { + "line": 141, + "column": 66 + } + } + } + ], + "range": [ + 4557, + 4612 + ], + "loc": { + "start": { + "line": 141, + "column": 12 + }, + "end": { + "line": 141, + "column": 67 + } + } + }, + "range": [ + 4557, + 4613 + ], + "loc": { + "start": { + "line": 141, + "column": 12 + }, + "end": { + "line": 141, + "column": 68 + } + } + } + ], + "range": [ + 4543, + 4625 + ], + "loc": { + "start": { + "line": 140, + "column": 36 + }, + "end": { + "line": 142, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 4517, + 4625 + ], + "loc": { + "start": { + "line": 140, + "column": 10 + }, + "end": { + "line": 142, + "column": 11 + } + } + } + ], + "range": [ + 4505, + 4635 + ], + "loc": { + "start": { + "line": 139, + "column": 53 + }, + "end": { + "line": 143, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 4492, + 4635 + ], + "loc": { + "start": { + "line": 139, + "column": 40 + }, + "end": { + "line": 143, + "column": 9 + } + } + } + ], + "range": [ + 4460, + 4636 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 143, + "column": 10 + } + } + }, + "range": [ + 4460, + 4637 + ], + "loc": { + "start": { + "line": 139, + "column": 8 + }, + "end": { + "line": 143, + "column": 11 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4650, + 4654 + ], + "loc": { + "start": { + "line": 144, + "column": 12 + }, + "end": { + "line": 144, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 4655, + 4673 + ], + "loc": { + "start": { + "line": 144, + "column": 17 + }, + "end": { + "line": 144, + "column": 35 + } + } + }, + "range": [ + 4650, + 4673 + ], + "loc": { + "start": { + "line": 144, + "column": 12 + }, + "end": { + "line": 144, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 4674, + 4679 + ], + "loc": { + "start": { + "line": 144, + "column": 36 + }, + "end": { + "line": 144, + "column": 41 + } + } + }, + "range": [ + 4650, + 4680 + ], + "loc": { + "start": { + "line": 144, + "column": 12 + }, + "end": { + "line": 144, + "column": 42 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4681, + 4687 + ], + "loc": { + "start": { + "line": 144, + "column": 43 + }, + "end": { + "line": 144, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4688, + 4692 + ], + "loc": { + "start": { + "line": 144, + "column": 50 + }, + "end": { + "line": 144, + "column": 54 + } + } + }, + "range": [ + 4681, + 4692 + ], + "loc": { + "start": { + "line": 144, + "column": 43 + }, + "end": { + "line": 144, + "column": 54 + } + } + }, + "range": [ + 4650, + 4693 + ], + "loc": { + "start": { + "line": 144, + "column": 12 + }, + "end": { + "line": 144, + "column": 55 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4697, + 4701 + ], + "loc": { + "start": { + "line": 144, + "column": 59 + }, + "end": { + "line": 144, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 4702, + 4720 + ], + "loc": { + "start": { + "line": 144, + "column": 64 + }, + "end": { + "line": 144, + "column": 82 + } + } + }, + "range": [ + 4697, + 4720 + ], + "loc": { + "start": { + "line": 144, + "column": 59 + }, + "end": { + "line": 144, + "column": 82 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 4721, + 4726 + ], + "loc": { + "start": { + "line": 144, + "column": 83 + }, + "end": { + "line": 144, + "column": 88 + } + } + }, + "range": [ + 4697, + 4727 + ], + "loc": { + "start": { + "line": 144, + "column": 59 + }, + "end": { + "line": 144, + "column": 89 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4728, + 4734 + ], + "loc": { + "start": { + "line": 144, + "column": 90 + }, + "end": { + "line": 144, + "column": 96 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4735, + 4739 + ], + "loc": { + "start": { + "line": 144, + "column": 97 + }, + "end": { + "line": 144, + "column": 101 + } + } + }, + "range": [ + 4728, + 4739 + ], + "loc": { + "start": { + "line": 144, + "column": 90 + }, + "end": { + "line": 144, + "column": 101 + } + } + }, + "range": [ + 4697, + 4740 + ], + "loc": { + "start": { + "line": 144, + "column": 59 + }, + "end": { + "line": 144, + "column": 102 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4741, + 4747 + ], + "loc": { + "start": { + "line": 144, + "column": 103 + }, + "end": { + "line": 144, + "column": 109 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4748, + 4750 + ], + "loc": { + "start": { + "line": 144, + "column": 110 + }, + "end": { + "line": 144, + "column": 112 + } + } + }, + "range": [ + 4741, + 4750 + ], + "loc": { + "start": { + "line": 144, + "column": 103 + }, + "end": { + "line": 144, + "column": 112 + } + } + }, + "range": [ + 4697, + 4751 + ], + "loc": { + "start": { + "line": 144, + "column": 59 + }, + "end": { + "line": 144, + "column": 113 + } + } + }, + "range": [ + 4650, + 4751 + ], + "loc": { + "start": { + "line": 144, + "column": 12 + }, + "end": { + "line": 144, + "column": 113 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4766, + 4770 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 4771, + 4789 + ], + "loc": { + "start": { + "line": 145, + "column": 16 + }, + "end": { + "line": 145, + "column": 34 + } + } + }, + "range": [ + 4766, + 4789 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 4790, + 4795 + ], + "loc": { + "start": { + "line": 145, + "column": 35 + }, + "end": { + "line": 145, + "column": 40 + } + } + }, + "range": [ + 4766, + 4796 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 41 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4797, + 4803 + ], + "loc": { + "start": { + "line": 145, + "column": 42 + }, + "end": { + "line": 145, + "column": 48 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4804, + 4808 + ], + "loc": { + "start": { + "line": 145, + "column": 49 + }, + "end": { + "line": 145, + "column": 53 + } + } + }, + "range": [ + 4797, + 4808 + ], + "loc": { + "start": { + "line": 145, + "column": 42 + }, + "end": { + "line": 145, + "column": 53 + } + } + }, + "range": [ + 4766, + 4809 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 54 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4810, + 4816 + ], + "loc": { + "start": { + "line": 145, + "column": 55 + }, + "end": { + "line": 145, + "column": 61 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 4817, + 4819 + ], + "loc": { + "start": { + "line": 145, + "column": 62 + }, + "end": { + "line": 145, + "column": 64 + } + } + }, + "range": [ + 4810, + 4819 + ], + "loc": { + "start": { + "line": 145, + "column": 55 + }, + "end": { + "line": 145, + "column": 64 + } + } + }, + "range": [ + 4766, + 4820 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 65 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 4821, + 4828 + ], + "loc": { + "start": { + "line": 145, + "column": 66 + }, + "end": { + "line": 145, + "column": 73 + } + } + }, + "range": [ + 4766, + 4828 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 73 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 4829, + 4830 + ], + "loc": { + "start": { + "line": 145, + "column": 74 + }, + "end": { + "line": 145, + "column": 75 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 4834, + 4835 + ], + "loc": { + "start": { + "line": 145, + "column": 79 + }, + "end": { + "line": 145, + "column": 80 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 4836, + 4837 + ], + "loc": { + "start": { + "line": 145, + "column": 81 + }, + "end": { + "line": 145, + "column": 82 + } + } + }, + "range": [ + 4834, + 4838 + ], + "loc": { + "start": { + "line": 145, + "column": 79 + }, + "end": { + "line": 145, + "column": 83 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 4839, + 4843 + ], + "loc": { + "start": { + "line": 145, + "column": 84 + }, + "end": { + "line": 145, + "column": 88 + } + } + }, + "range": [ + 4834, + 4843 + ], + "loc": { + "start": { + "line": 145, + "column": 79 + }, + "end": { + "line": 145, + "column": 88 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 4844, + 4845 + ], + "loc": { + "start": { + "line": 145, + "column": 89 + }, + "end": { + "line": 145, + "column": 90 + } + } + }, + "property": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 4846, + 4847 + ], + "loc": { + "start": { + "line": 145, + "column": 91 + }, + "end": { + "line": 145, + "column": 92 + } + } + }, + "range": [ + 4844, + 4848 + ], + "loc": { + "start": { + "line": 145, + "column": 89 + }, + "end": { + "line": 145, + "column": 93 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 4850, + 4858 + ], + "loc": { + "start": { + "line": 145, + "column": 95 + }, + "end": { + "line": 145, + "column": 103 + } + } + } + ], + "range": [ + 4834, + 4859 + ], + "loc": { + "start": { + "line": 145, + "column": 79 + }, + "end": { + "line": 145, + "column": 104 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 4829, + 4859 + ], + "loc": { + "start": { + "line": 145, + "column": 74 + }, + "end": { + "line": 145, + "column": 104 + } + } + } + ], + "range": [ + 4766, + 4860 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 105 + } + } + }, + "range": [ + 4766, + 4861 + ], + "loc": { + "start": { + "line": 145, + "column": 11 + }, + "end": { + "line": 145, + "column": 106 + } + } + } + ], + "range": [ + 4753, + 4871 + ], + "loc": { + "start": { + "line": 144, + "column": 115 + }, + "end": { + "line": 146, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 4646, + 4871 + ], + "loc": { + "start": { + "line": 144, + "column": 8 + }, + "end": { + "line": 146, + "column": 9 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4884, + 4888 + ], + "loc": { + "start": { + "line": 147, + "column": 12 + }, + "end": { + "line": 147, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 4889, + 4909 + ], + "loc": { + "start": { + "line": 147, + "column": 17 + }, + "end": { + "line": 147, + "column": 37 + } + } + }, + "range": [ + 4884, + 4909 + ], + "loc": { + "start": { + "line": 147, + "column": 12 + }, + "end": { + "line": 147, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 4910, + 4915 + ], + "loc": { + "start": { + "line": 147, + "column": 38 + }, + "end": { + "line": 147, + "column": 43 + } + } + }, + "range": [ + 4884, + 4916 + ], + "loc": { + "start": { + "line": 147, + "column": 12 + }, + "end": { + "line": 147, + "column": 44 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4917, + 4923 + ], + "loc": { + "start": { + "line": 147, + "column": 45 + }, + "end": { + "line": 147, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4924, + 4928 + ], + "loc": { + "start": { + "line": 147, + "column": 52 + }, + "end": { + "line": 147, + "column": 56 + } + } + }, + "range": [ + 4917, + 4928 + ], + "loc": { + "start": { + "line": 147, + "column": 45 + }, + "end": { + "line": 147, + "column": 56 + } + } + }, + "range": [ + 4884, + 4929 + ], + "loc": { + "start": { + "line": 147, + "column": 12 + }, + "end": { + "line": 147, + "column": 57 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 4943, + 4947 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 4948, + 4968 + ], + "loc": { + "start": { + "line": 148, + "column": 15 + }, + "end": { + "line": 148, + "column": 35 + } + } + }, + "range": [ + 4943, + 4968 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 4969, + 4974 + ], + "loc": { + "start": { + "line": 148, + "column": 36 + }, + "end": { + "line": 148, + "column": 41 + } + } + }, + "range": [ + 4943, + 4975 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 42 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 4976, + 4982 + ], + "loc": { + "start": { + "line": 148, + "column": 43 + }, + "end": { + "line": 148, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 4983, + 4987 + ], + "loc": { + "start": { + "line": 148, + "column": 50 + }, + "end": { + "line": 148, + "column": 54 + } + } + }, + "range": [ + 4976, + 4987 + ], + "loc": { + "start": { + "line": 148, + "column": 43 + }, + "end": { + "line": 148, + "column": 54 + } + } + }, + "range": [ + 4943, + 4988 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 4989, + 4996 + ], + "loc": { + "start": { + "line": 148, + "column": 56 + }, + "end": { + "line": 148, + "column": 63 + } + } + }, + "range": [ + 4943, + 4996 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 63 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 4997, + 4998 + ], + "loc": { + "start": { + "line": 148, + "column": 64 + }, + "end": { + "line": 148, + "column": 65 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 5002, + 5003 + ], + "loc": { + "start": { + "line": 148, + "column": 69 + }, + "end": { + "line": 148, + "column": 70 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 5004, + 5005 + ], + "loc": { + "start": { + "line": 148, + "column": 71 + }, + "end": { + "line": 148, + "column": 72 + } + } + }, + "range": [ + 5002, + 5006 + ], + "loc": { + "start": { + "line": 148, + "column": 69 + }, + "end": { + "line": 148, + "column": 73 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 5007, + 5011 + ], + "loc": { + "start": { + "line": 148, + "column": 74 + }, + "end": { + "line": 148, + "column": 78 + } + } + }, + "range": [ + 5002, + 5011 + ], + "loc": { + "start": { + "line": 148, + "column": 69 + }, + "end": { + "line": 148, + "column": 78 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 5012, + 5013 + ], + "loc": { + "start": { + "line": 148, + "column": 79 + }, + "end": { + "line": 148, + "column": 80 + } + } + }, + "property": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 5014, + 5015 + ], + "loc": { + "start": { + "line": 148, + "column": 81 + }, + "end": { + "line": 148, + "column": 82 + } + } + }, + "range": [ + 5012, + 5016 + ], + "loc": { + "start": { + "line": 148, + "column": 79 + }, + "end": { + "line": 148, + "column": 83 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 5018, + 5026 + ], + "loc": { + "start": { + "line": 148, + "column": 85 + }, + "end": { + "line": 148, + "column": 93 + } + } + } + ], + "range": [ + 5002, + 5027 + ], + "loc": { + "start": { + "line": 148, + "column": 69 + }, + "end": { + "line": 148, + "column": 94 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 4997, + 5027 + ], + "loc": { + "start": { + "line": 148, + "column": 64 + }, + "end": { + "line": 148, + "column": 94 + } + } + } + ], + "range": [ + 4943, + 5028 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 95 + } + } + }, + "range": [ + 4943, + 5029 + ], + "loc": { + "start": { + "line": 148, + "column": 10 + }, + "end": { + "line": 148, + "column": 96 + } + } + } + ], + "range": [ + 4931, + 5039 + ], + "loc": { + "start": { + "line": 147, + "column": 59 + }, + "end": { + "line": 149, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 4880, + 5039 + ], + "loc": { + "start": { + "line": 147, + "column": 8 + }, + "end": { + "line": 149, + "column": 9 + } + } + } + ], + "range": [ + 4236, + 5047 + ], + "loc": { + "start": { + "line": 135, + "column": 36 + }, + "end": { + "line": 150, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 5073, + 5082 + ], + "loc": { + "start": { + "line": 151, + "column": 18 + }, + "end": { + "line": 151, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The data must have a type and id", + "cooked": "The data must have a type and id" + }, + "tail": true, + "range": [ + 5083, + 5117 + ], + "loc": { + "start": { + "line": 151, + "column": 28 + }, + "end": { + "line": 151, + "column": 62 + } + } + } + ], + "expressions": [], + "range": [ + 5083, + 5117 + ], + "loc": { + "start": { + "line": 151, + "column": 28 + }, + "end": { + "line": 151, + "column": 62 + } + } + } + ], + "range": [ + 5069, + 5118 + ], + "loc": { + "start": { + "line": 151, + "column": 14 + }, + "end": { + "line": 151, + "column": 63 + } + } + }, + "range": [ + 5063, + 5119 + ], + "loc": { + "start": { + "line": 151, + "column": 8 + }, + "end": { + "line": 151, + "column": 64 + } + } + } + ], + "range": [ + 5053, + 5127 + ], + "loc": { + "start": { + "line": 150, + "column": 13 + }, + "end": { + "line": 152, + "column": 7 + } + } + }, + "range": [ + 4206, + 5127 + ], + "loc": { + "start": { + "line": 135, + "column": 6 + }, + "end": { + "line": 152, + "column": 7 + } + } + } + ], + "range": [ + 4198, + 5133 + ], + "loc": { + "start": { + "line": 134, + "column": 16 + }, + "end": { + "line": 153, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 5157, + 5166 + ], + "loc": { + "start": { + "line": 154, + "column": 16 + }, + "end": { + "line": 154, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide data to add", + "cooked": "You must provide data to add" + }, + "tail": true, + "range": [ + 5167, + 5197 + ], + "loc": { + "start": { + "line": 154, + "column": 26 + }, + "end": { + "line": 154, + "column": 56 + } + } + } + ], + "expressions": [], + "range": [ + 5167, + 5197 + ], + "loc": { + "start": { + "line": 154, + "column": 26 + }, + "end": { + "line": 154, + "column": 56 + } + } + } + ], + "range": [ + 5153, + 5198 + ], + "loc": { + "start": { + "line": 154, + "column": 12 + }, + "end": { + "line": 154, + "column": 57 + } + } + }, + "range": [ + 5147, + 5199 + ], + "loc": { + "start": { + "line": 154, + "column": 6 + }, + "end": { + "line": 154, + "column": 58 + } + } + } + ], + "range": [ + 5139, + 5205 + ], + "loc": { + "start": { + "line": 153, + "column": 11 + }, + "end": { + "line": 155, + "column": 5 + } + } + }, + "range": [ + 4186, + 5205 + ], + "loc": { + "start": { + "line": 134, + "column": 4 + }, + "end": { + "line": 155, + "column": 5 + } + } + } + ], + "range": [ + 4180, + 5209 + ], + "loc": { + "start": { + "line": 133, + "column": 14 + }, + "end": { + "line": 156, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 4171, + 5209 + ], + "loc": { + "start": { + "line": 133, + "column": 5 + }, + "end": { + "line": 156, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 4168, + 5209 + ], + "loc": { + "start": { + "line": 133, + "column": 2 + }, + "end": { + "line": 156, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - Resource Object to add. See:\n http://jsonapi.org/format/#document-resource-objects\n * @return {undefined} - Nothing.\n ", + "range": [ + 3873, + 4165 + ], + "loc": { + "start": { + "line": 124, + "column": 2 + }, + "end": { + "line": 132, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 5213, + 5659 + ], + "loc": { + "start": { + "line": 158, + "column": 2 + }, + "end": { + "line": 166, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "convert", + "range": [ + 5662, + 5669 + ], + "loc": { + "start": { + "line": 167, + "column": 2 + }, + "end": { + "line": 167, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 5670, + 5674 + ], + "loc": { + "start": { + "line": 167, + "column": 10 + }, + "end": { + "line": 167, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 5676, + 5678 + ], + "loc": { + "start": { + "line": 167, + "column": 16 + }, + "end": { + "line": 167, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 5680, + 5687 + ], + "loc": { + "start": { + "line": 167, + "column": 20 + }, + "end": { + "line": 167, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "type", + "range": [ + 5699, + 5703 + ], + "loc": { + "start": { + "line": 168, + "column": 8 + }, + "end": { + "line": 168, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "type", + "range": [ + 5714, + 5718 + ], + "loc": { + "start": { + "line": 168, + "column": 23 + }, + "end": { + "line": 168, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 5707, + 5718 + ], + "loc": { + "start": { + "line": 168, + "column": 16 + }, + "end": { + "line": 168, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 5723, + 5731 + ], + "loc": { + "start": { + "line": 168, + "column": 32 + }, + "end": { + "line": 168, + "column": 40 + } + } + }, + "range": [ + 5707, + 5731 + ], + "loc": { + "start": { + "line": 168, + "column": 16 + }, + "end": { + "line": 168, + "column": 40 + } + } + }, + "range": [ + 5699, + 5731 + ], + "loc": { + "start": { + "line": 168, + "column": 8 + }, + "end": { + "line": 168, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5748, + 5752 + ], + "loc": { + "start": { + "line": 169, + "column": 13 + }, + "end": { + "line": 169, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 5753, + 5760 + ], + "loc": { + "start": { + "line": 169, + "column": 18 + }, + "end": { + "line": 169, + "column": 25 + } + } + }, + "range": [ + 5748, + 5760 + ], + "loc": { + "start": { + "line": 169, + "column": 13 + }, + "end": { + "line": 169, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "type", + "range": [ + 5761, + 5765 + ], + "loc": { + "start": { + "line": 169, + "column": 26 + }, + "end": { + "line": 169, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5766, + 5770 + ], + "loc": { + "start": { + "line": 169, + "column": 31 + }, + "end": { + "line": 169, + "column": 35 + } + } + }, + "range": [ + 5761, + 5770 + ], + "loc": { + "start": { + "line": 169, + "column": 26 + }, + "end": { + "line": 169, + "column": 35 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "type", + "range": [ + 5772, + 5776 + ], + "loc": { + "start": { + "line": 169, + "column": 37 + }, + "end": { + "line": 169, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 5777, + 5779 + ], + "loc": { + "start": { + "line": 169, + "column": 42 + }, + "end": { + "line": 169, + "column": 44 + } + } + }, + "range": [ + 5772, + 5779 + ], + "loc": { + "start": { + "line": 169, + "column": 37 + }, + "end": { + "line": 169, + "column": 44 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 5781, + 5785 + ], + "loc": { + "start": { + "line": 169, + "column": 46 + }, + "end": { + "line": 169, + "column": 50 + } + } + } + ], + "range": [ + 5748, + 5786 + ], + "loc": { + "start": { + "line": 169, + "column": 13 + }, + "end": { + "line": 169, + "column": 51 + } + } + }, + "range": [ + 5741, + 5787 + ], + "loc": { + "start": { + "line": 169, + "column": 6 + }, + "end": { + "line": 169, + "column": 52 + } + } + } + ], + "range": [ + 5733, + 5793 + ], + "loc": { + "start": { + "line": 168, + "column": 42 + }, + "end": { + "line": 170, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 5803, + 5805 + ], + "loc": { + "start": { + "line": 170, + "column": 15 + }, + "end": { + "line": 170, + "column": 17 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "id", + "range": [ + 5816, + 5818 + ], + "loc": { + "start": { + "line": 170, + "column": 28 + }, + "end": { + "line": 170, + "column": 30 + } + } + }, + "prefix": true, + "range": [ + 5809, + 5818 + ], + "loc": { + "start": { + "line": 170, + "column": 21 + }, + "end": { + "line": 170, + "column": 30 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 5823, + 5831 + ], + "loc": { + "start": { + "line": 170, + "column": 35 + }, + "end": { + "line": 170, + "column": 43 + } + } + }, + "range": [ + 5809, + 5831 + ], + "loc": { + "start": { + "line": 170, + "column": 21 + }, + "end": { + "line": 170, + "column": 43 + } + } + }, + "range": [ + 5803, + 5831 + ], + "loc": { + "start": { + "line": 170, + "column": 15 + }, + "end": { + "line": 170, + "column": 43 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5848, + 5852 + ], + "loc": { + "start": { + "line": 171, + "column": 13 + }, + "end": { + "line": 171, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 5853, + 5860 + ], + "loc": { + "start": { + "line": 171, + "column": 18 + }, + "end": { + "line": 171, + "column": 25 + } + } + }, + "range": [ + 5848, + 5860 + ], + "loc": { + "start": { + "line": 171, + "column": 13 + }, + "end": { + "line": 171, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 5861, + 5865 + ], + "loc": { + "start": { + "line": 171, + "column": 26 + }, + "end": { + "line": 171, + "column": 30 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "id", + "range": [ + 5867, + 5869 + ], + "loc": { + "start": { + "line": 171, + "column": 32 + }, + "end": { + "line": 171, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 5870, + 5872 + ], + "loc": { + "start": { + "line": 171, + "column": 35 + }, + "end": { + "line": 171, + "column": 37 + } + } + }, + "range": [ + 5867, + 5872 + ], + "loc": { + "start": { + "line": 171, + "column": 32 + }, + "end": { + "line": 171, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 5874, + 5876 + ], + "loc": { + "start": { + "line": 171, + "column": 39 + }, + "end": { + "line": 171, + "column": 41 + } + } + } + ], + "range": [ + 5848, + 5877 + ], + "loc": { + "start": { + "line": 171, + "column": 13 + }, + "end": { + "line": 171, + "column": 42 + } + } + }, + "range": [ + 5841, + 5878 + ], + "loc": { + "start": { + "line": 171, + "column": 6 + }, + "end": { + "line": 171, + "column": 43 + } + } + } + ], + "range": [ + 5833, + 5884 + ], + "loc": { + "start": { + "line": 170, + "column": 45 + }, + "end": { + "line": 172, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "data", + "range": [ + 5902, + 5906 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 173, + "column": 14 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 5919, + 5923 + ], + "loc": { + "start": { + "line": 174, + "column": 8 + }, + "end": { + "line": 174, + "column": 12 + } + } + }, + "value": { + "type": "Identifier", + "name": "type", + "range": [ + 5925, + 5929 + ], + "loc": { + "start": { + "line": 174, + "column": 14 + }, + "end": { + "line": 174, + "column": 18 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 5919, + 5929 + ], + "loc": { + "start": { + "line": 174, + "column": 8 + }, + "end": { + "line": 174, + "column": 18 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "attributes", + "range": [ + 5939, + 5949 + ], + "loc": { + "start": { + "line": 175, + "column": 8 + }, + "end": { + "line": 175, + "column": 18 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 5951, + 5953 + ], + "loc": { + "start": { + "line": 175, + "column": 20 + }, + "end": { + "line": 175, + "column": 22 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 5939, + 5953 + ], + "loc": { + "start": { + "line": 175, + "column": 8 + }, + "end": { + "line": 175, + "column": 22 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "relationships", + "range": [ + 5963, + 5976 + ], + "loc": { + "start": { + "line": 176, + "column": 8 + }, + "end": { + "line": 176, + "column": 21 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 5978, + 5980 + ], + "loc": { + "start": { + "line": 176, + "column": 23 + }, + "end": { + "line": 176, + "column": 25 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 5963, + 5980 + ], + "loc": { + "start": { + "line": 176, + "column": 8 + }, + "end": { + "line": 176, + "column": 25 + } + } + } + ], + "range": [ + 5909, + 5988 + ], + "loc": { + "start": { + "line": 173, + "column": 17 + }, + "end": { + "line": 177, + "column": 7 + } + } + }, + "range": [ + 5902, + 5988 + ], + "loc": { + "start": { + "line": 173, + "column": 10 + }, + "end": { + "line": 177, + "column": 7 + } + } + } + ], + "kind": "let", + "range": [ + 5898, + 5989 + ], + "loc": { + "start": { + "line": 173, + "column": 6 + }, + "end": { + "line": 177, + "column": 8 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 6000, + 6002 + ], + "loc": { + "start": { + "line": 178, + "column": 10 + }, + "end": { + "line": 178, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 6014, + 6018 + ], + "loc": { + "start": { + "line": 179, + "column": 8 + }, + "end": { + "line": 179, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 6019, + 6021 + ], + "loc": { + "start": { + "line": 179, + "column": 13 + }, + "end": { + "line": 179, + "column": 15 + } + } + }, + "range": [ + 6014, + 6021 + ], + "loc": { + "start": { + "line": 179, + "column": 8 + }, + "end": { + "line": 179, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "id", + "range": [ + 6024, + 6026 + ], + "loc": { + "start": { + "line": 179, + "column": 18 + }, + "end": { + "line": 179, + "column": 20 + } + } + }, + "range": [ + 6014, + 6026 + ], + "loc": { + "start": { + "line": 179, + "column": 8 + }, + "end": { + "line": 179, + "column": 20 + } + } + }, + "range": [ + 6014, + 6027 + ], + "loc": { + "start": { + "line": 179, + "column": 8 + }, + "end": { + "line": 179, + "column": 21 + } + } + } + ], + "range": [ + 6004, + 6035 + ], + "loc": { + "start": { + "line": 178, + "column": 14 + }, + "end": { + "line": 180, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 5996, + 6035 + ], + "loc": { + "start": { + "line": 178, + "column": 6 + }, + "end": { + "line": 180, + "column": 7 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 6046, + 6056 + ], + "loc": { + "start": { + "line": 181, + "column": 10 + }, + "end": { + "line": 181, + "column": 20 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 6059, + 6063 + ], + "loc": { + "start": { + "line": 181, + "column": 23 + }, + "end": { + "line": 181, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 6064, + 6070 + ], + "loc": { + "start": { + "line": 181, + "column": 28 + }, + "end": { + "line": 181, + "column": 34 + } + } + }, + "range": [ + 6059, + 6070 + ], + "loc": { + "start": { + "line": 181, + "column": 23 + }, + "end": { + "line": 181, + "column": 34 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 6071, + 6075 + ], + "loc": { + "start": { + "line": 181, + "column": 35 + }, + "end": { + "line": 181, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 6076, + 6080 + ], + "loc": { + "start": { + "line": 181, + "column": 40 + }, + "end": { + "line": 181, + "column": 44 + } + } + }, + "range": [ + 6071, + 6080 + ], + "loc": { + "start": { + "line": 181, + "column": 35 + }, + "end": { + "line": 181, + "column": 44 + } + } + }, + "range": [ + 6059, + 6081 + ], + "loc": { + "start": { + "line": 181, + "column": 23 + }, + "end": { + "line": 181, + "column": 45 + } + } + }, + "range": [ + 6046, + 6081 + ], + "loc": { + "start": { + "line": 181, + "column": 10 + }, + "end": { + "line": 181, + "column": 45 + } + } + } + ], + "kind": "let", + "range": [ + 6042, + 6082 + ], + "loc": { + "start": { + "line": 181, + "column": 6 + }, + "end": { + "line": 181, + "column": 46 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 6089, + 6095 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 182, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 6096, + 6100 + ], + "loc": { + "start": { + "line": 182, + "column": 13 + }, + "end": { + "line": 182, + "column": 17 + } + } + }, + "range": [ + 6089, + 6100 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 182, + "column": 17 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 6101, + 6111 + ], + "loc": { + "start": { + "line": 182, + "column": 18 + }, + "end": { + "line": 182, + "column": 28 + } + } + } + ], + "range": [ + 6089, + 6112 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 182, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 6113, + 6120 + ], + "loc": { + "start": { + "line": 182, + "column": 30 + }, + "end": { + "line": 182, + "column": 37 + } + } + }, + "range": [ + 6089, + 6120 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 182, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 6121, + 6130 + ], + "loc": { + "start": { + "line": 182, + "column": 38 + }, + "end": { + "line": 182, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 6148, + 6157 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 21 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 6158, + 6159 + ], + "loc": { + "start": { + "line": 183, + "column": 22 + }, + "end": { + "line": 183, + "column": 23 + } + } + }, + "range": [ + 6148, + 6160 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 24 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 6165, + 6168 + ], + "loc": { + "start": { + "line": 183, + "column": 29 + }, + "end": { + "line": 183, + "column": 32 + } + } + }, + "range": [ + 6148, + 6168 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 32 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 6182, + 6192 + ], + "loc": { + "start": { + "line": 184, + "column": 10 + }, + "end": { + "line": 184, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 6193, + 6202 + ], + "loc": { + "start": { + "line": 184, + "column": 21 + }, + "end": { + "line": 184, + "column": 30 + } + } + }, + "range": [ + 6182, + 6203 + ], + "loc": { + "start": { + "line": 184, + "column": 10 + }, + "end": { + "line": 184, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "serialize", + "range": [ + 6204, + 6213 + ], + "loc": { + "start": { + "line": 184, + "column": 32 + }, + "end": { + "line": 184, + "column": 41 + } + } + }, + "range": [ + 6182, + 6213 + ], + "loc": { + "start": { + "line": 184, + "column": 10 + }, + "end": { + "line": 184, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "partial", + "range": [ + 6214, + 6221 + ], + "loc": { + "start": { + "line": 184, + "column": 42 + }, + "end": { + "line": 184, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 6223, + 6227 + ], + "loc": { + "start": { + "line": 184, + "column": 51 + }, + "end": { + "line": 184, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 6229, + 6238 + ], + "loc": { + "start": { + "line": 184, + "column": 57 + }, + "end": { + "line": 184, + "column": 66 + } + } + } + ], + "range": [ + 6182, + 6239 + ], + "loc": { + "start": { + "line": 184, + "column": 10 + }, + "end": { + "line": 184, + "column": 67 + } + } + }, + "range": [ + 6182, + 6240 + ], + "loc": { + "start": { + "line": 184, + "column": 10 + }, + "end": { + "line": 184, + "column": 68 + } + } + } + ], + "range": [ + 6170, + 6250 + ], + "loc": { + "start": { + "line": 183, + "column": 34 + }, + "end": { + "line": 185, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 6144, + 6250 + ], + "loc": { + "start": { + "line": 183, + "column": 8 + }, + "end": { + "line": 185, + "column": 9 + } + } + } + ], + "range": [ + 6134, + 6258 + ], + "loc": { + "start": { + "line": 182, + "column": 51 + }, + "end": { + "line": 186, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 6121, + 6258 + ], + "loc": { + "start": { + "line": 182, + "column": 38 + }, + "end": { + "line": 186, + "column": 7 + } + } + } + ], + "range": [ + 6089, + 6259 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 186, + "column": 8 + } + } + }, + "range": [ + 6089, + 6260 + ], + "loc": { + "start": { + "line": 182, + "column": 6 + }, + "end": { + "line": 186, + "column": 9 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "data", + "range": [ + 6274, + 6278 + ], + "loc": { + "start": { + "line": 187, + "column": 13 + }, + "end": { + "line": 187, + "column": 17 + } + } + }, + "range": [ + 6267, + 6279 + ], + "loc": { + "start": { + "line": 187, + "column": 6 + }, + "end": { + "line": 187, + "column": 18 + } + } + } + ], + "range": [ + 5890, + 6285 + ], + "loc": { + "start": { + "line": 172, + "column": 11 + }, + "end": { + "line": 188, + "column": 5 + } + } + }, + "range": [ + 5799, + 6285 + ], + "loc": { + "start": { + "line": 170, + "column": 11 + }, + "end": { + "line": 188, + "column": 5 + } + } + }, + "range": [ + 5695, + 6285 + ], + "loc": { + "start": { + "line": 168, + "column": 4 + }, + "end": { + "line": 188, + "column": 5 + } + } + } + ], + "range": [ + 5689, + 6289 + ], + "loc": { + "start": { + "line": 167, + "column": 29 + }, + "end": { + "line": 189, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5669, + 6289 + ], + "loc": { + "start": { + "line": 167, + "column": 9 + }, + "end": { + "line": 189, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 5662, + 6289 + ], + "loc": { + "start": { + "line": 167, + "column": 2 + }, + "end": { + "line": 189, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 5213, + 5659 + ], + "loc": { + "start": { + "line": 158, + "column": 2 + }, + "end": { + "line": 166, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 6293, + 6954 + ], + "loc": { + "start": { + "line": 191, + "column": 2 + }, + "end": { + "line": 209, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "create", + "range": [ + 6957, + 6963 + ], + "loc": { + "start": { + "line": 210, + "column": 2 + }, + "end": { + "line": 210, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 6964, + 6968 + ], + "loc": { + "start": { + "line": 210, + "column": 9 + }, + "end": { + "line": 210, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 6970, + 6977 + ], + "loc": { + "start": { + "line": 210, + "column": 15 + }, + "end": { + "line": 210, + "column": 22 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 6979, + 6986 + ], + "loc": { + "start": { + "line": 210, + "column": 24 + }, + "end": { + "line": 210, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 6988, + 6993 + ], + "loc": { + "start": { + "line": 210, + "column": 33 + }, + "end": { + "line": 210, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 6995, + 7002 + ], + "loc": { + "start": { + "line": 210, + "column": 40 + }, + "end": { + "line": 210, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7014, + 7018 + ], + "loc": { + "start": { + "line": 211, + "column": 8 + }, + "end": { + "line": 211, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 7019, + 7027 + ], + "loc": { + "start": { + "line": 211, + "column": 13 + }, + "end": { + "line": 211, + "column": 21 + } + } + }, + "range": [ + 7014, + 7027 + ], + "loc": { + "start": { + "line": 211, + "column": 8 + }, + "end": { + "line": 211, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7037, + 7041 + ], + "loc": { + "start": { + "line": 212, + "column": 6 + }, + "end": { + "line": 212, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 7042, + 7050 + ], + "loc": { + "start": { + "line": 212, + "column": 11 + }, + "end": { + "line": 212, + "column": 19 + } + } + }, + "range": [ + 7037, + 7050 + ], + "loc": { + "start": { + "line": 212, + "column": 6 + }, + "end": { + "line": 212, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "create", + "range": [ + 7051, + 7057 + ], + "loc": { + "start": { + "line": 212, + "column": 20 + }, + "end": { + "line": 212, + "column": 26 + } + } + }, + "range": [ + 7037, + 7057 + ], + "loc": { + "start": { + "line": 212, + "column": 6 + }, + "end": { + "line": 212, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 7058, + 7062 + ], + "loc": { + "start": { + "line": 212, + "column": 27 + }, + "end": { + "line": 212, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 7064, + 7068 + ], + "loc": { + "start": { + "line": 212, + "column": 33 + }, + "end": { + "line": 212, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 7070, + 7077 + ], + "loc": { + "start": { + "line": 212, + "column": 39 + }, + "end": { + "line": 212, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 7079, + 7086 + ], + "loc": { + "start": { + "line": 212, + "column": 48 + }, + "end": { + "line": 212, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 7088, + 7093 + ], + "loc": { + "start": { + "line": 212, + "column": 57 + }, + "end": { + "line": 212, + "column": 62 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 7095, + 7102 + ], + "loc": { + "start": { + "line": 212, + "column": 64 + }, + "end": { + "line": 212, + "column": 71 + } + } + } + ], + "range": [ + 7037, + 7103 + ], + "loc": { + "start": { + "line": 212, + "column": 6 + }, + "end": { + "line": 212, + "column": 72 + } + } + }, + "range": [ + 7037, + 7104 + ], + "loc": { + "start": { + "line": 212, + "column": 6 + }, + "end": { + "line": 212, + "column": 73 + } + } + } + ], + "range": [ + 7029, + 7110 + ], + "loc": { + "start": { + "line": 211, + "column": 23 + }, + "end": { + "line": 213, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 7134, + 7139 + ], + "loc": { + "start": { + "line": 214, + "column": 16 + }, + "end": { + "line": 214, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 7140, + 7236 + ], + "loc": { + "start": { + "line": 214, + "column": 22 + }, + "end": { + "line": 214, + "column": 118 + } + } + } + ], + "range": [ + 7130, + 7237 + ], + "loc": { + "start": { + "line": 214, + "column": 12 + }, + "end": { + "line": 214, + "column": 119 + } + } + }, + "range": [ + 7124, + 7238 + ], + "loc": { + "start": { + "line": 214, + "column": 6 + }, + "end": { + "line": 214, + "column": 120 + } + } + } + ], + "range": [ + 7116, + 7244 + ], + "loc": { + "start": { + "line": 213, + "column": 11 + }, + "end": { + "line": 215, + "column": 5 + } + } + }, + "range": [ + 7010, + 7244 + ], + "loc": { + "start": { + "line": 211, + "column": 4 + }, + "end": { + "line": 215, + "column": 5 + } + } + } + ], + "range": [ + 7004, + 7248 + ], + "loc": { + "start": { + "line": 210, + "column": 49 + }, + "end": { + "line": 216, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 6963, + 7248 + ], + "loc": { + "start": { + "line": 210, + "column": 8 + }, + "end": { + "line": 216, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 6957, + 7248 + ], + "loc": { + "start": { + "line": 210, + "column": 2 + }, + "end": { + "line": 216, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 6293, + 6954 + ], + "loc": { + "start": { + "line": 191, + "column": 2 + }, + "end": { + "line": 209, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n * @return {undefined} - Nothing.\n ", + "range": [ + 7252, + 7479 + ], + "loc": { + "start": { + "line": 218, + "column": 2 + }, + "end": { + "line": 225, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "define", + "range": [ + 7482, + 7488 + ], + "loc": { + "start": { + "line": 226, + "column": 2 + }, + "end": { + "line": 226, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "names", + "range": [ + 7489, + 7494 + ], + "loc": { + "start": { + "line": 226, + "column": 9 + }, + "end": { + "line": 226, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 7496, + 7506 + ], + "loc": { + "start": { + "line": 226, + "column": 16 + }, + "end": { + "line": 226, + "column": 26 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "names", + "range": [ + 7514, + 7519 + ], + "loc": { + "start": { + "line": 227, + "column": 4 + }, + "end": { + "line": 227, + "column": 9 + } + } + }, + "right": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 7523, + 7528 + ], + "loc": { + "start": { + "line": 227, + "column": 13 + }, + "end": { + "line": 227, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "constructor", + "range": [ + 7529, + 7540 + ], + "loc": { + "start": { + "line": 227, + "column": 19 + }, + "end": { + "line": 227, + "column": 30 + } + } + }, + "range": [ + 7523, + 7540 + ], + "loc": { + "start": { + "line": 227, + "column": 13 + }, + "end": { + "line": 227, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "Array", + "range": [ + 7545, + 7550 + ], + "loc": { + "start": { + "line": 227, + "column": 35 + }, + "end": { + "line": 227, + "column": 40 + } + } + }, + "range": [ + 7523, + 7550 + ], + "loc": { + "start": { + "line": 227, + "column": 13 + }, + "end": { + "line": 227, + "column": 40 + } + } + }, + "consequent": { + "type": "Identifier", + "name": "names", + "range": [ + 7554, + 7559 + ], + "loc": { + "start": { + "line": 227, + "column": 44 + }, + "end": { + "line": 227, + "column": 49 + } + } + }, + "alternate": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Identifier", + "name": "names", + "range": [ + 7564, + 7569 + ], + "loc": { + "start": { + "line": 227, + "column": 54 + }, + "end": { + "line": 227, + "column": 59 + } + } + } + ], + "range": [ + 7562, + 7571 + ], + "loc": { + "start": { + "line": 227, + "column": 52 + }, + "end": { + "line": 227, + "column": 61 + } + } + }, + "range": [ + 7522, + 7571 + ], + "loc": { + "start": { + "line": 227, + "column": 12 + }, + "end": { + "line": 227, + "column": 61 + } + } + }, + "range": [ + 7514, + 7571 + ], + "loc": { + "start": { + "line": 227, + "column": 4 + }, + "end": { + "line": 227, + "column": 61 + } + } + }, + "range": [ + 7514, + 7572 + ], + "loc": { + "start": { + "line": 227, + "column": 4 + }, + "end": { + "line": 227, + "column": 62 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "definition", + "range": [ + 7581, + 7591 + ], + "loc": { + "start": { + "line": 228, + "column": 8 + }, + "end": { + "line": 228, + "column": 18 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 7601, + 7611 + ], + "loc": { + "start": { + "line": 229, + "column": 6 + }, + "end": { + "line": 229, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 7612, + 7618 + ], + "loc": { + "start": { + "line": 229, + "column": 17 + }, + "end": { + "line": 229, + "column": 23 + } + } + }, + "range": [ + 7601, + 7618 + ], + "loc": { + "start": { + "line": 229, + "column": 6 + }, + "end": { + "line": 229, + "column": 23 + } + } + }, + "right": { + "type": "Identifier", + "name": "names", + "range": [ + 7621, + 7626 + ], + "loc": { + "start": { + "line": 229, + "column": 26 + }, + "end": { + "line": 229, + "column": 31 + } + } + }, + "range": [ + 7601, + 7626 + ], + "loc": { + "start": { + "line": 229, + "column": 6 + }, + "end": { + "line": 229, + "column": 31 + } + } + }, + "range": [ + 7601, + 7627 + ], + "loc": { + "start": { + "line": 229, + "column": 6 + }, + "end": { + "line": 229, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 7634, + 7639 + ], + "loc": { + "start": { + "line": 230, + "column": 6 + }, + "end": { + "line": 230, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 7640, + 7647 + ], + "loc": { + "start": { + "line": 230, + "column": 12 + }, + "end": { + "line": 230, + "column": 19 + } + } + }, + "range": [ + 7634, + 7647 + ], + "loc": { + "start": { + "line": 230, + "column": 6 + }, + "end": { + "line": 230, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 7648, + 7652 + ], + "loc": { + "start": { + "line": 230, + "column": 20 + }, + "end": { + "line": 230, + "column": 24 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7671, + 7675 + ], + "loc": { + "start": { + "line": 231, + "column": 13 + }, + "end": { + "line": 231, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 7676, + 7682 + ], + "loc": { + "start": { + "line": 231, + "column": 18 + }, + "end": { + "line": 231, + "column": 24 + } + } + }, + "range": [ + 7671, + 7682 + ], + "loc": { + "start": { + "line": 231, + "column": 13 + }, + "end": { + "line": 231, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 7683, + 7687 + ], + "loc": { + "start": { + "line": 231, + "column": 25 + }, + "end": { + "line": 231, + "column": 29 + } + } + }, + "range": [ + 7671, + 7688 + ], + "loc": { + "start": { + "line": 231, + "column": 13 + }, + "end": { + "line": 231, + "column": 30 + } + } + }, + "prefix": true, + "range": [ + 7670, + 7688 + ], + "loc": { + "start": { + "line": 231, + "column": 12 + }, + "end": { + "line": 231, + "column": 30 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7702, + 7706 + ], + "loc": { + "start": { + "line": 232, + "column": 10 + }, + "end": { + "line": 232, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 7707, + 7713 + ], + "loc": { + "start": { + "line": 232, + "column": 15 + }, + "end": { + "line": 232, + "column": 21 + } + } + }, + "range": [ + 7702, + 7713 + ], + "loc": { + "start": { + "line": 232, + "column": 10 + }, + "end": { + "line": 232, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 7714, + 7718 + ], + "loc": { + "start": { + "line": 232, + "column": 22 + }, + "end": { + "line": 232, + "column": 26 + } + } + }, + "range": [ + 7702, + 7719 + ], + "loc": { + "start": { + "line": 232, + "column": 10 + }, + "end": { + "line": 232, + "column": 27 + } + } + }, + "right": { + "type": "Identifier", + "name": "definition", + "range": [ + 7722, + 7732 + ], + "loc": { + "start": { + "line": 232, + "column": 30 + }, + "end": { + "line": 232, + "column": 40 + } + } + }, + "range": [ + 7702, + 7732 + ], + "loc": { + "start": { + "line": 232, + "column": 10 + }, + "end": { + "line": 232, + "column": 40 + } + } + }, + "range": [ + 7702, + 7733 + ], + "loc": { + "start": { + "line": 232, + "column": 10 + }, + "end": { + "line": 232, + "column": 41 + } + } + } + ], + "range": [ + 7690, + 7743 + ], + "loc": { + "start": { + "line": 231, + "column": 32 + }, + "end": { + "line": 233, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 7771, + 7776 + ], + "loc": { + "start": { + "line": 234, + "column": 20 + }, + "end": { + "line": 234, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The type '", + "cooked": "The type '" + }, + "tail": false, + "range": [ + 7777, + 7790 + ], + "loc": { + "start": { + "line": 234, + "column": 26 + }, + "end": { + "line": 234, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' has already been defined.", + "cooked": "' has already been defined." + }, + "tail": true, + "range": [ + 7794, + 7823 + ], + "loc": { + "start": { + "line": 234, + "column": 43 + }, + "end": { + "line": 234, + "column": 72 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 7790, + 7794 + ], + "loc": { + "start": { + "line": 234, + "column": 39 + }, + "end": { + "line": 234, + "column": 43 + } + } + } + ], + "range": [ + 7777, + 7823 + ], + "loc": { + "start": { + "line": 234, + "column": 26 + }, + "end": { + "line": 234, + "column": 72 + } + } + } + ], + "range": [ + 7767, + 7824 + ], + "loc": { + "start": { + "line": 234, + "column": 16 + }, + "end": { + "line": 234, + "column": 73 + } + } + }, + "range": [ + 7761, + 7825 + ], + "loc": { + "start": { + "line": 234, + "column": 10 + }, + "end": { + "line": 234, + "column": 74 + } + } + } + ], + "range": [ + 7749, + 7835 + ], + "loc": { + "start": { + "line": 233, + "column": 15 + }, + "end": { + "line": 235, + "column": 9 + } + } + }, + "range": [ + 7666, + 7835 + ], + "loc": { + "start": { + "line": 231, + "column": 8 + }, + "end": { + "line": 235, + "column": 9 + } + } + } + ], + "range": [ + 7656, + 7843 + ], + "loc": { + "start": { + "line": 230, + "column": 28 + }, + "end": { + "line": 236, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 7648, + 7843 + ], + "loc": { + "start": { + "line": 230, + "column": 20 + }, + "end": { + "line": 236, + "column": 7 + } + } + } + ], + "range": [ + 7634, + 7844 + ], + "loc": { + "start": { + "line": 230, + "column": 6 + }, + "end": { + "line": 236, + "column": 8 + } + } + }, + "range": [ + 7634, + 7845 + ], + "loc": { + "start": { + "line": 230, + "column": 6 + }, + "end": { + "line": 236, + "column": 9 + } + } + } + ], + "range": [ + 7593, + 7851 + ], + "loc": { + "start": { + "line": 228, + "column": 20 + }, + "end": { + "line": 237, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 7875, + 7880 + ], + "loc": { + "start": { + "line": 238, + "column": 16 + }, + "end": { + "line": 238, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a definition for the type '", + "cooked": "You must provide a definition for the type '" + }, + "tail": false, + "range": [ + 7881, + 7928 + ], + "loc": { + "start": { + "line": 238, + "column": 22 + }, + "end": { + "line": 238, + "column": 69 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'.", + "cooked": "'." + }, + "tail": true, + "range": [ + 7936, + 7940 + ], + "loc": { + "start": { + "line": 238, + "column": 77 + }, + "end": { + "line": 238, + "column": 81 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 7928, + 7933 + ], + "loc": { + "start": { + "line": 238, + "column": 69 + }, + "end": { + "line": 238, + "column": 74 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 7934, + 7935 + ], + "loc": { + "start": { + "line": 238, + "column": 75 + }, + "end": { + "line": 238, + "column": 76 + } + } + }, + "range": [ + 7928, + 7936 + ], + "loc": { + "start": { + "line": 238, + "column": 69 + }, + "end": { + "line": 238, + "column": 77 + } + } + } + ], + "range": [ + 7881, + 7940 + ], + "loc": { + "start": { + "line": 238, + "column": 22 + }, + "end": { + "line": 238, + "column": 81 + } + } + } + ], + "range": [ + 7871, + 7941 + ], + "loc": { + "start": { + "line": 238, + "column": 12 + }, + "end": { + "line": 238, + "column": 82 + } + } + }, + "range": [ + 7865, + 7942 + ], + "loc": { + "start": { + "line": 238, + "column": 6 + }, + "end": { + "line": 238, + "column": 83 + } + } + } + ], + "range": [ + 7857, + 7948 + ], + "loc": { + "start": { + "line": 237, + "column": 11 + }, + "end": { + "line": 239, + "column": 5 + } + } + }, + "range": [ + 7577, + 7948 + ], + "loc": { + "start": { + "line": 228, + "column": 4 + }, + "end": { + "line": 239, + "column": 5 + } + } + } + ], + "range": [ + 7508, + 7952 + ], + "loc": { + "start": { + "line": 226, + "column": 28 + }, + "end": { + "line": 240, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 7488, + 7952 + ], + "loc": { + "start": { + "line": 226, + "column": 8 + }, + "end": { + "line": 240, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 7482, + 7952 + ], + "loc": { + "start": { + "line": 226, + "column": 2 + }, + "end": { + "line": 240, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n * @return {undefined} - Nothing.\n ", + "range": [ + 7252, + 7479 + ], + "loc": { + "start": { + "line": 218, + "column": 2 + }, + "end": { + "line": 225, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\", () => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 7956, + 8575 + ], + "loc": { + "start": { + "line": 242, + "column": 2 + }, + "end": { + "line": 260, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "destroy", + "range": [ + 8578, + 8585 + ], + "loc": { + "start": { + "line": 261, + "column": 2 + }, + "end": { + "line": 261, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 8586, + 8590 + ], + "loc": { + "start": { + "line": 261, + "column": 10 + }, + "end": { + "line": 261, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 8592, + 8594 + ], + "loc": { + "start": { + "line": 261, + "column": 16 + }, + "end": { + "line": 261, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 8596, + 8603 + ], + "loc": { + "start": { + "line": 261, + "column": 20 + }, + "end": { + "line": 261, + "column": 27 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 8605, + 8610 + ], + "loc": { + "start": { + "line": 261, + "column": 29 + }, + "end": { + "line": 261, + "column": 34 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 8612, + 8619 + ], + "loc": { + "start": { + "line": 261, + "column": 36 + }, + "end": { + "line": 261, + "column": 43 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 8631, + 8635 + ], + "loc": { + "start": { + "line": 262, + "column": 8 + }, + "end": { + "line": 262, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 8636, + 8644 + ], + "loc": { + "start": { + "line": 262, + "column": 13 + }, + "end": { + "line": 262, + "column": 21 + } + } + }, + "range": [ + 8631, + 8644 + ], + "loc": { + "start": { + "line": 262, + "column": 8 + }, + "end": { + "line": 262, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 8654, + 8658 + ], + "loc": { + "start": { + "line": 263, + "column": 6 + }, + "end": { + "line": 263, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 8659, + 8667 + ], + "loc": { + "start": { + "line": 263, + "column": 11 + }, + "end": { + "line": 263, + "column": 19 + } + } + }, + "range": [ + 8654, + 8667 + ], + "loc": { + "start": { + "line": 263, + "column": 6 + }, + "end": { + "line": 263, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "destroy", + "range": [ + 8668, + 8675 + ], + "loc": { + "start": { + "line": 263, + "column": 20 + }, + "end": { + "line": 263, + "column": 27 + } + } + }, + "range": [ + 8654, + 8675 + ], + "loc": { + "start": { + "line": 263, + "column": 6 + }, + "end": { + "line": 263, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 8676, + 8680 + ], + "loc": { + "start": { + "line": 263, + "column": 28 + }, + "end": { + "line": 263, + "column": 32 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 8682, + 8686 + ], + "loc": { + "start": { + "line": 263, + "column": 34 + }, + "end": { + "line": 263, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 8688, + 8690 + ], + "loc": { + "start": { + "line": 263, + "column": 40 + }, + "end": { + "line": 263, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 8692, + 8699 + ], + "loc": { + "start": { + "line": 263, + "column": 44 + }, + "end": { + "line": 263, + "column": 51 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 8701, + 8706 + ], + "loc": { + "start": { + "line": 263, + "column": 53 + }, + "end": { + "line": 263, + "column": 58 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 8708, + 8715 + ], + "loc": { + "start": { + "line": 263, + "column": 60 + }, + "end": { + "line": 263, + "column": 67 + } + } + } + ], + "range": [ + 8654, + 8716 + ], + "loc": { + "start": { + "line": 263, + "column": 6 + }, + "end": { + "line": 263, + "column": 68 + } + } + }, + "range": [ + 8654, + 8717 + ], + "loc": { + "start": { + "line": 263, + "column": 6 + }, + "end": { + "line": 263, + "column": 69 + } + } + } + ], + "range": [ + 8646, + 8723 + ], + "loc": { + "start": { + "line": 262, + "column": 23 + }, + "end": { + "line": 264, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 8747, + 8752 + ], + "loc": { + "start": { + "line": 265, + "column": 16 + }, + "end": { + "line": 265, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 8753, + 8849 + ], + "loc": { + "start": { + "line": 265, + "column": 22 + }, + "end": { + "line": 265, + "column": 118 + } + } + } + ], + "range": [ + 8743, + 8850 + ], + "loc": { + "start": { + "line": 265, + "column": 12 + }, + "end": { + "line": 265, + "column": 119 + } + } + }, + "range": [ + 8737, + 8851 + ], + "loc": { + "start": { + "line": 265, + "column": 6 + }, + "end": { + "line": 265, + "column": 120 + } + } + } + ], + "range": [ + 8729, + 8857 + ], + "loc": { + "start": { + "line": 264, + "column": 11 + }, + "end": { + "line": 266, + "column": 5 + } + } + }, + "range": [ + 8627, + 8857 + ], + "loc": { + "start": { + "line": 262, + "column": 4 + }, + "end": { + "line": 266, + "column": 5 + } + } + } + ], + "range": [ + 8621, + 8861 + ], + "loc": { + "start": { + "line": 261, + "column": 45 + }, + "end": { + "line": 267, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 8585, + 8861 + ], + "loc": { + "start": { + "line": 261, + "column": 9 + }, + "end": { + "line": 267, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 8578, + 8861 + ], + "loc": { + "start": { + "line": 261, + "column": 2 + }, + "end": { + "line": 267, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\", () => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 7956, + 8575 + ], + "loc": { + "start": { + "line": 242, + "column": 2 + }, + "end": { + "line": 260, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Find a resource or entire collection of resources.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to find.\n * @param {string} [id] - The id of the resource to find. If omitted all\n * resources of the type will be returned.\n * @return {Object|Object[]} - Either the resource or an array of resources.\n ", + "range": [ + 8865, + 9375 + ], + "loc": { + "start": { + "line": 269, + "column": 2 + }, + "end": { + "line": 280, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "find", + "range": [ + 9378, + 9382 + ], + "loc": { + "start": { + "line": 281, + "column": 2 + }, + "end": { + "line": 281, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 9383, + 9387 + ], + "loc": { + "start": { + "line": 281, + "column": 7 + }, + "end": { + "line": 281, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 9389, + 9391 + ], + "loc": { + "start": { + "line": 281, + "column": 13 + }, + "end": { + "line": 281, + "column": 15 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "type", + "range": [ + 9403, + 9407 + ], + "loc": { + "start": { + "line": 282, + "column": 8 + }, + "end": { + "line": 282, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 9421, + 9431 + ], + "loc": { + "start": { + "line": 283, + "column": 10 + }, + "end": { + "line": 283, + "column": 20 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9434, + 9438 + ], + "loc": { + "start": { + "line": 283, + "column": 23 + }, + "end": { + "line": 283, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 9439, + 9445 + ], + "loc": { + "start": { + "line": 283, + "column": 28 + }, + "end": { + "line": 283, + "column": 34 + } + } + }, + "range": [ + 9434, + 9445 + ], + "loc": { + "start": { + "line": 283, + "column": 23 + }, + "end": { + "line": 283, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 9446, + 9450 + ], + "loc": { + "start": { + "line": 283, + "column": 35 + }, + "end": { + "line": 283, + "column": 39 + } + } + }, + "range": [ + 9434, + 9451 + ], + "loc": { + "start": { + "line": 283, + "column": 23 + }, + "end": { + "line": 283, + "column": 40 + } + } + }, + "range": [ + 9421, + 9451 + ], + "loc": { + "start": { + "line": 283, + "column": 10 + }, + "end": { + "line": 283, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 9417, + 9452 + ], + "loc": { + "start": { + "line": 283, + "column": 6 + }, + "end": { + "line": 283, + "column": 41 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "definition", + "range": [ + 9463, + 9473 + ], + "loc": { + "start": { + "line": 284, + "column": 10 + }, + "end": { + "line": 284, + "column": 20 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9490, + 9494 + ], + "loc": { + "start": { + "line": 285, + "column": 13 + }, + "end": { + "line": 285, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 9495, + 9500 + ], + "loc": { + "start": { + "line": 285, + "column": 18 + }, + "end": { + "line": 285, + "column": 23 + } + } + }, + "range": [ + 9490, + 9500 + ], + "loc": { + "start": { + "line": 285, + "column": 13 + }, + "end": { + "line": 285, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 9501, + 9505 + ], + "loc": { + "start": { + "line": 285, + "column": 24 + }, + "end": { + "line": 285, + "column": 28 + } + } + }, + "range": [ + 9490, + 9506 + ], + "loc": { + "start": { + "line": 285, + "column": 13 + }, + "end": { + "line": 285, + "column": 29 + } + } + }, + "prefix": true, + "range": [ + 9489, + 9506 + ], + "loc": { + "start": { + "line": 285, + "column": 12 + }, + "end": { + "line": 285, + "column": 29 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "collection", + "range": [ + 9524, + 9534 + ], + "loc": { + "start": { + "line": 286, + "column": 14 + }, + "end": { + "line": 286, + "column": 24 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 9537, + 9539 + ], + "loc": { + "start": { + "line": 286, + "column": 27 + }, + "end": { + "line": 286, + "column": 29 + } + } + }, + "range": [ + 9524, + 9539 + ], + "loc": { + "start": { + "line": 286, + "column": 14 + }, + "end": { + "line": 286, + "column": 29 + } + } + } + ], + "kind": "let", + "range": [ + 9520, + 9540 + ], + "loc": { + "start": { + "line": 286, + "column": 10 + }, + "end": { + "line": 286, + "column": 30 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 9551, + 9561 + ], + "loc": { + "start": { + "line": 287, + "column": 10 + }, + "end": { + "line": 287, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 9562, + 9568 + ], + "loc": { + "start": { + "line": 287, + "column": 21 + }, + "end": { + "line": 287, + "column": 27 + } + } + }, + "range": [ + 9551, + 9568 + ], + "loc": { + "start": { + "line": 287, + "column": 10 + }, + "end": { + "line": 287, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 9569, + 9576 + ], + "loc": { + "start": { + "line": 287, + "column": 28 + }, + "end": { + "line": 287, + "column": 35 + } + } + }, + "range": [ + 9551, + 9576 + ], + "loc": { + "start": { + "line": 287, + "column": 10 + }, + "end": { + "line": 287, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "t", + "range": [ + 9577, + 9578 + ], + "loc": { + "start": { + "line": 287, + "column": 36 + }, + "end": { + "line": 287, + "column": 37 + } + } + } + ], + "body": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9582, + 9586 + ], + "loc": { + "start": { + "line": 287, + "column": 41 + }, + "end": { + "line": 287, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 9587, + 9592 + ], + "loc": { + "start": { + "line": 287, + "column": 46 + }, + "end": { + "line": 287, + "column": 51 + } + } + }, + "range": [ + 9582, + 9592 + ], + "loc": { + "start": { + "line": 287, + "column": 41 + }, + "end": { + "line": 287, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "t", + "range": [ + 9593, + 9594 + ], + "loc": { + "start": { + "line": 287, + "column": 52 + }, + "end": { + "line": 287, + "column": 53 + } + } + }, + "range": [ + 9582, + 9595 + ], + "loc": { + "start": { + "line": 287, + "column": 41 + }, + "end": { + "line": 287, + "column": 54 + } + } + }, + "right": { + "type": "Identifier", + "name": "collection", + "range": [ + 9598, + 9608 + ], + "loc": { + "start": { + "line": 287, + "column": 57 + }, + "end": { + "line": 287, + "column": 67 + } + } + }, + "range": [ + 9582, + 9608 + ], + "loc": { + "start": { + "line": 287, + "column": 41 + }, + "end": { + "line": 287, + "column": 67 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 9577, + 9608 + ], + "loc": { + "start": { + "line": 287, + "column": 36 + }, + "end": { + "line": 287, + "column": 67 + } + } + } + ], + "range": [ + 9551, + 9609 + ], + "loc": { + "start": { + "line": 287, + "column": 10 + }, + "end": { + "line": 287, + "column": 68 + } + } + }, + "range": [ + 9551, + 9610 + ], + "loc": { + "start": { + "line": 287, + "column": 10 + }, + "end": { + "line": 287, + "column": 69 + } + } + } + ], + "range": [ + 9508, + 9620 + ], + "loc": { + "start": { + "line": 285, + "column": 31 + }, + "end": { + "line": 288, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 9485, + 9620 + ], + "loc": { + "start": { + "line": 285, + "column": 8 + }, + "end": { + "line": 288, + "column": 9 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 9633, + 9635 + ], + "loc": { + "start": { + "line": 289, + "column": 12 + }, + "end": { + "line": 289, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9654, + 9658 + ], + "loc": { + "start": { + "line": 290, + "column": 15 + }, + "end": { + "line": 290, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 9659, + 9664 + ], + "loc": { + "start": { + "line": 290, + "column": 20 + }, + "end": { + "line": 290, + "column": 25 + } + } + }, + "range": [ + 9654, + 9664 + ], + "loc": { + "start": { + "line": 290, + "column": 15 + }, + "end": { + "line": 290, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 9665, + 9669 + ], + "loc": { + "start": { + "line": 290, + "column": 26 + }, + "end": { + "line": 290, + "column": 30 + } + } + }, + "range": [ + 9654, + 9670 + ], + "loc": { + "start": { + "line": 290, + "column": 15 + }, + "end": { + "line": 290, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 9671, + 9673 + ], + "loc": { + "start": { + "line": 290, + "column": 32 + }, + "end": { + "line": 290, + "column": 34 + } + } + }, + "range": [ + 9654, + 9674 + ], + "loc": { + "start": { + "line": 290, + "column": 15 + }, + "end": { + "line": 290, + "column": 35 + } + } + }, + "prefix": true, + "range": [ + 9653, + 9674 + ], + "loc": { + "start": { + "line": 290, + "column": 14 + }, + "end": { + "line": 290, + "column": 35 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9690, + 9694 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 291, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 9695, + 9700 + ], + "loc": { + "start": { + "line": 291, + "column": 17 + }, + "end": { + "line": 291, + "column": 22 + } + } + }, + "range": [ + 9690, + 9700 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 291, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 9701, + 9705 + ], + "loc": { + "start": { + "line": 291, + "column": 23 + }, + "end": { + "line": 291, + "column": 27 + } + } + }, + "range": [ + 9690, + 9706 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 291, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 9707, + 9709 + ], + "loc": { + "start": { + "line": 291, + "column": 29 + }, + "end": { + "line": 291, + "column": 31 + } + } + }, + "range": [ + 9690, + 9710 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 291, + "column": 32 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 9729, + 9740 + ], + "loc": { + "start": { + "line": 292, + "column": 14 + }, + "end": { + "line": 292, + "column": 25 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 9742, + 9744 + ], + "loc": { + "start": { + "line": 292, + "column": 27 + }, + "end": { + "line": 292, + "column": 29 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 9729, + 9744 + ], + "loc": { + "start": { + "line": 292, + "column": 14 + }, + "end": { + "line": 292, + "column": 29 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 9760, + 9764 + ], + "loc": { + "start": { + "line": 293, + "column": 14 + }, + "end": { + "line": 293, + "column": 18 + } + } + }, + "value": { + "type": "Identifier", + "name": "type", + "range": [ + 9766, + 9770 + ], + "loc": { + "start": { + "line": 293, + "column": 20 + }, + "end": { + "line": 293, + "column": 24 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 9760, + 9770 + ], + "loc": { + "start": { + "line": 293, + "column": 14 + }, + "end": { + "line": 293, + "column": 24 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 9786, + 9788 + ], + "loc": { + "start": { + "line": 294, + "column": 14 + }, + "end": { + "line": 294, + "column": 16 + } + } + }, + "value": { + "type": "Identifier", + "name": "id", + "range": [ + 9790, + 9792 + ], + "loc": { + "start": { + "line": 294, + "column": 18 + }, + "end": { + "line": 294, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 9786, + 9792 + ], + "loc": { + "start": { + "line": 294, + "column": 14 + }, + "end": { + "line": 294, + "column": 20 + } + } + } + ], + "range": [ + 9713, + 9806 + ], + "loc": { + "start": { + "line": 291, + "column": 35 + }, + "end": { + "line": 295, + "column": 13 + } + } + }, + "range": [ + 9690, + 9806 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 295, + "column": 13 + } + } + }, + "range": [ + 9690, + 9807 + ], + "loc": { + "start": { + "line": 291, + "column": 12 + }, + "end": { + "line": 295, + "column": 14 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 9820, + 9826 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 296, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 9827, + 9831 + ], + "loc": { + "start": { + "line": 296, + "column": 19 + }, + "end": { + "line": 296, + "column": 23 + } + } + }, + "range": [ + 9820, + 9831 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 296, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 9832, + 9842 + ], + "loc": { + "start": { + "line": 296, + "column": 24 + }, + "end": { + "line": 296, + "column": 34 + } + } + } + ], + "range": [ + 9820, + 9843 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 296, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 9844, + 9851 + ], + "loc": { + "start": { + "line": 296, + "column": 36 + }, + "end": { + "line": 296, + "column": 43 + } + } + }, + "range": [ + 9820, + 9851 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 296, + "column": 43 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "key", + "range": [ + 9852, + 9855 + ], + "loc": { + "start": { + "line": 296, + "column": 44 + }, + "end": { + "line": 296, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "key", + "range": [ + 9879, + 9882 + ], + "loc": { + "start": { + "line": 297, + "column": 18 + }, + "end": { + "line": 297, + "column": 21 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 9883, + 9884 + ], + "loc": { + "start": { + "line": 297, + "column": 22 + }, + "end": { + "line": 297, + "column": 23 + } + } + }, + "range": [ + 9879, + 9885 + ], + "loc": { + "start": { + "line": 297, + "column": 18 + }, + "end": { + "line": 297, + "column": 24 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 9890, + 9893 + ], + "loc": { + "start": { + "line": 297, + "column": 29 + }, + "end": { + "line": 297, + "column": 32 + } + } + }, + "range": [ + 9879, + 9893 + ], + "loc": { + "start": { + "line": 297, + "column": 18 + }, + "end": { + "line": 297, + "column": 32 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9913, + 9917 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 9918, + 9923 + ], + "loc": { + "start": { + "line": 298, + "column": 21 + }, + "end": { + "line": 298, + "column": 26 + } + } + }, + "range": [ + 9913, + 9923 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 9924, + 9928 + ], + "loc": { + "start": { + "line": 298, + "column": 27 + }, + "end": { + "line": 298, + "column": 31 + } + } + }, + "range": [ + 9913, + 9929 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 9930, + 9932 + ], + "loc": { + "start": { + "line": 298, + "column": 33 + }, + "end": { + "line": 298, + "column": 35 + } + } + }, + "range": [ + 9913, + 9933 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 9934, + 9937 + ], + "loc": { + "start": { + "line": 298, + "column": 37 + }, + "end": { + "line": 298, + "column": 40 + } + } + }, + "range": [ + 9913, + 9938 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 41 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 9941, + 9951 + ], + "loc": { + "start": { + "line": 298, + "column": 44 + }, + "end": { + "line": 298, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 9952, + 9955 + ], + "loc": { + "start": { + "line": 298, + "column": 55 + }, + "end": { + "line": 298, + "column": 58 + } + } + }, + "range": [ + 9941, + 9956 + ], + "loc": { + "start": { + "line": 298, + "column": 44 + }, + "end": { + "line": 298, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "default", + "range": [ + 9957, + 9964 + ], + "loc": { + "start": { + "line": 298, + "column": 60 + }, + "end": { + "line": 298, + "column": 67 + } + } + }, + "range": [ + 9941, + 9964 + ], + "loc": { + "start": { + "line": 298, + "column": 44 + }, + "end": { + "line": 298, + "column": 67 + } + } + }, + "range": [ + 9913, + 9964 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 67 + } + } + }, + "range": [ + 9913, + 9965 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 68 + } + } + } + ], + "range": [ + 9895, + 9981 + ], + "loc": { + "start": { + "line": 297, + "column": 34 + }, + "end": { + "line": 299, + "column": 15 + } + } + }, + "alternate": null, + "range": [ + 9875, + 9981 + ], + "loc": { + "start": { + "line": 297, + "column": 14 + }, + "end": { + "line": 299, + "column": 15 + } + } + } + ], + "range": [ + 9859, + 9995 + ], + "loc": { + "start": { + "line": 296, + "column": 51 + }, + "end": { + "line": 300, + "column": 13 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 9852, + 9995 + ], + "loc": { + "start": { + "line": 296, + "column": 44 + }, + "end": { + "line": 300, + "column": 13 + } + } + } + ], + "range": [ + 9820, + 9996 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 300, + "column": 14 + } + } + }, + "range": [ + 9820, + 9997 + ], + "loc": { + "start": { + "line": 296, + "column": 12 + }, + "end": { + "line": 300, + "column": 15 + } + } + } + ], + "range": [ + 9676, + 10009 + ], + "loc": { + "start": { + "line": 290, + "column": 37 + }, + "end": { + "line": 301, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 9649, + 10009 + ], + "loc": { + "start": { + "line": 290, + "column": 10 + }, + "end": { + "line": 301, + "column": 11 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10027, + 10031 + ], + "loc": { + "start": { + "line": 302, + "column": 17 + }, + "end": { + "line": 302, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10032, + 10037 + ], + "loc": { + "start": { + "line": 302, + "column": 22 + }, + "end": { + "line": 302, + "column": 27 + } + } + }, + "range": [ + 10027, + 10037 + ], + "loc": { + "start": { + "line": 302, + "column": 17 + }, + "end": { + "line": 302, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10038, + 10042 + ], + "loc": { + "start": { + "line": 302, + "column": 28 + }, + "end": { + "line": 302, + "column": 32 + } + } + }, + "range": [ + 10027, + 10043 + ], + "loc": { + "start": { + "line": 302, + "column": 17 + }, + "end": { + "line": 302, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 10044, + 10046 + ], + "loc": { + "start": { + "line": 302, + "column": 34 + }, + "end": { + "line": 302, + "column": 36 + } + } + }, + "range": [ + 10027, + 10047 + ], + "loc": { + "start": { + "line": 302, + "column": 17 + }, + "end": { + "line": 302, + "column": 37 + } + } + }, + "range": [ + 10020, + 10048 + ], + "loc": { + "start": { + "line": 302, + "column": 10 + }, + "end": { + "line": 302, + "column": 38 + } + } + } + ], + "range": [ + 9637, + 10058 + ], + "loc": { + "start": { + "line": 289, + "column": 16 + }, + "end": { + "line": 303, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 10083, + 10089 + ], + "loc": { + "start": { + "line": 304, + "column": 17 + }, + "end": { + "line": 304, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 10090, + 10094 + ], + "loc": { + "start": { + "line": 304, + "column": 24 + }, + "end": { + "line": 304, + "column": 28 + } + } + }, + "range": [ + 10083, + 10094 + ], + "loc": { + "start": { + "line": 304, + "column": 17 + }, + "end": { + "line": 304, + "column": 28 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10095, + 10099 + ], + "loc": { + "start": { + "line": 304, + "column": 29 + }, + "end": { + "line": 304, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10100, + 10105 + ], + "loc": { + "start": { + "line": 304, + "column": 34 + }, + "end": { + "line": 304, + "column": 39 + } + } + }, + "range": [ + 10095, + 10105 + ], + "loc": { + "start": { + "line": 304, + "column": 29 + }, + "end": { + "line": 304, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10106, + 10110 + ], + "loc": { + "start": { + "line": 304, + "column": 40 + }, + "end": { + "line": 304, + "column": 44 + } + } + }, + "range": [ + 10095, + 10111 + ], + "loc": { + "start": { + "line": 304, + "column": 29 + }, + "end": { + "line": 304, + "column": 45 + } + } + } + ], + "range": [ + 10083, + 10112 + ], + "loc": { + "start": { + "line": 304, + "column": 17 + }, + "end": { + "line": 304, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 10113, + 10116 + ], + "loc": { + "start": { + "line": 304, + "column": 47 + }, + "end": { + "line": 304, + "column": 50 + } + } + }, + "range": [ + 10083, + 10116 + ], + "loc": { + "start": { + "line": 304, + "column": 17 + }, + "end": { + "line": 304, + "column": 50 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 10117, + 10118 + ], + "loc": { + "start": { + "line": 304, + "column": 51 + }, + "end": { + "line": 304, + "column": 52 + } + } + } + ], + "body": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10122, + 10126 + ], + "loc": { + "start": { + "line": 304, + "column": 56 + }, + "end": { + "line": 304, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10127, + 10132 + ], + "loc": { + "start": { + "line": 304, + "column": 61 + }, + "end": { + "line": 304, + "column": 66 + } + } + }, + "range": [ + 10122, + 10132 + ], + "loc": { + "start": { + "line": 304, + "column": 56 + }, + "end": { + "line": 304, + "column": 66 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10133, + 10137 + ], + "loc": { + "start": { + "line": 304, + "column": 67 + }, + "end": { + "line": 304, + "column": 71 + } + } + }, + "range": [ + 10122, + 10138 + ], + "loc": { + "start": { + "line": 304, + "column": 56 + }, + "end": { + "line": 304, + "column": 72 + } + } + }, + "property": { + "type": "Identifier", + "name": "x", + "range": [ + 10139, + 10140 + ], + "loc": { + "start": { + "line": 304, + "column": 73 + }, + "end": { + "line": 304, + "column": 74 + } + } + }, + "range": [ + 10122, + 10141 + ], + "loc": { + "start": { + "line": 304, + "column": 56 + }, + "end": { + "line": 304, + "column": 75 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 10117, + 10141 + ], + "loc": { + "start": { + "line": 304, + "column": 51 + }, + "end": { + "line": 304, + "column": 75 + } + } + } + ], + "range": [ + 10083, + 10142 + ], + "loc": { + "start": { + "line": 304, + "column": 17 + }, + "end": { + "line": 304, + "column": 76 + } + } + }, + "range": [ + 10076, + 10143 + ], + "loc": { + "start": { + "line": 304, + "column": 10 + }, + "end": { + "line": 304, + "column": 77 + } + } + } + ], + "range": [ + 10064, + 10153 + ], + "loc": { + "start": { + "line": 303, + "column": 15 + }, + "end": { + "line": 305, + "column": 9 + } + } + }, + "range": [ + 9629, + 10153 + ], + "loc": { + "start": { + "line": 289, + "column": 8 + }, + "end": { + "line": 305, + "column": 9 + } + } + } + ], + "range": [ + 9475, + 10161 + ], + "loc": { + "start": { + "line": 284, + "column": 22 + }, + "end": { + "line": 306, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 10187, + 10196 + ], + "loc": { + "start": { + "line": 307, + "column": 18 + }, + "end": { + "line": 307, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 10197, + 10214 + ], + "loc": { + "start": { + "line": 307, + "column": 28 + }, + "end": { + "line": 307, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 10218, + 10221 + ], + "loc": { + "start": { + "line": 307, + "column": 49 + }, + "end": { + "line": 307, + "column": 52 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 10214, + 10218 + ], + "loc": { + "start": { + "line": 307, + "column": 45 + }, + "end": { + "line": 307, + "column": 49 + } + } + } + ], + "range": [ + 10197, + 10221 + ], + "loc": { + "start": { + "line": 307, + "column": 28 + }, + "end": { + "line": 307, + "column": 52 + } + } + } + ], + "range": [ + 10183, + 10222 + ], + "loc": { + "start": { + "line": 307, + "column": 14 + }, + "end": { + "line": 307, + "column": 53 + } + } + }, + "range": [ + 10177, + 10223 + ], + "loc": { + "start": { + "line": 307, + "column": 8 + }, + "end": { + "line": 307, + "column": 54 + } + } + } + ], + "range": [ + 10167, + 10231 + ], + "loc": { + "start": { + "line": 306, + "column": 13 + }, + "end": { + "line": 308, + "column": 7 + } + } + }, + "range": [ + 9459, + 10231 + ], + "loc": { + "start": { + "line": 284, + "column": 6 + }, + "end": { + "line": 308, + "column": 7 + } + } + } + ], + "range": [ + 9409, + 10237 + ], + "loc": { + "start": { + "line": 282, + "column": 14 + }, + "end": { + "line": 309, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 10261, + 10270 + ], + "loc": { + "start": { + "line": 310, + "column": 16 + }, + "end": { + "line": 310, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a type", + "cooked": "You must provide a type" + }, + "tail": true, + "range": [ + 10271, + 10296 + ], + "loc": { + "start": { + "line": 310, + "column": 26 + }, + "end": { + "line": 310, + "column": 51 + } + } + } + ], + "expressions": [], + "range": [ + 10271, + 10296 + ], + "loc": { + "start": { + "line": 310, + "column": 26 + }, + "end": { + "line": 310, + "column": 51 + } + } + } + ], + "range": [ + 10257, + 10297 + ], + "loc": { + "start": { + "line": 310, + "column": 12 + }, + "end": { + "line": 310, + "column": 52 + } + } + }, + "range": [ + 10251, + 10298 + ], + "loc": { + "start": { + "line": 310, + "column": 6 + }, + "end": { + "line": 310, + "column": 53 + } + } + } + ], + "range": [ + 10243, + 10304 + ], + "loc": { + "start": { + "line": 309, + "column": 11 + }, + "end": { + "line": 311, + "column": 5 + } + } + }, + "range": [ + 9399, + 10304 + ], + "loc": { + "start": { + "line": 282, + "column": 4 + }, + "end": { + "line": 311, + "column": 5 + } + } + } + ], + "range": [ + 9393, + 10308 + ], + "loc": { + "start": { + "line": 281, + "column": 17 + }, + "end": { + "line": 312, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 9382, + 10308 + ], + "loc": { + "start": { + "line": 281, + "column": 6 + }, + "end": { + "line": 312, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 9378, + 10308 + ], + "loc": { + "start": { + "line": 281, + "column": 2 + }, + "end": { + "line": 312, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Find a resource or entire collection of resources.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to find.\n * @param {string} [id] - The id of the resource to find. If omitted all\n * resources of the type will be returned.\n * @return {Object|Object[]} - Either the resource or an array of resources.\n ", + "range": [ + 8865, + 9375 + ], + "loc": { + "start": { + "line": 269, + "column": 2 + }, + "end": { + "line": 280, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load the resource(s) through the adapter and adds it/them to\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} [id] - ID of resource.\n * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options)\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"product\", \"1\", (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 10312, + 11058 + ], + "loc": { + "start": { + "line": 314, + "column": 2 + }, + "end": { + "line": 333, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "load", + "range": [ + 11061, + 11065 + ], + "loc": { + "start": { + "line": 334, + "column": 2 + }, + "end": { + "line": 334, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 11066, + 11070 + ], + "loc": { + "start": { + "line": 334, + "column": 7 + }, + "end": { + "line": 334, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 11072, + 11074 + ], + "loc": { + "start": { + "line": 334, + "column": 13 + }, + "end": { + "line": 334, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 11076, + 11083 + ], + "loc": { + "start": { + "line": 334, + "column": 17 + }, + "end": { + "line": 334, + "column": 24 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 11085, + 11092 + ], + "loc": { + "start": { + "line": 334, + "column": 26 + }, + "end": { + "line": 334, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 11094, + 11099 + ], + "loc": { + "start": { + "line": 334, + "column": 35 + }, + "end": { + "line": 334, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 11101, + 11108 + ], + "loc": { + "start": { + "line": 334, + "column": 42 + }, + "end": { + "line": 334, + "column": 49 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11120, + 11124 + ], + "loc": { + "start": { + "line": 335, + "column": 8 + }, + "end": { + "line": 335, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 11125, + 11133 + ], + "loc": { + "start": { + "line": 335, + "column": 13 + }, + "end": { + "line": 335, + "column": 21 + } + } + }, + "range": [ + 11120, + 11133 + ], + "loc": { + "start": { + "line": 335, + "column": 8 + }, + "end": { + "line": 335, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11143, + 11147 + ], + "loc": { + "start": { + "line": 336, + "column": 6 + }, + "end": { + "line": 336, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 11148, + 11156 + ], + "loc": { + "start": { + "line": 336, + "column": 11 + }, + "end": { + "line": 336, + "column": 19 + } + } + }, + "range": [ + 11143, + 11156 + ], + "loc": { + "start": { + "line": 336, + "column": 6 + }, + "end": { + "line": 336, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 11157, + 11161 + ], + "loc": { + "start": { + "line": 336, + "column": 20 + }, + "end": { + "line": 336, + "column": 24 + } + } + }, + "range": [ + 11143, + 11161 + ], + "loc": { + "start": { + "line": 336, + "column": 6 + }, + "end": { + "line": 336, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 11162, + 11166 + ], + "loc": { + "start": { + "line": 336, + "column": 25 + }, + "end": { + "line": 336, + "column": 29 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 11168, + 11172 + ], + "loc": { + "start": { + "line": 336, + "column": 31 + }, + "end": { + "line": 336, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 11174, + 11176 + ], + "loc": { + "start": { + "line": 336, + "column": 37 + }, + "end": { + "line": 336, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 11178, + 11185 + ], + "loc": { + "start": { + "line": 336, + "column": 41 + }, + "end": { + "line": 336, + "column": 48 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 11187, + 11194 + ], + "loc": { + "start": { + "line": 336, + "column": 50 + }, + "end": { + "line": 336, + "column": 57 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 11196, + 11201 + ], + "loc": { + "start": { + "line": 336, + "column": 59 + }, + "end": { + "line": 336, + "column": 64 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 11203, + 11210 + ], + "loc": { + "start": { + "line": 336, + "column": 66 + }, + "end": { + "line": 336, + "column": 73 + } + } + } + ], + "range": [ + 11143, + 11211 + ], + "loc": { + "start": { + "line": 336, + "column": 6 + }, + "end": { + "line": 336, + "column": 74 + } + } + }, + "range": [ + 11143, + 11212 + ], + "loc": { + "start": { + "line": 336, + "column": 6 + }, + "end": { + "line": 336, + "column": 75 + } + } + } + ], + "range": [ + 11135, + 11218 + ], + "loc": { + "start": { + "line": 335, + "column": 23 + }, + "end": { + "line": 337, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 11242, + 11247 + ], + "loc": { + "start": { + "line": 338, + "column": 16 + }, + "end": { + "line": 338, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 11248, + 11344 + ], + "loc": { + "start": { + "line": 338, + "column": 22 + }, + "end": { + "line": 338, + "column": 118 + } + } + } + ], + "range": [ + 11238, + 11345 + ], + "loc": { + "start": { + "line": 338, + "column": 12 + }, + "end": { + "line": 338, + "column": 119 + } + } + }, + "range": [ + 11232, + 11346 + ], + "loc": { + "start": { + "line": 338, + "column": 6 + }, + "end": { + "line": 338, + "column": 120 + } + } + } + ], + "range": [ + 11224, + 11352 + ], + "loc": { + "start": { + "line": 337, + "column": 11 + }, + "end": { + "line": 339, + "column": 5 + } + } + }, + "range": [ + 11116, + 11352 + ], + "loc": { + "start": { + "line": 335, + "column": 4 + }, + "end": { + "line": 339, + "column": 5 + } + } + } + ], + "range": [ + 11110, + 11356 + ], + "loc": { + "start": { + "line": 334, + "column": 51 + }, + "end": { + "line": 340, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 11065, + 11356 + ], + "loc": { + "start": { + "line": 334, + "column": 6 + }, + "end": { + "line": 340, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 11061, + 11356 + ], + "loc": { + "start": { + "line": 334, + "column": 2 + }, + "end": { + "line": 340, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load the resource(s) through the adapter and adds it/them to\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} [id] - ID of resource.\n * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options)\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"product\", \"1\", (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 10312, + 11058 + ], + "loc": { + "start": { + "line": 314, + "column": 2 + }, + "end": { + "line": 333, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n * @return {undefined} - Nothing.\n ", + "range": [ + 11360, + 11763 + ], + "loc": { + "start": { + "line": 342, + "column": 2 + }, + "end": { + "line": 351, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "off", + "range": [ + 11766, + 11769 + ], + "loc": { + "start": { + "line": 352, + "column": 2 + }, + "end": { + "line": 352, + "column": 5 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 11770, + 11775 + ], + "loc": { + "start": { + "line": 352, + "column": 6 + }, + "end": { + "line": 352, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 11777, + 11781 + ], + "loc": { + "start": { + "line": 352, + "column": 13 + }, + "end": { + "line": 352, + "column": 17 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 11783, + 11785 + ], + "loc": { + "start": { + "line": 352, + "column": 19 + }, + "end": { + "line": 352, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 11787, + 11795 + ], + "loc": { + "start": { + "line": 352, + "column": 23 + }, + "end": { + "line": 352, + "column": 31 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11807, + 11811 + ], + "loc": { + "start": { + "line": 353, + "column": 8 + }, + "end": { + "line": 353, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 11812, + 11830 + ], + "loc": { + "start": { + "line": 353, + "column": 13 + }, + "end": { + "line": 353, + "column": 31 + } + } + }, + "range": [ + 11807, + 11830 + ], + "loc": { + "start": { + "line": 353, + "column": 8 + }, + "end": { + "line": 353, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 11831, + 11836 + ], + "loc": { + "start": { + "line": 353, + "column": 32 + }, + "end": { + "line": 353, + "column": 37 + } + } + }, + "range": [ + 11807, + 11837 + ], + "loc": { + "start": { + "line": 353, + "column": 8 + }, + "end": { + "line": 353, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11841, + 11845 + ], + "loc": { + "start": { + "line": 353, + "column": 42 + }, + "end": { + "line": 353, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 11846, + 11866 + ], + "loc": { + "start": { + "line": 353, + "column": 47 + }, + "end": { + "line": 353, + "column": 67 + } + } + }, + "range": [ + 11841, + 11866 + ], + "loc": { + "start": { + "line": 353, + "column": 42 + }, + "end": { + "line": 353, + "column": 67 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 11867, + 11872 + ], + "loc": { + "start": { + "line": 353, + "column": 68 + }, + "end": { + "line": 353, + "column": 73 + } + } + }, + "range": [ + 11841, + 11873 + ], + "loc": { + "start": { + "line": 353, + "column": 42 + }, + "end": { + "line": 353, + "column": 74 + } + } + }, + "range": [ + 11807, + 11873 + ], + "loc": { + "start": { + "line": 353, + "column": 8 + }, + "end": { + "line": 353, + "column": 74 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11887, + 11891 + ], + "loc": { + "start": { + "line": 354, + "column": 10 + }, + "end": { + "line": 354, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 11892, + 11898 + ], + "loc": { + "start": { + "line": 354, + "column": 15 + }, + "end": { + "line": 354, + "column": 21 + } + } + }, + "range": [ + 11887, + 11898 + ], + "loc": { + "start": { + "line": 354, + "column": 10 + }, + "end": { + "line": 354, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 11899, + 11903 + ], + "loc": { + "start": { + "line": 354, + "column": 22 + }, + "end": { + "line": 354, + "column": 26 + } + } + }, + "range": [ + 11887, + 11904 + ], + "loc": { + "start": { + "line": 354, + "column": 10 + }, + "end": { + "line": 354, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 11920, + 11922 + ], + "loc": { + "start": { + "line": 355, + "column": 12 + }, + "end": { + "line": 355, + "column": 14 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 11927, + 11929 + ], + "loc": { + "start": { + "line": 355, + "column": 19 + }, + "end": { + "line": 355, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 11931, + 11939 + ], + "loc": { + "start": { + "line": 355, + "column": 23 + }, + "end": { + "line": 355, + "column": 31 + } + } + }, + "range": [ + 11926, + 11939 + ], + "loc": { + "start": { + "line": 355, + "column": 18 + }, + "end": { + "line": 355, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 11940, + 11944 + ], + "loc": { + "start": { + "line": 355, + "column": 32 + }, + "end": { + "line": 355, + "column": 36 + } + } + }, + "range": [ + 11926, + 11944 + ], + "loc": { + "start": { + "line": 355, + "column": 18 + }, + "end": { + "line": 355, + "column": 36 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 11945, + 11947 + ], + "loc": { + "start": { + "line": 355, + "column": 37 + }, + "end": { + "line": 355, + "column": 39 + } + } + } + ], + "range": [ + 11926, + 11948 + ], + "loc": { + "start": { + "line": 355, + "column": 18 + }, + "end": { + "line": 355, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 11953, + 11972 + ], + "loc": { + "start": { + "line": 355, + "column": 45 + }, + "end": { + "line": 355, + "column": 64 + } + } + }, + "range": [ + 11926, + 11972 + ], + "loc": { + "start": { + "line": 355, + "column": 18 + }, + "end": { + "line": 355, + "column": 64 + } + } + }, + "range": [ + 11920, + 11972 + ], + "loc": { + "start": { + "line": 355, + "column": 12 + }, + "end": { + "line": 355, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11986, + 11990 + ], + "loc": { + "start": { + "line": 356, + "column": 10 + }, + "end": { + "line": 356, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "off", + "range": [ + 11991, + 11994 + ], + "loc": { + "start": { + "line": 356, + "column": 15 + }, + "end": { + "line": 356, + "column": 18 + } + } + }, + "range": [ + 11986, + 11994 + ], + "loc": { + "start": { + "line": 356, + "column": 10 + }, + "end": { + "line": 356, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 11995, + 11999 + ], + "loc": { + "start": { + "line": 356, + "column": 19 + }, + "end": { + "line": 356, + "column": 23 + } + } + }, + "range": [ + 11986, + 11999 + ], + "loc": { + "start": { + "line": 356, + "column": 10 + }, + "end": { + "line": 356, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 12000, + 12004 + ], + "loc": { + "start": { + "line": 356, + "column": 24 + }, + "end": { + "line": 356, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 12006, + 12011 + ], + "loc": { + "start": { + "line": 356, + "column": 30 + }, + "end": { + "line": 356, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 12013, + 12017 + ], + "loc": { + "start": { + "line": 356, + "column": 37 + }, + "end": { + "line": 356, + "column": 41 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 12019, + 12023 + ], + "loc": { + "start": { + "line": 356, + "column": 43 + }, + "end": { + "line": 356, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 12025, + 12027 + ], + "loc": { + "start": { + "line": 356, + "column": 49 + }, + "end": { + "line": 356, + "column": 51 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 12029, + 12037 + ], + "loc": { + "start": { + "line": 356, + "column": 53 + }, + "end": { + "line": 356, + "column": 61 + } + } + } + ], + "range": [ + 11986, + 12038 + ], + "loc": { + "start": { + "line": 356, + "column": 10 + }, + "end": { + "line": 356, + "column": 62 + } + } + }, + "range": [ + 11986, + 12039 + ], + "loc": { + "start": { + "line": 356, + "column": 10 + }, + "end": { + "line": 356, + "column": 63 + } + } + } + ], + "range": [ + 11974, + 12049 + ], + "loc": { + "start": { + "line": 355, + "column": 66 + }, + "end": { + "line": 357, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12187, + 12191 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 359, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 12192, + 12198 + ], + "loc": { + "start": { + "line": 359, + "column": 15 + }, + "end": { + "line": 359, + "column": 21 + } + } + }, + "range": [ + 12187, + 12198 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 359, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12199, + 12203 + ], + "loc": { + "start": { + "line": 359, + "column": 22 + }, + "end": { + "line": 359, + "column": 26 + } + } + }, + "range": [ + 12187, + 12204 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 359, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 12205, + 12211 + ], + "loc": { + "start": { + "line": 359, + "column": 28 + }, + "end": { + "line": 359, + "column": 34 + } + } + }, + "range": [ + 12187, + 12211 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 359, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 12212, + 12219 + ], + "loc": { + "start": { + "line": 359, + "column": 35 + }, + "end": { + "line": 359, + "column": 42 + } + } + }, + "range": [ + 12187, + 12219 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 359, + "column": 42 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 12220, + 12224 + ], + "loc": { + "start": { + "line": 359, + "column": 43 + }, + "end": { + "line": 359, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 12246, + 12248 + ], + "loc": { + "start": { + "line": 360, + "column": 16 + }, + "end": { + "line": 360, + "column": 18 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12270, + 12274 + ], + "loc": { + "start": { + "line": 361, + "column": 18 + }, + "end": { + "line": 361, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 12275, + 12293 + ], + "loc": { + "start": { + "line": 361, + "column": 23 + }, + "end": { + "line": 361, + "column": 41 + } + } + }, + "range": [ + 12270, + 12293 + ], + "loc": { + "start": { + "line": 361, + "column": 18 + }, + "end": { + "line": 361, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12294, + 12299 + ], + "loc": { + "start": { + "line": 361, + "column": 42 + }, + "end": { + "line": 361, + "column": 47 + } + } + }, + "range": [ + 12270, + 12300 + ], + "loc": { + "start": { + "line": 361, + "column": 18 + }, + "end": { + "line": 361, + "column": 48 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12301, + 12305 + ], + "loc": { + "start": { + "line": 361, + "column": 49 + }, + "end": { + "line": 361, + "column": 53 + } + } + }, + "range": [ + 12270, + 12306 + ], + "loc": { + "start": { + "line": 361, + "column": 18 + }, + "end": { + "line": 361, + "column": 54 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12310, + 12314 + ], + "loc": { + "start": { + "line": 361, + "column": 58 + }, + "end": { + "line": 361, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 12315, + 12333 + ], + "loc": { + "start": { + "line": 361, + "column": 63 + }, + "end": { + "line": 361, + "column": 81 + } + } + }, + "range": [ + 12310, + 12333 + ], + "loc": { + "start": { + "line": 361, + "column": 58 + }, + "end": { + "line": 361, + "column": 81 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12334, + 12339 + ], + "loc": { + "start": { + "line": 361, + "column": 82 + }, + "end": { + "line": 361, + "column": 87 + } + } + }, + "range": [ + 12310, + 12340 + ], + "loc": { + "start": { + "line": 361, + "column": 58 + }, + "end": { + "line": 361, + "column": 88 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12341, + 12345 + ], + "loc": { + "start": { + "line": 361, + "column": 89 + }, + "end": { + "line": 361, + "column": 93 + } + } + }, + "range": [ + 12310, + 12346 + ], + "loc": { + "start": { + "line": 361, + "column": 58 + }, + "end": { + "line": 361, + "column": 94 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 12347, + 12349 + ], + "loc": { + "start": { + "line": 361, + "column": 95 + }, + "end": { + "line": 361, + "column": 97 + } + } + }, + "range": [ + 12310, + 12350 + ], + "loc": { + "start": { + "line": 361, + "column": 58 + }, + "end": { + "line": 361, + "column": 98 + } + } + }, + "range": [ + 12270, + 12350 + ], + "loc": { + "start": { + "line": 361, + "column": 18 + }, + "end": { + "line": 361, + "column": 98 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12370, + 12374 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 362, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 12375, + 12393 + ], + "loc": { + "start": { + "line": 362, + "column": 21 + }, + "end": { + "line": 362, + "column": 39 + } + } + }, + "range": [ + 12370, + 12393 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 362, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12394, + 12399 + ], + "loc": { + "start": { + "line": 362, + "column": 40 + }, + "end": { + "line": 362, + "column": 45 + } + } + }, + "range": [ + 12370, + 12400 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 362, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12401, + 12405 + ], + "loc": { + "start": { + "line": 362, + "column": 47 + }, + "end": { + "line": 362, + "column": 51 + } + } + }, + "range": [ + 12370, + 12406 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 362, + "column": 52 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 12407, + 12409 + ], + "loc": { + "start": { + "line": 362, + "column": 53 + }, + "end": { + "line": 362, + "column": 55 + } + } + }, + "range": [ + 12370, + 12410 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 362, + "column": 56 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12413, + 12417 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 12418, + 12436 + ], + "loc": { + "start": { + "line": 362, + "column": 64 + }, + "end": { + "line": 362, + "column": 82 + } + } + }, + "range": [ + 12413, + 12436 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 82 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12437, + 12442 + ], + "loc": { + "start": { + "line": 362, + "column": 83 + }, + "end": { + "line": 362, + "column": 88 + } + } + }, + "range": [ + 12413, + 12443 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12444, + 12448 + ], + "loc": { + "start": { + "line": 362, + "column": 90 + }, + "end": { + "line": 362, + "column": 94 + } + } + }, + "range": [ + 12413, + 12449 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 95 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 12450, + 12452 + ], + "loc": { + "start": { + "line": 362, + "column": 96 + }, + "end": { + "line": 362, + "column": 98 + } + } + }, + "range": [ + 12413, + 12453 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 99 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 12454, + 12460 + ], + "loc": { + "start": { + "line": 362, + "column": 100 + }, + "end": { + "line": 362, + "column": 106 + } + } + }, + "range": [ + 12413, + 12460 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 362, + "column": 106 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 12461, + 12462 + ], + "loc": { + "start": { + "line": 362, + "column": 107 + }, + "end": { + "line": 362, + "column": 108 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 12493, + 12494 + ], + "loc": { + "start": { + "line": 363, + "column": 25 + }, + "end": { + "line": 363, + "column": 26 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 12495, + 12496 + ], + "loc": { + "start": { + "line": 363, + "column": 27 + }, + "end": { + "line": 363, + "column": 28 + } + } + }, + "range": [ + 12493, + 12497 + ], + "loc": { + "start": { + "line": 363, + "column": 25 + }, + "end": { + "line": 363, + "column": 29 + } + } + }, + "right": { + "type": "Identifier", + "name": "callback", + "range": [ + 12502, + 12510 + ], + "loc": { + "start": { + "line": 363, + "column": 34 + }, + "end": { + "line": 363, + "column": 42 + } + } + }, + "range": [ + 12493, + 12510 + ], + "loc": { + "start": { + "line": 363, + "column": 25 + }, + "end": { + "line": 363, + "column": 42 + } + } + }, + "range": [ + 12486, + 12511 + ], + "loc": { + "start": { + "line": 363, + "column": 18 + }, + "end": { + "line": 363, + "column": 43 + } + } + } + ], + "range": [ + 12466, + 12529 + ], + "loc": { + "start": { + "line": 362, + "column": 112 + }, + "end": { + "line": 364, + "column": 17 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 12461, + 12529 + ], + "loc": { + "start": { + "line": 362, + "column": 107 + }, + "end": { + "line": 364, + "column": 17 + } + } + } + ], + "range": [ + 12413, + 12530 + ], + "loc": { + "start": { + "line": 362, + "column": 59 + }, + "end": { + "line": 364, + "column": 18 + } + } + }, + "range": [ + 12370, + 12530 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 364, + "column": 18 + } + } + }, + "range": [ + 12370, + 12531 + ], + "loc": { + "start": { + "line": 362, + "column": 16 + }, + "end": { + "line": 364, + "column": 19 + } + } + } + ], + "range": [ + 12352, + 12547 + ], + "loc": { + "start": { + "line": 361, + "column": 100 + }, + "end": { + "line": 365, + "column": 15 + } + } + }, + "alternate": null, + "range": [ + 12266, + 12547 + ], + "loc": { + "start": { + "line": 361, + "column": 14 + }, + "end": { + "line": 365, + "column": 15 + } + } + } + ], + "range": [ + 12250, + 12561 + ], + "loc": { + "start": { + "line": 360, + "column": 20 + }, + "end": { + "line": 366, + "column": 13 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12571, + 12575 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 12576, + 12596 + ], + "loc": { + "start": { + "line": 366, + "column": 28 + }, + "end": { + "line": 366, + "column": 48 + } + } + }, + "range": [ + 12571, + 12596 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 48 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12597, + 12602 + ], + "loc": { + "start": { + "line": 366, + "column": 49 + }, + "end": { + "line": 366, + "column": 54 + } + } + }, + "range": [ + 12571, + 12603 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12604, + 12608 + ], + "loc": { + "start": { + "line": 366, + "column": 56 + }, + "end": { + "line": 366, + "column": 60 + } + } + }, + "range": [ + 12571, + 12609 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 61 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12627, + 12631 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 367, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 12632, + 12652 + ], + "loc": { + "start": { + "line": 367, + "column": 19 + }, + "end": { + "line": 367, + "column": 39 + } + } + }, + "range": [ + 12627, + 12652 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 367, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12653, + 12658 + ], + "loc": { + "start": { + "line": 367, + "column": 40 + }, + "end": { + "line": 367, + "column": 45 + } + } + }, + "range": [ + 12627, + 12659 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 367, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12660, + 12664 + ], + "loc": { + "start": { + "line": 367, + "column": 47 + }, + "end": { + "line": 367, + "column": 51 + } + } + }, + "range": [ + 12627, + 12665 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 367, + "column": 52 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12668, + 12672 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 367, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 12673, + 12693 + ], + "loc": { + "start": { + "line": 367, + "column": 60 + }, + "end": { + "line": 367, + "column": 80 + } + } + }, + "range": [ + 12668, + 12693 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 367, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 12694, + 12699 + ], + "loc": { + "start": { + "line": 367, + "column": 81 + }, + "end": { + "line": 367, + "column": 86 + } + } + }, + "range": [ + 12668, + 12700 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 367, + "column": 87 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 12701, + 12705 + ], + "loc": { + "start": { + "line": 367, + "column": 88 + }, + "end": { + "line": 367, + "column": 92 + } + } + }, + "range": [ + 12668, + 12706 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 367, + "column": 93 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 12707, + 12713 + ], + "loc": { + "start": { + "line": 367, + "column": 94 + }, + "end": { + "line": 367, + "column": 100 + } + } + }, + "range": [ + 12668, + 12713 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 367, + "column": 100 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 12714, + 12715 + ], + "loc": { + "start": { + "line": 367, + "column": 101 + }, + "end": { + "line": 367, + "column": 102 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 12744, + 12745 + ], + "loc": { + "start": { + "line": 368, + "column": 23 + }, + "end": { + "line": 368, + "column": 24 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 12746, + 12747 + ], + "loc": { + "start": { + "line": 368, + "column": 25 + }, + "end": { + "line": 368, + "column": 26 + } + } + }, + "range": [ + 12744, + 12748 + ], + "loc": { + "start": { + "line": 368, + "column": 23 + }, + "end": { + "line": 368, + "column": 27 + } + } + }, + "right": { + "type": "Identifier", + "name": "callback", + "range": [ + 12753, + 12761 + ], + "loc": { + "start": { + "line": 368, + "column": 32 + }, + "end": { + "line": 368, + "column": 40 + } + } + }, + "range": [ + 12744, + 12761 + ], + "loc": { + "start": { + "line": 368, + "column": 23 + }, + "end": { + "line": 368, + "column": 40 + } + } + }, + "range": [ + 12737, + 12762 + ], + "loc": { + "start": { + "line": 368, + "column": 16 + }, + "end": { + "line": 368, + "column": 41 + } + } + } + ], + "range": [ + 12719, + 12778 + ], + "loc": { + "start": { + "line": 367, + "column": 106 + }, + "end": { + "line": 369, + "column": 15 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 12714, + 12778 + ], + "loc": { + "start": { + "line": 367, + "column": 101 + }, + "end": { + "line": 369, + "column": 15 + } + } + } + ], + "range": [ + 12668, + 12779 + ], + "loc": { + "start": { + "line": 367, + "column": 55 + }, + "end": { + "line": 369, + "column": 16 + } + } + }, + "range": [ + 12627, + 12779 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 369, + "column": 16 + } + } + }, + "range": [ + 12627, + 12780 + ], + "loc": { + "start": { + "line": 367, + "column": 14 + }, + "end": { + "line": 369, + "column": 17 + } + } + } + ], + "range": [ + 12611, + 12794 + ], + "loc": { + "start": { + "line": 366, + "column": 63 + }, + "end": { + "line": 370, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 12567, + 12794 + ], + "loc": { + "start": { + "line": 366, + "column": 19 + }, + "end": { + "line": 370, + "column": 13 + } + } + }, + "range": [ + 12242, + 12794 + ], + "loc": { + "start": { + "line": 360, + "column": 12 + }, + "end": { + "line": 370, + "column": 13 + } + } + } + ], + "range": [ + 12228, + 12806 + ], + "loc": { + "start": { + "line": 359, + "column": 51 + }, + "end": { + "line": 371, + "column": 11 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 12220, + 12806 + ], + "loc": { + "start": { + "line": 359, + "column": 43 + }, + "end": { + "line": 371, + "column": 11 + } + } + } + ], + "range": [ + 12187, + 12807 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 371, + "column": 12 + } + } + }, + "range": [ + 12187, + 12808 + ], + "loc": { + "start": { + "line": 359, + "column": 10 + }, + "end": { + "line": 371, + "column": 13 + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " TODO: Performance-wise, this can be made way better. There shouldn't be a need to maintain separate lists.", + "range": [ + 12067, + 12176 + ], + "loc": { + "start": { + "line": 358, + "column": 10 + }, + "end": { + "line": 358, + "column": 119 + } + } + } + ] + } + ], + "range": [ + 12055, + 12818 + ], + "loc": { + "start": { + "line": 357, + "column": 15 + }, + "end": { + "line": 372, + "column": 9 + } + } + }, + "range": [ + 11916, + 12818 + ], + "loc": { + "start": { + "line": 355, + "column": 8 + }, + "end": { + "line": 372, + "column": 9 + } + } + } + ], + "range": [ + 11906, + 12826 + ], + "loc": { + "start": { + "line": 354, + "column": 29 + }, + "end": { + "line": 373, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 12852, + 12857 + ], + "loc": { + "start": { + "line": 374, + "column": 18 + }, + "end": { + "line": 374, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 12858, + 12875 + ], + "loc": { + "start": { + "line": 374, + "column": 24 + }, + "end": { + "line": 374, + "column": 41 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 12879, + 12882 + ], + "loc": { + "start": { + "line": 374, + "column": 45 + }, + "end": { + "line": 374, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 12875, + 12879 + ], + "loc": { + "start": { + "line": 374, + "column": 41 + }, + "end": { + "line": 374, + "column": 45 + } + } + } + ], + "range": [ + 12858, + 12882 + ], + "loc": { + "start": { + "line": 374, + "column": 24 + }, + "end": { + "line": 374, + "column": 48 + } + } + } + ], + "range": [ + 12848, + 12883 + ], + "loc": { + "start": { + "line": 374, + "column": 14 + }, + "end": { + "line": 374, + "column": 49 + } + } + }, + "range": [ + 12842, + 12884 + ], + "loc": { + "start": { + "line": 374, + "column": 8 + }, + "end": { + "line": 374, + "column": 50 + } + } + } + ], + "range": [ + 12832, + 12892 + ], + "loc": { + "start": { + "line": 373, + "column": 13 + }, + "end": { + "line": 375, + "column": 7 + } + } + }, + "range": [ + 11883, + 12892 + ], + "loc": { + "start": { + "line": 354, + "column": 6 + }, + "end": { + "line": 375, + "column": 7 + } + } + } + ], + "range": [ + 11875, + 12898 + ], + "loc": { + "start": { + "line": 353, + "column": 76 + }, + "end": { + "line": 376, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 12922, + 12927 + ], + "loc": { + "start": { + "line": 377, + "column": 16 + }, + "end": { + "line": 377, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown event '", + "cooked": "Unknown event '" + }, + "tail": false, + "range": [ + 12928, + 12946 + ], + "loc": { + "start": { + "line": 377, + "column": 22 + }, + "end": { + "line": 377, + "column": 40 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 12951, + 12954 + ], + "loc": { + "start": { + "line": 377, + "column": 45 + }, + "end": { + "line": 377, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 12946, + 12951 + ], + "loc": { + "start": { + "line": 377, + "column": 40 + }, + "end": { + "line": 377, + "column": 45 + } + } + } + ], + "range": [ + 12928, + 12954 + ], + "loc": { + "start": { + "line": 377, + "column": 22 + }, + "end": { + "line": 377, + "column": 48 + } + } + } + ], + "range": [ + 12918, + 12955 + ], + "loc": { + "start": { + "line": 377, + "column": 12 + }, + "end": { + "line": 377, + "column": 49 + } + } + }, + "range": [ + 12912, + 12956 + ], + "loc": { + "start": { + "line": 377, + "column": 6 + }, + "end": { + "line": 377, + "column": 50 + } + } + } + ], + "range": [ + 12904, + 12962 + ], + "loc": { + "start": { + "line": 376, + "column": 11 + }, + "end": { + "line": 378, + "column": 5 + } + } + }, + "range": [ + 11803, + 12962 + ], + "loc": { + "start": { + "line": 353, + "column": 4 + }, + "end": { + "line": 378, + "column": 5 + } + } + } + ], + "range": [ + 11797, + 12966 + ], + "loc": { + "start": { + "line": 352, + "column": 33 + }, + "end": { + "line": 379, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 11769, + 12966 + ], + "loc": { + "start": { + "line": 352, + "column": 5 + }, + "end": { + "line": 379, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 11766, + 12966 + ], + "loc": { + "start": { + "line": 352, + "column": 2 + }, + "end": { + "line": 379, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n * @return {undefined} - Nothing.\n ", + "range": [ + 11360, + 11763 + ], + "loc": { + "start": { + "line": 342, + "column": 2 + }, + "end": { + "line": 351, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n * @return {undefined} - Nothing.\n ", + "range": [ + 12970, + 13410 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 391, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "on", + "range": [ + 13413, + 13415 + ], + "loc": { + "start": { + "line": 392, + "column": 2 + }, + "end": { + "line": 392, + "column": 4 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 13416, + 13421 + ], + "loc": { + "start": { + "line": 392, + "column": 5 + }, + "end": { + "line": 392, + "column": 10 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 13423, + 13427 + ], + "loc": { + "start": { + "line": 392, + "column": 12 + }, + "end": { + "line": 392, + "column": 16 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 13429, + 13431 + ], + "loc": { + "start": { + "line": 392, + "column": 18 + }, + "end": { + "line": 392, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 13433, + 13441 + ], + "loc": { + "start": { + "line": 392, + "column": 22 + }, + "end": { + "line": 392, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 13443, + 13450 + ], + "loc": { + "start": { + "line": 392, + "column": 32 + }, + "end": { + "line": 392, + "column": 39 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13462, + 13466 + ], + "loc": { + "start": { + "line": 393, + "column": 8 + }, + "end": { + "line": 393, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 13467, + 13485 + ], + "loc": { + "start": { + "line": 393, + "column": 13 + }, + "end": { + "line": 393, + "column": 31 + } + } + }, + "range": [ + 13462, + 13485 + ], + "loc": { + "start": { + "line": 393, + "column": 8 + }, + "end": { + "line": 393, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 13486, + 13491 + ], + "loc": { + "start": { + "line": 393, + "column": 32 + }, + "end": { + "line": 393, + "column": 37 + } + } + }, + "range": [ + 13462, + 13492 + ], + "loc": { + "start": { + "line": 393, + "column": 8 + }, + "end": { + "line": 393, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13496, + 13500 + ], + "loc": { + "start": { + "line": 393, + "column": 42 + }, + "end": { + "line": 393, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 13501, + 13521 + ], + "loc": { + "start": { + "line": 393, + "column": 47 + }, + "end": { + "line": 393, + "column": 67 + } + } + }, + "range": [ + 13496, + 13521 + ], + "loc": { + "start": { + "line": 393, + "column": 42 + }, + "end": { + "line": 393, + "column": 67 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 13522, + 13527 + ], + "loc": { + "start": { + "line": 393, + "column": 68 + }, + "end": { + "line": 393, + "column": 73 + } + } + }, + "range": [ + 13496, + 13528 + ], + "loc": { + "start": { + "line": 393, + "column": 42 + }, + "end": { + "line": 393, + "column": 74 + } + } + }, + "range": [ + 13462, + 13528 + ], + "loc": { + "start": { + "line": 393, + "column": 8 + }, + "end": { + "line": 393, + "column": 74 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13542, + 13546 + ], + "loc": { + "start": { + "line": 394, + "column": 10 + }, + "end": { + "line": 394, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 13547, + 13553 + ], + "loc": { + "start": { + "line": 394, + "column": 15 + }, + "end": { + "line": 394, + "column": 21 + } + } + }, + "range": [ + 13542, + 13553 + ], + "loc": { + "start": { + "line": 394, + "column": 10 + }, + "end": { + "line": 394, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 13554, + 13558 + ], + "loc": { + "start": { + "line": 394, + "column": 22 + }, + "end": { + "line": 394, + "column": 26 + } + } + }, + "range": [ + 13542, + 13559 + ], + "loc": { + "start": { + "line": 394, + "column": 10 + }, + "end": { + "line": 394, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 13575, + 13577 + ], + "loc": { + "start": { + "line": 395, + "column": 12 + }, + "end": { + "line": 395, + "column": 14 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 13582, + 13584 + ], + "loc": { + "start": { + "line": 395, + "column": 19 + }, + "end": { + "line": 395, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 13586, + 13594 + ], + "loc": { + "start": { + "line": 395, + "column": 23 + }, + "end": { + "line": 395, + "column": 31 + } + } + }, + "range": [ + 13581, + 13594 + ], + "loc": { + "start": { + "line": 395, + "column": 18 + }, + "end": { + "line": 395, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 13595, + 13599 + ], + "loc": { + "start": { + "line": 395, + "column": 32 + }, + "end": { + "line": 395, + "column": 36 + } + } + }, + "range": [ + 13581, + 13599 + ], + "loc": { + "start": { + "line": 395, + "column": 18 + }, + "end": { + "line": 395, + "column": 36 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 13600, + 13602 + ], + "loc": { + "start": { + "line": 395, + "column": 37 + }, + "end": { + "line": 395, + "column": 39 + } + } + } + ], + "range": [ + 13581, + 13603 + ], + "loc": { + "start": { + "line": 395, + "column": 18 + }, + "end": { + "line": 395, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 13608, + 13627 + ], + "loc": { + "start": { + "line": 395, + "column": 45 + }, + "end": { + "line": 395, + "column": 64 + } + } + }, + "range": [ + 13581, + 13627 + ], + "loc": { + "start": { + "line": 395, + "column": 18 + }, + "end": { + "line": 395, + "column": 64 + } + } + }, + "range": [ + 13575, + 13627 + ], + "loc": { + "start": { + "line": 395, + "column": 12 + }, + "end": { + "line": 395, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13641, + 13645 + ], + "loc": { + "start": { + "line": 396, + "column": 10 + }, + "end": { + "line": 396, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "on", + "range": [ + 13646, + 13648 + ], + "loc": { + "start": { + "line": 396, + "column": 15 + }, + "end": { + "line": 396, + "column": 17 + } + } + }, + "range": [ + 13641, + 13648 + ], + "loc": { + "start": { + "line": 396, + "column": 10 + }, + "end": { + "line": 396, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 13649, + 13653 + ], + "loc": { + "start": { + "line": 396, + "column": 18 + }, + "end": { + "line": 396, + "column": 22 + } + } + }, + "range": [ + 13641, + 13653 + ], + "loc": { + "start": { + "line": 396, + "column": 10 + }, + "end": { + "line": 396, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 13654, + 13658 + ], + "loc": { + "start": { + "line": 396, + "column": 23 + }, + "end": { + "line": 396, + "column": 27 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 13660, + 13665 + ], + "loc": { + "start": { + "line": 396, + "column": 29 + }, + "end": { + "line": 396, + "column": 34 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 13667, + 13671 + ], + "loc": { + "start": { + "line": 396, + "column": 36 + }, + "end": { + "line": 396, + "column": 40 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 13673, + 13677 + ], + "loc": { + "start": { + "line": 396, + "column": 42 + }, + "end": { + "line": 396, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 13679, + 13681 + ], + "loc": { + "start": { + "line": 396, + "column": 48 + }, + "end": { + "line": 396, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 13683, + 13691 + ], + "loc": { + "start": { + "line": 396, + "column": 52 + }, + "end": { + "line": 396, + "column": 60 + } + } + } + ], + "range": [ + 13641, + 13692 + ], + "loc": { + "start": { + "line": 396, + "column": 10 + }, + "end": { + "line": 396, + "column": 61 + } + } + }, + "range": [ + 13641, + 13693 + ], + "loc": { + "start": { + "line": 396, + "column": 10 + }, + "end": { + "line": 396, + "column": 62 + } + } + } + ], + "range": [ + 13629, + 13703 + ], + "loc": { + "start": { + "line": 395, + "column": 66 + }, + "end": { + "line": 397, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13841, + 13845 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 399, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 13846, + 13852 + ], + "loc": { + "start": { + "line": 399, + "column": 15 + }, + "end": { + "line": 399, + "column": 21 + } + } + }, + "range": [ + 13841, + 13852 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 399, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 13853, + 13857 + ], + "loc": { + "start": { + "line": 399, + "column": 22 + }, + "end": { + "line": 399, + "column": 26 + } + } + }, + "range": [ + 13841, + 13858 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 399, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 13859, + 13865 + ], + "loc": { + "start": { + "line": 399, + "column": 28 + }, + "end": { + "line": 399, + "column": 34 + } + } + }, + "range": [ + 13841, + 13865 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 399, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 13866, + 13873 + ], + "loc": { + "start": { + "line": 399, + "column": 35 + }, + "end": { + "line": 399, + "column": 42 + } + } + }, + "range": [ + 13841, + 13873 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 399, + "column": 42 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 13874, + 13878 + ], + "loc": { + "start": { + "line": 399, + "column": 43 + }, + "end": { + "line": 399, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 13900, + 13902 + ], + "loc": { + "start": { + "line": 400, + "column": 16 + }, + "end": { + "line": 400, + "column": 18 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13920, + 13924 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 13925, + 13943 + ], + "loc": { + "start": { + "line": 401, + "column": 19 + }, + "end": { + "line": 401, + "column": 37 + } + } + }, + "range": [ + 13920, + 13943 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 13944, + 13949 + ], + "loc": { + "start": { + "line": 401, + "column": 38 + }, + "end": { + "line": 401, + "column": 43 + } + } + }, + "range": [ + 13920, + 13950 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 13951, + 13955 + ], + "loc": { + "start": { + "line": 401, + "column": 45 + }, + "end": { + "line": 401, + "column": 49 + } + } + }, + "range": [ + 13920, + 13956 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 50 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13959, + 13963 + ], + "loc": { + "start": { + "line": 401, + "column": 53 + }, + "end": { + "line": 401, + "column": 57 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 13964, + 13982 + ], + "loc": { + "start": { + "line": 401, + "column": 58 + }, + "end": { + "line": 401, + "column": 76 + } + } + }, + "range": [ + 13959, + 13982 + ], + "loc": { + "start": { + "line": 401, + "column": 53 + }, + "end": { + "line": 401, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 13983, + 13988 + ], + "loc": { + "start": { + "line": 401, + "column": 77 + }, + "end": { + "line": 401, + "column": 82 + } + } + }, + "range": [ + 13959, + 13989 + ], + "loc": { + "start": { + "line": 401, + "column": 53 + }, + "end": { + "line": 401, + "column": 83 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 13990, + 13994 + ], + "loc": { + "start": { + "line": 401, + "column": 84 + }, + "end": { + "line": 401, + "column": 88 + } + } + }, + "range": [ + 13959, + 13995 + ], + "loc": { + "start": { + "line": 401, + "column": 53 + }, + "end": { + "line": 401, + "column": 89 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 13999, + 14001 + ], + "loc": { + "start": { + "line": 401, + "column": 93 + }, + "end": { + "line": 401, + "column": 95 + } + } + }, + "range": [ + 13959, + 14001 + ], + "loc": { + "start": { + "line": 401, + "column": 53 + }, + "end": { + "line": 401, + "column": 95 + } + } + }, + "range": [ + 13920, + 14001 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 95 + } + } + }, + "range": [ + 13920, + 14002 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 96 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14017, + 14021 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 14022, + 14040 + ], + "loc": { + "start": { + "line": 402, + "column": 19 + }, + "end": { + "line": 402, + "column": 37 + } + } + }, + "range": [ + 14017, + 14040 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14041, + 14046 + ], + "loc": { + "start": { + "line": 402, + "column": 38 + }, + "end": { + "line": 402, + "column": 43 + } + } + }, + "range": [ + 14017, + 14047 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14048, + 14052 + ], + "loc": { + "start": { + "line": 402, + "column": 45 + }, + "end": { + "line": 402, + "column": 49 + } + } + }, + "range": [ + 14017, + 14053 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 14054, + 14056 + ], + "loc": { + "start": { + "line": 402, + "column": 51 + }, + "end": { + "line": 402, + "column": 53 + } + } + }, + "range": [ + 14017, + 14057 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 54 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14060, + 14064 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 61 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 14065, + 14083 + ], + "loc": { + "start": { + "line": 402, + "column": 62 + }, + "end": { + "line": 402, + "column": 80 + } + } + }, + "range": [ + 14060, + 14083 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14084, + 14089 + ], + "loc": { + "start": { + "line": 402, + "column": 81 + }, + "end": { + "line": 402, + "column": 86 + } + } + }, + "range": [ + 14060, + 14090 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 87 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14091, + 14095 + ], + "loc": { + "start": { + "line": 402, + "column": 88 + }, + "end": { + "line": 402, + "column": 92 + } + } + }, + "range": [ + 14060, + 14096 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 93 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 14097, + 14099 + ], + "loc": { + "start": { + "line": 402, + "column": 94 + }, + "end": { + "line": 402, + "column": 96 + } + } + }, + "range": [ + 14060, + 14100 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 97 + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 14104, + 14106 + ], + "loc": { + "start": { + "line": 402, + "column": 101 + }, + "end": { + "line": 402, + "column": 103 + } + } + }, + "range": [ + 14060, + 14106 + ], + "loc": { + "start": { + "line": 402, + "column": 57 + }, + "end": { + "line": 402, + "column": 103 + } + } + }, + "range": [ + 14017, + 14106 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 103 + } + } + }, + "range": [ + 14017, + 14107 + ], + "loc": { + "start": { + "line": 402, + "column": 14 + }, + "end": { + "line": 402, + "column": 104 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14127, + 14131 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 14132, + 14150 + ], + "loc": { + "start": { + "line": 403, + "column": 24 + }, + "end": { + "line": 403, + "column": 42 + } + } + }, + "range": [ + 14127, + 14150 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14151, + 14156 + ], + "loc": { + "start": { + "line": 403, + "column": 43 + }, + "end": { + "line": 403, + "column": 48 + } + } + }, + "range": [ + 14127, + 14157 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14158, + 14162 + ], + "loc": { + "start": { + "line": 403, + "column": 50 + }, + "end": { + "line": 403, + "column": 54 + } + } + }, + "range": [ + 14127, + 14163 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 14164, + 14166 + ], + "loc": { + "start": { + "line": 403, + "column": 56 + }, + "end": { + "line": 403, + "column": 58 + } + } + }, + "range": [ + 14127, + 14167 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 14168, + 14172 + ], + "loc": { + "start": { + "line": 403, + "column": 60 + }, + "end": { + "line": 403, + "column": 64 + } + } + }, + "range": [ + 14127, + 14172 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 64 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 14173, + 14174 + ], + "loc": { + "start": { + "line": 403, + "column": 65 + }, + "end": { + "line": 403, + "column": 66 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 14178, + 14179 + ], + "loc": { + "start": { + "line": 403, + "column": 70 + }, + "end": { + "line": 403, + "column": 71 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 14180, + 14181 + ], + "loc": { + "start": { + "line": 403, + "column": 72 + }, + "end": { + "line": 403, + "column": 73 + } + } + }, + "range": [ + 14178, + 14182 + ], + "loc": { + "start": { + "line": 403, + "column": 70 + }, + "end": { + "line": 403, + "column": 74 + } + } + }, + "right": { + "type": "Identifier", + "name": "callback", + "range": [ + 14187, + 14195 + ], + "loc": { + "start": { + "line": 403, + "column": 79 + }, + "end": { + "line": 403, + "column": 87 + } + } + }, + "range": [ + 14178, + 14195 + ], + "loc": { + "start": { + "line": 403, + "column": 70 + }, + "end": { + "line": 403, + "column": 87 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 14173, + 14195 + ], + "loc": { + "start": { + "line": 403, + "column": 65 + }, + "end": { + "line": 403, + "column": 87 + } + } + } + ], + "range": [ + 14127, + 14196 + ], + "loc": { + "start": { + "line": 403, + "column": 19 + }, + "end": { + "line": 403, + "column": 88 + } + } + }, + "prefix": true, + "range": [ + 14126, + 14196 + ], + "loc": { + "start": { + "line": 403, + "column": 18 + }, + "end": { + "line": 403, + "column": 88 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14216, + 14220 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 14221, + 14239 + ], + "loc": { + "start": { + "line": 404, + "column": 21 + }, + "end": { + "line": 404, + "column": 39 + } + } + }, + "range": [ + 14216, + 14239 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14240, + 14245 + ], + "loc": { + "start": { + "line": 404, + "column": 40 + }, + "end": { + "line": 404, + "column": 45 + } + } + }, + "range": [ + 14216, + 14246 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14247, + 14251 + ], + "loc": { + "start": { + "line": 404, + "column": 47 + }, + "end": { + "line": 404, + "column": 51 + } + } + }, + "range": [ + 14216, + 14252 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 52 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 14253, + 14255 + ], + "loc": { + "start": { + "line": 404, + "column": 53 + }, + "end": { + "line": 404, + "column": 55 + } + } + }, + "range": [ + 14216, + 14256 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 14257, + 14261 + ], + "loc": { + "start": { + "line": 404, + "column": 57 + }, + "end": { + "line": 404, + "column": 61 + } + } + }, + "range": [ + 14216, + 14261 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 61 + } + } + }, + "arguments": [ + { + "type": "ArrayExpression", + "elements": [ + { + "type": "Identifier", + "name": "callback", + "range": [ + 14264, + 14272 + ], + "loc": { + "start": { + "line": 404, + "column": 64 + }, + "end": { + "line": 404, + "column": 72 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 14274, + 14281 + ], + "loc": { + "start": { + "line": 404, + "column": 74 + }, + "end": { + "line": 404, + "column": 81 + } + } + } + ], + "range": [ + 14262, + 14283 + ], + "loc": { + "start": { + "line": 404, + "column": 62 + }, + "end": { + "line": 404, + "column": 83 + } + } + } + ], + "range": [ + 14216, + 14284 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 84 + } + } + }, + "range": [ + 14216, + 14285 + ], + "loc": { + "start": { + "line": 404, + "column": 16 + }, + "end": { + "line": 404, + "column": 85 + } + } + } + ], + "range": [ + 14198, + 14301 + ], + "loc": { + "start": { + "line": 403, + "column": 90 + }, + "end": { + "line": 405, + "column": 15 + } + } + }, + "alternate": null, + "range": [ + 14122, + 14301 + ], + "loc": { + "start": { + "line": 403, + "column": 14 + }, + "end": { + "line": 405, + "column": 15 + } + } + } + ], + "range": [ + 13904, + 14315 + ], + "loc": { + "start": { + "line": 400, + "column": 20 + }, + "end": { + "line": 406, + "column": 13 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14337, + 14341 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 14342, + 14362 + ], + "loc": { + "start": { + "line": 407, + "column": 19 + }, + "end": { + "line": 407, + "column": 39 + } + } + }, + "range": [ + 14337, + 14362 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14363, + 14368 + ], + "loc": { + "start": { + "line": 407, + "column": 40 + }, + "end": { + "line": 407, + "column": 45 + } + } + }, + "range": [ + 14337, + 14369 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14370, + 14374 + ], + "loc": { + "start": { + "line": 407, + "column": 47 + }, + "end": { + "line": 407, + "column": 51 + } + } + }, + "range": [ + 14337, + 14375 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 52 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14378, + 14382 + ], + "loc": { + "start": { + "line": 407, + "column": 55 + }, + "end": { + "line": 407, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 14383, + 14403 + ], + "loc": { + "start": { + "line": 407, + "column": 60 + }, + "end": { + "line": 407, + "column": 80 + } + } + }, + "range": [ + 14378, + 14403 + ], + "loc": { + "start": { + "line": 407, + "column": 55 + }, + "end": { + "line": 407, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14404, + 14409 + ], + "loc": { + "start": { + "line": 407, + "column": 81 + }, + "end": { + "line": 407, + "column": 86 + } + } + }, + "range": [ + 14378, + 14410 + ], + "loc": { + "start": { + "line": 407, + "column": 55 + }, + "end": { + "line": 407, + "column": 87 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14411, + 14415 + ], + "loc": { + "start": { + "line": 407, + "column": 88 + }, + "end": { + "line": 407, + "column": 92 + } + } + }, + "range": [ + 14378, + 14416 + ], + "loc": { + "start": { + "line": 407, + "column": 55 + }, + "end": { + "line": 407, + "column": 93 + } + } + }, + "right": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 14420, + 14422 + ], + "loc": { + "start": { + "line": 407, + "column": 97 + }, + "end": { + "line": 407, + "column": 99 + } + } + }, + "range": [ + 14378, + 14422 + ], + "loc": { + "start": { + "line": 407, + "column": 55 + }, + "end": { + "line": 407, + "column": 99 + } + } + }, + "range": [ + 14337, + 14422 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 99 + } + } + }, + "range": [ + 14337, + 14423 + ], + "loc": { + "start": { + "line": 407, + "column": 14 + }, + "end": { + "line": 407, + "column": 100 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14443, + 14447 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 14448, + 14468 + ], + "loc": { + "start": { + "line": 408, + "column": 24 + }, + "end": { + "line": 408, + "column": 44 + } + } + }, + "range": [ + 14443, + 14468 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14469, + 14474 + ], + "loc": { + "start": { + "line": 408, + "column": 45 + }, + "end": { + "line": 408, + "column": 50 + } + } + }, + "range": [ + 14443, + 14475 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14476, + 14480 + ], + "loc": { + "start": { + "line": 408, + "column": 52 + }, + "end": { + "line": 408, + "column": 56 + } + } + }, + "range": [ + 14443, + 14481 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 57 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 14482, + 14486 + ], + "loc": { + "start": { + "line": 408, + "column": 58 + }, + "end": { + "line": 408, + "column": 62 + } + } + }, + "range": [ + 14443, + 14486 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 62 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 14487, + 14488 + ], + "loc": { + "start": { + "line": 408, + "column": 63 + }, + "end": { + "line": 408, + "column": 64 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 14492, + 14493 + ], + "loc": { + "start": { + "line": 408, + "column": 68 + }, + "end": { + "line": 408, + "column": 69 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 14494, + 14495 + ], + "loc": { + "start": { + "line": 408, + "column": 70 + }, + "end": { + "line": 408, + "column": 71 + } + } + }, + "range": [ + 14492, + 14496 + ], + "loc": { + "start": { + "line": 408, + "column": 68 + }, + "end": { + "line": 408, + "column": 72 + } + } + }, + "right": { + "type": "Identifier", + "name": "callback", + "range": [ + 14501, + 14509 + ], + "loc": { + "start": { + "line": 408, + "column": 77 + }, + "end": { + "line": 408, + "column": 85 + } + } + }, + "range": [ + 14492, + 14509 + ], + "loc": { + "start": { + "line": 408, + "column": 68 + }, + "end": { + "line": 408, + "column": 85 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 14487, + 14509 + ], + "loc": { + "start": { + "line": 408, + "column": 63 + }, + "end": { + "line": 408, + "column": 85 + } + } + } + ], + "range": [ + 14443, + 14510 + ], + "loc": { + "start": { + "line": 408, + "column": 19 + }, + "end": { + "line": 408, + "column": 86 + } + } + }, + "prefix": true, + "range": [ + 14442, + 14510 + ], + "loc": { + "start": { + "line": 408, + "column": 18 + }, + "end": { + "line": 408, + "column": 86 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14530, + 14534 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 14535, + 14555 + ], + "loc": { + "start": { + "line": 409, + "column": 21 + }, + "end": { + "line": 409, + "column": 41 + } + } + }, + "range": [ + 14530, + 14555 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14556, + 14561 + ], + "loc": { + "start": { + "line": 409, + "column": 42 + }, + "end": { + "line": 409, + "column": 47 + } + } + }, + "range": [ + 14530, + 14562 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 48 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14563, + 14567 + ], + "loc": { + "start": { + "line": 409, + "column": 49 + }, + "end": { + "line": 409, + "column": 53 + } + } + }, + "range": [ + 14530, + 14568 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 14569, + 14573 + ], + "loc": { + "start": { + "line": 409, + "column": 55 + }, + "end": { + "line": 409, + "column": 59 + } + } + }, + "range": [ + 14530, + 14573 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 59 + } + } + }, + "arguments": [ + { + "type": "ArrayExpression", + "elements": [ + { + "type": "Identifier", + "name": "callback", + "range": [ + 14576, + 14584 + ], + "loc": { + "start": { + "line": 409, + "column": 62 + }, + "end": { + "line": 409, + "column": 70 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 14586, + 14593 + ], + "loc": { + "start": { + "line": 409, + "column": 72 + }, + "end": { + "line": 409, + "column": 79 + } + } + } + ], + "range": [ + 14574, + 14595 + ], + "loc": { + "start": { + "line": 409, + "column": 60 + }, + "end": { + "line": 409, + "column": 81 + } + } + } + ], + "range": [ + 14530, + 14596 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 82 + } + } + }, + "range": [ + 14530, + 14597 + ], + "loc": { + "start": { + "line": 409, + "column": 16 + }, + "end": { + "line": 409, + "column": 83 + } + } + } + ], + "range": [ + 14512, + 14613 + ], + "loc": { + "start": { + "line": 408, + "column": 88 + }, + "end": { + "line": 410, + "column": 15 + } + } + }, + "alternate": null, + "range": [ + 14438, + 14613 + ], + "loc": { + "start": { + "line": 408, + "column": 14 + }, + "end": { + "line": 410, + "column": 15 + } + } + } + ], + "range": [ + 14321, + 14627 + ], + "loc": { + "start": { + "line": 406, + "column": 19 + }, + "end": { + "line": 411, + "column": 13 + } + } + }, + "range": [ + 13896, + 14627 + ], + "loc": { + "start": { + "line": 400, + "column": 12 + }, + "end": { + "line": 411, + "column": 13 + } + } + } + ], + "range": [ + 13882, + 14639 + ], + "loc": { + "start": { + "line": 399, + "column": 51 + }, + "end": { + "line": 412, + "column": 11 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 13874, + 14639 + ], + "loc": { + "start": { + "line": 399, + "column": 43 + }, + "end": { + "line": 412, + "column": 11 + } + } + } + ], + "range": [ + 13841, + 14640 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 412, + "column": 12 + } + } + }, + "range": [ + 13841, + 14641 + ], + "loc": { + "start": { + "line": 399, + "column": 10 + }, + "end": { + "line": 412, + "column": 13 + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " TODO: Performance-wise, this can be made way better. There shouldn't be a need to maintain separate lists.", + "range": [ + 13721, + 13830 + ], + "loc": { + "start": { + "line": 398, + "column": 10 + }, + "end": { + "line": 398, + "column": 119 + } + } + } + ] + } + ], + "range": [ + 13709, + 14651 + ], + "loc": { + "start": { + "line": 397, + "column": 15 + }, + "end": { + "line": 413, + "column": 9 + } + } + }, + "range": [ + 13571, + 14651 + ], + "loc": { + "start": { + "line": 395, + "column": 8 + }, + "end": { + "line": 413, + "column": 9 + } + } + } + ], + "range": [ + 13561, + 14659 + ], + "loc": { + "start": { + "line": 394, + "column": 29 + }, + "end": { + "line": 414, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 14685, + 14690 + ], + "loc": { + "start": { + "line": 415, + "column": 18 + }, + "end": { + "line": 415, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 14691, + 14708 + ], + "loc": { + "start": { + "line": 415, + "column": 24 + }, + "end": { + "line": 415, + "column": 41 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 14712, + 14715 + ], + "loc": { + "start": { + "line": 415, + "column": 45 + }, + "end": { + "line": 415, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 14708, + 14712 + ], + "loc": { + "start": { + "line": 415, + "column": 41 + }, + "end": { + "line": 415, + "column": 45 + } + } + } + ], + "range": [ + 14691, + 14715 + ], + "loc": { + "start": { + "line": 415, + "column": 24 + }, + "end": { + "line": 415, + "column": 48 + } + } + } + ], + "range": [ + 14681, + 14716 + ], + "loc": { + "start": { + "line": 415, + "column": 14 + }, + "end": { + "line": 415, + "column": 49 + } + } + }, + "range": [ + 14675, + 14717 + ], + "loc": { + "start": { + "line": 415, + "column": 8 + }, + "end": { + "line": 415, + "column": 50 + } + } + } + ], + "range": [ + 14665, + 14725 + ], + "loc": { + "start": { + "line": 414, + "column": 13 + }, + "end": { + "line": 416, + "column": 7 + } + } + }, + "range": [ + 13538, + 14725 + ], + "loc": { + "start": { + "line": 394, + "column": 6 + }, + "end": { + "line": 416, + "column": 7 + } + } + } + ], + "range": [ + 13530, + 14731 + ], + "loc": { + "start": { + "line": 393, + "column": 76 + }, + "end": { + "line": 417, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 14755, + 14760 + ], + "loc": { + "start": { + "line": 418, + "column": 16 + }, + "end": { + "line": 418, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown event '", + "cooked": "Unknown event '" + }, + "tail": false, + "range": [ + 14761, + 14779 + ], + "loc": { + "start": { + "line": 418, + "column": 22 + }, + "end": { + "line": 418, + "column": 40 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 14784, + 14787 + ], + "loc": { + "start": { + "line": 418, + "column": 45 + }, + "end": { + "line": 418, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 14779, + 14784 + ], + "loc": { + "start": { + "line": 418, + "column": 40 + }, + "end": { + "line": 418, + "column": 45 + } + } + } + ], + "range": [ + 14761, + 14787 + ], + "loc": { + "start": { + "line": 418, + "column": 22 + }, + "end": { + "line": 418, + "column": 48 + } + } + } + ], + "range": [ + 14751, + 14788 + ], + "loc": { + "start": { + "line": 418, + "column": 12 + }, + "end": { + "line": 418, + "column": 49 + } + } + }, + "range": [ + 14745, + 14789 + ], + "loc": { + "start": { + "line": 418, + "column": 6 + }, + "end": { + "line": 418, + "column": 50 + } + } + } + ], + "range": [ + 14737, + 14795 + ], + "loc": { + "start": { + "line": 417, + "column": 11 + }, + "end": { + "line": 419, + "column": 5 + } + } + }, + "range": [ + 13458, + 14795 + ], + "loc": { + "start": { + "line": 393, + "column": 4 + }, + "end": { + "line": 419, + "column": 5 + } + } + } + ], + "range": [ + 13452, + 14799 + ], + "loc": { + "start": { + "line": 392, + "column": 41 + }, + "end": { + "line": 420, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 13415, + 14799 + ], + "loc": { + "start": { + "line": 392, + "column": 4 + }, + "end": { + "line": 420, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 13413, + 14799 + ], + "loc": { + "start": { + "line": 392, + "column": 2 + }, + "end": { + "line": 420, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n * @return {undefined} - Nothing.\n ", + "range": [ + 12970, + 13410 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 391, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n * @return {undefined} - Nothing.\n ", + "range": [ + 14803, + 15137 + ], + "loc": { + "start": { + "line": 422, + "column": 2 + }, + "end": { + "line": 430, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "push", + "range": [ + 15140, + 15144 + ], + "loc": { + "start": { + "line": 431, + "column": 2 + }, + "end": { + "line": 431, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "root", + "range": [ + 15145, + 15149 + ], + "loc": { + "start": { + "line": 431, + "column": 7 + }, + "end": { + "line": 431, + "column": 11 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 15161, + 15165 + ], + "loc": { + "start": { + "line": 432, + "column": 8 + }, + "end": { + "line": 432, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 15166, + 15170 + ], + "loc": { + "start": { + "line": 432, + "column": 13 + }, + "end": { + "line": 432, + "column": 17 + } + } + }, + "range": [ + 15161, + 15170 + ], + "loc": { + "start": { + "line": 432, + "column": 8 + }, + "end": { + "line": 432, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "constructor", + "range": [ + 15171, + 15182 + ], + "loc": { + "start": { + "line": 432, + "column": 18 + }, + "end": { + "line": 432, + "column": 29 + } + } + }, + "range": [ + 15161, + 15182 + ], + "loc": { + "start": { + "line": 432, + "column": 8 + }, + "end": { + "line": 432, + "column": 29 + } + } + }, + "right": { + "type": "Identifier", + "name": "Array", + "range": [ + 15187, + 15192 + ], + "loc": { + "start": { + "line": 432, + "column": 34 + }, + "end": { + "line": 432, + "column": 39 + } + } + }, + "range": [ + 15161, + 15192 + ], + "loc": { + "start": { + "line": 432, + "column": 8 + }, + "end": { + "line": 432, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 15202, + 15206 + ], + "loc": { + "start": { + "line": 433, + "column": 6 + }, + "end": { + "line": 433, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 15207, + 15211 + ], + "loc": { + "start": { + "line": 433, + "column": 11 + }, + "end": { + "line": 433, + "column": 15 + } + } + }, + "range": [ + 15202, + 15211 + ], + "loc": { + "start": { + "line": 433, + "column": 6 + }, + "end": { + "line": 433, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 15212, + 15219 + ], + "loc": { + "start": { + "line": 433, + "column": 16 + }, + "end": { + "line": 433, + "column": 23 + } + } + }, + "range": [ + 15202, + 15219 + ], + "loc": { + "start": { + "line": 433, + "column": 6 + }, + "end": { + "line": 433, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 15220, + 15221 + ], + "loc": { + "start": { + "line": 433, + "column": 24 + }, + "end": { + "line": 433, + "column": 25 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15225, + 15229 + ], + "loc": { + "start": { + "line": 433, + "column": 29 + }, + "end": { + "line": 433, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 15230, + 15233 + ], + "loc": { + "start": { + "line": 433, + "column": 34 + }, + "end": { + "line": 433, + "column": 37 + } + } + }, + "range": [ + 15225, + 15233 + ], + "loc": { + "start": { + "line": 433, + "column": 29 + }, + "end": { + "line": 433, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 15234, + 15235 + ], + "loc": { + "start": { + "line": 433, + "column": 38 + }, + "end": { + "line": 433, + "column": 39 + } + } + } + ], + "range": [ + 15225, + 15236 + ], + "loc": { + "start": { + "line": 433, + "column": 29 + }, + "end": { + "line": 433, + "column": 40 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 15220, + 15236 + ], + "loc": { + "start": { + "line": 433, + "column": 24 + }, + "end": { + "line": 433, + "column": 40 + } + } + } + ], + "range": [ + 15202, + 15237 + ], + "loc": { + "start": { + "line": 433, + "column": 6 + }, + "end": { + "line": 433, + "column": 41 + } + } + }, + "range": [ + 15202, + 15238 + ], + "loc": { + "start": { + "line": 433, + "column": 6 + }, + "end": { + "line": 433, + "column": 42 + } + } + } + ], + "range": [ + 15194, + 15244 + ], + "loc": { + "start": { + "line": 432, + "column": 41 + }, + "end": { + "line": 434, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15258, + 15262 + ], + "loc": { + "start": { + "line": 435, + "column": 6 + }, + "end": { + "line": 435, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 15263, + 15266 + ], + "loc": { + "start": { + "line": 435, + "column": 11 + }, + "end": { + "line": 435, + "column": 14 + } + } + }, + "range": [ + 15258, + 15266 + ], + "loc": { + "start": { + "line": 435, + "column": 6 + }, + "end": { + "line": 435, + "column": 14 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 15267, + 15271 + ], + "loc": { + "start": { + "line": 435, + "column": 15 + }, + "end": { + "line": 435, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 15272, + 15276 + ], + "loc": { + "start": { + "line": 435, + "column": 20 + }, + "end": { + "line": 435, + "column": 24 + } + } + }, + "range": [ + 15267, + 15276 + ], + "loc": { + "start": { + "line": 435, + "column": 15 + }, + "end": { + "line": 435, + "column": 24 + } + } + } + ], + "range": [ + 15258, + 15277 + ], + "loc": { + "start": { + "line": 435, + "column": 6 + }, + "end": { + "line": 435, + "column": 25 + } + } + }, + "range": [ + 15258, + 15278 + ], + "loc": { + "start": { + "line": 435, + "column": 6 + }, + "end": { + "line": 435, + "column": 26 + } + } + } + ], + "range": [ + 15250, + 15284 + ], + "loc": { + "start": { + "line": 434, + "column": 11 + }, + "end": { + "line": 436, + "column": 5 + } + } + }, + "range": [ + 15157, + 15284 + ], + "loc": { + "start": { + "line": 432, + "column": 4 + }, + "end": { + "line": 436, + "column": 5 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 15293, + 15297 + ], + "loc": { + "start": { + "line": 437, + "column": 8 + }, + "end": { + "line": 437, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "included", + "range": [ + 15298, + 15306 + ], + "loc": { + "start": { + "line": 437, + "column": 13 + }, + "end": { + "line": 437, + "column": 21 + } + } + }, + "range": [ + 15293, + 15306 + ], + "loc": { + "start": { + "line": 437, + "column": 8 + }, + "end": { + "line": 437, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 15316, + 15320 + ], + "loc": { + "start": { + "line": 438, + "column": 6 + }, + "end": { + "line": 438, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "included", + "range": [ + 15321, + 15329 + ], + "loc": { + "start": { + "line": 438, + "column": 11 + }, + "end": { + "line": 438, + "column": 19 + } + } + }, + "range": [ + 15316, + 15329 + ], + "loc": { + "start": { + "line": 438, + "column": 6 + }, + "end": { + "line": 438, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 15330, + 15337 + ], + "loc": { + "start": { + "line": 438, + "column": 20 + }, + "end": { + "line": 438, + "column": 27 + } + } + }, + "range": [ + 15316, + 15337 + ], + "loc": { + "start": { + "line": 438, + "column": 6 + }, + "end": { + "line": 438, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 15338, + 15339 + ], + "loc": { + "start": { + "line": 438, + "column": 28 + }, + "end": { + "line": 438, + "column": 29 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15343, + 15347 + ], + "loc": { + "start": { + "line": 438, + "column": 33 + }, + "end": { + "line": 438, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 15348, + 15351 + ], + "loc": { + "start": { + "line": 438, + "column": 38 + }, + "end": { + "line": 438, + "column": 41 + } + } + }, + "range": [ + 15343, + 15351 + ], + "loc": { + "start": { + "line": 438, + "column": 33 + }, + "end": { + "line": 438, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 15352, + 15353 + ], + "loc": { + "start": { + "line": 438, + "column": 42 + }, + "end": { + "line": 438, + "column": 43 + } + } + } + ], + "range": [ + 15343, + 15354 + ], + "loc": { + "start": { + "line": 438, + "column": 33 + }, + "end": { + "line": 438, + "column": 44 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 15338, + 15354 + ], + "loc": { + "start": { + "line": 438, + "column": 28 + }, + "end": { + "line": 438, + "column": 44 + } + } + } + ], + "range": [ + 15316, + 15355 + ], + "loc": { + "start": { + "line": 438, + "column": 6 + }, + "end": { + "line": 438, + "column": 45 + } + } + }, + "range": [ + 15316, + 15356 + ], + "loc": { + "start": { + "line": 438, + "column": 6 + }, + "end": { + "line": 438, + "column": 46 + } + } + } + ], + "range": [ + 15308, + 15362 + ], + "loc": { + "start": { + "line": 437, + "column": 23 + }, + "end": { + "line": 439, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 15289, + 15362 + ], + "loc": { + "start": { + "line": 437, + "column": 4 + }, + "end": { + "line": 439, + "column": 5 + } + } + } + ], + "range": [ + 15151, + 15366 + ], + "loc": { + "start": { + "line": 431, + "column": 13 + }, + "end": { + "line": 440, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 15144, + 15366 + ], + "loc": { + "start": { + "line": 431, + "column": 6 + }, + "end": { + "line": 440, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 15140, + 15366 + ], + "loc": { + "start": { + "line": 431, + "column": 2 + }, + "end": { + "line": 440, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n * @return {undefined} - Nothing.\n ", + "range": [ + 14803, + 15137 + ], + "loc": { + "start": { + "line": 422, + "column": 2 + }, + "end": { + "line": 430, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n * @return {undefined} - Nothing.\n ", + "range": [ + 15370, + 15712 + ], + "loc": { + "start": { + "line": 442, + "column": 2 + }, + "end": { + "line": 450, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "remove", + "range": [ + 15715, + 15721 + ], + "loc": { + "start": { + "line": 451, + "column": 2 + }, + "end": { + "line": 451, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 15722, + 15726 + ], + "loc": { + "start": { + "line": 451, + "column": 9 + }, + "end": { + "line": 451, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 15728, + 15730 + ], + "loc": { + "start": { + "line": 451, + "column": 15 + }, + "end": { + "line": 451, + "column": 17 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "type", + "range": [ + 15742, + 15746 + ], + "loc": { + "start": { + "line": 452, + "column": 8 + }, + "end": { + "line": 452, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15760, + 15764 + ], + "loc": { + "start": { + "line": 453, + "column": 10 + }, + "end": { + "line": 453, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 15765, + 15771 + ], + "loc": { + "start": { + "line": 453, + "column": 15 + }, + "end": { + "line": 453, + "column": 21 + } + } + }, + "range": [ + 15760, + 15771 + ], + "loc": { + "start": { + "line": 453, + "column": 10 + }, + "end": { + "line": 453, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15772, + 15776 + ], + "loc": { + "start": { + "line": 453, + "column": 22 + }, + "end": { + "line": 453, + "column": 26 + } + } + }, + "range": [ + 15760, + 15777 + ], + "loc": { + "start": { + "line": 453, + "column": 10 + }, + "end": { + "line": 453, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 15793, + 15795 + ], + "loc": { + "start": { + "line": 454, + "column": 12 + }, + "end": { + "line": 454, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "resource", + "range": [ + 15813, + 15821 + ], + "loc": { + "start": { + "line": 455, + "column": 14 + }, + "end": { + "line": 455, + "column": 22 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15824, + 15828 + ], + "loc": { + "start": { + "line": 455, + "column": 25 + }, + "end": { + "line": 455, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 15829, + 15834 + ], + "loc": { + "start": { + "line": 455, + "column": 30 + }, + "end": { + "line": 455, + "column": 35 + } + } + }, + "range": [ + 15824, + 15834 + ], + "loc": { + "start": { + "line": 455, + "column": 25 + }, + "end": { + "line": 455, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15835, + 15839 + ], + "loc": { + "start": { + "line": 455, + "column": 36 + }, + "end": { + "line": 455, + "column": 40 + } + } + }, + "range": [ + 15824, + 15840 + ], + "loc": { + "start": { + "line": 455, + "column": 25 + }, + "end": { + "line": 455, + "column": 41 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15844, + 15848 + ], + "loc": { + "start": { + "line": 455, + "column": 45 + }, + "end": { + "line": 455, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 15849, + 15854 + ], + "loc": { + "start": { + "line": 455, + "column": 50 + }, + "end": { + "line": 455, + "column": 55 + } + } + }, + "range": [ + 15844, + 15854 + ], + "loc": { + "start": { + "line": 455, + "column": 45 + }, + "end": { + "line": 455, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15855, + 15859 + ], + "loc": { + "start": { + "line": 455, + "column": 56 + }, + "end": { + "line": 455, + "column": 60 + } + } + }, + "range": [ + 15844, + 15860 + ], + "loc": { + "start": { + "line": 455, + "column": 45 + }, + "end": { + "line": 455, + "column": 61 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 15861, + 15863 + ], + "loc": { + "start": { + "line": 455, + "column": 62 + }, + "end": { + "line": 455, + "column": 64 + } + } + }, + "range": [ + 15844, + 15864 + ], + "loc": { + "start": { + "line": 455, + "column": 45 + }, + "end": { + "line": 455, + "column": 65 + } + } + }, + "range": [ + 15824, + 15864 + ], + "loc": { + "start": { + "line": 455, + "column": 25 + }, + "end": { + "line": 455, + "column": 65 + } + } + }, + "range": [ + 15813, + 15864 + ], + "loc": { + "start": { + "line": 455, + "column": 14 + }, + "end": { + "line": 455, + "column": 65 + } + } + } + ], + "kind": "let", + "range": [ + 15809, + 15865 + ], + "loc": { + "start": { + "line": 455, + "column": 10 + }, + "end": { + "line": 455, + "column": 66 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "resource", + "range": [ + 15880, + 15888 + ], + "loc": { + "start": { + "line": 456, + "column": 14 + }, + "end": { + "line": 456, + "column": 22 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15904, + 15908 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_remove", + "range": [ + 15909, + 15916 + ], + "loc": { + "start": { + "line": 457, + "column": 17 + }, + "end": { + "line": 457, + "column": 24 + } + } + }, + "range": [ + 15904, + 15916 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 15917, + 15925 + ], + "loc": { + "start": { + "line": 457, + "column": 25 + }, + "end": { + "line": 457, + "column": 33 + } + } + } + ], + "range": [ + 15904, + 15926 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 34 + } + } + }, + "range": [ + 15904, + 15927 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 35 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15944, + 15948 + ], + "loc": { + "start": { + "line": 458, + "column": 16 + }, + "end": { + "line": 458, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 15949, + 15967 + ], + "loc": { + "start": { + "line": 458, + "column": 21 + }, + "end": { + "line": 458, + "column": 39 + } + } + }, + "range": [ + 15944, + 15967 + ], + "loc": { + "start": { + "line": 458, + "column": 16 + }, + "end": { + "line": 458, + "column": 39 + } + } + }, + "property": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 15968, + 15977 + ], + "loc": { + "start": { + "line": 458, + "column": 40 + }, + "end": { + "line": 458, + "column": 49 + } + } + }, + "range": [ + 15944, + 15978 + ], + "loc": { + "start": { + "line": 458, + "column": 16 + }, + "end": { + "line": 458, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15979, + 15983 + ], + "loc": { + "start": { + "line": 458, + "column": 51 + }, + "end": { + "line": 458, + "column": 55 + } + } + }, + "range": [ + 15944, + 15984 + ], + "loc": { + "start": { + "line": 458, + "column": 16 + }, + "end": { + "line": 458, + "column": 56 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15988, + 15992 + ], + "loc": { + "start": { + "line": 458, + "column": 60 + }, + "end": { + "line": 458, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 15993, + 16011 + ], + "loc": { + "start": { + "line": 458, + "column": 65 + }, + "end": { + "line": 458, + "column": 83 + } + } + }, + "range": [ + 15988, + 16011 + ], + "loc": { + "start": { + "line": 458, + "column": 60 + }, + "end": { + "line": 458, + "column": 83 + } + } + }, + "property": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 16012, + 16021 + ], + "loc": { + "start": { + "line": 458, + "column": 84 + }, + "end": { + "line": 458, + "column": 93 + } + } + }, + "range": [ + 15988, + 16022 + ], + "loc": { + "start": { + "line": 458, + "column": 60 + }, + "end": { + "line": 458, + "column": 94 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16023, + 16027 + ], + "loc": { + "start": { + "line": 458, + "column": 95 + }, + "end": { + "line": 458, + "column": 99 + } + } + }, + "range": [ + 15988, + 16028 + ], + "loc": { + "start": { + "line": 458, + "column": 60 + }, + "end": { + "line": 458, + "column": 100 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 16029, + 16031 + ], + "loc": { + "start": { + "line": 458, + "column": 101 + }, + "end": { + "line": 458, + "column": 103 + } + } + }, + "range": [ + 15988, + 16032 + ], + "loc": { + "start": { + "line": 458, + "column": 60 + }, + "end": { + "line": 458, + "column": 104 + } + } + }, + "range": [ + 15944, + 16032 + ], + "loc": { + "start": { + "line": 458, + "column": 16 + }, + "end": { + "line": 458, + "column": 104 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16051, + 16055 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "_resourceListeners", + "range": [ + 16056, + 16074 + ], + "loc": { + "start": { + "line": 459, + "column": 20 + }, + "end": { + "line": 459, + "column": 38 + } + } + }, + "range": [ + 16051, + 16074 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 38 + } + } + }, + "property": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 16075, + 16084 + ], + "loc": { + "start": { + "line": 459, + "column": 39 + }, + "end": { + "line": 459, + "column": 48 + } + } + }, + "range": [ + 16051, + 16085 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16086, + 16090 + ], + "loc": { + "start": { + "line": 459, + "column": 50 + }, + "end": { + "line": 459, + "column": 54 + } + } + }, + "range": [ + 16051, + 16091 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 16092, + 16094 + ], + "loc": { + "start": { + "line": 459, + "column": 56 + }, + "end": { + "line": 459, + "column": 58 + } + } + }, + "range": [ + 16051, + 16095 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 16096, + 16103 + ], + "loc": { + "start": { + "line": 459, + "column": 60 + }, + "end": { + "line": 459, + "column": 67 + } + } + }, + "range": [ + 16051, + 16103 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 67 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 16104, + 16105 + ], + "loc": { + "start": { + "line": 459, + "column": 68 + }, + "end": { + "line": 459, + "column": 69 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 16109, + 16110 + ], + "loc": { + "start": { + "line": 459, + "column": 73 + }, + "end": { + "line": 459, + "column": 74 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 16111, + 16112 + ], + "loc": { + "start": { + "line": 459, + "column": 75 + }, + "end": { + "line": 459, + "column": 76 + } + } + }, + "range": [ + 16109, + 16113 + ], + "loc": { + "start": { + "line": 459, + "column": 73 + }, + "end": { + "line": 459, + "column": 77 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 16114, + 16118 + ], + "loc": { + "start": { + "line": 459, + "column": 78 + }, + "end": { + "line": 459, + "column": 82 + } + } + }, + "range": [ + 16109, + 16118 + ], + "loc": { + "start": { + "line": 459, + "column": 73 + }, + "end": { + "line": 459, + "column": 82 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 16119, + 16120 + ], + "loc": { + "start": { + "line": 459, + "column": 83 + }, + "end": { + "line": 459, + "column": 84 + } + } + }, + "property": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 16121, + 16122 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 86 + } + } + }, + "range": [ + 16119, + 16123 + ], + "loc": { + "start": { + "line": 459, + "column": 83 + }, + "end": { + "line": 459, + "column": 87 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 16125, + 16133 + ], + "loc": { + "start": { + "line": 459, + "column": 89 + }, + "end": { + "line": 459, + "column": 97 + } + } + } + ], + "range": [ + 16109, + 16134 + ], + "loc": { + "start": { + "line": 459, + "column": 73 + }, + "end": { + "line": 459, + "column": 98 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16104, + 16134 + ], + "loc": { + "start": { + "line": 459, + "column": 68 + }, + "end": { + "line": 459, + "column": 98 + } + } + } + ], + "range": [ + 16051, + 16135 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 99 + } + } + }, + "range": [ + 16051, + 16136 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 459, + "column": 100 + } + } + } + ], + "range": [ + 16034, + 16150 + ], + "loc": { + "start": { + "line": 458, + "column": 106 + }, + "end": { + "line": 460, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 15940, + 16150 + ], + "loc": { + "start": { + "line": 458, + "column": 12 + }, + "end": { + "line": 460, + "column": 13 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16167, + 16171 + ], + "loc": { + "start": { + "line": 461, + "column": 16 + }, + "end": { + "line": 461, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 16172, + 16192 + ], + "loc": { + "start": { + "line": 461, + "column": 21 + }, + "end": { + "line": 461, + "column": 41 + } + } + }, + "range": [ + 16167, + 16192 + ], + "loc": { + "start": { + "line": 461, + "column": 16 + }, + "end": { + "line": 461, + "column": 41 + } + } + }, + "property": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 16193, + 16202 + ], + "loc": { + "start": { + "line": 461, + "column": 42 + }, + "end": { + "line": 461, + "column": 51 + } + } + }, + "range": [ + 16167, + 16203 + ], + "loc": { + "start": { + "line": 461, + "column": 16 + }, + "end": { + "line": 461, + "column": 52 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16204, + 16208 + ], + "loc": { + "start": { + "line": 461, + "column": 53 + }, + "end": { + "line": 461, + "column": 57 + } + } + }, + "range": [ + 16167, + 16209 + ], + "loc": { + "start": { + "line": 461, + "column": 16 + }, + "end": { + "line": 461, + "column": 58 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16227, + 16231 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_collectionListeners", + "range": [ + 16232, + 16252 + ], + "loc": { + "start": { + "line": 462, + "column": 19 + }, + "end": { + "line": 462, + "column": 39 + } + } + }, + "range": [ + 16227, + 16252 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 39 + } + } + }, + "property": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 16253, + 16262 + ], + "loc": { + "start": { + "line": 462, + "column": 40 + }, + "end": { + "line": 462, + "column": 49 + } + } + }, + "range": [ + 16227, + 16263 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16264, + 16268 + ], + "loc": { + "start": { + "line": 462, + "column": 51 + }, + "end": { + "line": 462, + "column": 55 + } + } + }, + "range": [ + 16227, + 16269 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 16270, + 16277 + ], + "loc": { + "start": { + "line": 462, + "column": 57 + }, + "end": { + "line": 462, + "column": 64 + } + } + }, + "range": [ + 16227, + 16277 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 64 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 16278, + 16279 + ], + "loc": { + "start": { + "line": 462, + "column": 65 + }, + "end": { + "line": 462, + "column": 66 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 16283, + 16284 + ], + "loc": { + "start": { + "line": 462, + "column": 70 + }, + "end": { + "line": 462, + "column": 71 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 16285, + 16286 + ], + "loc": { + "start": { + "line": 462, + "column": 72 + }, + "end": { + "line": 462, + "column": 73 + } + } + }, + "range": [ + 16283, + 16287 + ], + "loc": { + "start": { + "line": 462, + "column": 70 + }, + "end": { + "line": 462, + "column": 74 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 16288, + 16292 + ], + "loc": { + "start": { + "line": 462, + "column": 75 + }, + "end": { + "line": 462, + "column": 79 + } + } + }, + "range": [ + 16283, + 16292 + ], + "loc": { + "start": { + "line": 462, + "column": 70 + }, + "end": { + "line": 462, + "column": 79 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 16293, + 16294 + ], + "loc": { + "start": { + "line": 462, + "column": 80 + }, + "end": { + "line": 462, + "column": 81 + } + } + }, + "property": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 16295, + 16296 + ], + "loc": { + "start": { + "line": 462, + "column": 82 + }, + "end": { + "line": 462, + "column": 83 + } + } + }, + "range": [ + 16293, + 16297 + ], + "loc": { + "start": { + "line": 462, + "column": 80 + }, + "end": { + "line": 462, + "column": 84 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 16299, + 16307 + ], + "loc": { + "start": { + "line": 462, + "column": 86 + }, + "end": { + "line": 462, + "column": 94 + } + } + } + ], + "range": [ + 16283, + 16308 + ], + "loc": { + "start": { + "line": 462, + "column": 70 + }, + "end": { + "line": 462, + "column": 95 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16278, + 16308 + ], + "loc": { + "start": { + "line": 462, + "column": 65 + }, + "end": { + "line": 462, + "column": 95 + } + } + } + ], + "range": [ + 16227, + 16309 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 96 + } + } + }, + "range": [ + 16227, + 16310 + ], + "loc": { + "start": { + "line": 462, + "column": 14 + }, + "end": { + "line": 462, + "column": 97 + } + } + } + ], + "range": [ + 16211, + 16324 + ], + "loc": { + "start": { + "line": 461, + "column": 60 + }, + "end": { + "line": 463, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 16163, + 16324 + ], + "loc": { + "start": { + "line": 461, + "column": 12 + }, + "end": { + "line": 463, + "column": 13 + } + } + } + ], + "range": [ + 15890, + 16336 + ], + "loc": { + "start": { + "line": 456, + "column": 24 + }, + "end": { + "line": 464, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 15876, + 16336 + ], + "loc": { + "start": { + "line": 456, + "column": 10 + }, + "end": { + "line": 464, + "column": 11 + } + } + } + ], + "range": [ + 15797, + 16346 + ], + "loc": { + "start": { + "line": 454, + "column": 16 + }, + "end": { + "line": 465, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 16364, + 16370 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 16371, + 16375 + ], + "loc": { + "start": { + "line": 466, + "column": 17 + }, + "end": { + "line": 466, + "column": 21 + } + } + }, + "range": [ + 16364, + 16375 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16376, + 16380 + ], + "loc": { + "start": { + "line": 466, + "column": 22 + }, + "end": { + "line": 466, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 16381, + 16386 + ], + "loc": { + "start": { + "line": 466, + "column": 27 + }, + "end": { + "line": 466, + "column": 32 + } + } + }, + "range": [ + 16376, + 16386 + ], + "loc": { + "start": { + "line": 466, + "column": 22 + }, + "end": { + "line": 466, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16387, + 16391 + ], + "loc": { + "start": { + "line": 466, + "column": 33 + }, + "end": { + "line": 466, + "column": 37 + } + } + }, + "range": [ + 16376, + 16392 + ], + "loc": { + "start": { + "line": 466, + "column": 22 + }, + "end": { + "line": 466, + "column": 38 + } + } + } + ], + "range": [ + 16364, + 16393 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 16394, + 16401 + ], + "loc": { + "start": { + "line": 466, + "column": 40 + }, + "end": { + "line": 466, + "column": 47 + } + } + }, + "range": [ + 16364, + 16401 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 47 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 16402, + 16404 + ], + "loc": { + "start": { + "line": 466, + "column": 48 + }, + "end": { + "line": 466, + "column": 50 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16408, + 16412 + ], + "loc": { + "start": { + "line": 466, + "column": 54 + }, + "end": { + "line": 466, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "remove", + "range": [ + 16413, + 16419 + ], + "loc": { + "start": { + "line": 466, + "column": 59 + }, + "end": { + "line": 466, + "column": 65 + } + } + }, + "range": [ + 16408, + 16419 + ], + "loc": { + "start": { + "line": 466, + "column": 54 + }, + "end": { + "line": 466, + "column": 65 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 16420, + 16424 + ], + "loc": { + "start": { + "line": 466, + "column": 66 + }, + "end": { + "line": 466, + "column": 70 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 16426, + 16428 + ], + "loc": { + "start": { + "line": 466, + "column": 72 + }, + "end": { + "line": 466, + "column": 74 + } + } + } + ], + "range": [ + 16408, + 16429 + ], + "loc": { + "start": { + "line": 466, + "column": 54 + }, + "end": { + "line": 466, + "column": 75 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16402, + 16429 + ], + "loc": { + "start": { + "line": 466, + "column": 48 + }, + "end": { + "line": 466, + "column": 75 + } + } + } + ], + "range": [ + 16364, + 16430 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 76 + } + } + }, + "range": [ + 16364, + 16431 + ], + "loc": { + "start": { + "line": 466, + "column": 10 + }, + "end": { + "line": 466, + "column": 77 + } + } + } + ], + "range": [ + 16352, + 16441 + ], + "loc": { + "start": { + "line": 465, + "column": 15 + }, + "end": { + "line": 467, + "column": 9 + } + } + }, + "range": [ + 15789, + 16441 + ], + "loc": { + "start": { + "line": 454, + "column": 8 + }, + "end": { + "line": 467, + "column": 9 + } + } + } + ], + "range": [ + 15779, + 16449 + ], + "loc": { + "start": { + "line": 453, + "column": 29 + }, + "end": { + "line": 468, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 16475, + 16484 + ], + "loc": { + "start": { + "line": 469, + "column": 18 + }, + "end": { + "line": 469, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 16485, + 16502 + ], + "loc": { + "start": { + "line": 469, + "column": 28 + }, + "end": { + "line": 469, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 16506, + 16509 + ], + "loc": { + "start": { + "line": 469, + "column": 49 + }, + "end": { + "line": 469, + "column": 52 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 16502, + 16506 + ], + "loc": { + "start": { + "line": 469, + "column": 45 + }, + "end": { + "line": 469, + "column": 49 + } + } + } + ], + "range": [ + 16485, + 16509 + ], + "loc": { + "start": { + "line": 469, + "column": 28 + }, + "end": { + "line": 469, + "column": 52 + } + } + } + ], + "range": [ + 16471, + 16510 + ], + "loc": { + "start": { + "line": 469, + "column": 14 + }, + "end": { + "line": 469, + "column": 53 + } + } + }, + "range": [ + 16465, + 16511 + ], + "loc": { + "start": { + "line": 469, + "column": 8 + }, + "end": { + "line": 469, + "column": 54 + } + } + } + ], + "range": [ + 16455, + 16519 + ], + "loc": { + "start": { + "line": 468, + "column": 13 + }, + "end": { + "line": 470, + "column": 7 + } + } + }, + "range": [ + 15756, + 16519 + ], + "loc": { + "start": { + "line": 453, + "column": 6 + }, + "end": { + "line": 470, + "column": 7 + } + } + } + ], + "range": [ + 15748, + 16525 + ], + "loc": { + "start": { + "line": 452, + "column": 14 + }, + "end": { + "line": 471, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 16549, + 16558 + ], + "loc": { + "start": { + "line": 472, + "column": 16 + }, + "end": { + "line": 472, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a type to remove", + "cooked": "You must provide a type to remove" + }, + "tail": true, + "range": [ + 16559, + 16594 + ], + "loc": { + "start": { + "line": 472, + "column": 26 + }, + "end": { + "line": 472, + "column": 61 + } + } + } + ], + "expressions": [], + "range": [ + 16559, + 16594 + ], + "loc": { + "start": { + "line": 472, + "column": 26 + }, + "end": { + "line": 472, + "column": 61 + } + } + } + ], + "range": [ + 16545, + 16595 + ], + "loc": { + "start": { + "line": 472, + "column": 12 + }, + "end": { + "line": 472, + "column": 62 + } + } + }, + "range": [ + 16539, + 16596 + ], + "loc": { + "start": { + "line": 472, + "column": 6 + }, + "end": { + "line": 472, + "column": 63 + } + } + } + ], + "range": [ + 16531, + 16602 + ], + "loc": { + "start": { + "line": 471, + "column": 11 + }, + "end": { + "line": 473, + "column": 5 + } + } + }, + "range": [ + 15738, + 16602 + ], + "loc": { + "start": { + "line": 452, + "column": 4 + }, + "end": { + "line": 473, + "column": 5 + } + } + } + ], + "range": [ + 15732, + 16606 + ], + "loc": { + "start": { + "line": 451, + "column": 19 + }, + "end": { + "line": 474, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 15721, + 16606 + ], + "loc": { + "start": { + "line": 451, + "column": 8 + }, + "end": { + "line": 474, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 15715, + 16606 + ], + "loc": { + "start": { + "line": 451, + "column": 2 + }, + "end": { + "line": 474, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n * @return {undefined} - Nothing.\n ", + "range": [ + 15370, + 15712 + ], + "loc": { + "start": { + "line": 442, + "column": 2 + }, + "end": { + "line": 450, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 16610, + 17319 + ], + "loc": { + "start": { + "line": 476, + "column": 2 + }, + "end": { + "line": 495, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "update", + "range": [ + 17322, + 17328 + ], + "loc": { + "start": { + "line": 496, + "column": 2 + }, + "end": { + "line": 496, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 17329, + 17333 + ], + "loc": { + "start": { + "line": 496, + "column": 9 + }, + "end": { + "line": 496, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 17335, + 17337 + ], + "loc": { + "start": { + "line": 496, + "column": 15 + }, + "end": { + "line": 496, + "column": 17 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 17339, + 17346 + ], + "loc": { + "start": { + "line": 496, + "column": 19 + }, + "end": { + "line": 496, + "column": 26 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 17348, + 17355 + ], + "loc": { + "start": { + "line": 496, + "column": 28 + }, + "end": { + "line": 496, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 17357, + 17362 + ], + "loc": { + "start": { + "line": 496, + "column": 37 + }, + "end": { + "line": 496, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 17364, + 17371 + ], + "loc": { + "start": { + "line": 496, + "column": 44 + }, + "end": { + "line": 496, + "column": 51 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17383, + 17387 + ], + "loc": { + "start": { + "line": 497, + "column": 8 + }, + "end": { + "line": 497, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 17388, + 17396 + ], + "loc": { + "start": { + "line": 497, + "column": 13 + }, + "end": { + "line": 497, + "column": 21 + } + } + }, + "range": [ + 17383, + 17396 + ], + "loc": { + "start": { + "line": 497, + "column": 8 + }, + "end": { + "line": 497, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17406, + 17410 + ], + "loc": { + "start": { + "line": 498, + "column": 6 + }, + "end": { + "line": 498, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 17411, + 17419 + ], + "loc": { + "start": { + "line": 498, + "column": 11 + }, + "end": { + "line": 498, + "column": 19 + } + } + }, + "range": [ + 17406, + 17419 + ], + "loc": { + "start": { + "line": 498, + "column": 6 + }, + "end": { + "line": 498, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "update", + "range": [ + 17420, + 17426 + ], + "loc": { + "start": { + "line": 498, + "column": 20 + }, + "end": { + "line": 498, + "column": 26 + } + } + }, + "range": [ + 17406, + 17426 + ], + "loc": { + "start": { + "line": 498, + "column": 6 + }, + "end": { + "line": 498, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 17427, + 17431 + ], + "loc": { + "start": { + "line": 498, + "column": 27 + }, + "end": { + "line": 498, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 17433, + 17437 + ], + "loc": { + "start": { + "line": 498, + "column": 33 + }, + "end": { + "line": 498, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 17439, + 17441 + ], + "loc": { + "start": { + "line": 498, + "column": 39 + }, + "end": { + "line": 498, + "column": 41 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 17443, + 17450 + ], + "loc": { + "start": { + "line": 498, + "column": 43 + }, + "end": { + "line": 498, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "success", + "range": [ + 17452, + 17459 + ], + "loc": { + "start": { + "line": 498, + "column": 52 + }, + "end": { + "line": 498, + "column": 59 + } + } + }, + { + "type": "Identifier", + "name": "error", + "range": [ + 17461, + 17466 + ], + "loc": { + "start": { + "line": 498, + "column": 61 + }, + "end": { + "line": 498, + "column": 66 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 17468, + 17475 + ], + "loc": { + "start": { + "line": 498, + "column": 68 + }, + "end": { + "line": 498, + "column": 75 + } + } + } + ], + "range": [ + 17406, + 17476 + ], + "loc": { + "start": { + "line": 498, + "column": 6 + }, + "end": { + "line": 498, + "column": 76 + } + } + }, + "range": [ + 17406, + 17477 + ], + "loc": { + "start": { + "line": 498, + "column": 6 + }, + "end": { + "line": 498, + "column": 77 + } + } + } + ], + "range": [ + 17398, + 17483 + ], + "loc": { + "start": { + "line": 497, + "column": 23 + }, + "end": { + "line": 499, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 17507, + 17512 + ], + "loc": { + "start": { + "line": 500, + "column": 16 + }, + "end": { + "line": 500, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 17513, + 17609 + ], + "loc": { + "start": { + "line": 500, + "column": 22 + }, + "end": { + "line": 500, + "column": 118 + } + } + } + ], + "range": [ + 17503, + 17610 + ], + "loc": { + "start": { + "line": 500, + "column": 12 + }, + "end": { + "line": 500, + "column": 119 + } + } + }, + "range": [ + 17497, + 17611 + ], + "loc": { + "start": { + "line": 500, + "column": 6 + }, + "end": { + "line": 500, + "column": 120 + } + } + } + ], + "range": [ + 17489, + 17617 + ], + "loc": { + "start": { + "line": 499, + "column": 11 + }, + "end": { + "line": 501, + "column": 5 + } + } + }, + "range": [ + 17379, + 17617 + ], + "loc": { + "start": { + "line": 497, + "column": 4 + }, + "end": { + "line": 501, + "column": 5 + } + } + } + ], + "range": [ + 17373, + 17621 + ], + "loc": { + "start": { + "line": 496, + "column": 53 + }, + "end": { + "line": 502, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 17328, + 17621 + ], + "loc": { + "start": { + "line": 496, + "column": 8 + }, + "end": { + "line": 502, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 17322, + 17621 + ], + "loc": { + "start": { + "line": 496, + "column": 2 + }, + "end": { + "line": 502, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 16610, + 17319 + ], + "loc": { + "start": { + "line": 476, + "column": 2 + }, + "end": { + "line": 495, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_addField", + "range": [ + 17625, + 17634 + ], + "loc": { + "start": { + "line": 504, + "column": 2 + }, + "end": { + "line": 504, + "column": 11 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 17635, + 17641 + ], + "loc": { + "start": { + "line": 504, + "column": 12 + }, + "end": { + "line": 504, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 17643, + 17651 + ], + "loc": { + "start": { + "line": 504, + "column": 20 + }, + "end": { + "line": 504, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 17653, + 17663 + ], + "loc": { + "start": { + "line": 504, + "column": 30 + }, + "end": { + "line": 504, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17665, + 17674 + ], + "loc": { + "start": { + "line": 504, + "column": 42 + }, + "end": { + "line": 504, + "column": 51 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "field", + "range": [ + 17686, + 17691 + ], + "loc": { + "start": { + "line": 505, + "column": 8 + }, + "end": { + "line": 505, + "column": 13 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 17694, + 17704 + ], + "loc": { + "start": { + "line": 505, + "column": 16 + }, + "end": { + "line": 505, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17705, + 17714 + ], + "loc": { + "start": { + "line": 505, + "column": 27 + }, + "end": { + "line": 505, + "column": 36 + } + } + }, + "range": [ + 17694, + 17715 + ], + "loc": { + "start": { + "line": 505, + "column": 16 + }, + "end": { + "line": 505, + "column": 37 + } + } + }, + "range": [ + 17686, + 17715 + ], + "loc": { + "start": { + "line": 505, + "column": 8 + }, + "end": { + "line": 505, + "column": 37 + } + } + } + ], + "kind": "var", + "range": [ + 17682, + 17716 + ], + "loc": { + "start": { + "line": 505, + "column": 4 + }, + "end": { + "line": 505, + "column": 38 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "newValue", + "range": [ + 17725, + 17733 + ], + "loc": { + "start": { + "line": 506, + "column": 8 + }, + "end": { + "line": 506, + "column": 16 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 17736, + 17741 + ], + "loc": { + "start": { + "line": 506, + "column": 19 + }, + "end": { + "line": 506, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 17742, + 17753 + ], + "loc": { + "start": { + "line": 506, + "column": 25 + }, + "end": { + "line": 506, + "column": 36 + } + } + }, + "range": [ + 17736, + 17753 + ], + "loc": { + "start": { + "line": 506, + "column": 19 + }, + "end": { + "line": 506, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 17754, + 17758 + ], + "loc": { + "start": { + "line": 506, + "column": 37 + }, + "end": { + "line": 506, + "column": 41 + } + } + }, + "range": [ + 17736, + 17758 + ], + "loc": { + "start": { + "line": 506, + "column": 19 + }, + "end": { + "line": 506, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 17759, + 17763 + ], + "loc": { + "start": { + "line": 506, + "column": 42 + }, + "end": { + "line": 506, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "object", + "range": [ + 17765, + 17771 + ], + "loc": { + "start": { + "line": 506, + "column": 48 + }, + "end": { + "line": 506, + "column": 54 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17773, + 17782 + ], + "loc": { + "start": { + "line": 506, + "column": 56 + }, + "end": { + "line": 506, + "column": 65 + } + } + } + ], + "range": [ + 17736, + 17783 + ], + "loc": { + "start": { + "line": 506, + "column": 19 + }, + "end": { + "line": 506, + "column": 66 + } + } + }, + "range": [ + 17725, + 17783 + ], + "loc": { + "start": { + "line": 506, + "column": 8 + }, + "end": { + "line": 506, + "column": 66 + } + } + } + ], + "kind": "var", + "range": [ + 17721, + 17784 + ], + "loc": { + "start": { + "line": 506, + "column": 4 + }, + "end": { + "line": 506, + "column": 67 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "newValue", + "range": [ + 17800, + 17808 + ], + "loc": { + "start": { + "line": 507, + "column": 15 + }, + "end": { + "line": 507, + "column": 23 + } + } + }, + "prefix": true, + "range": [ + 17793, + 17808 + ], + "loc": { + "start": { + "line": 507, + "column": 8 + }, + "end": { + "line": 507, + "column": 23 + } + } + }, + "right": { + "type": "Literal", + "value": "undefined", + "raw": "\"undefined\"", + "range": [ + 17813, + 17824 + ], + "loc": { + "start": { + "line": 507, + "column": 28 + }, + "end": { + "line": 507, + "column": 39 + } + } + }, + "range": [ + 17793, + 17824 + ], + "loc": { + "start": { + "line": 507, + "column": 8 + }, + "end": { + "line": 507, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 17838, + 17843 + ], + "loc": { + "start": { + "line": 508, + "column": 10 + }, + "end": { + "line": 508, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 17844, + 17848 + ], + "loc": { + "start": { + "line": 508, + "column": 16 + }, + "end": { + "line": 508, + "column": 20 + } + } + }, + "range": [ + 17838, + 17848 + ], + "loc": { + "start": { + "line": 508, + "column": 10 + }, + "end": { + "line": 508, + "column": 20 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 17853, + 17862 + ], + "loc": { + "start": { + "line": 508, + "column": 25 + }, + "end": { + "line": 508, + "column": 34 + } + } + }, + "range": [ + 17838, + 17862 + ], + "loc": { + "start": { + "line": 508, + "column": 10 + }, + "end": { + "line": 508, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 17878, + 17886 + ], + "loc": { + "start": { + "line": 509, + "column": 12 + }, + "end": { + "line": 509, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17887, + 17896 + ], + "loc": { + "start": { + "line": 509, + "column": 21 + }, + "end": { + "line": 509, + "column": 30 + } + } + }, + "range": [ + 17878, + 17897 + ], + "loc": { + "start": { + "line": 509, + "column": 12 + }, + "end": { + "line": 509, + "column": 31 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17911, + 17915 + ], + "loc": { + "start": { + "line": 510, + "column": 10 + }, + "end": { + "line": 510, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 17916, + 17942 + ], + "loc": { + "start": { + "line": 510, + "column": 15 + }, + "end": { + "line": 510, + "column": 41 + } + } + }, + "range": [ + 17911, + 17942 + ], + "loc": { + "start": { + "line": 510, + "column": 10 + }, + "end": { + "line": 510, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 17943, + 17951 + ], + "loc": { + "start": { + "line": 510, + "column": 42 + }, + "end": { + "line": 510, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17953, + 17962 + ], + "loc": { + "start": { + "line": 510, + "column": 52 + }, + "end": { + "line": 510, + "column": 61 + } + } + }, + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 17964, + 17972 + ], + "loc": { + "start": { + "line": 510, + "column": 63 + }, + "end": { + "line": 510, + "column": 71 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 17973, + 17982 + ], + "loc": { + "start": { + "line": 510, + "column": 72 + }, + "end": { + "line": 510, + "column": 81 + } + } + }, + "range": [ + 17964, + 17983 + ], + "loc": { + "start": { + "line": 510, + "column": 63 + }, + "end": { + "line": 510, + "column": 82 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 17985, + 17990 + ], + "loc": { + "start": { + "line": 510, + "column": 84 + }, + "end": { + "line": 510, + "column": 89 + } + } + } + ], + "range": [ + 17911, + 17991 + ], + "loc": { + "start": { + "line": 510, + "column": 10 + }, + "end": { + "line": 510, + "column": 90 + } + } + }, + "range": [ + 17911, + 17992 + ], + "loc": { + "start": { + "line": 510, + "column": 10 + }, + "end": { + "line": 510, + "column": 91 + } + } + } + ], + "range": [ + 17899, + 18002 + ], + "loc": { + "start": { + "line": 509, + "column": 33 + }, + "end": { + "line": 511, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 17874, + 18002 + ], + "loc": { + "start": { + "line": 509, + "column": 8 + }, + "end": { + "line": 511, + "column": 9 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "newValue", + "range": [ + 18015, + 18023 + ], + "loc": { + "start": { + "line": 512, + "column": 12 + }, + "end": { + "line": 512, + "column": 20 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18037, + 18041 + ], + "loc": { + "start": { + "line": 513, + "column": 10 + }, + "end": { + "line": 513, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 18042, + 18065 + ], + "loc": { + "start": { + "line": 513, + "column": 15 + }, + "end": { + "line": 513, + "column": 38 + } + } + }, + "range": [ + 18037, + 18065 + ], + "loc": { + "start": { + "line": 513, + "column": 10 + }, + "end": { + "line": 513, + "column": 38 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 18066, + 18074 + ], + "loc": { + "start": { + "line": 513, + "column": 39 + }, + "end": { + "line": 513, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18076, + 18085 + ], + "loc": { + "start": { + "line": 513, + "column": 49 + }, + "end": { + "line": 513, + "column": 58 + } + } + }, + { + "type": "Identifier", + "name": "newValue", + "range": [ + 18087, + 18095 + ], + "loc": { + "start": { + "line": 513, + "column": 60 + }, + "end": { + "line": 513, + "column": 68 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 18097, + 18102 + ], + "loc": { + "start": { + "line": 513, + "column": 70 + }, + "end": { + "line": 513, + "column": 75 + } + } + } + ], + "range": [ + 18037, + 18103 + ], + "loc": { + "start": { + "line": 513, + "column": 10 + }, + "end": { + "line": 513, + "column": 76 + } + } + }, + "range": [ + 18037, + 18104 + ], + "loc": { + "start": { + "line": 513, + "column": 10 + }, + "end": { + "line": 513, + "column": 77 + } + } + } + ], + "range": [ + 18025, + 18114 + ], + "loc": { + "start": { + "line": 512, + "column": 22 + }, + "end": { + "line": 514, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 18011, + 18114 + ], + "loc": { + "start": { + "line": 512, + "column": 8 + }, + "end": { + "line": 514, + "column": 9 + } + } + } + ], + "range": [ + 17864, + 18122 + ], + "loc": { + "start": { + "line": 508, + "column": 36 + }, + "end": { + "line": 515, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 18132, + 18137 + ], + "loc": { + "start": { + "line": 515, + "column": 17 + }, + "end": { + "line": 515, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18138, + 18142 + ], + "loc": { + "start": { + "line": 515, + "column": 23 + }, + "end": { + "line": 515, + "column": 27 + } + } + }, + "range": [ + 18132, + 18142 + ], + "loc": { + "start": { + "line": 515, + "column": 17 + }, + "end": { + "line": 515, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 18147, + 18157 + ], + "loc": { + "start": { + "line": 515, + "column": 32 + }, + "end": { + "line": 515, + "column": 42 + } + } + }, + "range": [ + 18132, + 18157 + ], + "loc": { + "start": { + "line": 515, + "column": 17 + }, + "end": { + "line": 515, + "column": 42 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 18169, + 18177 + ], + "loc": { + "start": { + "line": 516, + "column": 8 + }, + "end": { + "line": 516, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18178, + 18187 + ], + "loc": { + "start": { + "line": 516, + "column": 17 + }, + "end": { + "line": 516, + "column": 26 + } + } + }, + "range": [ + 18169, + 18188 + ], + "loc": { + "start": { + "line": 516, + "column": 8 + }, + "end": { + "line": 516, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 18189, + 18196 + ], + "loc": { + "start": { + "line": 516, + "column": 28 + }, + "end": { + "line": 516, + "column": 35 + } + } + }, + "range": [ + 18169, + 18196 + ], + "loc": { + "start": { + "line": 516, + "column": 8 + }, + "end": { + "line": 516, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 18197, + 18198 + ], + "loc": { + "start": { + "line": 516, + "column": 36 + }, + "end": { + "line": 516, + "column": 37 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 18218, + 18226 + ], + "loc": { + "start": { + "line": 517, + "column": 14 + }, + "end": { + "line": 517, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18227, + 18236 + ], + "loc": { + "start": { + "line": 517, + "column": 23 + }, + "end": { + "line": 517, + "column": 32 + } + } + }, + "range": [ + 18218, + 18237 + ], + "loc": { + "start": { + "line": 517, + "column": 14 + }, + "end": { + "line": 517, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 18238, + 18245 + ], + "loc": { + "start": { + "line": 517, + "column": 34 + }, + "end": { + "line": 517, + "column": 41 + } + } + }, + "range": [ + 18218, + 18245 + ], + "loc": { + "start": { + "line": 517, + "column": 14 + }, + "end": { + "line": 517, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 18246, + 18247 + ], + "loc": { + "start": { + "line": 517, + "column": 42 + }, + "end": { + "line": 517, + "column": 43 + } + } + } + ], + "range": [ + 18218, + 18248 + ], + "loc": { + "start": { + "line": 517, + "column": 14 + }, + "end": { + "line": 517, + "column": 44 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 18254, + 18255 + ], + "loc": { + "start": { + "line": 517, + "column": 50 + }, + "end": { + "line": 517, + "column": 51 + } + } + }, + "prefix": true, + "range": [ + 18253, + 18255 + ], + "loc": { + "start": { + "line": 517, + "column": 49 + }, + "end": { + "line": 517, + "column": 51 + } + } + }, + "range": [ + 18218, + 18255 + ], + "loc": { + "start": { + "line": 517, + "column": 14 + }, + "end": { + "line": 517, + "column": 51 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18271, + 18275 + ], + "loc": { + "start": { + "line": 518, + "column": 12 + }, + "end": { + "line": 518, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 18276, + 18302 + ], + "loc": { + "start": { + "line": 518, + "column": 17 + }, + "end": { + "line": 518, + "column": 43 + } + } + }, + "range": [ + 18271, + 18302 + ], + "loc": { + "start": { + "line": 518, + "column": 12 + }, + "end": { + "line": 518, + "column": 43 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 18303, + 18311 + ], + "loc": { + "start": { + "line": 518, + "column": 44 + }, + "end": { + "line": 518, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18313, + 18322 + ], + "loc": { + "start": { + "line": 518, + "column": 54 + }, + "end": { + "line": 518, + "column": 63 + } + } + }, + { + "type": "Identifier", + "name": "r", + "range": [ + 18324, + 18325 + ], + "loc": { + "start": { + "line": 518, + "column": 65 + }, + "end": { + "line": 518, + "column": 66 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 18327, + 18332 + ], + "loc": { + "start": { + "line": 518, + "column": 68 + }, + "end": { + "line": 518, + "column": 73 + } + } + } + ], + "range": [ + 18271, + 18333 + ], + "loc": { + "start": { + "line": 518, + "column": 12 + }, + "end": { + "line": 518, + "column": 74 + } + } + }, + "range": [ + 18271, + 18334 + ], + "loc": { + "start": { + "line": 518, + "column": 12 + }, + "end": { + "line": 518, + "column": 75 + } + } + } + ], + "range": [ + 18257, + 18346 + ], + "loc": { + "start": { + "line": 517, + "column": 53 + }, + "end": { + "line": 519, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 18214, + 18346 + ], + "loc": { + "start": { + "line": 517, + "column": 10 + }, + "end": { + "line": 519, + "column": 11 + } + } + } + ], + "range": [ + 18202, + 18356 + ], + "loc": { + "start": { + "line": 516, + "column": 41 + }, + "end": { + "line": 520, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 18197, + 18356 + ], + "loc": { + "start": { + "line": 516, + "column": 36 + }, + "end": { + "line": 520, + "column": 9 + } + } + } + ], + "range": [ + 18169, + 18357 + ], + "loc": { + "start": { + "line": 516, + "column": 8 + }, + "end": { + "line": 520, + "column": 10 + } + } + }, + "range": [ + 18169, + 18358 + ], + "loc": { + "start": { + "line": 516, + "column": 8 + }, + "end": { + "line": 520, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "newValue", + "range": [ + 18367, + 18375 + ], + "loc": { + "start": { + "line": 521, + "column": 8 + }, + "end": { + "line": 521, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 18376, + 18383 + ], + "loc": { + "start": { + "line": 521, + "column": 17 + }, + "end": { + "line": 521, + "column": 24 + } + } + }, + "range": [ + 18367, + 18383 + ], + "loc": { + "start": { + "line": 521, + "column": 8 + }, + "end": { + "line": 521, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 18384, + 18385 + ], + "loc": { + "start": { + "line": 521, + "column": 25 + }, + "end": { + "line": 521, + "column": 26 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18401, + 18405 + ], + "loc": { + "start": { + "line": 522, + "column": 10 + }, + "end": { + "line": 522, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 18406, + 18429 + ], + "loc": { + "start": { + "line": 522, + "column": 15 + }, + "end": { + "line": 522, + "column": 38 + } + } + }, + "range": [ + 18401, + 18429 + ], + "loc": { + "start": { + "line": 522, + "column": 10 + }, + "end": { + "line": 522, + "column": 38 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 18430, + 18438 + ], + "loc": { + "start": { + "line": 522, + "column": 39 + }, + "end": { + "line": 522, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18440, + 18449 + ], + "loc": { + "start": { + "line": 522, + "column": 49 + }, + "end": { + "line": 522, + "column": 58 + } + } + }, + { + "type": "Identifier", + "name": "r", + "range": [ + 18451, + 18452 + ], + "loc": { + "start": { + "line": 522, + "column": 60 + }, + "end": { + "line": 522, + "column": 61 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 18454, + 18459 + ], + "loc": { + "start": { + "line": 522, + "column": 63 + }, + "end": { + "line": 522, + "column": 68 + } + } + } + ], + "range": [ + 18401, + 18460 + ], + "loc": { + "start": { + "line": 522, + "column": 10 + }, + "end": { + "line": 522, + "column": 69 + } + } + }, + "range": [ + 18401, + 18461 + ], + "loc": { + "start": { + "line": 522, + "column": 10 + }, + "end": { + "line": 522, + "column": 70 + } + } + } + ], + "range": [ + 18389, + 18471 + ], + "loc": { + "start": { + "line": 521, + "column": 30 + }, + "end": { + "line": 523, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 18384, + 18471 + ], + "loc": { + "start": { + "line": 521, + "column": 25 + }, + "end": { + "line": 523, + "column": 9 + } + } + } + ], + "range": [ + 18367, + 18472 + ], + "loc": { + "start": { + "line": 521, + "column": 8 + }, + "end": { + "line": 523, + "column": 10 + } + } + }, + "range": [ + 18367, + 18473 + ], + "loc": { + "start": { + "line": 521, + "column": 8 + }, + "end": { + "line": 523, + "column": 11 + } + } + } + ], + "range": [ + 18159, + 18481 + ], + "loc": { + "start": { + "line": 515, + "column": 44 + }, + "end": { + "line": 524, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 18128, + 18481 + ], + "loc": { + "start": { + "line": 515, + "column": 13 + }, + "end": { + "line": 524, + "column": 7 + } + } + }, + "range": [ + 17834, + 18481 + ], + "loc": { + "start": { + "line": 508, + "column": 6 + }, + "end": { + "line": 524, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 18488, + 18496 + ], + "loc": { + "start": { + "line": 525, + "column": 6 + }, + "end": { + "line": 525, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 18497, + 18506 + ], + "loc": { + "start": { + "line": 525, + "column": 15 + }, + "end": { + "line": 525, + "column": 24 + } + } + }, + "range": [ + 18488, + 18507 + ], + "loc": { + "start": { + "line": 525, + "column": 6 + }, + "end": { + "line": 525, + "column": 25 + } + } + }, + "right": { + "type": "Identifier", + "name": "newValue", + "range": [ + 18510, + 18518 + ], + "loc": { + "start": { + "line": 525, + "column": 28 + }, + "end": { + "line": 525, + "column": 36 + } + } + }, + "range": [ + 18488, + 18518 + ], + "loc": { + "start": { + "line": 525, + "column": 6 + }, + "end": { + "line": 525, + "column": 36 + } + } + }, + "range": [ + 18488, + 18519 + ], + "loc": { + "start": { + "line": 525, + "column": 6 + }, + "end": { + "line": 525, + "column": 37 + } + } + } + ], + "range": [ + 17826, + 18525 + ], + "loc": { + "start": { + "line": 507, + "column": 41 + }, + "end": { + "line": 526, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 17789, + 18525 + ], + "loc": { + "start": { + "line": 507, + "column": 4 + }, + "end": { + "line": 526, + "column": 5 + } + } + } + ], + "range": [ + 17676, + 18529 + ], + "loc": { + "start": { + "line": 504, + "column": 53 + }, + "end": { + "line": 527, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 17634, + 18529 + ], + "loc": { + "start": { + "line": 504, + "column": 11 + }, + "end": { + "line": 527, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 17625, + 18529 + ], + "loc": { + "start": { + "line": 504, + "column": 2 + }, + "end": { + "line": 527, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 18533, + 18556 + ], + "loc": { + "start": { + "line": 529, + "column": 2 + }, + "end": { + "line": 529, + "column": 25 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 18557, + 18571 + ], + "loc": { + "start": { + "line": 529, + "column": 26 + }, + "end": { + "line": 529, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 18573, + 18588 + ], + "loc": { + "start": { + "line": 529, + "column": 42 + }, + "end": { + "line": 529, + "column": 57 + } + } + }, + { + "type": "Identifier", + "name": "targetResource", + "range": [ + 18590, + 18604 + ], + "loc": { + "start": { + "line": 529, + "column": 59 + }, + "end": { + "line": 529, + "column": 73 + } + } + }, + { + "type": "Identifier", + "name": "sourceField", + "range": [ + 18606, + 18617 + ], + "loc": { + "start": { + "line": 529, + "column": 75 + }, + "end": { + "line": 529, + "column": 86 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 18629, + 18645 + ], + "loc": { + "start": { + "line": 530, + "column": 8 + }, + "end": { + "line": 530, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18648, + 18652 + ], + "loc": { + "start": { + "line": 530, + "column": 27 + }, + "end": { + "line": 530, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 18653, + 18659 + ], + "loc": { + "start": { + "line": 530, + "column": 32 + }, + "end": { + "line": 530, + "column": 38 + } + } + }, + "range": [ + 18648, + 18659 + ], + "loc": { + "start": { + "line": 530, + "column": 27 + }, + "end": { + "line": 530, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 18660, + 18674 + ], + "loc": { + "start": { + "line": 530, + "column": 39 + }, + "end": { + "line": 530, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18675, + 18679 + ], + "loc": { + "start": { + "line": 530, + "column": 54 + }, + "end": { + "line": 530, + "column": 58 + } + } + }, + "range": [ + 18660, + 18679 + ], + "loc": { + "start": { + "line": 530, + "column": 39 + }, + "end": { + "line": 530, + "column": 58 + } + } + }, + "range": [ + 18648, + 18680 + ], + "loc": { + "start": { + "line": 530, + "column": 27 + }, + "end": { + "line": 530, + "column": 59 + } + } + }, + "range": [ + 18629, + 18680 + ], + "loc": { + "start": { + "line": 530, + "column": 8 + }, + "end": { + "line": 530, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 18625, + 18681 + ], + "loc": { + "start": { + "line": 530, + "column": 4 + }, + "end": { + "line": 530, + "column": 60 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "sourceDefinition", + "range": [ + 18690, + 18706 + ], + "loc": { + "start": { + "line": 531, + "column": 8 + }, + "end": { + "line": 531, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18709, + 18713 + ], + "loc": { + "start": { + "line": 531, + "column": 27 + }, + "end": { + "line": 531, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 18714, + 18720 + ], + "loc": { + "start": { + "line": 531, + "column": 32 + }, + "end": { + "line": 531, + "column": 38 + } + } + }, + "range": [ + 18709, + 18720 + ], + "loc": { + "start": { + "line": 531, + "column": 27 + }, + "end": { + "line": 531, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 18721, + 18735 + ], + "loc": { + "start": { + "line": 531, + "column": 39 + }, + "end": { + "line": 531, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18736, + 18740 + ], + "loc": { + "start": { + "line": 531, + "column": 54 + }, + "end": { + "line": 531, + "column": 58 + } + } + }, + "range": [ + 18721, + 18740 + ], + "loc": { + "start": { + "line": 531, + "column": 39 + }, + "end": { + "line": 531, + "column": 58 + } + } + }, + "range": [ + 18709, + 18741 + ], + "loc": { + "start": { + "line": 531, + "column": 27 + }, + "end": { + "line": 531, + "column": 59 + } + } + }, + "range": [ + 18690, + 18741 + ], + "loc": { + "start": { + "line": 531, + "column": 8 + }, + "end": { + "line": 531, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 18686, + 18742 + ], + "loc": { + "start": { + "line": 531, + "column": 4 + }, + "end": { + "line": 531, + "column": 60 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 18751, + 18767 + ], + "loc": { + "start": { + "line": 532, + "column": 8 + }, + "end": { + "line": 532, + "column": 24 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 18781, + 18796 + ], + "loc": { + "start": { + "line": 533, + "column": 10 + }, + "end": { + "line": 533, + "column": 25 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 18801, + 18812 + ], + "loc": { + "start": { + "line": 533, + "column": 30 + }, + "end": { + "line": 533, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 18813, + 18820 + ], + "loc": { + "start": { + "line": 533, + "column": 42 + }, + "end": { + "line": 533, + "column": 49 + } + } + }, + "range": [ + 18801, + 18820 + ], + "loc": { + "start": { + "line": 533, + "column": 30 + }, + "end": { + "line": 533, + "column": 49 + } + } + } + ], + "range": [ + 18799, + 18822 + ], + "loc": { + "start": { + "line": 533, + "column": 28 + }, + "end": { + "line": 533, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "concat", + "range": [ + 18823, + 18829 + ], + "loc": { + "start": { + "line": 533, + "column": 52 + }, + "end": { + "line": 533, + "column": 58 + } + } + }, + "range": [ + 18799, + 18829 + ], + "loc": { + "start": { + "line": 533, + "column": 28 + }, + "end": { + "line": 533, + "column": 58 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceDefinition", + "range": [ + 18830, + 18846 + ], + "loc": { + "start": { + "line": 533, + "column": 59 + }, + "end": { + "line": 533, + "column": 75 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 18847, + 18853 + ], + "loc": { + "start": { + "line": 533, + "column": 76 + }, + "end": { + "line": 533, + "column": 82 + } + } + }, + "range": [ + 18830, + 18853 + ], + "loc": { + "start": { + "line": 533, + "column": 59 + }, + "end": { + "line": 533, + "column": 82 + } + } + } + ], + "range": [ + 18799, + 18854 + ], + "loc": { + "start": { + "line": 533, + "column": 28 + }, + "end": { + "line": 533, + "column": 83 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 18855, + 18859 + ], + "loc": { + "start": { + "line": 533, + "column": 84 + }, + "end": { + "line": 533, + "column": 88 + } + } + }, + "range": [ + 18799, + 18859 + ], + "loc": { + "start": { + "line": 533, + "column": 28 + }, + "end": { + "line": 533, + "column": 88 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 18860, + 18861 + ], + "loc": { + "start": { + "line": 533, + "column": 89 + }, + "end": { + "line": 533, + "column": 90 + } + } + } + ], + "body": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 18865, + 18881 + ], + "loc": { + "start": { + "line": 533, + "column": 94 + }, + "end": { + "line": 533, + "column": 110 + } + } + }, + "property": { + "type": "Identifier", + "name": "x", + "range": [ + 18882, + 18883 + ], + "loc": { + "start": { + "line": 533, + "column": 111 + }, + "end": { + "line": 533, + "column": 112 + } + } + }, + "range": [ + 18865, + 18884 + ], + "loc": { + "start": { + "line": 533, + "column": 94 + }, + "end": { + "line": 533, + "column": 113 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 18860, + 18884 + ], + "loc": { + "start": { + "line": 533, + "column": 89 + }, + "end": { + "line": 533, + "column": 113 + } + } + } + ], + "range": [ + 18799, + 18885 + ], + "loc": { + "start": { + "line": 533, + "column": 28 + }, + "end": { + "line": 533, + "column": 114 + } + } + }, + "range": [ + 18781, + 18885 + ], + "loc": { + "start": { + "line": 533, + "column": 10 + }, + "end": { + "line": 533, + "column": 114 + } + } + } + ], + "kind": "let", + "range": [ + 18777, + 18886 + ], + "loc": { + "start": { + "line": 533, + "column": 6 + }, + "end": { + "line": 533, + "column": 115 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetField", + "range": [ + 18897, + 18908 + ], + "loc": { + "start": { + "line": 534, + "column": 10 + }, + "end": { + "line": 534, + "column": 21 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 18911, + 18927 + ], + "loc": { + "start": { + "line": 534, + "column": 24 + }, + "end": { + "line": 534, + "column": 40 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 18931, + 18947 + ], + "loc": { + "start": { + "line": 534, + "column": 44 + }, + "end": { + "line": 534, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 18948, + 18963 + ], + "loc": { + "start": { + "line": 534, + "column": 61 + }, + "end": { + "line": 534, + "column": 76 + } + } + }, + "range": [ + 18931, + 18964 + ], + "loc": { + "start": { + "line": 534, + "column": 44 + }, + "end": { + "line": 534, + "column": 77 + } + } + }, + "range": [ + 18911, + 18964 + ], + "loc": { + "start": { + "line": 534, + "column": 24 + }, + "end": { + "line": 534, + "column": 77 + } + } + }, + "range": [ + 18897, + 18964 + ], + "loc": { + "start": { + "line": 534, + "column": 10 + }, + "end": { + "line": 534, + "column": 77 + } + } + } + ], + "kind": "let", + "range": [ + 18893, + 18965 + ], + "loc": { + "start": { + "line": 534, + "column": 6 + }, + "end": { + "line": 534, + "column": 78 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 18972, + 18986 + ], + "loc": { + "start": { + "line": 535, + "column": 6 + }, + "end": { + "line": 535, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 18987, + 18998 + ], + "loc": { + "start": { + "line": 535, + "column": 21 + }, + "end": { + "line": 535, + "column": 32 + } + } + }, + "range": [ + 18972, + 18998 + ], + "loc": { + "start": { + "line": 535, + "column": 6 + }, + "end": { + "line": 535, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 18999, + 19003 + ], + "loc": { + "start": { + "line": 535, + "column": 33 + }, + "end": { + "line": 535, + "column": 37 + } + } + }, + "range": [ + 18972, + 19003 + ], + "loc": { + "start": { + "line": 535, + "column": 6 + }, + "end": { + "line": 535, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 19006, + 19010 + ], + "loc": { + "start": { + "line": 535, + "column": 40 + }, + "end": { + "line": 535, + "column": 44 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19012, + 19026 + ], + "loc": { + "start": { + "line": 535, + "column": 46 + }, + "end": { + "line": 535, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19027, + 19031 + ], + "loc": { + "start": { + "line": 535, + "column": 61 + }, + "end": { + "line": 535, + "column": 65 + } + } + }, + "range": [ + 19012, + 19031 + ], + "loc": { + "start": { + "line": 535, + "column": 46 + }, + "end": { + "line": 535, + "column": 65 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19006, + 19031 + ], + "loc": { + "start": { + "line": 535, + "column": 40 + }, + "end": { + "line": 535, + "column": 65 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 19033, + 19035 + ], + "loc": { + "start": { + "line": 535, + "column": 67 + }, + "end": { + "line": 535, + "column": 69 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19037, + 19051 + ], + "loc": { + "start": { + "line": 535, + "column": 71 + }, + "end": { + "line": 535, + "column": 85 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 19052, + 19054 + ], + "loc": { + "start": { + "line": 535, + "column": 86 + }, + "end": { + "line": 535, + "column": 88 + } + } + }, + "range": [ + 19037, + 19054 + ], + "loc": { + "start": { + "line": 535, + "column": 71 + }, + "end": { + "line": 535, + "column": 88 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19033, + 19054 + ], + "loc": { + "start": { + "line": 535, + "column": 67 + }, + "end": { + "line": 535, + "column": 88 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19056, + 19065 + ], + "loc": { + "start": { + "line": 535, + "column": 90 + }, + "end": { + "line": 535, + "column": 99 + } + } + }, + "value": { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 19067, + 19082 + ], + "loc": { + "start": { + "line": 535, + "column": 101 + }, + "end": { + "line": 535, + "column": 116 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19056, + 19082 + ], + "loc": { + "start": { + "line": 535, + "column": 90 + }, + "end": { + "line": 535, + "column": 116 + } + } + } + ], + "range": [ + 19004, + 19084 + ], + "loc": { + "start": { + "line": 535, + "column": 38 + }, + "end": { + "line": 535, + "column": 118 + } + } + } + ], + "range": [ + 18972, + 19085 + ], + "loc": { + "start": { + "line": 535, + "column": 6 + }, + "end": { + "line": 535, + "column": 119 + } + } + }, + "range": [ + 18972, + 19086 + ], + "loc": { + "start": { + "line": 535, + "column": 6 + }, + "end": { + "line": 535, + "column": 120 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetField", + "range": [ + 19097, + 19108 + ], + "loc": { + "start": { + "line": 536, + "column": 10 + }, + "end": { + "line": 536, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 19124, + 19135 + ], + "loc": { + "start": { + "line": 537, + "column": 12 + }, + "end": { + "line": 537, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19136, + 19140 + ], + "loc": { + "start": { + "line": 537, + "column": 24 + }, + "end": { + "line": 537, + "column": 28 + } + } + }, + "range": [ + 19124, + 19140 + ], + "loc": { + "start": { + "line": 537, + "column": 12 + }, + "end": { + "line": 537, + "column": 28 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 19145, + 19154 + ], + "loc": { + "start": { + "line": 537, + "column": 33 + }, + "end": { + "line": 537, + "column": 42 + } + } + }, + "range": [ + 19124, + 19154 + ], + "loc": { + "start": { + "line": 537, + "column": 12 + }, + "end": { + "line": 537, + "column": 42 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19168, + 19182 + ], + "loc": { + "start": { + "line": 538, + "column": 10 + }, + "end": { + "line": 538, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 19183, + 19194 + ], + "loc": { + "start": { + "line": 538, + "column": 25 + }, + "end": { + "line": 538, + "column": 36 + } + } + }, + "range": [ + 19168, + 19194 + ], + "loc": { + "start": { + "line": 538, + "column": 10 + }, + "end": { + "line": 538, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 19195, + 19199 + ], + "loc": { + "start": { + "line": 538, + "column": 37 + }, + "end": { + "line": 538, + "column": 41 + } + } + }, + "range": [ + 19168, + 19199 + ], + "loc": { + "start": { + "line": 538, + "column": 10 + }, + "end": { + "line": 538, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 19202, + 19206 + ], + "loc": { + "start": { + "line": 538, + "column": 44 + }, + "end": { + "line": 538, + "column": 48 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19208, + 19222 + ], + "loc": { + "start": { + "line": 538, + "column": 50 + }, + "end": { + "line": 538, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19223, + 19227 + ], + "loc": { + "start": { + "line": 538, + "column": 65 + }, + "end": { + "line": 538, + "column": 69 + } + } + }, + "range": [ + 19208, + 19227 + ], + "loc": { + "start": { + "line": 538, + "column": 50 + }, + "end": { + "line": 538, + "column": 69 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19202, + 19227 + ], + "loc": { + "start": { + "line": 538, + "column": 44 + }, + "end": { + "line": 538, + "column": 69 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 19229, + 19231 + ], + "loc": { + "start": { + "line": 538, + "column": 71 + }, + "end": { + "line": 538, + "column": 73 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19233, + 19247 + ], + "loc": { + "start": { + "line": 538, + "column": 75 + }, + "end": { + "line": 538, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 19248, + 19250 + ], + "loc": { + "start": { + "line": 538, + "column": 90 + }, + "end": { + "line": 538, + "column": 92 + } + } + }, + "range": [ + 19233, + 19250 + ], + "loc": { + "start": { + "line": 538, + "column": 75 + }, + "end": { + "line": 538, + "column": 92 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19229, + 19250 + ], + "loc": { + "start": { + "line": 538, + "column": 71 + }, + "end": { + "line": 538, + "column": 92 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19252, + 19261 + ], + "loc": { + "start": { + "line": 538, + "column": 94 + }, + "end": { + "line": 538, + "column": 103 + } + } + }, + "value": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19263, + 19278 + ], + "loc": { + "start": { + "line": 538, + "column": 105 + }, + "end": { + "line": 538, + "column": 120 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19252, + 19278 + ], + "loc": { + "start": { + "line": 538, + "column": 94 + }, + "end": { + "line": 538, + "column": 120 + } + } + } + ], + "range": [ + 19200, + 19280 + ], + "loc": { + "start": { + "line": 538, + "column": 42 + }, + "end": { + "line": 538, + "column": 122 + } + } + } + ], + "range": [ + 19168, + 19281 + ], + "loc": { + "start": { + "line": 538, + "column": 10 + }, + "end": { + "line": 538, + "column": 123 + } + } + }, + "range": [ + 19168, + 19282 + ], + "loc": { + "start": { + "line": 538, + "column": 10 + }, + "end": { + "line": 538, + "column": 124 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19293, + 19307 + ], + "loc": { + "start": { + "line": 539, + "column": 10 + }, + "end": { + "line": 539, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19308, + 19323 + ], + "loc": { + "start": { + "line": 539, + "column": 25 + }, + "end": { + "line": 539, + "column": 40 + } + } + }, + "range": [ + 19293, + 19324 + ], + "loc": { + "start": { + "line": 539, + "column": 10 + }, + "end": { + "line": 539, + "column": 41 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19327, + 19341 + ], + "loc": { + "start": { + "line": 539, + "column": 44 + }, + "end": { + "line": 539, + "column": 58 + } + } + }, + "range": [ + 19293, + 19341 + ], + "loc": { + "start": { + "line": 539, + "column": 10 + }, + "end": { + "line": 539, + "column": 58 + } + } + }, + "range": [ + 19293, + 19342 + ], + "loc": { + "start": { + "line": 539, + "column": 10 + }, + "end": { + "line": 539, + "column": 59 + } + } + } + ], + "range": [ + 19156, + 19352 + ], + "loc": { + "start": { + "line": 537, + "column": 44 + }, + "end": { + "line": 540, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 19362, + 19373 + ], + "loc": { + "start": { + "line": 540, + "column": 19 + }, + "end": { + "line": 540, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19374, + 19378 + ], + "loc": { + "start": { + "line": 540, + "column": 31 + }, + "end": { + "line": 540, + "column": 35 + } + } + }, + "range": [ + 19362, + 19378 + ], + "loc": { + "start": { + "line": 540, + "column": 19 + }, + "end": { + "line": 540, + "column": 35 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 19383, + 19393 + ], + "loc": { + "start": { + "line": 540, + "column": 40 + }, + "end": { + "line": 540, + "column": 50 + } + } + }, + "range": [ + 19362, + 19393 + ], + "loc": { + "start": { + "line": 540, + "column": 19 + }, + "end": { + "line": 540, + "column": 50 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19407, + 19421 + ], + "loc": { + "start": { + "line": 541, + "column": 10 + }, + "end": { + "line": 541, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 19422, + 19433 + ], + "loc": { + "start": { + "line": 541, + "column": 25 + }, + "end": { + "line": 541, + "column": 36 + } + } + }, + "range": [ + 19407, + 19433 + ], + "loc": { + "start": { + "line": 541, + "column": 10 + }, + "end": { + "line": 541, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 19434, + 19438 + ], + "loc": { + "start": { + "line": 541, + "column": 37 + }, + "end": { + "line": 541, + "column": 41 + } + } + }, + "range": [ + 19407, + 19438 + ], + "loc": { + "start": { + "line": 541, + "column": 10 + }, + "end": { + "line": 541, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 19441, + 19445 + ], + "loc": { + "start": { + "line": 541, + "column": 44 + }, + "end": { + "line": 541, + "column": 48 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19447, + 19461 + ], + "loc": { + "start": { + "line": 541, + "column": 50 + }, + "end": { + "line": 541, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19462, + 19466 + ], + "loc": { + "start": { + "line": 541, + "column": 65 + }, + "end": { + "line": 541, + "column": 69 + } + } + }, + "range": [ + 19447, + 19466 + ], + "loc": { + "start": { + "line": 541, + "column": 50 + }, + "end": { + "line": 541, + "column": 69 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19441, + 19466 + ], + "loc": { + "start": { + "line": 541, + "column": 44 + }, + "end": { + "line": 541, + "column": 69 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 19468, + 19470 + ], + "loc": { + "start": { + "line": 541, + "column": 71 + }, + "end": { + "line": 541, + "column": 73 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19472, + 19486 + ], + "loc": { + "start": { + "line": 541, + "column": 75 + }, + "end": { + "line": 541, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 19487, + 19489 + ], + "loc": { + "start": { + "line": 541, + "column": 90 + }, + "end": { + "line": 541, + "column": 92 + } + } + }, + "range": [ + 19472, + 19489 + ], + "loc": { + "start": { + "line": 541, + "column": 75 + }, + "end": { + "line": 541, + "column": 92 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19468, + 19489 + ], + "loc": { + "start": { + "line": 541, + "column": 71 + }, + "end": { + "line": 541, + "column": 92 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19491, + 19500 + ], + "loc": { + "start": { + "line": 541, + "column": 94 + }, + "end": { + "line": 541, + "column": 103 + } + } + }, + "value": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19502, + 19517 + ], + "loc": { + "start": { + "line": 541, + "column": 105 + }, + "end": { + "line": 541, + "column": 120 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 19491, + 19517 + ], + "loc": { + "start": { + "line": 541, + "column": 94 + }, + "end": { + "line": 541, + "column": 120 + } + } + } + ], + "range": [ + 19439, + 19519 + ], + "loc": { + "start": { + "line": 541, + "column": 42 + }, + "end": { + "line": 541, + "column": 122 + } + } + } + ], + "range": [ + 19407, + 19520 + ], + "loc": { + "start": { + "line": 541, + "column": 10 + }, + "end": { + "line": 541, + "column": 123 + } + } + }, + "range": [ + 19407, + 19521 + ], + "loc": { + "start": { + "line": 541, + "column": 10 + }, + "end": { + "line": 541, + "column": 124 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19536, + 19550 + ], + "loc": { + "start": { + "line": 542, + "column": 14 + }, + "end": { + "line": 542, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19551, + 19566 + ], + "loc": { + "start": { + "line": 542, + "column": 29 + }, + "end": { + "line": 542, + "column": 44 + } + } + }, + "range": [ + 19536, + 19567 + ], + "loc": { + "start": { + "line": 542, + "column": 14 + }, + "end": { + "line": 542, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 19568, + 19575 + ], + "loc": { + "start": { + "line": 542, + "column": 46 + }, + "end": { + "line": 542, + "column": 53 + } + } + }, + "range": [ + 19536, + 19575 + ], + "loc": { + "start": { + "line": 542, + "column": 14 + }, + "end": { + "line": 542, + "column": 53 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19576, + 19590 + ], + "loc": { + "start": { + "line": 542, + "column": 54 + }, + "end": { + "line": 542, + "column": 68 + } + } + } + ], + "range": [ + 19536, + 19591 + ], + "loc": { + "start": { + "line": 542, + "column": 14 + }, + "end": { + "line": 542, + "column": 69 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 19597, + 19598 + ], + "loc": { + "start": { + "line": 542, + "column": 75 + }, + "end": { + "line": 542, + "column": 76 + } + } + }, + "prefix": true, + "range": [ + 19596, + 19598 + ], + "loc": { + "start": { + "line": 542, + "column": 74 + }, + "end": { + "line": 542, + "column": 76 + } + } + }, + "range": [ + 19536, + 19598 + ], + "loc": { + "start": { + "line": 542, + "column": 14 + }, + "end": { + "line": 542, + "column": 76 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 19614, + 19628 + ], + "loc": { + "start": { + "line": 543, + "column": 12 + }, + "end": { + "line": 543, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19629, + 19644 + ], + "loc": { + "start": { + "line": 543, + "column": 27 + }, + "end": { + "line": 543, + "column": 42 + } + } + }, + "range": [ + 19614, + 19645 + ], + "loc": { + "start": { + "line": 543, + "column": 12 + }, + "end": { + "line": 543, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 19646, + 19650 + ], + "loc": { + "start": { + "line": 543, + "column": 44 + }, + "end": { + "line": 543, + "column": 48 + } + } + }, + "range": [ + 19614, + 19650 + ], + "loc": { + "start": { + "line": 543, + "column": 12 + }, + "end": { + "line": 543, + "column": 48 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 19651, + 19665 + ], + "loc": { + "start": { + "line": 543, + "column": 49 + }, + "end": { + "line": 543, + "column": 63 + } + } + } + ], + "range": [ + 19614, + 19666 + ], + "loc": { + "start": { + "line": 543, + "column": 12 + }, + "end": { + "line": 543, + "column": 64 + } + } + }, + "range": [ + 19614, + 19667 + ], + "loc": { + "start": { + "line": 543, + "column": 12 + }, + "end": { + "line": 543, + "column": 65 + } + } + } + ], + "range": [ + 19600, + 19679 + ], + "loc": { + "start": { + "line": 542, + "column": 78 + }, + "end": { + "line": 544, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 19532, + 19679 + ], + "loc": { + "start": { + "line": 542, + "column": 10 + }, + "end": { + "line": 544, + "column": 11 + } + } + } + ], + "range": [ + 19395, + 19689 + ], + "loc": { + "start": { + "line": 540, + "column": 52 + }, + "end": { + "line": 545, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 19699, + 19710 + ], + "loc": { + "start": { + "line": 545, + "column": 19 + }, + "end": { + "line": 545, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19711, + 19715 + ], + "loc": { + "start": { + "line": 545, + "column": 31 + }, + "end": { + "line": 545, + "column": 35 + } + } + }, + "range": [ + 19699, + 19715 + ], + "loc": { + "start": { + "line": 545, + "column": 19 + }, + "end": { + "line": 545, + "column": 35 + } + } + }, + "right": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 19720, + 19726 + ], + "loc": { + "start": { + "line": 545, + "column": 40 + }, + "end": { + "line": 545, + "column": 46 + } + } + }, + "range": [ + 19699, + 19726 + ], + "loc": { + "start": { + "line": 545, + "column": 19 + }, + "end": { + "line": 545, + "column": 46 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 19750, + 19755 + ], + "loc": { + "start": { + "line": 546, + "column": 20 + }, + "end": { + "line": 546, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 19756, + 19793 + ], + "loc": { + "start": { + "line": 546, + "column": 26 + }, + "end": { + "line": 546, + "column": 63 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is an attribute ('", + "cooked": "' is an attribute ('" + }, + "tail": false, + "range": [ + 19808, + 19831 + ], + "loc": { + "start": { + "line": 546, + "column": 78 + }, + "end": { + "line": 546, + "column": 101 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 19846, + 19850 + ], + "loc": { + "start": { + "line": 546, + "column": 116 + }, + "end": { + "line": 546, + "column": 120 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 19793, + 19808 + ], + "loc": { + "start": { + "line": 546, + "column": 63 + }, + "end": { + "line": 546, + "column": 78 + } + } + }, + { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 19831, + 19846 + ], + "loc": { + "start": { + "line": 546, + "column": 101 + }, + "end": { + "line": 546, + "column": 116 + } + } + } + ], + "range": [ + 19756, + 19850 + ], + "loc": { + "start": { + "line": 546, + "column": 26 + }, + "end": { + "line": 546, + "column": 120 + } + } + } + ], + "range": [ + 19746, + 19851 + ], + "loc": { + "start": { + "line": 546, + "column": 16 + }, + "end": { + "line": 546, + "column": 121 + } + } + }, + "range": [ + 19740, + 19852 + ], + "loc": { + "start": { + "line": 546, + "column": 10 + }, + "end": { + "line": 546, + "column": 122 + } + } + } + ], + "range": [ + 19728, + 19862 + ], + "loc": { + "start": { + "line": 545, + "column": 48 + }, + "end": { + "line": 547, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 19695, + 19862 + ], + "loc": { + "start": { + "line": 545, + "column": 15 + }, + "end": { + "line": 547, + "column": 9 + } + } + }, + "range": [ + 19358, + 19862 + ], + "loc": { + "start": { + "line": 540, + "column": 15 + }, + "end": { + "line": 547, + "column": 9 + } + } + }, + "range": [ + 19120, + 19862 + ], + "loc": { + "start": { + "line": 537, + "column": 8 + }, + "end": { + "line": 547, + "column": 9 + } + } + } + ], + "range": [ + 19110, + 19870 + ], + "loc": { + "start": { + "line": 536, + "column": 23 + }, + "end": { + "line": 548, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 19880, + 19891 + ], + "loc": { + "start": { + "line": 548, + "column": 17 + }, + "end": { + "line": 548, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 19892, + 19899 + ], + "loc": { + "start": { + "line": 548, + "column": 29 + }, + "end": { + "line": 548, + "column": 36 + } + } + }, + "range": [ + 19880, + 19899 + ], + "loc": { + "start": { + "line": 548, + "column": 17 + }, + "end": { + "line": 548, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 19921, + 19926 + ], + "loc": { + "start": { + "line": 549, + "column": 18 + }, + "end": { + "line": 549, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 19927, + 19964 + ], + "loc": { + "start": { + "line": 549, + "column": 24 + }, + "end": { + "line": 549, + "column": 61 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is missing ('", + "cooked": "' is missing ('" + }, + "tail": false, + "range": [ + 19979, + 19997 + ], + "loc": { + "start": { + "line": 549, + "column": 76 + }, + "end": { + "line": 549, + "column": 94 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 20016, + 20020 + ], + "loc": { + "start": { + "line": 549, + "column": 113 + }, + "end": { + "line": 549, + "column": 117 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 19964, + 19979 + ], + "loc": { + "start": { + "line": 549, + "column": 61 + }, + "end": { + "line": 549, + "column": 76 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 19997, + 20008 + ], + "loc": { + "start": { + "line": 549, + "column": 94 + }, + "end": { + "line": 549, + "column": 105 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 20009, + 20016 + ], + "loc": { + "start": { + "line": 549, + "column": 106 + }, + "end": { + "line": 549, + "column": 113 + } + } + }, + "range": [ + 19997, + 20016 + ], + "loc": { + "start": { + "line": 549, + "column": 94 + }, + "end": { + "line": 549, + "column": 113 + } + } + } + ], + "range": [ + 19927, + 20020 + ], + "loc": { + "start": { + "line": 549, + "column": 24 + }, + "end": { + "line": 549, + "column": 117 + } + } + } + ], + "range": [ + 19917, + 20021 + ], + "loc": { + "start": { + "line": 549, + "column": 14 + }, + "end": { + "line": 549, + "column": 118 + } + } + }, + "range": [ + 19911, + 20022 + ], + "loc": { + "start": { + "line": 549, + "column": 8 + }, + "end": { + "line": 549, + "column": 119 + } + } + } + ], + "range": [ + 19901, + 20030 + ], + "loc": { + "start": { + "line": 548, + "column": 38 + }, + "end": { + "line": 550, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 19876, + 20030 + ], + "loc": { + "start": { + "line": 548, + "column": 13 + }, + "end": { + "line": 550, + "column": 7 + } + } + }, + "range": [ + 19093, + 20030 + ], + "loc": { + "start": { + "line": 536, + "column": 6 + }, + "end": { + "line": 550, + "column": 7 + } + } + } + ], + "range": [ + 18769, + 20036 + ], + "loc": { + "start": { + "line": 532, + "column": 26 + }, + "end": { + "line": 551, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 18747, + 20036 + ], + "loc": { + "start": { + "line": 532, + "column": 4 + }, + "end": { + "line": 551, + "column": 5 + } + } + } + ], + "range": [ + 18619, + 20040 + ], + "loc": { + "start": { + "line": 529, + "column": 88 + }, + "end": { + "line": 552, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 18556, + 20040 + ], + "loc": { + "start": { + "line": 529, + "column": 25 + }, + "end": { + "line": 552, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 18533, + 20040 + ], + "loc": { + "start": { + "line": 529, + "column": 2 + }, + "end": { + "line": 552, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_remove", + "range": [ + 20044, + 20051 + ], + "loc": { + "start": { + "line": 554, + "column": 2 + }, + "end": { + "line": 554, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20052, + 20060 + ], + "loc": { + "start": { + "line": 554, + "column": 10 + }, + "end": { + "line": 554, + "column": 18 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20068, + 20076 + ], + "loc": { + "start": { + "line": 555, + "column": 4 + }, + "end": { + "line": 555, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 20077, + 20088 + ], + "loc": { + "start": { + "line": 555, + "column": 13 + }, + "end": { + "line": 555, + "column": 24 + } + } + }, + "range": [ + 20068, + 20088 + ], + "loc": { + "start": { + "line": 555, + "column": 4 + }, + "end": { + "line": 555, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 20089, + 20096 + ], + "loc": { + "start": { + "line": 555, + "column": 25 + }, + "end": { + "line": 555, + "column": 32 + } + } + }, + "range": [ + 20068, + 20096 + ], + "loc": { + "start": { + "line": 555, + "column": 4 + }, + "end": { + "line": 555, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "dependent", + "range": [ + 20097, + 20106 + ], + "loc": { + "start": { + "line": 555, + "column": 33 + }, + "end": { + "line": 555, + "column": 42 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20122, + 20139 + ], + "loc": { + "start": { + "line": 556, + "column": 10 + }, + "end": { + "line": 556, + "column": 27 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20142, + 20146 + ], + "loc": { + "start": { + "line": 556, + "column": 30 + }, + "end": { + "line": 556, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 20147, + 20152 + ], + "loc": { + "start": { + "line": 556, + "column": 35 + }, + "end": { + "line": 556, + "column": 40 + } + } + }, + "range": [ + 20142, + 20152 + ], + "loc": { + "start": { + "line": 556, + "column": 30 + }, + "end": { + "line": 556, + "column": 40 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20153, + 20162 + ], + "loc": { + "start": { + "line": 556, + "column": 41 + }, + "end": { + "line": 556, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20163, + 20167 + ], + "loc": { + "start": { + "line": 556, + "column": 51 + }, + "end": { + "line": 556, + "column": 55 + } + } + }, + "range": [ + 20153, + 20167 + ], + "loc": { + "start": { + "line": 556, + "column": 41 + }, + "end": { + "line": 556, + "column": 55 + } + } + }, + "range": [ + 20142, + 20168 + ], + "loc": { + "start": { + "line": 556, + "column": 30 + }, + "end": { + "line": 556, + "column": 56 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20169, + 20178 + ], + "loc": { + "start": { + "line": 556, + "column": 57 + }, + "end": { + "line": 556, + "column": 66 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 20179, + 20181 + ], + "loc": { + "start": { + "line": 556, + "column": 67 + }, + "end": { + "line": 556, + "column": 69 + } + } + }, + "range": [ + 20169, + 20181 + ], + "loc": { + "start": { + "line": 556, + "column": 57 + }, + "end": { + "line": 556, + "column": 69 + } + } + }, + "range": [ + 20142, + 20182 + ], + "loc": { + "start": { + "line": 556, + "column": 30 + }, + "end": { + "line": 556, + "column": 70 + } + } + }, + "range": [ + 20122, + 20182 + ], + "loc": { + "start": { + "line": 556, + "column": 10 + }, + "end": { + "line": 556, + "column": 70 + } + } + } + ], + "kind": "let", + "range": [ + 20118, + 20183 + ], + "loc": { + "start": { + "line": 556, + "column": 6 + }, + "end": { + "line": 556, + "column": 71 + } + } + }, + { + "type": "SwitchStatement", + "discriminant": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20198, + 20202 + ], + "loc": { + "start": { + "line": 557, + "column": 14 + }, + "end": { + "line": 557, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 20203, + 20209 + ], + "loc": { + "start": { + "line": 557, + "column": 19 + }, + "end": { + "line": 557, + "column": 25 + } + } + }, + "range": [ + 20198, + 20209 + ], + "loc": { + "start": { + "line": 557, + "column": 14 + }, + "end": { + "line": 557, + "column": 25 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20210, + 20219 + ], + "loc": { + "start": { + "line": 557, + "column": 26 + }, + "end": { + "line": 557, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20220, + 20224 + ], + "loc": { + "start": { + "line": 557, + "column": 36 + }, + "end": { + "line": 557, + "column": 40 + } + } + }, + "range": [ + 20210, + 20224 + ], + "loc": { + "start": { + "line": 557, + "column": 26 + }, + "end": { + "line": 557, + "column": 40 + } + } + }, + "range": [ + 20198, + 20225 + ], + "loc": { + "start": { + "line": 557, + "column": 14 + }, + "end": { + "line": 557, + "column": 41 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20226, + 20235 + ], + "loc": { + "start": { + "line": 557, + "column": 42 + }, + "end": { + "line": 557, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20236, + 20245 + ], + "loc": { + "start": { + "line": 557, + "column": 52 + }, + "end": { + "line": 557, + "column": 61 + } + } + }, + "range": [ + 20226, + 20245 + ], + "loc": { + "start": { + "line": 557, + "column": 42 + }, + "end": { + "line": 557, + "column": 61 + } + } + }, + "range": [ + 20198, + 20246 + ], + "loc": { + "start": { + "line": 557, + "column": 14 + }, + "end": { + "line": 557, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20247, + 20251 + ], + "loc": { + "start": { + "line": 557, + "column": 63 + }, + "end": { + "line": 557, + "column": 67 + } + } + }, + "range": [ + 20198, + 20251 + ], + "loc": { + "start": { + "line": 557, + "column": 14 + }, + "end": { + "line": 557, + "column": 67 + } + } + }, + "cases": [ + { + "type": "SwitchCase", + "test": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 20268, + 20277 + ], + "loc": { + "start": { + "line": 558, + "column": 13 + }, + "end": { + "line": 558, + "column": 22 + } + } + }, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20291, + 20308 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 27 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20309, + 20318 + ], + "loc": { + "start": { + "line": 559, + "column": 28 + }, + "end": { + "line": 559, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20319, + 20328 + ], + "loc": { + "start": { + "line": 559, + "column": 38 + }, + "end": { + "line": 559, + "column": 47 + } + } + }, + "range": [ + 20309, + 20328 + ], + "loc": { + "start": { + "line": 559, + "column": 28 + }, + "end": { + "line": 559, + "column": 47 + } + } + }, + "range": [ + 20291, + 20329 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 48 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 20332, + 20336 + ], + "loc": { + "start": { + "line": 559, + "column": 51 + }, + "end": { + "line": 559, + "column": 55 + } + } + }, + "range": [ + 20291, + 20336 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 55 + } + } + }, + "range": [ + 20291, + 20337 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 56 + } + } + }, + { + "type": "BreakStatement", + "label": null, + "range": [ + 20348, + 20354 + ], + "loc": { + "start": { + "line": 560, + "column": 10 + }, + "end": { + "line": 560, + "column": 16 + } + } + } + ], + "range": [ + 20279, + 20364 + ], + "loc": { + "start": { + "line": 558, + "column": 24 + }, + "end": { + "line": 561, + "column": 9 + } + } + } + ], + "range": [ + 20263, + 20364 + ], + "loc": { + "start": { + "line": 558, + "column": 8 + }, + "end": { + "line": 561, + "column": 9 + } + } + }, + { + "type": "SwitchCase", + "test": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 20378, + 20388 + ], + "loc": { + "start": { + "line": 562, + "column": 13 + }, + "end": { + "line": 562, + "column": 23 + } + } + }, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "index", + "range": [ + 20406, + 20411 + ], + "loc": { + "start": { + "line": 563, + "column": 14 + }, + "end": { + "line": 563, + "column": 19 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20414, + 20431 + ], + "loc": { + "start": { + "line": 563, + "column": 22 + }, + "end": { + "line": 563, + "column": 39 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20432, + 20441 + ], + "loc": { + "start": { + "line": 563, + "column": 40 + }, + "end": { + "line": 563, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20442, + 20451 + ], + "loc": { + "start": { + "line": 563, + "column": 50 + }, + "end": { + "line": 563, + "column": 59 + } + } + }, + "range": [ + 20432, + 20451 + ], + "loc": { + "start": { + "line": 563, + "column": 40 + }, + "end": { + "line": 563, + "column": 59 + } + } + }, + "range": [ + 20414, + 20452 + ], + "loc": { + "start": { + "line": 563, + "column": 22 + }, + "end": { + "line": 563, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 20453, + 20460 + ], + "loc": { + "start": { + "line": 563, + "column": 61 + }, + "end": { + "line": 563, + "column": 68 + } + } + }, + "range": [ + 20414, + 20460 + ], + "loc": { + "start": { + "line": 563, + "column": 22 + }, + "end": { + "line": 563, + "column": 68 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20461, + 20469 + ], + "loc": { + "start": { + "line": 563, + "column": 69 + }, + "end": { + "line": 563, + "column": 77 + } + } + } + ], + "range": [ + 20414, + 20470 + ], + "loc": { + "start": { + "line": 563, + "column": 22 + }, + "end": { + "line": 563, + "column": 78 + } + } + }, + "range": [ + 20406, + 20470 + ], + "loc": { + "start": { + "line": 563, + "column": 14 + }, + "end": { + "line": 563, + "column": 78 + } + } + } + ], + "kind": "let", + "range": [ + 20402, + 20471 + ], + "loc": { + "start": { + "line": 563, + "column": 10 + }, + "end": { + "line": 563, + "column": 79 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "Identifier", + "name": "index", + "range": [ + 20486, + 20491 + ], + "loc": { + "start": { + "line": 564, + "column": 14 + }, + "end": { + "line": 564, + "column": 19 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 20497, + 20498 + ], + "loc": { + "start": { + "line": 564, + "column": 25 + }, + "end": { + "line": 564, + "column": 26 + } + } + }, + "prefix": true, + "range": [ + 20496, + 20498 + ], + "loc": { + "start": { + "line": 564, + "column": 24 + }, + "end": { + "line": 564, + "column": 26 + } + } + }, + "range": [ + 20486, + 20498 + ], + "loc": { + "start": { + "line": 564, + "column": 14 + }, + "end": { + "line": 564, + "column": 26 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20514, + 20531 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 29 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 20532, + 20541 + ], + "loc": { + "start": { + "line": 565, + "column": 30 + }, + "end": { + "line": 565, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20542, + 20551 + ], + "loc": { + "start": { + "line": 565, + "column": 40 + }, + "end": { + "line": 565, + "column": 49 + } + } + }, + "range": [ + 20532, + 20551 + ], + "loc": { + "start": { + "line": 565, + "column": 30 + }, + "end": { + "line": 565, + "column": 49 + } + } + }, + "range": [ + 20514, + 20552 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "splice", + "range": [ + 20553, + 20559 + ], + "loc": { + "start": { + "line": 565, + "column": 51 + }, + "end": { + "line": 565, + "column": 57 + } + } + }, + "range": [ + 20514, + 20559 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 57 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "index", + "range": [ + 20560, + 20565 + ], + "loc": { + "start": { + "line": 565, + "column": 58 + }, + "end": { + "line": 565, + "column": 63 + } + } + }, + { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 20567, + 20568 + ], + "loc": { + "start": { + "line": 565, + "column": 65 + }, + "end": { + "line": 565, + "column": 66 + } + } + } + ], + "range": [ + 20514, + 20569 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 67 + } + } + }, + "range": [ + 20514, + 20570 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 68 + } + } + } + ], + "range": [ + 20500, + 20582 + ], + "loc": { + "start": { + "line": 564, + "column": 28 + }, + "end": { + "line": 566, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 20482, + 20582 + ], + "loc": { + "start": { + "line": 564, + "column": 10 + }, + "end": { + "line": 566, + "column": 11 + } + } + }, + { + "type": "BreakStatement", + "label": null, + "range": [ + 20593, + 20599 + ], + "loc": { + "start": { + "line": 567, + "column": 10 + }, + "end": { + "line": 567, + "column": 16 + } + } + } + ], + "range": [ + 20390, + 20609 + ], + "loc": { + "start": { + "line": 562, + "column": 25 + }, + "end": { + "line": 568, + "column": 9 + } + } + } + ], + "range": [ + 20373, + 20609 + ], + "loc": { + "start": { + "line": 562, + "column": 8 + }, + "end": { + "line": 568, + "column": 9 + } + } + }, + { + "type": "SwitchCase", + "test": null, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "BreakStatement", + "label": null, + "range": [ + 20639, + 20645 + ], + "loc": { + "start": { + "line": 570, + "column": 10 + }, + "end": { + "line": 570, + "column": 16 + } + } + } + ], + "range": [ + 20627, + 20655 + ], + "loc": { + "start": { + "line": 569, + "column": 17 + }, + "end": { + "line": 571, + "column": 9 + } + } + } + ], + "range": [ + 20618, + 20655 + ], + "loc": { + "start": { + "line": 569, + "column": 8 + }, + "end": { + "line": 571, + "column": 9 + } + } + } + ], + "range": [ + 20190, + 20663 + ], + "loc": { + "start": { + "line": 557, + "column": 6 + }, + "end": { + "line": 572, + "column": 7 + } + }, + "trailingComments": [ + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 20670, + 20729 + ], + "loc": { + "start": { + "line": 573, + "column": 6 + }, + "end": { + "line": 573, + "column": 65 + } + } + } + ] + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20736, + 20753 + ], + "loc": { + "start": { + "line": 574, + "column": 6 + }, + "end": { + "line": 574, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 20754, + 20765 + ], + "loc": { + "start": { + "line": 574, + "column": 24 + }, + "end": { + "line": 574, + "column": 35 + } + } + }, + "range": [ + 20736, + 20765 + ], + "loc": { + "start": { + "line": 574, + "column": 6 + }, + "end": { + "line": 574, + "column": 35 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 20768, + 20785 + ], + "loc": { + "start": { + "line": 574, + "column": 38 + }, + "end": { + "line": 574, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 20786, + 20797 + ], + "loc": { + "start": { + "line": 574, + "column": 56 + }, + "end": { + "line": 574, + "column": 67 + } + } + }, + "range": [ + 20768, + 20797 + ], + "loc": { + "start": { + "line": 574, + "column": 38 + }, + "end": { + "line": 574, + "column": 67 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 20798, + 20804 + ], + "loc": { + "start": { + "line": 574, + "column": 68 + }, + "end": { + "line": 574, + "column": 74 + } + } + }, + "range": [ + 20768, + 20804 + ], + "loc": { + "start": { + "line": 574, + "column": 38 + }, + "end": { + "line": 574, + "column": 74 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 20805, + 20806 + ], + "loc": { + "start": { + "line": 574, + "column": 75 + }, + "end": { + "line": 574, + "column": 76 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 20829, + 20830 + ], + "loc": { + "start": { + "line": 575, + "column": 17 + }, + "end": { + "line": 575, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20831, + 20835 + ], + "loc": { + "start": { + "line": 575, + "column": 19 + }, + "end": { + "line": 575, + "column": 23 + } + } + }, + "range": [ + 20829, + 20835 + ], + "loc": { + "start": { + "line": 575, + "column": 17 + }, + "end": { + "line": 575, + "column": 23 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20840, + 20848 + ], + "loc": { + "start": { + "line": 575, + "column": 28 + }, + "end": { + "line": 575, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20849, + 20853 + ], + "loc": { + "start": { + "line": 575, + "column": 37 + }, + "end": { + "line": 575, + "column": 41 + } + } + }, + "range": [ + 20840, + 20853 + ], + "loc": { + "start": { + "line": 575, + "column": 28 + }, + "end": { + "line": 575, + "column": 41 + } + } + }, + "range": [ + 20829, + 20853 + ], + "loc": { + "start": { + "line": 575, + "column": 17 + }, + "end": { + "line": 575, + "column": 41 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 20857, + 20858 + ], + "loc": { + "start": { + "line": 575, + "column": 45 + }, + "end": { + "line": 575, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 20859, + 20861 + ], + "loc": { + "start": { + "line": 575, + "column": 47 + }, + "end": { + "line": 575, + "column": 49 + } + } + }, + "range": [ + 20857, + 20861 + ], + "loc": { + "start": { + "line": 575, + "column": 45 + }, + "end": { + "line": 575, + "column": 49 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20866, + 20874 + ], + "loc": { + "start": { + "line": 575, + "column": 54 + }, + "end": { + "line": 575, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 20875, + 20877 + ], + "loc": { + "start": { + "line": 575, + "column": 63 + }, + "end": { + "line": 575, + "column": 65 + } + } + }, + "range": [ + 20866, + 20877 + ], + "loc": { + "start": { + "line": 575, + "column": 54 + }, + "end": { + "line": 575, + "column": 65 + } + } + }, + "range": [ + 20857, + 20877 + ], + "loc": { + "start": { + "line": 575, + "column": 45 + }, + "end": { + "line": 575, + "column": 65 + } + } + }, + "range": [ + 20829, + 20877 + ], + "loc": { + "start": { + "line": 575, + "column": 17 + }, + "end": { + "line": 575, + "column": 65 + } + } + }, + "prefix": true, + "range": [ + 20827, + 20878 + ], + "loc": { + "start": { + "line": 575, + "column": 15 + }, + "end": { + "line": 575, + "column": 66 + } + } + }, + "range": [ + 20820, + 20879 + ], + "loc": { + "start": { + "line": 575, + "column": 8 + }, + "end": { + "line": 575, + "column": 67 + } + } + } + ], + "range": [ + 20810, + 20887 + ], + "loc": { + "start": { + "line": 574, + "column": 80 + }, + "end": { + "line": 576, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20805, + 20887 + ], + "loc": { + "start": { + "line": 574, + "column": 75 + }, + "end": { + "line": 576, + "column": 7 + } + } + } + ], + "range": [ + 20768, + 20888 + ], + "loc": { + "start": { + "line": 574, + "column": 38 + }, + "end": { + "line": 576, + "column": 8 + } + } + }, + "range": [ + 20736, + 20888 + ], + "loc": { + "start": { + "line": 574, + "column": 6 + }, + "end": { + "line": 576, + "column": 8 + } + } + }, + "range": [ + 20736, + 20889 + ], + "loc": { + "start": { + "line": 574, + "column": 6 + }, + "end": { + "line": 576, + "column": 9 + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 20670, + 20729 + ], + "loc": { + "start": { + "line": 573, + "column": 6 + }, + "end": { + "line": 573, + "column": 65 + } + } + } + ] + } + ], + "range": [ + 20110, + 20895 + ], + "loc": { + "start": { + "line": 555, + "column": 46 + }, + "end": { + "line": 577, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20097, + 20895 + ], + "loc": { + "start": { + "line": 555, + "column": 33 + }, + "end": { + "line": 577, + "column": 5 + } + } + } + ], + "range": [ + 20068, + 20896 + ], + "loc": { + "start": { + "line": 555, + "column": 4 + }, + "end": { + "line": 577, + "column": 6 + } + } + }, + "range": [ + 20068, + 20897 + ], + "loc": { + "start": { + "line": 555, + "column": 4 + }, + "end": { + "line": 577, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UnaryExpression", + "operator": "delete", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20909, + 20913 + ], + "loc": { + "start": { + "line": 578, + "column": 11 + }, + "end": { + "line": 578, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 20914, + 20919 + ], + "loc": { + "start": { + "line": 578, + "column": 16 + }, + "end": { + "line": 578, + "column": 21 + } + } + }, + "range": [ + 20909, + 20919 + ], + "loc": { + "start": { + "line": 578, + "column": 11 + }, + "end": { + "line": 578, + "column": 21 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20920, + 20928 + ], + "loc": { + "start": { + "line": 578, + "column": 22 + }, + "end": { + "line": 578, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20929, + 20933 + ], + "loc": { + "start": { + "line": 578, + "column": 31 + }, + "end": { + "line": 578, + "column": 35 + } + } + }, + "range": [ + 20920, + 20933 + ], + "loc": { + "start": { + "line": 578, + "column": 22 + }, + "end": { + "line": 578, + "column": 35 + } + } + }, + "range": [ + 20909, + 20934 + ], + "loc": { + "start": { + "line": 578, + "column": 11 + }, + "end": { + "line": 578, + "column": 36 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20935, + 20943 + ], + "loc": { + "start": { + "line": 578, + "column": 37 + }, + "end": { + "line": 578, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 20944, + 20946 + ], + "loc": { + "start": { + "line": 578, + "column": 46 + }, + "end": { + "line": 578, + "column": 48 + } + } + }, + "range": [ + 20935, + 20946 + ], + "loc": { + "start": { + "line": 578, + "column": 37 + }, + "end": { + "line": 578, + "column": 48 + } + } + }, + "range": [ + 20909, + 20947 + ], + "loc": { + "start": { + "line": 578, + "column": 11 + }, + "end": { + "line": 578, + "column": 49 + } + } + }, + "prefix": true, + "range": [ + 20902, + 20947 + ], + "loc": { + "start": { + "line": 578, + "column": 4 + }, + "end": { + "line": 578, + "column": 49 + } + } + }, + "range": [ + 20902, + 20948 + ], + "loc": { + "start": { + "line": 578, + "column": 4 + }, + "end": { + "line": 578, + "column": 50 + } + } + } + ], + "range": [ + 20062, + 20952 + ], + "loc": { + "start": { + "line": 554, + "column": 20 + }, + "end": { + "line": 579, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20051, + 20952 + ], + "loc": { + "start": { + "line": 554, + "column": 9 + }, + "end": { + "line": 579, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 20044, + 20952 + ], + "loc": { + "start": { + "line": 554, + "column": 2 + }, + "end": { + "line": 579, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 20956, + 20982 + ], + "loc": { + "start": { + "line": 581, + "column": 2 + }, + "end": { + "line": 581, + "column": 28 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 20983, + 20997 + ], + "loc": { + "start": { + "line": 581, + "column": 29 + }, + "end": { + "line": 581, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 20999, + 21014 + ], + "loc": { + "start": { + "line": 581, + "column": 45 + }, + "end": { + "line": 581, + "column": 60 + } + } + }, + { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21016, + 21030 + ], + "loc": { + "start": { + "line": 581, + "column": 62 + }, + "end": { + "line": 581, + "column": 76 + } + } + }, + { + "type": "Identifier", + "name": "sourceField", + "range": [ + 21032, + 21043 + ], + "loc": { + "start": { + "line": 581, + "column": 78 + }, + "end": { + "line": 581, + "column": 89 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 21055, + 21071 + ], + "loc": { + "start": { + "line": 582, + "column": 8 + }, + "end": { + "line": 582, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 21074, + 21078 + ], + "loc": { + "start": { + "line": 582, + "column": 27 + }, + "end": { + "line": 582, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 21079, + 21085 + ], + "loc": { + "start": { + "line": 582, + "column": 32 + }, + "end": { + "line": 582, + "column": 38 + } + } + }, + "range": [ + 21074, + 21085 + ], + "loc": { + "start": { + "line": 582, + "column": 27 + }, + "end": { + "line": 582, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21086, + 21100 + ], + "loc": { + "start": { + "line": 582, + "column": 39 + }, + "end": { + "line": 582, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21101, + 21105 + ], + "loc": { + "start": { + "line": 582, + "column": 54 + }, + "end": { + "line": 582, + "column": 58 + } + } + }, + "range": [ + 21086, + 21105 + ], + "loc": { + "start": { + "line": 582, + "column": 39 + }, + "end": { + "line": 582, + "column": 58 + } + } + }, + "range": [ + 21074, + 21106 + ], + "loc": { + "start": { + "line": 582, + "column": 27 + }, + "end": { + "line": 582, + "column": 59 + } + } + }, + "range": [ + 21055, + 21106 + ], + "loc": { + "start": { + "line": 582, + "column": 8 + }, + "end": { + "line": 582, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 21051, + 21107 + ], + "loc": { + "start": { + "line": 582, + "column": 4 + }, + "end": { + "line": 582, + "column": 60 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21116, + 21131 + ], + "loc": { + "start": { + "line": 583, + "column": 8 + }, + "end": { + "line": 583, + "column": 23 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 21134, + 21145 + ], + "loc": { + "start": { + "line": 583, + "column": 26 + }, + "end": { + "line": 583, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 21146, + 21153 + ], + "loc": { + "start": { + "line": 583, + "column": 38 + }, + "end": { + "line": 583, + "column": 45 + } + } + }, + "range": [ + 21134, + 21153 + ], + "loc": { + "start": { + "line": 583, + "column": 26 + }, + "end": { + "line": 583, + "column": 45 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21157, + 21171 + ], + "loc": { + "start": { + "line": 583, + "column": 49 + }, + "end": { + "line": 583, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21172, + 21176 + ], + "loc": { + "start": { + "line": 583, + "column": 64 + }, + "end": { + "line": 583, + "column": 68 + } + } + }, + "range": [ + 21157, + 21176 + ], + "loc": { + "start": { + "line": 583, + "column": 49 + }, + "end": { + "line": 583, + "column": 68 + } + } + }, + "range": [ + 21134, + 21176 + ], + "loc": { + "start": { + "line": 583, + "column": 26 + }, + "end": { + "line": 583, + "column": 68 + } + } + }, + "range": [ + 21116, + 21176 + ], + "loc": { + "start": { + "line": 583, + "column": 8 + }, + "end": { + "line": 583, + "column": 68 + } + } + } + ], + "kind": "var", + "range": [ + 21112, + 21177 + ], + "loc": { + "start": { + "line": 583, + "column": 4 + }, + "end": { + "line": 583, + "column": 69 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21186, + 21197 + ], + "loc": { + "start": { + "line": 584, + "column": 8 + }, + "end": { + "line": 584, + "column": 19 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 21200, + 21216 + ], + "loc": { + "start": { + "line": 584, + "column": 22 + }, + "end": { + "line": 584, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 21220, + 21236 + ], + "loc": { + "start": { + "line": 584, + "column": 42 + }, + "end": { + "line": 584, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21237, + 21252 + ], + "loc": { + "start": { + "line": 584, + "column": 59 + }, + "end": { + "line": 584, + "column": 74 + } + } + }, + "range": [ + 21220, + 21253 + ], + "loc": { + "start": { + "line": 584, + "column": 42 + }, + "end": { + "line": 584, + "column": 75 + } + } + }, + "range": [ + 21200, + 21253 + ], + "loc": { + "start": { + "line": 584, + "column": 22 + }, + "end": { + "line": 584, + "column": 75 + } + } + }, + "range": [ + 21186, + 21253 + ], + "loc": { + "start": { + "line": 584, + "column": 8 + }, + "end": { + "line": 584, + "column": 75 + } + } + } + ], + "kind": "var", + "range": [ + 21182, + 21254 + ], + "loc": { + "start": { + "line": 584, + "column": 4 + }, + "end": { + "line": 584, + "column": 76 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21259, + 21273 + ], + "loc": { + "start": { + "line": 585, + "column": 4 + }, + "end": { + "line": 585, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21274, + 21285 + ], + "loc": { + "start": { + "line": 585, + "column": 19 + }, + "end": { + "line": 585, + "column": 30 + } + } + }, + "range": [ + 21259, + 21285 + ], + "loc": { + "start": { + "line": 585, + "column": 4 + }, + "end": { + "line": 585, + "column": 30 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21288, + 21302 + ], + "loc": { + "start": { + "line": 585, + "column": 33 + }, + "end": { + "line": 585, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21303, + 21314 + ], + "loc": { + "start": { + "line": 585, + "column": 48 + }, + "end": { + "line": 585, + "column": 59 + } + } + }, + "range": [ + 21288, + 21314 + ], + "loc": { + "start": { + "line": 585, + "column": 33 + }, + "end": { + "line": 585, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 21315, + 21321 + ], + "loc": { + "start": { + "line": 585, + "column": 60 + }, + "end": { + "line": 585, + "column": 66 + } + } + }, + "range": [ + 21288, + 21321 + ], + "loc": { + "start": { + "line": 585, + "column": 33 + }, + "end": { + "line": 585, + "column": 66 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 21322, + 21323 + ], + "loc": { + "start": { + "line": 585, + "column": 67 + }, + "end": { + "line": 585, + "column": 68 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21344, + 21345 + ], + "loc": { + "start": { + "line": 586, + "column": 15 + }, + "end": { + "line": 586, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21346, + 21350 + ], + "loc": { + "start": { + "line": 586, + "column": 17 + }, + "end": { + "line": 586, + "column": 21 + } + } + }, + "range": [ + 21344, + 21350 + ], + "loc": { + "start": { + "line": 586, + "column": 15 + }, + "end": { + "line": 586, + "column": 21 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21355, + 21369 + ], + "loc": { + "start": { + "line": 586, + "column": 26 + }, + "end": { + "line": 586, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21370, + 21374 + ], + "loc": { + "start": { + "line": 586, + "column": 41 + }, + "end": { + "line": 586, + "column": 45 + } + } + }, + "range": [ + 21355, + 21374 + ], + "loc": { + "start": { + "line": 586, + "column": 26 + }, + "end": { + "line": 586, + "column": 45 + } + } + }, + "range": [ + 21344, + 21374 + ], + "loc": { + "start": { + "line": 586, + "column": 15 + }, + "end": { + "line": 586, + "column": 45 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21378, + 21379 + ], + "loc": { + "start": { + "line": 586, + "column": 49 + }, + "end": { + "line": 586, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21380, + 21382 + ], + "loc": { + "start": { + "line": 586, + "column": 51 + }, + "end": { + "line": 586, + "column": 53 + } + } + }, + "range": [ + 21378, + 21382 + ], + "loc": { + "start": { + "line": 586, + "column": 49 + }, + "end": { + "line": 586, + "column": 53 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21387, + 21401 + ], + "loc": { + "start": { + "line": 586, + "column": 58 + }, + "end": { + "line": 586, + "column": 72 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21402, + 21404 + ], + "loc": { + "start": { + "line": 586, + "column": 73 + }, + "end": { + "line": 586, + "column": 75 + } + } + }, + "range": [ + 21387, + 21404 + ], + "loc": { + "start": { + "line": 586, + "column": 58 + }, + "end": { + "line": 586, + "column": 75 + } + } + }, + "range": [ + 21378, + 21404 + ], + "loc": { + "start": { + "line": 586, + "column": 49 + }, + "end": { + "line": 586, + "column": 75 + } + } + }, + "range": [ + 21344, + 21404 + ], + "loc": { + "start": { + "line": 586, + "column": 15 + }, + "end": { + "line": 586, + "column": 75 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21408, + 21409 + ], + "loc": { + "start": { + "line": 586, + "column": 79 + }, + "end": { + "line": 586, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21410, + 21419 + ], + "loc": { + "start": { + "line": 586, + "column": 81 + }, + "end": { + "line": 586, + "column": 90 + } + } + }, + "range": [ + 21408, + 21419 + ], + "loc": { + "start": { + "line": 586, + "column": 79 + }, + "end": { + "line": 586, + "column": 90 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 21424, + 21439 + ], + "loc": { + "start": { + "line": 586, + "column": 95 + }, + "end": { + "line": 586, + "column": 110 + } + } + }, + "range": [ + 21408, + 21439 + ], + "loc": { + "start": { + "line": 586, + "column": 79 + }, + "end": { + "line": 586, + "column": 110 + } + } + }, + "range": [ + 21344, + 21439 + ], + "loc": { + "start": { + "line": 586, + "column": 15 + }, + "end": { + "line": 586, + "column": 110 + } + } + }, + "prefix": true, + "range": [ + 21342, + 21440 + ], + "loc": { + "start": { + "line": 586, + "column": 13 + }, + "end": { + "line": 586, + "column": 111 + } + } + }, + "range": [ + 21335, + 21441 + ], + "loc": { + "start": { + "line": 586, + "column": 6 + }, + "end": { + "line": 586, + "column": 112 + } + } + } + ], + "range": [ + 21327, + 21447 + ], + "loc": { + "start": { + "line": 585, + "column": 72 + }, + "end": { + "line": 587, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 21322, + 21447 + ], + "loc": { + "start": { + "line": 585, + "column": 67 + }, + "end": { + "line": 587, + "column": 5 + } + } + } + ], + "range": [ + 21288, + 21448 + ], + "loc": { + "start": { + "line": 585, + "column": 33 + }, + "end": { + "line": 587, + "column": 6 + } + } + }, + "range": [ + 21259, + 21448 + ], + "loc": { + "start": { + "line": 585, + "column": 4 + }, + "end": { + "line": 587, + "column": 6 + } + } + }, + "range": [ + 21259, + 21449 + ], + "loc": { + "start": { + "line": 585, + "column": 4 + }, + "end": { + "line": 587, + "column": 7 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21458, + 21469 + ], + "loc": { + "start": { + "line": 588, + "column": 8 + }, + "end": { + "line": 588, + "column": 19 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21483, + 21494 + ], + "loc": { + "start": { + "line": 589, + "column": 10 + }, + "end": { + "line": 589, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21495, + 21499 + ], + "loc": { + "start": { + "line": 589, + "column": 22 + }, + "end": { + "line": 589, + "column": 26 + } + } + }, + "range": [ + 21483, + 21499 + ], + "loc": { + "start": { + "line": 589, + "column": 10 + }, + "end": { + "line": 589, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 21504, + 21513 + ], + "loc": { + "start": { + "line": 589, + "column": 31 + }, + "end": { + "line": 589, + "column": 40 + } + } + }, + "range": [ + 21483, + 21513 + ], + "loc": { + "start": { + "line": 589, + "column": 10 + }, + "end": { + "line": 589, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21525, + 21539 + ], + "loc": { + "start": { + "line": 590, + "column": 8 + }, + "end": { + "line": 590, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21540, + 21551 + ], + "loc": { + "start": { + "line": 590, + "column": 23 + }, + "end": { + "line": 590, + "column": 34 + } + } + }, + "range": [ + 21525, + 21551 + ], + "loc": { + "start": { + "line": 590, + "column": 8 + }, + "end": { + "line": 590, + "column": 34 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21554, + 21568 + ], + "loc": { + "start": { + "line": 590, + "column": 37 + }, + "end": { + "line": 590, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21569, + 21580 + ], + "loc": { + "start": { + "line": 590, + "column": 52 + }, + "end": { + "line": 590, + "column": 63 + } + } + }, + "range": [ + 21554, + 21580 + ], + "loc": { + "start": { + "line": 590, + "column": 37 + }, + "end": { + "line": 590, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 21581, + 21587 + ], + "loc": { + "start": { + "line": 590, + "column": 64 + }, + "end": { + "line": 590, + "column": 70 + } + } + }, + "range": [ + 21554, + 21587 + ], + "loc": { + "start": { + "line": 590, + "column": 37 + }, + "end": { + "line": 590, + "column": 70 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 21588, + 21589 + ], + "loc": { + "start": { + "line": 590, + "column": 71 + }, + "end": { + "line": 590, + "column": 72 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21614, + 21615 + ], + "loc": { + "start": { + "line": 591, + "column": 19 + }, + "end": { + "line": 591, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21616, + 21620 + ], + "loc": { + "start": { + "line": 591, + "column": 21 + }, + "end": { + "line": 591, + "column": 25 + } + } + }, + "range": [ + 21614, + 21620 + ], + "loc": { + "start": { + "line": 591, + "column": 19 + }, + "end": { + "line": 591, + "column": 25 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21625, + 21639 + ], + "loc": { + "start": { + "line": 591, + "column": 30 + }, + "end": { + "line": 591, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21640, + 21644 + ], + "loc": { + "start": { + "line": 591, + "column": 45 + }, + "end": { + "line": 591, + "column": 49 + } + } + }, + "range": [ + 21625, + 21644 + ], + "loc": { + "start": { + "line": 591, + "column": 30 + }, + "end": { + "line": 591, + "column": 49 + } + } + }, + "range": [ + 21614, + 21644 + ], + "loc": { + "start": { + "line": 591, + "column": 19 + }, + "end": { + "line": 591, + "column": 49 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21648, + 21649 + ], + "loc": { + "start": { + "line": 591, + "column": 53 + }, + "end": { + "line": 591, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21650, + 21652 + ], + "loc": { + "start": { + "line": 591, + "column": 55 + }, + "end": { + "line": 591, + "column": 57 + } + } + }, + "range": [ + 21648, + 21652 + ], + "loc": { + "start": { + "line": 591, + "column": 53 + }, + "end": { + "line": 591, + "column": 57 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21657, + 21671 + ], + "loc": { + "start": { + "line": 591, + "column": 62 + }, + "end": { + "line": 591, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21672, + 21674 + ], + "loc": { + "start": { + "line": 591, + "column": 77 + }, + "end": { + "line": 591, + "column": 79 + } + } + }, + "range": [ + 21657, + 21674 + ], + "loc": { + "start": { + "line": 591, + "column": 62 + }, + "end": { + "line": 591, + "column": 79 + } + } + }, + "range": [ + 21648, + 21674 + ], + "loc": { + "start": { + "line": 591, + "column": 53 + }, + "end": { + "line": 591, + "column": 79 + } + } + }, + "range": [ + 21614, + 21674 + ], + "loc": { + "start": { + "line": 591, + "column": 19 + }, + "end": { + "line": 591, + "column": 79 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21678, + 21679 + ], + "loc": { + "start": { + "line": 591, + "column": 83 + }, + "end": { + "line": 591, + "column": 84 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21680, + 21689 + ], + "loc": { + "start": { + "line": 591, + "column": 85 + }, + "end": { + "line": 591, + "column": 94 + } + } + }, + "range": [ + 21678, + 21689 + ], + "loc": { + "start": { + "line": 591, + "column": 83 + }, + "end": { + "line": 591, + "column": 94 + } + } + }, + "right": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21694, + 21709 + ], + "loc": { + "start": { + "line": 591, + "column": 99 + }, + "end": { + "line": 591, + "column": 114 + } + } + }, + "range": [ + 21678, + 21709 + ], + "loc": { + "start": { + "line": 591, + "column": 83 + }, + "end": { + "line": 591, + "column": 114 + } + } + }, + "range": [ + 21614, + 21709 + ], + "loc": { + "start": { + "line": 591, + "column": 19 + }, + "end": { + "line": 591, + "column": 114 + } + } + }, + "prefix": true, + "range": [ + 21612, + 21710 + ], + "loc": { + "start": { + "line": 591, + "column": 17 + }, + "end": { + "line": 591, + "column": 115 + } + } + }, + "range": [ + 21605, + 21711 + ], + "loc": { + "start": { + "line": 591, + "column": 10 + }, + "end": { + "line": 591, + "column": 116 + } + } + } + ], + "range": [ + 21593, + 21721 + ], + "loc": { + "start": { + "line": 590, + "column": 76 + }, + "end": { + "line": 592, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 21588, + 21721 + ], + "loc": { + "start": { + "line": 590, + "column": 71 + }, + "end": { + "line": 592, + "column": 9 + } + } + } + ], + "range": [ + 21554, + 21722 + ], + "loc": { + "start": { + "line": 590, + "column": 37 + }, + "end": { + "line": 592, + "column": 10 + } + } + }, + "range": [ + 21525, + 21722 + ], + "loc": { + "start": { + "line": 590, + "column": 8 + }, + "end": { + "line": 592, + "column": 10 + } + } + }, + "range": [ + 21525, + 21723 + ], + "loc": { + "start": { + "line": 590, + "column": 8 + }, + "end": { + "line": 592, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21732, + 21746 + ], + "loc": { + "start": { + "line": 593, + "column": 8 + }, + "end": { + "line": 593, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21747, + 21762 + ], + "loc": { + "start": { + "line": 593, + "column": 23 + }, + "end": { + "line": 593, + "column": 38 + } + } + }, + "range": [ + 21732, + 21763 + ], + "loc": { + "start": { + "line": 593, + "column": 8 + }, + "end": { + "line": 593, + "column": 39 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 21766, + 21770 + ], + "loc": { + "start": { + "line": 593, + "column": 42 + }, + "end": { + "line": 593, + "column": 46 + } + } + }, + "range": [ + 21732, + 21770 + ], + "loc": { + "start": { + "line": 593, + "column": 8 + }, + "end": { + "line": 593, + "column": 46 + } + } + }, + "range": [ + 21732, + 21771 + ], + "loc": { + "start": { + "line": 593, + "column": 8 + }, + "end": { + "line": 593, + "column": 47 + } + } + } + ], + "range": [ + 21515, + 21779 + ], + "loc": { + "start": { + "line": 589, + "column": 42 + }, + "end": { + "line": 594, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21789, + 21800 + ], + "loc": { + "start": { + "line": 594, + "column": 17 + }, + "end": { + "line": 594, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21801, + 21805 + ], + "loc": { + "start": { + "line": 594, + "column": 29 + }, + "end": { + "line": 594, + "column": 33 + } + } + }, + "range": [ + 21789, + 21805 + ], + "loc": { + "start": { + "line": 594, + "column": 17 + }, + "end": { + "line": 594, + "column": 33 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 21810, + 21820 + ], + "loc": { + "start": { + "line": 594, + "column": 38 + }, + "end": { + "line": 594, + "column": 48 + } + } + }, + "range": [ + 21789, + 21820 + ], + "loc": { + "start": { + "line": 594, + "column": 17 + }, + "end": { + "line": 594, + "column": 48 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21832, + 21846 + ], + "loc": { + "start": { + "line": 595, + "column": 8 + }, + "end": { + "line": 595, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21847, + 21858 + ], + "loc": { + "start": { + "line": 595, + "column": 23 + }, + "end": { + "line": 595, + "column": 34 + } + } + }, + "range": [ + 21832, + 21858 + ], + "loc": { + "start": { + "line": 595, + "column": 8 + }, + "end": { + "line": 595, + "column": 34 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21861, + 21875 + ], + "loc": { + "start": { + "line": 595, + "column": 37 + }, + "end": { + "line": 595, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21876, + 21887 + ], + "loc": { + "start": { + "line": 595, + "column": 52 + }, + "end": { + "line": 595, + "column": 63 + } + } + }, + "range": [ + 21861, + 21887 + ], + "loc": { + "start": { + "line": 595, + "column": 37 + }, + "end": { + "line": 595, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 21888, + 21894 + ], + "loc": { + "start": { + "line": 595, + "column": 64 + }, + "end": { + "line": 595, + "column": 70 + } + } + }, + "range": [ + 21861, + 21894 + ], + "loc": { + "start": { + "line": 595, + "column": 37 + }, + "end": { + "line": 595, + "column": 70 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 21895, + 21896 + ], + "loc": { + "start": { + "line": 595, + "column": 71 + }, + "end": { + "line": 595, + "column": 72 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21921, + 21922 + ], + "loc": { + "start": { + "line": 596, + "column": 19 + }, + "end": { + "line": 596, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21923, + 21927 + ], + "loc": { + "start": { + "line": 596, + "column": 21 + }, + "end": { + "line": 596, + "column": 25 + } + } + }, + "range": [ + 21921, + 21927 + ], + "loc": { + "start": { + "line": 596, + "column": 19 + }, + "end": { + "line": 596, + "column": 25 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21932, + 21946 + ], + "loc": { + "start": { + "line": 596, + "column": 30 + }, + "end": { + "line": 596, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21947, + 21951 + ], + "loc": { + "start": { + "line": 596, + "column": 45 + }, + "end": { + "line": 596, + "column": 49 + } + } + }, + "range": [ + 21932, + 21951 + ], + "loc": { + "start": { + "line": 596, + "column": 30 + }, + "end": { + "line": 596, + "column": 49 + } + } + }, + "range": [ + 21921, + 21951 + ], + "loc": { + "start": { + "line": 596, + "column": 19 + }, + "end": { + "line": 596, + "column": 49 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21955, + 21956 + ], + "loc": { + "start": { + "line": 596, + "column": 53 + }, + "end": { + "line": 596, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21957, + 21959 + ], + "loc": { + "start": { + "line": 596, + "column": 55 + }, + "end": { + "line": 596, + "column": 57 + } + } + }, + "range": [ + 21955, + 21959 + ], + "loc": { + "start": { + "line": 596, + "column": 53 + }, + "end": { + "line": 596, + "column": 57 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21964, + 21978 + ], + "loc": { + "start": { + "line": 596, + "column": 62 + }, + "end": { + "line": 596, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21979, + 21981 + ], + "loc": { + "start": { + "line": 596, + "column": 77 + }, + "end": { + "line": 596, + "column": 79 + } + } + }, + "range": [ + 21964, + 21981 + ], + "loc": { + "start": { + "line": 596, + "column": 62 + }, + "end": { + "line": 596, + "column": 79 + } + } + }, + "range": [ + 21955, + 21981 + ], + "loc": { + "start": { + "line": 596, + "column": 53 + }, + "end": { + "line": 596, + "column": 79 + } + } + }, + "range": [ + 21921, + 21981 + ], + "loc": { + "start": { + "line": 596, + "column": 19 + }, + "end": { + "line": 596, + "column": 79 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 21985, + 21986 + ], + "loc": { + "start": { + "line": 596, + "column": 83 + }, + "end": { + "line": 596, + "column": 84 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21987, + 21996 + ], + "loc": { + "start": { + "line": 596, + "column": 85 + }, + "end": { + "line": 596, + "column": 94 + } + } + }, + "range": [ + 21985, + 21996 + ], + "loc": { + "start": { + "line": 596, + "column": 83 + }, + "end": { + "line": 596, + "column": 94 + } + } + }, + "right": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 22001, + 22016 + ], + "loc": { + "start": { + "line": 596, + "column": 99 + }, + "end": { + "line": 596, + "column": 114 + } + } + }, + "range": [ + 21985, + 22016 + ], + "loc": { + "start": { + "line": 596, + "column": 83 + }, + "end": { + "line": 596, + "column": 114 + } + } + }, + "range": [ + 21921, + 22016 + ], + "loc": { + "start": { + "line": 596, + "column": 19 + }, + "end": { + "line": 596, + "column": 114 + } + } + }, + "prefix": true, + "range": [ + 21919, + 22017 + ], + "loc": { + "start": { + "line": 596, + "column": 17 + }, + "end": { + "line": 596, + "column": 115 + } + } + }, + "range": [ + 21912, + 22018 + ], + "loc": { + "start": { + "line": 596, + "column": 10 + }, + "end": { + "line": 596, + "column": 116 + } + } + } + ], + "range": [ + 21900, + 22028 + ], + "loc": { + "start": { + "line": 595, + "column": 76 + }, + "end": { + "line": 597, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 21895, + 22028 + ], + "loc": { + "start": { + "line": 595, + "column": 71 + }, + "end": { + "line": 597, + "column": 9 + } + } + } + ], + "range": [ + 21861, + 22029 + ], + "loc": { + "start": { + "line": 595, + "column": 37 + }, + "end": { + "line": 597, + "column": 10 + } + } + }, + "range": [ + 21832, + 22029 + ], + "loc": { + "start": { + "line": 595, + "column": 8 + }, + "end": { + "line": 597, + "column": 10 + } + } + }, + "range": [ + 21832, + 22030 + ], + "loc": { + "start": { + "line": 595, + "column": 8 + }, + "end": { + "line": 597, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 22039, + 22053 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 598, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 22054, + 22069 + ], + "loc": { + "start": { + "line": 598, + "column": 23 + }, + "end": { + "line": 598, + "column": 38 + } + } + }, + "range": [ + 22039, + 22070 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 598, + "column": 39 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 22073, + 22087 + ], + "loc": { + "start": { + "line": 598, + "column": 42 + }, + "end": { + "line": 598, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 22088, + 22103 + ], + "loc": { + "start": { + "line": 598, + "column": 57 + }, + "end": { + "line": 598, + "column": 72 + } + } + }, + "range": [ + 22073, + 22104 + ], + "loc": { + "start": { + "line": 598, + "column": 42 + }, + "end": { + "line": 598, + "column": 73 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 22105, + 22111 + ], + "loc": { + "start": { + "line": 598, + "column": 74 + }, + "end": { + "line": 598, + "column": 80 + } + } + }, + "range": [ + 22073, + 22111 + ], + "loc": { + "start": { + "line": 598, + "column": 42 + }, + "end": { + "line": 598, + "column": 80 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 22112, + 22113 + ], + "loc": { + "start": { + "line": 598, + "column": 81 + }, + "end": { + "line": 598, + "column": 82 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "Identifier", + "name": "r", + "range": [ + 22136, + 22137 + ], + "loc": { + "start": { + "line": 599, + "column": 17 + }, + "end": { + "line": 599, + "column": 18 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 22142, + 22156 + ], + "loc": { + "start": { + "line": 599, + "column": 23 + }, + "end": { + "line": 599, + "column": 37 + } + } + }, + "range": [ + 22136, + 22156 + ], + "loc": { + "start": { + "line": 599, + "column": 17 + }, + "end": { + "line": 599, + "column": 37 + } + } + }, + "range": [ + 22129, + 22157 + ], + "loc": { + "start": { + "line": 599, + "column": 10 + }, + "end": { + "line": 599, + "column": 38 + } + } + } + ], + "range": [ + 22117, + 22167 + ], + "loc": { + "start": { + "line": 598, + "column": 86 + }, + "end": { + "line": 600, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 22112, + 22167 + ], + "loc": { + "start": { + "line": 598, + "column": 81 + }, + "end": { + "line": 600, + "column": 9 + } + } + } + ], + "range": [ + 22073, + 22168 + ], + "loc": { + "start": { + "line": 598, + "column": 42 + }, + "end": { + "line": 600, + "column": 10 + } + } + }, + "range": [ + 22039, + 22168 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 600, + "column": 10 + } + } + }, + "range": [ + 22039, + 22169 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 600, + "column": 11 + } + } + } + ], + "range": [ + 21822, + 22177 + ], + "loc": { + "start": { + "line": 594, + "column": 50 + }, + "end": { + "line": 601, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 22187, + 22198 + ], + "loc": { + "start": { + "line": 601, + "column": 17 + }, + "end": { + "line": 601, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22199, + 22203 + ], + "loc": { + "start": { + "line": 601, + "column": 29 + }, + "end": { + "line": 601, + "column": 33 + } + } + }, + "range": [ + 22187, + 22203 + ], + "loc": { + "start": { + "line": 601, + "column": 17 + }, + "end": { + "line": 601, + "column": 33 + } + } + }, + "right": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 22208, + 22214 + ], + "loc": { + "start": { + "line": 601, + "column": 38 + }, + "end": { + "line": 601, + "column": 44 + } + } + }, + "range": [ + 22187, + 22214 + ], + "loc": { + "start": { + "line": 601, + "column": 17 + }, + "end": { + "line": 601, + "column": 44 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 22236, + 22241 + ], + "loc": { + "start": { + "line": 602, + "column": 18 + }, + "end": { + "line": 602, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 22242, + 22279 + ], + "loc": { + "start": { + "line": 602, + "column": 24 + }, + "end": { + "line": 602, + "column": 61 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is an attribute ('", + "cooked": "' is an attribute ('" + }, + "tail": false, + "range": [ + 22294, + 22317 + ], + "loc": { + "start": { + "line": 602, + "column": 76 + }, + "end": { + "line": 602, + "column": 99 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 22332, + 22336 + ], + "loc": { + "start": { + "line": 602, + "column": 114 + }, + "end": { + "line": 602, + "column": 118 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 22279, + 22294 + ], + "loc": { + "start": { + "line": 602, + "column": 61 + }, + "end": { + "line": 602, + "column": 76 + } + } + }, + { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 22317, + 22332 + ], + "loc": { + "start": { + "line": 602, + "column": 99 + }, + "end": { + "line": 602, + "column": 114 + } + } + } + ], + "range": [ + 22242, + 22336 + ], + "loc": { + "start": { + "line": 602, + "column": 24 + }, + "end": { + "line": 602, + "column": 118 + } + } + } + ], + "range": [ + 22232, + 22337 + ], + "loc": { + "start": { + "line": 602, + "column": 14 + }, + "end": { + "line": 602, + "column": 119 + } + } + }, + "range": [ + 22226, + 22338 + ], + "loc": { + "start": { + "line": 602, + "column": 8 + }, + "end": { + "line": 602, + "column": 120 + } + } + } + ], + "range": [ + 22216, + 22346 + ], + "loc": { + "start": { + "line": 601, + "column": 46 + }, + "end": { + "line": 603, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 22183, + 22346 + ], + "loc": { + "start": { + "line": 601, + "column": 13 + }, + "end": { + "line": 603, + "column": 7 + } + } + }, + "range": [ + 21785, + 22346 + ], + "loc": { + "start": { + "line": 594, + "column": 13 + }, + "end": { + "line": 603, + "column": 7 + } + } + }, + "range": [ + 21479, + 22346 + ], + "loc": { + "start": { + "line": 589, + "column": 6 + }, + "end": { + "line": 603, + "column": 7 + } + } + } + ], + "range": [ + 21471, + 22352 + ], + "loc": { + "start": { + "line": 588, + "column": 21 + }, + "end": { + "line": 604, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 22362, + 22373 + ], + "loc": { + "start": { + "line": 604, + "column": 15 + }, + "end": { + "line": 604, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 22374, + 22381 + ], + "loc": { + "start": { + "line": 604, + "column": 27 + }, + "end": { + "line": 604, + "column": 34 + } + } + }, + "range": [ + 22362, + 22381 + ], + "loc": { + "start": { + "line": 604, + "column": 15 + }, + "end": { + "line": 604, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 22401, + 22406 + ], + "loc": { + "start": { + "line": 605, + "column": 16 + }, + "end": { + "line": 605, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 22407, + 22444 + ], + "loc": { + "start": { + "line": 605, + "column": 22 + }, + "end": { + "line": 605, + "column": 59 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is missing ('", + "cooked": "' is missing ('" + }, + "tail": false, + "range": [ + 22459, + 22477 + ], + "loc": { + "start": { + "line": 605, + "column": 74 + }, + "end": { + "line": 605, + "column": 92 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 22496, + 22500 + ], + "loc": { + "start": { + "line": 605, + "column": 111 + }, + "end": { + "line": 605, + "column": 115 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 22444, + 22459 + ], + "loc": { + "start": { + "line": 605, + "column": 59 + }, + "end": { + "line": 605, + "column": 74 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 22477, + 22488 + ], + "loc": { + "start": { + "line": 605, + "column": 92 + }, + "end": { + "line": 605, + "column": 103 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 22489, + 22496 + ], + "loc": { + "start": { + "line": 605, + "column": 104 + }, + "end": { + "line": 605, + "column": 111 + } + } + }, + "range": [ + 22477, + 22496 + ], + "loc": { + "start": { + "line": 605, + "column": 92 + }, + "end": { + "line": 605, + "column": 111 + } + } + } + ], + "range": [ + 22407, + 22500 + ], + "loc": { + "start": { + "line": 605, + "column": 22 + }, + "end": { + "line": 605, + "column": 115 + } + } + } + ], + "range": [ + 22397, + 22501 + ], + "loc": { + "start": { + "line": 605, + "column": 12 + }, + "end": { + "line": 605, + "column": 116 + } + } + }, + "range": [ + 22391, + 22502 + ], + "loc": { + "start": { + "line": 605, + "column": 6 + }, + "end": { + "line": 605, + "column": 117 + } + } + } + ], + "range": [ + 22383, + 22508 + ], + "loc": { + "start": { + "line": 604, + "column": 36 + }, + "end": { + "line": 606, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 22358, + 22508 + ], + "loc": { + "start": { + "line": 604, + "column": 11 + }, + "end": { + "line": 606, + "column": 5 + } + } + }, + "range": [ + 21454, + 22508 + ], + "loc": { + "start": { + "line": 588, + "column": 4 + }, + "end": { + "line": 606, + "column": 5 + } + } + } + ], + "range": [ + 21045, + 22512 + ], + "loc": { + "start": { + "line": 581, + "column": 91 + }, + "end": { + "line": 607, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20982, + 22512 + ], + "loc": { + "start": { + "line": 581, + "column": 28 + }, + "end": { + "line": 607, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 20956, + 22512 + ], + "loc": { + "start": { + "line": 581, + "column": 2 + }, + "end": { + "line": 607, + "column": 3 + } + }, + "static": false + } + ], + "range": [ + 101, + 22515 + ], + "loc": { + "start": { + "line": 4, + "column": 27 + }, + "end": { + "line": 609, + "column": 1 + } + } + }, + "range": [ + 89, + 22515 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 609, + "column": 1 + } + }, + "leadingComments": [], + "trailingComments": [] + }, + "range": [ + 74, + 22515 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 609, + "column": 1 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 22517, + 22522 + ], + "loc": { + "start": { + "line": 611, + "column": 0 + }, + "end": { + "line": 611, + "column": 5 + } + } + }, + "property": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 22523, + 22534 + ], + "loc": { + "start": { + "line": 611, + "column": 6 + }, + "end": { + "line": 611, + "column": 17 + } + } + }, + "range": [ + 22517, + 22534 + ], + "loc": { + "start": { + "line": 611, + "column": 0 + }, + "end": { + "line": 611, + "column": 17 + } + } + }, + "right": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 22537, + 22548 + ], + "loc": { + "start": { + "line": 611, + "column": 20 + }, + "end": { + "line": 611, + "column": 31 + } + } + }, + "range": [ + 22517, + 22548 + ], + "loc": { + "start": { + "line": 611, + "column": 0 + }, + "end": { + "line": 611, + "column": 31 + } + } + }, + "range": [ + 22517, + 22549 + ], + "loc": { + "start": { + "line": 611, + "column": 0 + }, + "end": { + "line": 611, + "column": 32 + } + } + } + ], + "sourceType": "module", + "range": [ + 0, + 22549 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 611, + "column": 32 + } + }, + "comments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n ", + "range": [ + 106, + 428 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 897, + 1234 + ], + "loc": { + "start": { + "line": 32, + "column": 2 + }, + "end": { + "line": 40, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2282, + 2620 + ], + "loc": { + "start": { + "line": 74, + "column": 2 + }, + "end": { + "line": 82, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - Resource Object to add. See:\n http://jsonapi.org/format/#document-resource-objects\n * @return {undefined} - Nothing.\n ", + "range": [ + 3873, + 4165 + ], + "loc": { + "start": { + "line": 124, + "column": 2 + }, + "end": { + "line": 132, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 5213, + 5659 + ], + "loc": { + "start": { + "line": 158, + "column": 2 + }, + "end": { + "line": 166, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 6293, + 6954 + ], + "loc": { + "start": { + "line": 191, + "column": 2 + }, + "end": { + "line": 209, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n * @return {undefined} - Nothing.\n ", + "range": [ + 7252, + 7479 + ], + "loc": { + "start": { + "line": 218, + "column": 2 + }, + "end": { + "line": 225, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\", () => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 7956, + 8575 + ], + "loc": { + "start": { + "line": 242, + "column": 2 + }, + "end": { + "line": 260, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Find a resource or entire collection of resources.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to find.\n * @param {string} [id] - The id of the resource to find. If omitted all\n * resources of the type will be returned.\n * @return {Object|Object[]} - Either the resource or an array of resources.\n ", + "range": [ + 8865, + 9375 + ], + "loc": { + "start": { + "line": 269, + "column": 2 + }, + "end": { + "line": 280, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to load the resource(s) through the adapter and adds it/them to\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} [id] - ID of resource.\n * @param {Object} [options] - **NOT YET IMPLEMENTED** (this will include sorting, filtering and pagination options)\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"product\", \"1\", (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 10312, + 11058 + ], + "loc": { + "start": { + "line": 314, + "column": 2 + }, + "end": { + "line": 333, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n * @return {undefined} - Nothing.\n ", + "range": [ + 11360, + 11763 + ], + "loc": { + "start": { + "line": 342, + "column": 2 + }, + "end": { + "line": 351, + "column": 5 + } + } + }, + { + "type": "Line", + "value": " TODO: Performance-wise, this can be made way better. There shouldn't be a need to maintain separate lists.", + "range": [ + 12067, + 12176 + ], + "loc": { + "start": { + "line": 358, + "column": 10 + }, + "end": { + "line": 358, + "column": 119 + } + } + }, + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n * @return {undefined} - Nothing.\n ", + "range": [ + 12970, + 13410 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 391, + "column": 5 + } + } + }, + { + "type": "Line", + "value": " TODO: Performance-wise, this can be made way better. There shouldn't be a need to maintain separate lists.", + "range": [ + 13721, + 13830 + ], + "loc": { + "start": { + "line": 398, + "column": 10 + }, + "end": { + "line": 398, + "column": 119 + } + } + }, + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n * @return {undefined} - Nothing.\n ", + "range": [ + 14803, + 15137 + ], + "loc": { + "start": { + "line": 422, + "column": 2 + }, + "end": { + "line": 430, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n * @return {undefined} - Nothing.\n ", + "range": [ + 15370, + 15712 + ], + "loc": { + "start": { + "line": 442, + "column": 2 + }, + "end": { + "line": 450, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {function} [success] - Callback on success.\n * @param {function} [error] - Callback on error.\n * @param {Object} [context] - Context for the callbacks.\n * @return {undefined} - Nothing.\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }, (product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 16610, + 17319 + ], + "loc": { + "start": { + "line": 476, + "column": 2 + }, + "end": { + "line": 495, + "column": 5 + } + } + }, + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 20670, + 20729 + ], + "loc": { + "start": { + "line": 573, + "column": 6 + }, + "end": { + "line": 573, + "column": 65 + } + } + } + ] +} \ No newline at end of file diff --git a/docs/v0.7.0/ast/source/store.js.json b/docs/v0.7.0/ast/source/store.js.json new file mode 100644 index 0000000..4aad12b --- /dev/null +++ b/docs/v0.7.0/ast/source/store.js.json @@ -0,0 +1,45520 @@ +{ + "type": "Program", + "body": [ + { + "type": "ImportDeclaration", + "specifiers": [], + "source": { + "type": "Literal", + "value": "array.prototype.find", + "raw": "\"array.prototype.find\"", + "range": [ + 7, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 29 + } + } + }, + "range": [ + 0, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "ImportDeclaration", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "Rx", + "range": [ + 38, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "range": [ + 38, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "source": { + "type": "Literal", + "value": "rx", + "raw": "\"rx\"", + "range": [ + 46, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "range": [ + 31, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "ImportDeclaration", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 59, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 18 + } + } + }, + "range": [ + 59, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 18 + } + } + } + ], + "source": { + "type": "Literal", + "value": "./ajax-adapter", + "raw": "\"./ajax-adapter\"", + "range": [ + 76, + 92 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 40 + } + } + }, + "range": [ + 52, + 93 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 41 + } + } + }, + { + "type": "ExportDefaultDeclaration", + "declaration": { + "type": "ClassDeclaration", + "id": { + "type": "Identifier", + "name": "Store", + "range": [ + 116, + 121 + ], + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "superClass": null, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "attr", + "range": [ + 459, + 463 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 13 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 464, + 468 + ], + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 470, + 477 + ], + "loc": { + "start": { + "line": 16, + "column": 20 + }, + "end": { + "line": 16, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 489, + 493 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 504, + 508 + ], + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 497, + 508 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 17, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 513, + 521 + ], + "loc": { + "start": { + "line": 17, + "column": 32 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "range": [ + 497, + 521 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "range": [ + 489, + 521 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 538, + 543 + ], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "attr", + "range": [ + 544, + 548 + ], + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 23 + } + } + }, + "range": [ + 538, + 548 + ], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 549, + 553 + ], + "loc": { + "start": { + "line": 18, + "column": 24 + }, + "end": { + "line": 18, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 555, + 559 + ], + "loc": { + "start": { + "line": 18, + "column": 30 + }, + "end": { + "line": 18, + "column": 34 + } + } + } + ], + "range": [ + 538, + 560 + ], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 35 + } + } + }, + "range": [ + 531, + 561 + ], + "loc": { + "start": { + "line": 18, + "column": 6 + }, + "end": { + "line": 18, + "column": 36 + } + } + } + ], + "range": [ + 523, + 567 + ], + "loc": { + "start": { + "line": 17, + "column": 42 + }, + "end": { + "line": 19, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 598, + 602 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 604, + 610 + ], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 598, + 610 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 20 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "default", + "range": [ + 620, + 627 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 629, + 636 + ], + "loc": { + "start": { + "line": 22, + "column": 17 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 640, + 647 + ], + "loc": { + "start": { + "line": 22, + "column": 28 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "default", + "range": [ + 648, + 655 + ], + "loc": { + "start": { + "line": 22, + "column": 36 + }, + "end": { + "line": 22, + "column": 43 + } + } + }, + "range": [ + 640, + 655 + ], + "loc": { + "start": { + "line": 22, + "column": 28 + }, + "end": { + "line": 22, + "column": 43 + } + } + }, + "range": [ + 629, + 655 + ], + "loc": { + "start": { + "line": 22, + "column": 17 + }, + "end": { + "line": 22, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 620, + 655 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 22, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 665, + 676 + ], + "loc": { + "start": { + "line": 23, + "column": 8 + }, + "end": { + "line": 23, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 688, + 692 + ], + "loc": { + "start": { + "line": 23, + "column": 31 + }, + "end": { + "line": 23, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 694, + 697 + ], + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 718, + 722 + ], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 723, + 733 + ], + "loc": { + "start": { + "line": 24, + "column": 22 + }, + "end": { + "line": 24, + "column": 32 + } + } + }, + "range": [ + 718, + 733 + ], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 737, + 741 + ], + "loc": { + "start": { + "line": 24, + "column": 36 + }, + "end": { + "line": 24, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 742, + 752 + ], + "loc": { + "start": { + "line": 24, + "column": 41 + }, + "end": { + "line": 24, + "column": 51 + } + } + }, + "range": [ + 737, + 752 + ], + "loc": { + "start": { + "line": 24, + "column": 36 + }, + "end": { + "line": 24, + "column": 51 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 753, + 757 + ], + "loc": { + "start": { + "line": 24, + "column": 52 + }, + "end": { + "line": 24, + "column": 56 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 761, + 764 + ], + "loc": { + "start": { + "line": 24, + "column": 60 + }, + "end": { + "line": 24, + "column": 63 + } + } + }, + "range": [ + 753, + 764 + ], + "loc": { + "start": { + "line": 24, + "column": 52 + }, + "end": { + "line": 24, + "column": 63 + } + } + }, + "range": [ + 737, + 765 + ], + "loc": { + "start": { + "line": 24, + "column": 36 + }, + "end": { + "line": 24, + "column": 64 + } + } + }, + "range": [ + 718, + 765 + ], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 64 + } + } + }, + "range": [ + 711, + 766 + ], + "loc": { + "start": { + "line": 24, + "column": 10 + }, + "end": { + "line": 24, + "column": 65 + } + } + } + ], + "range": [ + 699, + 776 + ], + "loc": { + "start": { + "line": 23, + "column": 42 + }, + "end": { + "line": 25, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 678, + 776 + ], + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 25, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 665, + 776 + ], + "loc": { + "start": { + "line": 23, + "column": 8 + }, + "end": { + "line": 25, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 786, + 795 + ], + "loc": { + "start": { + "line": 26, + "column": 8 + }, + "end": { + "line": 26, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 807, + 815 + ], + "loc": { + "start": { + "line": 26, + "column": 29 + }, + "end": { + "line": 26, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 817, + 821 + ], + "loc": { + "start": { + "line": 26, + "column": 39 + }, + "end": { + "line": 26, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 823, + 826 + ], + "loc": { + "start": { + "line": 26, + "column": 45 + }, + "end": { + "line": 26, + "column": 48 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 840, + 844 + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "attributes", + "range": [ + 845, + 855 + ], + "loc": { + "start": { + "line": 27, + "column": 15 + }, + "end": { + "line": 27, + "column": 25 + } + } + }, + "range": [ + 840, + 855 + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 25 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 856, + 860 + ], + "loc": { + "start": { + "line": 27, + "column": 26 + }, + "end": { + "line": 27, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 864, + 867 + ], + "loc": { + "start": { + "line": 27, + "column": 34 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + "range": [ + 856, + 867 + ], + "loc": { + "start": { + "line": 27, + "column": 26 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + "range": [ + 840, + 868 + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 871, + 879 + ], + "loc": { + "start": { + "line": 27, + "column": 41 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 880, + 883 + ], + "loc": { + "start": { + "line": 27, + "column": 50 + }, + "end": { + "line": 27, + "column": 53 + } + } + }, + "range": [ + 871, + 884 + ], + "loc": { + "start": { + "line": 27, + "column": 41 + }, + "end": { + "line": 27, + "column": 54 + } + } + }, + "range": [ + 840, + 884 + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 54 + } + } + }, + "range": [ + 840, + 885 + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 55 + } + } + } + ], + "range": [ + 828, + 895 + ], + "loc": { + "start": { + "line": 26, + "column": 50 + }, + "end": { + "line": 28, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 797, + 895 + ], + "loc": { + "start": { + "line": 26, + "column": 19 + }, + "end": { + "line": 28, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 786, + 895 + ], + "loc": { + "start": { + "line": 26, + "column": 8 + }, + "end": { + "line": 28, + "column": 9 + } + } + } + ], + "range": [ + 588, + 903 + ], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 29, + "column": 7 + } + } + }, + "range": [ + 581, + 904 + ], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 29, + "column": 8 + } + } + } + ], + "range": [ + 573, + 910 + ], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 30, + "column": 5 + } + } + }, + "range": [ + 485, + 910 + ], + "loc": { + "start": { + "line": 17, + "column": 4 + }, + "end": { + "line": 30, + "column": 5 + } + } + } + ], + "range": [ + 479, + 914 + ], + "loc": { + "start": { + "line": 16, + "column": 29 + }, + "end": { + "line": 31, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 463, + 914 + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 31, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 452, + 914 + ], + "loc": { + "start": { + "line": 16, + "column": 2 + }, + "end": { + "line": 31, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n ", + "range": [ + 127, + 449 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 15, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 918, + 1255 + ], + "loc": { + "start": { + "line": 33, + "column": 2 + }, + "end": { + "line": 41, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "hasOne", + "range": [ + 1265, + 1271 + ], + "loc": { + "start": { + "line": 42, + "column": 9 + }, + "end": { + "line": 42, + "column": 15 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 1272, + 1276 + ], + "loc": { + "start": { + "line": 42, + "column": 16 + }, + "end": { + "line": 42, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 1278, + 1285 + ], + "loc": { + "start": { + "line": 42, + "column": 22 + }, + "end": { + "line": 42, + "column": 29 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1297, + 1301 + ], + "loc": { + "start": { + "line": 43, + "column": 8 + }, + "end": { + "line": 43, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 1312, + 1316 + ], + "loc": { + "start": { + "line": 43, + "column": 23 + }, + "end": { + "line": 43, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 1305, + 1316 + ], + "loc": { + "start": { + "line": 43, + "column": 16 + }, + "end": { + "line": 43, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 1321, + 1329 + ], + "loc": { + "start": { + "line": 43, + "column": 32 + }, + "end": { + "line": 43, + "column": 40 + } + } + }, + "range": [ + 1305, + 1329 + ], + "loc": { + "start": { + "line": 43, + "column": 16 + }, + "end": { + "line": 43, + "column": 40 + } + } + }, + "range": [ + 1297, + 1329 + ], + "loc": { + "start": { + "line": 43, + "column": 8 + }, + "end": { + "line": 43, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 1346, + 1351 + ], + "loc": { + "start": { + "line": 44, + "column": 13 + }, + "end": { + "line": 44, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasOne", + "range": [ + 1352, + 1358 + ], + "loc": { + "start": { + "line": 44, + "column": 19 + }, + "end": { + "line": 44, + "column": 25 + } + } + }, + "range": [ + 1346, + 1358 + ], + "loc": { + "start": { + "line": 44, + "column": 13 + }, + "end": { + "line": 44, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1359, + 1363 + ], + "loc": { + "start": { + "line": 44, + "column": 26 + }, + "end": { + "line": 44, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 1365, + 1369 + ], + "loc": { + "start": { + "line": 44, + "column": 32 + }, + "end": { + "line": 44, + "column": 36 + } + } + } + ], + "range": [ + 1346, + 1370 + ], + "loc": { + "start": { + "line": 44, + "column": 13 + }, + "end": { + "line": 44, + "column": 37 + } + } + }, + "range": [ + 1339, + 1371 + ], + "loc": { + "start": { + "line": 44, + "column": 6 + }, + "end": { + "line": 44, + "column": 38 + } + } + } + ], + "range": [ + 1331, + 1377 + ], + "loc": { + "start": { + "line": 43, + "column": 42 + }, + "end": { + "line": 45, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 1408, + 1412 + ], + "loc": { + "start": { + "line": 47, + "column": 8 + }, + "end": { + "line": 47, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 1414, + 1423 + ], + "loc": { + "start": { + "line": 47, + "column": 14 + }, + "end": { + "line": 47, + "column": 23 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1408, + 1423 + ], + "loc": { + "start": { + "line": 47, + "column": 8 + }, + "end": { + "line": 47, + "column": 23 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "inverse", + "range": [ + 1433, + 1440 + ], + "loc": { + "start": { + "line": 48, + "column": 8 + }, + "end": { + "line": 48, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 1442, + 1449 + ], + "loc": { + "start": { + "line": 48, + "column": 17 + }, + "end": { + "line": 48, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 1453, + 1460 + ], + "loc": { + "start": { + "line": 48, + "column": 28 + }, + "end": { + "line": 48, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 1461, + 1468 + ], + "loc": { + "start": { + "line": 48, + "column": 36 + }, + "end": { + "line": 48, + "column": 43 + } + } + }, + "range": [ + 1453, + 1468 + ], + "loc": { + "start": { + "line": 48, + "column": 28 + }, + "end": { + "line": 48, + "column": 43 + } + } + }, + "range": [ + 1442, + 1468 + ], + "loc": { + "start": { + "line": 48, + "column": 17 + }, + "end": { + "line": 48, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1433, + 1468 + ], + "loc": { + "start": { + "line": 48, + "column": 8 + }, + "end": { + "line": 48, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 1478, + 1489 + ], + "loc": { + "start": { + "line": 49, + "column": 8 + }, + "end": { + "line": 49, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 1501, + 1505 + ], + "loc": { + "start": { + "line": 49, + "column": 31 + }, + "end": { + "line": 49, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 1507, + 1510 + ], + "loc": { + "start": { + "line": 49, + "column": 37 + }, + "end": { + "line": 49, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1524, + 1528 + ], + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 14 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 1531, + 1535 + ], + "loc": { + "start": { + "line": 50, + "column": 17 + }, + "end": { + "line": 50, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 1539, + 1542 + ], + "loc": { + "start": { + "line": 50, + "column": 25 + }, + "end": { + "line": 50, + "column": 28 + } + } + }, + "range": [ + 1531, + 1542 + ], + "loc": { + "start": { + "line": 50, + "column": 17 + }, + "end": { + "line": 50, + "column": 28 + } + } + }, + "range": [ + 1524, + 1542 + ], + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 28 + } + } + }, + "range": [ + 1524, + 1543 + ], + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 29 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1558, + 1562 + ], + "loc": { + "start": { + "line": 51, + "column": 14 + }, + "end": { + "line": 51, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1563, + 1576 + ], + "loc": { + "start": { + "line": 51, + "column": 19 + }, + "end": { + "line": 51, + "column": 32 + } + } + }, + "range": [ + 1558, + 1576 + ], + "loc": { + "start": { + "line": 51, + "column": 14 + }, + "end": { + "line": 51, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1580, + 1584 + ], + "loc": { + "start": { + "line": 51, + "column": 36 + }, + "end": { + "line": 51, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1585, + 1598 + ], + "loc": { + "start": { + "line": 51, + "column": 41 + }, + "end": { + "line": 51, + "column": 54 + } + } + }, + "range": [ + 1580, + 1598 + ], + "loc": { + "start": { + "line": 51, + "column": 36 + }, + "end": { + "line": 51, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1599, + 1603 + ], + "loc": { + "start": { + "line": 51, + "column": 55 + }, + "end": { + "line": 51, + "column": 59 + } + } + }, + "range": [ + 1580, + 1604 + ], + "loc": { + "start": { + "line": 51, + "column": 36 + }, + "end": { + "line": 51, + "column": 60 + } + } + }, + "range": [ + 1558, + 1604 + ], + "loc": { + "start": { + "line": 51, + "column": 14 + }, + "end": { + "line": 51, + "column": 60 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1624, + 1628 + ], + "loc": { + "start": { + "line": 52, + "column": 16 + }, + "end": { + "line": 52, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1629, + 1642 + ], + "loc": { + "start": { + "line": 52, + "column": 21 + }, + "end": { + "line": 52, + "column": 34 + } + } + }, + "range": [ + 1624, + 1642 + ], + "loc": { + "start": { + "line": 52, + "column": 16 + }, + "end": { + "line": 52, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1643, + 1647 + ], + "loc": { + "start": { + "line": 52, + "column": 35 + }, + "end": { + "line": 52, + "column": 39 + } + } + }, + "range": [ + 1624, + 1648 + ], + "loc": { + "start": { + "line": 52, + "column": 16 + }, + "end": { + "line": 52, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1649, + 1653 + ], + "loc": { + "start": { + "line": 52, + "column": 41 + }, + "end": { + "line": 52, + "column": 45 + } + } + }, + "range": [ + 1624, + 1653 + ], + "loc": { + "start": { + "line": 52, + "column": 16 + }, + "end": { + "line": 52, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1658, + 1662 + ], + "loc": { + "start": { + "line": 52, + "column": 50 + }, + "end": { + "line": 52, + "column": 54 + } + } + }, + "range": [ + 1624, + 1662 + ], + "loc": { + "start": { + "line": 52, + "column": 16 + }, + "end": { + "line": 52, + "column": 54 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1687, + 1691 + ], + "loc": { + "start": { + "line": 53, + "column": 21 + }, + "end": { + "line": 53, + "column": 25 + } + } + }, + "range": [ + 1680, + 1692 + ], + "loc": { + "start": { + "line": 53, + "column": 14 + }, + "end": { + "line": 53, + "column": 26 + } + } + } + ], + "range": [ + 1664, + 1706 + ], + "loc": { + "start": { + "line": 52, + "column": 56 + }, + "end": { + "line": 54, + "column": 13 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1716, + 1720 + ], + "loc": { + "start": { + "line": 54, + "column": 23 + }, + "end": { + "line": 54, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1721, + 1734 + ], + "loc": { + "start": { + "line": 54, + "column": 28 + }, + "end": { + "line": 54, + "column": 41 + } + } + }, + "range": [ + 1716, + 1734 + ], + "loc": { + "start": { + "line": 54, + "column": 23 + }, + "end": { + "line": 54, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1735, + 1739 + ], + "loc": { + "start": { + "line": 54, + "column": 42 + }, + "end": { + "line": 54, + "column": 46 + } + } + }, + "range": [ + 1716, + 1740 + ], + "loc": { + "start": { + "line": 54, + "column": 23 + }, + "end": { + "line": 54, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1741, + 1745 + ], + "loc": { + "start": { + "line": 54, + "column": 48 + }, + "end": { + "line": 54, + "column": 52 + } + } + }, + "range": [ + 1716, + 1745 + ], + "loc": { + "start": { + "line": 54, + "column": 23 + }, + "end": { + "line": 54, + "column": 52 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 1770, + 1774 + ], + "loc": { + "start": { + "line": 55, + "column": 21 + }, + "end": { + "line": 55, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 1775, + 1779 + ], + "loc": { + "start": { + "line": 55, + "column": 26 + }, + "end": { + "line": 55, + "column": 30 + } + } + }, + "range": [ + 1770, + 1779 + ], + "loc": { + "start": { + "line": 55, + "column": 21 + }, + "end": { + "line": 55, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1780, + 1784 + ], + "loc": { + "start": { + "line": 55, + "column": 31 + }, + "end": { + "line": 55, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1785, + 1798 + ], + "loc": { + "start": { + "line": 55, + "column": 36 + }, + "end": { + "line": 55, + "column": 49 + } + } + }, + "range": [ + 1780, + 1798 + ], + "loc": { + "start": { + "line": 55, + "column": 31 + }, + "end": { + "line": 55, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1799, + 1803 + ], + "loc": { + "start": { + "line": 55, + "column": 50 + }, + "end": { + "line": 55, + "column": 54 + } + } + }, + "range": [ + 1780, + 1804 + ], + "loc": { + "start": { + "line": 55, + "column": 31 + }, + "end": { + "line": 55, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1805, + 1809 + ], + "loc": { + "start": { + "line": 55, + "column": 56 + }, + "end": { + "line": 55, + "column": 60 + } + } + }, + "range": [ + 1780, + 1809 + ], + "loc": { + "start": { + "line": 55, + "column": 31 + }, + "end": { + "line": 55, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 1810, + 1814 + ], + "loc": { + "start": { + "line": 55, + "column": 61 + }, + "end": { + "line": 55, + "column": 65 + } + } + }, + "range": [ + 1780, + 1814 + ], + "loc": { + "start": { + "line": 55, + "column": 31 + }, + "end": { + "line": 55, + "column": 65 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 1816, + 1820 + ], + "loc": { + "start": { + "line": 55, + "column": 67 + }, + "end": { + "line": 55, + "column": 71 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 1821, + 1834 + ], + "loc": { + "start": { + "line": 55, + "column": 72 + }, + "end": { + "line": 55, + "column": 85 + } + } + }, + "range": [ + 1816, + 1834 + ], + "loc": { + "start": { + "line": 55, + "column": 67 + }, + "end": { + "line": 55, + "column": 85 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 1835, + 1839 + ], + "loc": { + "start": { + "line": 55, + "column": 86 + }, + "end": { + "line": 55, + "column": 90 + } + } + }, + "range": [ + 1816, + 1840 + ], + "loc": { + "start": { + "line": 55, + "column": 67 + }, + "end": { + "line": 55, + "column": 91 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 1841, + 1845 + ], + "loc": { + "start": { + "line": 55, + "column": 92 + }, + "end": { + "line": 55, + "column": 96 + } + } + }, + "range": [ + 1816, + 1845 + ], + "loc": { + "start": { + "line": 55, + "column": 67 + }, + "end": { + "line": 55, + "column": 96 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 1846, + 1848 + ], + "loc": { + "start": { + "line": 55, + "column": 97 + }, + "end": { + "line": 55, + "column": 99 + } + } + }, + "range": [ + 1816, + 1848 + ], + "loc": { + "start": { + "line": 55, + "column": 67 + }, + "end": { + "line": 55, + "column": 99 + } + } + } + ], + "range": [ + 1770, + 1849 + ], + "loc": { + "start": { + "line": 55, + "column": 21 + }, + "end": { + "line": 55, + "column": 100 + } + } + }, + "range": [ + 1763, + 1850 + ], + "loc": { + "start": { + "line": 55, + "column": 14 + }, + "end": { + "line": 55, + "column": 101 + } + } + } + ], + "range": [ + 1747, + 1864 + ], + "loc": { + "start": { + "line": 54, + "column": 54 + }, + "end": { + "line": 56, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 1712, + 1864 + ], + "loc": { + "start": { + "line": 54, + "column": 19 + }, + "end": { + "line": 56, + "column": 13 + } + } + }, + "range": [ + 1620, + 1864 + ], + "loc": { + "start": { + "line": 52, + "column": 12 + }, + "end": { + "line": 56, + "column": 13 + } + } + } + ], + "range": [ + 1606, + 1876 + ], + "loc": { + "start": { + "line": 51, + "column": 62 + }, + "end": { + "line": 57, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 1554, + 1876 + ], + "loc": { + "start": { + "line": 51, + "column": 10 + }, + "end": { + "line": 57, + "column": 11 + } + } + } + ], + "range": [ + 1512, + 1886 + ], + "loc": { + "start": { + "line": 49, + "column": 42 + }, + "end": { + "line": 58, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1491, + 1886 + ], + "loc": { + "start": { + "line": 49, + "column": 21 + }, + "end": { + "line": 58, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1478, + 1886 + ], + "loc": { + "start": { + "line": 49, + "column": 8 + }, + "end": { + "line": 58, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 1896, + 1905 + ], + "loc": { + "start": { + "line": 59, + "column": 8 + }, + "end": { + "line": 59, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": { + "type": "Identifier", + "name": "serialize", + "range": [ + 1916, + 1925 + ], + "loc": { + "start": { + "line": 59, + "column": 28 + }, + "end": { + "line": 59, + "column": 37 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 1926, + 1934 + ], + "loc": { + "start": { + "line": 59, + "column": 38 + }, + "end": { + "line": 59, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 1936, + 1940 + ], + "loc": { + "start": { + "line": 59, + "column": 48 + }, + "end": { + "line": 59, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 1942, + 1945 + ], + "loc": { + "start": { + "line": 59, + "column": 54 + }, + "end": { + "line": 59, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 1963, + 1971 + ], + "loc": { + "start": { + "line": 60, + "column": 14 + }, + "end": { + "line": 60, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 1972, + 1975 + ], + "loc": { + "start": { + "line": 60, + "column": 23 + }, + "end": { + "line": 60, + "column": 26 + } + } + }, + "range": [ + 1963, + 1976 + ], + "loc": { + "start": { + "line": 60, + "column": 14 + }, + "end": { + "line": 60, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 1981, + 1985 + ], + "loc": { + "start": { + "line": 60, + "column": 32 + }, + "end": { + "line": 60, + "column": 36 + } + } + }, + "range": [ + 1963, + 1985 + ], + "loc": { + "start": { + "line": 60, + "column": 14 + }, + "end": { + "line": 60, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2001, + 2005 + ], + "loc": { + "start": { + "line": 61, + "column": 12 + }, + "end": { + "line": 61, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2006, + 2019 + ], + "loc": { + "start": { + "line": 61, + "column": 17 + }, + "end": { + "line": 61, + "column": 30 + } + } + }, + "range": [ + 2001, + 2019 + ], + "loc": { + "start": { + "line": 61, + "column": 12 + }, + "end": { + "line": 61, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2020, + 2024 + ], + "loc": { + "start": { + "line": 61, + "column": 31 + }, + "end": { + "line": 61, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2028, + 2031 + ], + "loc": { + "start": { + "line": 61, + "column": 39 + }, + "end": { + "line": 61, + "column": 42 + } + } + }, + "range": [ + 2020, + 2031 + ], + "loc": { + "start": { + "line": 61, + "column": 31 + }, + "end": { + "line": 61, + "column": 42 + } + } + }, + "range": [ + 2001, + 2032 + ], + "loc": { + "start": { + "line": 61, + "column": 12 + }, + "end": { + "line": 61, + "column": 43 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2035, + 2039 + ], + "loc": { + "start": { + "line": 61, + "column": 46 + }, + "end": { + "line": 61, + "column": 50 + } + } + }, + "range": [ + 2001, + 2039 + ], + "loc": { + "start": { + "line": 61, + "column": 12 + }, + "end": { + "line": 61, + "column": 50 + } + } + }, + "range": [ + 2001, + 2040 + ], + "loc": { + "start": { + "line": 61, + "column": 12 + }, + "end": { + "line": 61, + "column": 51 + } + } + } + ], + "range": [ + 1987, + 2052 + ], + "loc": { + "start": { + "line": 60, + "column": 38 + }, + "end": { + "line": 62, + "column": 11 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2062, + 2070 + ], + "loc": { + "start": { + "line": 62, + "column": 21 + }, + "end": { + "line": 62, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2071, + 2074 + ], + "loc": { + "start": { + "line": 62, + "column": 30 + }, + "end": { + "line": 62, + "column": 33 + } + } + }, + "range": [ + 2062, + 2075 + ], + "loc": { + "start": { + "line": 62, + "column": 21 + }, + "end": { + "line": 62, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2091, + 2095 + ], + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 63, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2096, + 2109 + ], + "loc": { + "start": { + "line": 63, + "column": 17 + }, + "end": { + "line": 63, + "column": 30 + } + } + }, + "range": [ + 2091, + 2109 + ], + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 63, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2110, + 2114 + ], + "loc": { + "start": { + "line": 63, + "column": 31 + }, + "end": { + "line": 63, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2118, + 2121 + ], + "loc": { + "start": { + "line": 63, + "column": 39 + }, + "end": { + "line": 63, + "column": 42 + } + } + }, + "range": [ + 2110, + 2121 + ], + "loc": { + "start": { + "line": 63, + "column": 31 + }, + "end": { + "line": 63, + "column": 42 + } + } + }, + "range": [ + 2091, + 2122 + ], + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 63, + "column": 43 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 2141, + 2145 + ], + "loc": { + "start": { + "line": 64, + "column": 14 + }, + "end": { + "line": 64, + "column": 18 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 2165, + 2169 + ], + "loc": { + "start": { + "line": 65, + "column": 16 + }, + "end": { + "line": 65, + "column": 20 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2171, + 2179 + ], + "loc": { + "start": { + "line": 65, + "column": 22 + }, + "end": { + "line": 65, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2180, + 2183 + ], + "loc": { + "start": { + "line": 65, + "column": 31 + }, + "end": { + "line": 65, + "column": 34 + } + } + }, + "range": [ + 2171, + 2184 + ], + "loc": { + "start": { + "line": 65, + "column": 22 + }, + "end": { + "line": 65, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 2185, + 2189 + ], + "loc": { + "start": { + "line": 65, + "column": 36 + }, + "end": { + "line": 65, + "column": 40 + } + } + }, + "range": [ + 2171, + 2189 + ], + "loc": { + "start": { + "line": 65, + "column": 22 + }, + "end": { + "line": 65, + "column": 40 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2165, + 2189 + ], + "loc": { + "start": { + "line": 65, + "column": 16 + }, + "end": { + "line": 65, + "column": 40 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 2207, + 2209 + ], + "loc": { + "start": { + "line": 66, + "column": 16 + }, + "end": { + "line": 66, + "column": 18 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 2211, + 2219 + ], + "loc": { + "start": { + "line": 66, + "column": 20 + }, + "end": { + "line": 66, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 2220, + 2223 + ], + "loc": { + "start": { + "line": 66, + "column": 29 + }, + "end": { + "line": 66, + "column": 32 + } + } + }, + "range": [ + 2211, + 2224 + ], + "loc": { + "start": { + "line": 66, + "column": 20 + }, + "end": { + "line": 66, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 2225, + 2227 + ], + "loc": { + "start": { + "line": 66, + "column": 34 + }, + "end": { + "line": 66, + "column": 36 + } + } + }, + "range": [ + 2211, + 2227 + ], + "loc": { + "start": { + "line": 66, + "column": 20 + }, + "end": { + "line": 66, + "column": 36 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2207, + 2227 + ], + "loc": { + "start": { + "line": 66, + "column": 16 + }, + "end": { + "line": 66, + "column": 36 + } + } + } + ], + "range": [ + 2147, + 2243 + ], + "loc": { + "start": { + "line": 64, + "column": 20 + }, + "end": { + "line": 67, + "column": 15 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2141, + 2243 + ], + "loc": { + "start": { + "line": 64, + "column": 14 + }, + "end": { + "line": 67, + "column": 15 + } + } + } + ], + "range": [ + 2125, + 2257 + ], + "loc": { + "start": { + "line": 63, + "column": 46 + }, + "end": { + "line": 68, + "column": 13 + } + } + }, + "range": [ + 2091, + 2257 + ], + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 68, + "column": 13 + } + } + }, + "range": [ + 2091, + 2258 + ], + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 68, + "column": 14 + } + } + } + ], + "range": [ + 2077, + 2270 + ], + "loc": { + "start": { + "line": 62, + "column": 36 + }, + "end": { + "line": 69, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 2058, + 2270 + ], + "loc": { + "start": { + "line": 62, + "column": 17 + }, + "end": { + "line": 69, + "column": 11 + } + } + }, + "range": [ + 1959, + 2270 + ], + "loc": { + "start": { + "line": 60, + "column": 10 + }, + "end": { + "line": 69, + "column": 11 + } + } + } + ], + "range": [ + 1947, + 2280 + ], + "loc": { + "start": { + "line": 59, + "column": 59 + }, + "end": { + "line": 70, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1907, + 2280 + ], + "loc": { + "start": { + "line": 59, + "column": 19 + }, + "end": { + "line": 70, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 1896, + 2280 + ], + "loc": { + "start": { + "line": 59, + "column": 8 + }, + "end": { + "line": 70, + "column": 9 + } + } + } + ], + "range": [ + 1398, + 2288 + ], + "loc": { + "start": { + "line": 46, + "column": 13 + }, + "end": { + "line": 71, + "column": 7 + } + } + }, + "range": [ + 1391, + 2289 + ], + "loc": { + "start": { + "line": 46, + "column": 6 + }, + "end": { + "line": 71, + "column": 8 + } + } + } + ], + "range": [ + 1383, + 2295 + ], + "loc": { + "start": { + "line": 45, + "column": 11 + }, + "end": { + "line": 72, + "column": 5 + } + } + }, + "range": [ + 1293, + 2295 + ], + "loc": { + "start": { + "line": 43, + "column": 4 + }, + "end": { + "line": 72, + "column": 5 + } + } + } + ], + "range": [ + 1287, + 2299 + ], + "loc": { + "start": { + "line": 42, + "column": 31 + }, + "end": { + "line": 73, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 1271, + 2299 + ], + "loc": { + "start": { + "line": 42, + "column": 15 + }, + "end": { + "line": 73, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 1258, + 2299 + ], + "loc": { + "start": { + "line": 42, + "column": 2 + }, + "end": { + "line": 73, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 918, + 1255 + ], + "loc": { + "start": { + "line": 33, + "column": 2 + }, + "end": { + "line": 41, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2303, + 2641 + ], + "loc": { + "start": { + "line": 75, + "column": 2 + }, + "end": { + "line": 83, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "hasMany", + "range": [ + 2651, + 2658 + ], + "loc": { + "start": { + "line": 84, + "column": 9 + }, + "end": { + "line": 84, + "column": 16 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 2659, + 2663 + ], + "loc": { + "start": { + "line": 84, + "column": 17 + }, + "end": { + "line": 84, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 2665, + 2672 + ], + "loc": { + "start": { + "line": 84, + "column": 23 + }, + "end": { + "line": 84, + "column": 30 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2684, + 2688 + ], + "loc": { + "start": { + "line": 85, + "column": 8 + }, + "end": { + "line": 85, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "name", + "range": [ + 2699, + 2703 + ], + "loc": { + "start": { + "line": 85, + "column": 23 + }, + "end": { + "line": 85, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 2692, + 2703 + ], + "loc": { + "start": { + "line": 85, + "column": 16 + }, + "end": { + "line": 85, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "'object'", + "range": [ + 2708, + 2716 + ], + "loc": { + "start": { + "line": 85, + "column": 32 + }, + "end": { + "line": 85, + "column": 40 + } + } + }, + "range": [ + 2692, + 2716 + ], + "loc": { + "start": { + "line": 85, + "column": 16 + }, + "end": { + "line": 85, + "column": 40 + } + } + }, + "range": [ + 2684, + 2716 + ], + "loc": { + "start": { + "line": 85, + "column": 8 + }, + "end": { + "line": 85, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 2733, + 2738 + ], + "loc": { + "start": { + "line": 86, + "column": 13 + }, + "end": { + "line": 86, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasMany", + "range": [ + 2739, + 2746 + ], + "loc": { + "start": { + "line": 86, + "column": 19 + }, + "end": { + "line": 86, + "column": 26 + } + } + }, + "range": [ + 2733, + 2746 + ], + "loc": { + "start": { + "line": 86, + "column": 13 + }, + "end": { + "line": 86, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 2747, + 2751 + ], + "loc": { + "start": { + "line": 86, + "column": 27 + }, + "end": { + "line": 86, + "column": 31 + } + } + }, + { + "type": "Identifier", + "name": "name", + "range": [ + 2753, + 2757 + ], + "loc": { + "start": { + "line": 86, + "column": 33 + }, + "end": { + "line": 86, + "column": 37 + } + } + } + ], + "range": [ + 2733, + 2758 + ], + "loc": { + "start": { + "line": 86, + "column": 13 + }, + "end": { + "line": 86, + "column": 38 + } + } + }, + "range": [ + 2726, + 2759 + ], + "loc": { + "start": { + "line": 86, + "column": 6 + }, + "end": { + "line": 86, + "column": 39 + } + } + } + ], + "range": [ + 2718, + 2765 + ], + "loc": { + "start": { + "line": 85, + "column": 42 + }, + "end": { + "line": 87, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 2796, + 2800 + ], + "loc": { + "start": { + "line": 89, + "column": 8 + }, + "end": { + "line": 89, + "column": 12 + } + } + }, + "value": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 2802, + 2812 + ], + "loc": { + "start": { + "line": 89, + "column": 14 + }, + "end": { + "line": 89, + "column": 24 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2796, + 2812 + ], + "loc": { + "start": { + "line": 89, + "column": 8 + }, + "end": { + "line": 89, + "column": 24 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "default", + "range": [ + 2822, + 2829 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 15 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 2831, + 2833 + ], + "loc": { + "start": { + "line": 90, + "column": 17 + }, + "end": { + "line": 90, + "column": 19 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2822, + 2833 + ], + "loc": { + "start": { + "line": 90, + "column": 8 + }, + "end": { + "line": 90, + "column": 19 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "inverse", + "range": [ + 2843, + 2850 + ], + "loc": { + "start": { + "line": 91, + "column": 8 + }, + "end": { + "line": 91, + "column": 15 + } + } + }, + "value": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "options", + "range": [ + 2852, + 2859 + ], + "loc": { + "start": { + "line": 91, + "column": 17 + }, + "end": { + "line": 91, + "column": 24 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "options", + "range": [ + 2863, + 2870 + ], + "loc": { + "start": { + "line": 91, + "column": 28 + }, + "end": { + "line": 91, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 2871, + 2878 + ], + "loc": { + "start": { + "line": 91, + "column": 36 + }, + "end": { + "line": 91, + "column": 43 + } + } + }, + "range": [ + 2863, + 2878 + ], + "loc": { + "start": { + "line": 91, + "column": 28 + }, + "end": { + "line": 91, + "column": 43 + } + } + }, + "range": [ + 2852, + 2878 + ], + "loc": { + "start": { + "line": 91, + "column": 17 + }, + "end": { + "line": 91, + "column": 43 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2843, + 2878 + ], + "loc": { + "start": { + "line": 91, + "column": 8 + }, + "end": { + "line": 91, + "column": 43 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 2888, + 2899 + ], + "loc": { + "start": { + "line": 92, + "column": 8 + }, + "end": { + "line": 92, + "column": 19 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 2911, + 2915 + ], + "loc": { + "start": { + "line": 92, + "column": 31 + }, + "end": { + "line": 92, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 2917, + 2920 + ], + "loc": { + "start": { + "line": 92, + "column": 37 + }, + "end": { + "line": 92, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2934, + 2938 + ], + "loc": { + "start": { + "line": 93, + "column": 10 + }, + "end": { + "line": 93, + "column": 14 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 2941, + 2945 + ], + "loc": { + "start": { + "line": 93, + "column": 17 + }, + "end": { + "line": 93, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 2949, + 2952 + ], + "loc": { + "start": { + "line": 93, + "column": 25 + }, + "end": { + "line": 93, + "column": 28 + } + } + }, + "range": [ + 2941, + 2952 + ], + "loc": { + "start": { + "line": 93, + "column": 17 + }, + "end": { + "line": 93, + "column": 28 + } + } + }, + "range": [ + 2934, + 2952 + ], + "loc": { + "start": { + "line": 93, + "column": 10 + }, + "end": { + "line": 93, + "column": 28 + } + } + }, + "range": [ + 2934, + 2953 + ], + "loc": { + "start": { + "line": 93, + "column": 10 + }, + "end": { + "line": 93, + "column": 29 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2968, + 2972 + ], + "loc": { + "start": { + "line": 94, + "column": 14 + }, + "end": { + "line": 94, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2973, + 2986 + ], + "loc": { + "start": { + "line": 94, + "column": 19 + }, + "end": { + "line": 94, + "column": 32 + } + } + }, + "range": [ + 2968, + 2986 + ], + "loc": { + "start": { + "line": 94, + "column": 14 + }, + "end": { + "line": 94, + "column": 32 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 2990, + 2994 + ], + "loc": { + "start": { + "line": 94, + "column": 36 + }, + "end": { + "line": 94, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 2995, + 3008 + ], + "loc": { + "start": { + "line": 94, + "column": 41 + }, + "end": { + "line": 94, + "column": 54 + } + } + }, + "range": [ + 2990, + 3008 + ], + "loc": { + "start": { + "line": 94, + "column": 36 + }, + "end": { + "line": 94, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3009, + 3013 + ], + "loc": { + "start": { + "line": 94, + "column": 55 + }, + "end": { + "line": 94, + "column": 59 + } + } + }, + "range": [ + 2990, + 3014 + ], + "loc": { + "start": { + "line": 94, + "column": 36 + }, + "end": { + "line": 94, + "column": 60 + } + } + }, + "range": [ + 2968, + 3014 + ], + "loc": { + "start": { + "line": 94, + "column": 14 + }, + "end": { + "line": 94, + "column": 60 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3034, + 3038 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3039, + 3052 + ], + "loc": { + "start": { + "line": 95, + "column": 21 + }, + "end": { + "line": 95, + "column": 34 + } + } + }, + "range": [ + 3034, + 3052 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3053, + 3057 + ], + "loc": { + "start": { + "line": 95, + "column": 35 + }, + "end": { + "line": 95, + "column": 39 + } + } + }, + "range": [ + 3034, + 3058 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3059, + 3063 + ], + "loc": { + "start": { + "line": 95, + "column": 41 + }, + "end": { + "line": 95, + "column": 45 + } + } + }, + "range": [ + 3034, + 3063 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 3068, + 3072 + ], + "loc": { + "start": { + "line": 95, + "column": 50 + }, + "end": { + "line": 95, + "column": 54 + } + } + }, + "range": [ + 3034, + 3072 + ], + "loc": { + "start": { + "line": 95, + "column": 16 + }, + "end": { + "line": 95, + "column": 54 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 3097, + 3099 + ], + "loc": { + "start": { + "line": 96, + "column": 21 + }, + "end": { + "line": 96, + "column": 23 + } + } + }, + "range": [ + 3090, + 3100 + ], + "loc": { + "start": { + "line": 96, + "column": 14 + }, + "end": { + "line": 96, + "column": 24 + } + } + } + ], + "range": [ + 3074, + 3114 + ], + "loc": { + "start": { + "line": 95, + "column": 56 + }, + "end": { + "line": 97, + "column": 13 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3124, + 3128 + ], + "loc": { + "start": { + "line": 97, + "column": 23 + }, + "end": { + "line": 97, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3129, + 3142 + ], + "loc": { + "start": { + "line": 97, + "column": 28 + }, + "end": { + "line": 97, + "column": 41 + } + } + }, + "range": [ + 3124, + 3142 + ], + "loc": { + "start": { + "line": 97, + "column": 23 + }, + "end": { + "line": 97, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3143, + 3147 + ], + "loc": { + "start": { + "line": 97, + "column": 42 + }, + "end": { + "line": 97, + "column": 46 + } + } + }, + "range": [ + 3124, + 3148 + ], + "loc": { + "start": { + "line": 97, + "column": 23 + }, + "end": { + "line": 97, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3149, + 3153 + ], + "loc": { + "start": { + "line": 97, + "column": 48 + }, + "end": { + "line": 97, + "column": 52 + } + } + }, + "range": [ + 3124, + 3153 + ], + "loc": { + "start": { + "line": 97, + "column": 23 + }, + "end": { + "line": 97, + "column": 52 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3178, + 3182 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3183, + 3196 + ], + "loc": { + "start": { + "line": 98, + "column": 26 + }, + "end": { + "line": 98, + "column": 39 + } + } + }, + "range": [ + 3178, + 3196 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 3197, + 3201 + ], + "loc": { + "start": { + "line": 98, + "column": 40 + }, + "end": { + "line": 98, + "column": 44 + } + } + }, + "range": [ + 3178, + 3202 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 3203, + 3207 + ], + "loc": { + "start": { + "line": 98, + "column": 46 + }, + "end": { + "line": 98, + "column": 50 + } + } + }, + "range": [ + 3178, + 3207 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 3208, + 3211 + ], + "loc": { + "start": { + "line": 98, + "column": 51 + }, + "end": { + "line": 98, + "column": 54 + } + } + }, + "range": [ + 3178, + 3211 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 98, + "column": 54 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "c", + "range": [ + 3213, + 3214 + ], + "loc": { + "start": { + "line": 98, + "column": 56 + }, + "end": { + "line": 98, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3244, + 3248 + ], + "loc": { + "start": { + "line": 99, + "column": 23 + }, + "end": { + "line": 99, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 3249, + 3253 + ], + "loc": { + "start": { + "line": 99, + "column": 28 + }, + "end": { + "line": 99, + "column": 32 + } + } + }, + "range": [ + 3244, + 3253 + ], + "loc": { + "start": { + "line": 99, + "column": 23 + }, + "end": { + "line": 99, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "c", + "range": [ + 3254, + 3255 + ], + "loc": { + "start": { + "line": 99, + "column": 33 + }, + "end": { + "line": 99, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 3256, + 3260 + ], + "loc": { + "start": { + "line": 99, + "column": 35 + }, + "end": { + "line": 99, + "column": 39 + } + } + }, + "range": [ + 3254, + 3260 + ], + "loc": { + "start": { + "line": 99, + "column": 33 + }, + "end": { + "line": 99, + "column": 39 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "c", + "range": [ + 3262, + 3263 + ], + "loc": { + "start": { + "line": 99, + "column": 41 + }, + "end": { + "line": 99, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 3264, + 3266 + ], + "loc": { + "start": { + "line": 99, + "column": 43 + }, + "end": { + "line": 99, + "column": 45 + } + } + }, + "range": [ + 3262, + 3266 + ], + "loc": { + "start": { + "line": 99, + "column": 41 + }, + "end": { + "line": 99, + "column": 45 + } + } + } + ], + "range": [ + 3244, + 3267 + ], + "loc": { + "start": { + "line": 99, + "column": 23 + }, + "end": { + "line": 99, + "column": 46 + } + } + }, + "range": [ + 3237, + 3268 + ], + "loc": { + "start": { + "line": 99, + "column": 16 + }, + "end": { + "line": 99, + "column": 47 + } + } + } + ], + "range": [ + 3219, + 3284 + ], + "loc": { + "start": { + "line": 98, + "column": 62 + }, + "end": { + "line": 100, + "column": 15 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3212, + 3284 + ], + "loc": { + "start": { + "line": 98, + "column": 55 + }, + "end": { + "line": 100, + "column": 15 + } + } + } + ], + "range": [ + 3178, + 3285 + ], + "loc": { + "start": { + "line": 98, + "column": 21 + }, + "end": { + "line": 100, + "column": 16 + } + } + }, + "range": [ + 3171, + 3286 + ], + "loc": { + "start": { + "line": 98, + "column": 14 + }, + "end": { + "line": 100, + "column": 17 + } + } + } + ], + "range": [ + 3155, + 3300 + ], + "loc": { + "start": { + "line": 97, + "column": 54 + }, + "end": { + "line": 101, + "column": 13 + } + } + }, + "alternate": null, + "range": [ + 3120, + 3300 + ], + "loc": { + "start": { + "line": 97, + "column": 19 + }, + "end": { + "line": 101, + "column": 13 + } + } + }, + "range": [ + 3030, + 3300 + ], + "loc": { + "start": { + "line": 95, + "column": 12 + }, + "end": { + "line": 101, + "column": 13 + } + } + } + ], + "range": [ + 3016, + 3312 + ], + "loc": { + "start": { + "line": 94, + "column": 62 + }, + "end": { + "line": 102, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 2964, + 3312 + ], + "loc": { + "start": { + "line": 94, + "column": 10 + }, + "end": { + "line": 102, + "column": 11 + } + } + } + ], + "range": [ + 2922, + 3322 + ], + "loc": { + "start": { + "line": 92, + "column": 42 + }, + "end": { + "line": 103, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 2901, + 3322 + ], + "loc": { + "start": { + "line": 92, + "column": 21 + }, + "end": { + "line": 103, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 2888, + 3322 + ], + "loc": { + "start": { + "line": 92, + "column": 8 + }, + "end": { + "line": 103, + "column": 9 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "serialize", + "range": [ + 3332, + 3341 + ], + "loc": { + "start": { + "line": 104, + "column": 8 + }, + "end": { + "line": 104, + "column": 17 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": { + "type": "Identifier", + "name": "serialize", + "range": [ + 3352, + 3361 + ], + "loc": { + "start": { + "line": 104, + "column": 28 + }, + "end": { + "line": 104, + "column": 37 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 3362, + 3370 + ], + "loc": { + "start": { + "line": 104, + "column": 38 + }, + "end": { + "line": 104, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 3372, + 3376 + ], + "loc": { + "start": { + "line": 104, + "column": 48 + }, + "end": { + "line": 104, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "key", + "range": [ + 3378, + 3381 + ], + "loc": { + "start": { + "line": 104, + "column": 54 + }, + "end": { + "line": 104, + "column": 57 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 3399, + 3407 + ], + "loc": { + "start": { + "line": 105, + "column": 14 + }, + "end": { + "line": 105, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 3408, + 3411 + ], + "loc": { + "start": { + "line": 105, + "column": 23 + }, + "end": { + "line": 105, + "column": 26 + } + } + }, + "range": [ + 3399, + 3412 + ], + "loc": { + "start": { + "line": 105, + "column": 14 + }, + "end": { + "line": 105, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 3428, + 3432 + ], + "loc": { + "start": { + "line": 106, + "column": 12 + }, + "end": { + "line": 106, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "relationships", + "range": [ + 3433, + 3446 + ], + "loc": { + "start": { + "line": 106, + "column": 17 + }, + "end": { + "line": 106, + "column": 30 + } + } + }, + "range": [ + 3428, + 3446 + ], + "loc": { + "start": { + "line": 106, + "column": 12 + }, + "end": { + "line": 106, + "column": 30 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "name", + "range": [ + 3447, + 3451 + ], + "loc": { + "start": { + "line": 106, + "column": 31 + }, + "end": { + "line": 106, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "key", + "range": [ + 3455, + 3458 + ], + "loc": { + "start": { + "line": 106, + "column": 39 + }, + "end": { + "line": 106, + "column": 42 + } + } + }, + "range": [ + 3447, + 3458 + ], + "loc": { + "start": { + "line": 106, + "column": 31 + }, + "end": { + "line": 106, + "column": 42 + } + } + }, + "range": [ + 3428, + 3459 + ], + "loc": { + "start": { + "line": 106, + "column": 12 + }, + "end": { + "line": 106, + "column": 43 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "data", + "range": [ + 3478, + 3482 + ], + "loc": { + "start": { + "line": 107, + "column": 14 + }, + "end": { + "line": 107, + "column": 18 + } + } + }, + "value": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 3484, + 3492 + ], + "loc": { + "start": { + "line": 107, + "column": 20 + }, + "end": { + "line": 107, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 3493, + 3496 + ], + "loc": { + "start": { + "line": 107, + "column": 29 + }, + "end": { + "line": 107, + "column": 32 + } + } + }, + "range": [ + 3484, + 3497 + ], + "loc": { + "start": { + "line": 107, + "column": 20 + }, + "end": { + "line": 107, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 3498, + 3501 + ], + "loc": { + "start": { + "line": 107, + "column": 34 + }, + "end": { + "line": 107, + "column": 37 + } + } + }, + "range": [ + 3484, + 3501 + ], + "loc": { + "start": { + "line": 107, + "column": 20 + }, + "end": { + "line": 107, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 3502, + 3503 + ], + "loc": { + "start": { + "line": 107, + "column": 38 + }, + "end": { + "line": 107, + "column": 39 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 3534, + 3538 + ], + "loc": { + "start": { + "line": 108, + "column": 25 + }, + "end": { + "line": 108, + "column": 29 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 3540, + 3541 + ], + "loc": { + "start": { + "line": 108, + "column": 31 + }, + "end": { + "line": 108, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 3542, + 3546 + ], + "loc": { + "start": { + "line": 108, + "column": 33 + }, + "end": { + "line": 108, + "column": 37 + } + } + }, + "range": [ + 3540, + 3546 + ], + "loc": { + "start": { + "line": 108, + "column": 31 + }, + "end": { + "line": 108, + "column": 37 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3534, + 3546 + ], + "loc": { + "start": { + "line": 108, + "column": 25 + }, + "end": { + "line": 108, + "column": 37 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 3548, + 3550 + ], + "loc": { + "start": { + "line": 108, + "column": 39 + }, + "end": { + "line": 108, + "column": 41 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "x", + "range": [ + 3552, + 3553 + ], + "loc": { + "start": { + "line": 108, + "column": 43 + }, + "end": { + "line": 108, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 3554, + 3556 + ], + "loc": { + "start": { + "line": 108, + "column": 45 + }, + "end": { + "line": 108, + "column": 47 + } + } + }, + "range": [ + 3552, + 3556 + ], + "loc": { + "start": { + "line": 108, + "column": 43 + }, + "end": { + "line": 108, + "column": 47 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3548, + 3556 + ], + "loc": { + "start": { + "line": 108, + "column": 39 + }, + "end": { + "line": 108, + "column": 47 + } + } + } + ], + "range": [ + 3532, + 3558 + ], + "loc": { + "start": { + "line": 108, + "column": 23 + }, + "end": { + "line": 108, + "column": 49 + } + } + }, + "range": [ + 3525, + 3559 + ], + "loc": { + "start": { + "line": 108, + "column": 16 + }, + "end": { + "line": 108, + "column": 50 + } + } + } + ], + "range": [ + 3507, + 3575 + ], + "loc": { + "start": { + "line": 107, + "column": 43 + }, + "end": { + "line": 109, + "column": 15 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3502, + 3575 + ], + "loc": { + "start": { + "line": 107, + "column": 38 + }, + "end": { + "line": 109, + "column": 15 + } + } + } + ], + "range": [ + 3484, + 3576 + ], + "loc": { + "start": { + "line": 107, + "column": 20 + }, + "end": { + "line": 109, + "column": 16 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3478, + 3576 + ], + "loc": { + "start": { + "line": 107, + "column": 14 + }, + "end": { + "line": 109, + "column": 16 + } + } + } + ], + "range": [ + 3462, + 3590 + ], + "loc": { + "start": { + "line": 106, + "column": 46 + }, + "end": { + "line": 110, + "column": 13 + } + } + }, + "range": [ + 3428, + 3590 + ], + "loc": { + "start": { + "line": 106, + "column": 12 + }, + "end": { + "line": 110, + "column": 13 + } + } + }, + "range": [ + 3428, + 3591 + ], + "loc": { + "start": { + "line": 106, + "column": 12 + }, + "end": { + "line": 110, + "column": 14 + } + } + } + ], + "range": [ + 3414, + 3603 + ], + "loc": { + "start": { + "line": 105, + "column": 29 + }, + "end": { + "line": 111, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 3395, + 3603 + ], + "loc": { + "start": { + "line": 105, + "column": 10 + }, + "end": { + "line": 111, + "column": 11 + } + } + } + ], + "range": [ + 3383, + 3613 + ], + "loc": { + "start": { + "line": 104, + "column": 59 + }, + "end": { + "line": 112, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3343, + 3613 + ], + "loc": { + "start": { + "line": 104, + "column": 19 + }, + "end": { + "line": 112, + "column": 9 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 3332, + 3613 + ], + "loc": { + "start": { + "line": 104, + "column": 8 + }, + "end": { + "line": 112, + "column": 9 + } + } + } + ], + "range": [ + 2786, + 3621 + ], + "loc": { + "start": { + "line": 88, + "column": 13 + }, + "end": { + "line": 113, + "column": 7 + } + } + }, + "range": [ + 2779, + 3622 + ], + "loc": { + "start": { + "line": 88, + "column": 6 + }, + "end": { + "line": 113, + "column": 8 + } + } + } + ], + "range": [ + 2771, + 3628 + ], + "loc": { + "start": { + "line": 87, + "column": 11 + }, + "end": { + "line": 114, + "column": 5 + } + } + }, + "range": [ + 2680, + 3628 + ], + "loc": { + "start": { + "line": 85, + "column": 4 + }, + "end": { + "line": 114, + "column": 5 + } + } + } + ], + "range": [ + 2674, + 3632 + ], + "loc": { + "start": { + "line": 84, + "column": 32 + }, + "end": { + "line": 115, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 2658, + 3632 + ], + "loc": { + "start": { + "line": 84, + "column": 16 + }, + "end": { + "line": 115, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 2644, + 3632 + ], + "loc": { + "start": { + "line": 84, + "column": 2 + }, + "end": { + "line": 115, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2303, + 2641 + ], + "loc": { + "start": { + "line": 75, + "column": 2 + }, + "end": { + "line": 83, + "column": 5 + } + } + } + ], + "static": true + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 3636, + 3647 + ], + "loc": { + "start": { + "line": 117, + "column": 2 + }, + "end": { + "line": 117, + "column": 13 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "adapter", + "range": [ + 3648, + 3655 + ], + "loc": { + "start": { + "line": 117, + "column": 14 + }, + "end": { + "line": 117, + "column": 21 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3664, + 3668 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 3669, + 3677 + ], + "loc": { + "start": { + "line": 119, + "column": 9 + }, + "end": { + "line": 119, + "column": 17 + } + } + }, + "range": [ + 3664, + 3677 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 17 + } + } + }, + "right": { + "type": "Identifier", + "name": "adapter", + "range": [ + 3680, + 3687 + ], + "loc": { + "start": { + "line": 119, + "column": 20 + }, + "end": { + "line": 119, + "column": 27 + } + } + }, + "range": [ + 3664, + 3687 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 27 + } + } + }, + "range": [ + 3664, + 3688 + ], + "loc": { + "start": { + "line": 119, + "column": 4 + }, + "end": { + "line": 119, + "column": 28 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3693, + 3697 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 3698, + 3703 + ], + "loc": { + "start": { + "line": 120, + "column": 9 + }, + "end": { + "line": 120, + "column": 14 + } + } + }, + "range": [ + 3693, + 3703 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 14 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3706, + 3708 + ], + "loc": { + "start": { + "line": 120, + "column": 17 + }, + "end": { + "line": 120, + "column": 19 + } + } + }, + "range": [ + 3693, + 3708 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 19 + } + } + }, + "range": [ + 3693, + 3709 + ], + "loc": { + "start": { + "line": 120, + "column": 4 + }, + "end": { + "line": 120, + "column": 20 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3714, + 3718 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subject", + "range": [ + 3719, + 3727 + ], + "loc": { + "start": { + "line": 121, + "column": 9 + }, + "end": { + "line": 121, + "column": 17 + } + } + }, + "range": [ + 3714, + 3727 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 17 + } + } + }, + "right": { + "type": "NewExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Rx", + "range": [ + 3734, + 3736 + ], + "loc": { + "start": { + "line": 121, + "column": 24 + }, + "end": { + "line": 121, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "Subject", + "range": [ + 3737, + 3744 + ], + "loc": { + "start": { + "line": 121, + "column": 27 + }, + "end": { + "line": 121, + "column": 34 + } + } + }, + "range": [ + 3734, + 3744 + ], + "loc": { + "start": { + "line": 121, + "column": 24 + }, + "end": { + "line": 121, + "column": 34 + } + } + }, + "arguments": [], + "range": [ + 3730, + 3746 + ], + "loc": { + "start": { + "line": 121, + "column": 20 + }, + "end": { + "line": 121, + "column": 36 + } + } + }, + "range": [ + 3714, + 3746 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 36 + } + } + }, + "range": [ + 3714, + 3747 + ], + "loc": { + "start": { + "line": 121, + "column": 4 + }, + "end": { + "line": 121, + "column": 37 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3752, + 3756 + ], + "loc": { + "start": { + "line": 122, + "column": 4 + }, + "end": { + "line": 122, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 3757, + 3771 + ], + "loc": { + "start": { + "line": 122, + "column": 9 + }, + "end": { + "line": 122, + "column": 23 + } + } + }, + "range": [ + 3752, + 3771 + ], + "loc": { + "start": { + "line": 122, + "column": 4 + }, + "end": { + "line": 122, + "column": 23 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3774, + 3776 + ], + "loc": { + "start": { + "line": 122, + "column": 26 + }, + "end": { + "line": 122, + "column": 28 + } + } + }, + "range": [ + 3752, + 3776 + ], + "loc": { + "start": { + "line": 122, + "column": 4 + }, + "end": { + "line": 122, + "column": 28 + } + } + }, + "range": [ + 3752, + 3777 + ], + "loc": { + "start": { + "line": 122, + "column": 4 + }, + "end": { + "line": 122, + "column": 29 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 3782, + 3786 + ], + "loc": { + "start": { + "line": 123, + "column": 4 + }, + "end": { + "line": 123, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 3787, + 3793 + ], + "loc": { + "start": { + "line": 123, + "column": 9 + }, + "end": { + "line": 123, + "column": 15 + } + } + }, + "range": [ + 3782, + 3793 + ], + "loc": { + "start": { + "line": 123, + "column": 4 + }, + "end": { + "line": 123, + "column": 15 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 3796, + 3798 + ], + "loc": { + "start": { + "line": 123, + "column": 18 + }, + "end": { + "line": 123, + "column": 20 + } + } + }, + "range": [ + 3782, + 3798 + ], + "loc": { + "start": { + "line": 123, + "column": 4 + }, + "end": { + "line": 123, + "column": 20 + } + } + }, + "range": [ + 3782, + 3799 + ], + "loc": { + "start": { + "line": 123, + "column": 4 + }, + "end": { + "line": 123, + "column": 21 + } + }, + "trailingComments": [ + { + "type": "Block", + "value": "*\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n ", + "range": [ + 3805, + 5173 + ], + "loc": { + "start": { + "line": 125, + "column": 4 + }, + "end": { + "line": 162, + "column": 7 + } + } + } + ] + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5178, + 5182 + ], + "loc": { + "start": { + "line": 163, + "column": 4 + }, + "end": { + "line": 163, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "observable", + "range": [ + 5183, + 5193 + ], + "loc": { + "start": { + "line": 163, + "column": 9 + }, + "end": { + "line": 163, + "column": 19 + } + } + }, + "range": [ + 5178, + 5193 + ], + "loc": { + "start": { + "line": 163, + "column": 4 + }, + "end": { + "line": 163, + "column": 19 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5196, + 5200 + ], + "loc": { + "start": { + "line": 163, + "column": 22 + }, + "end": { + "line": 163, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subject", + "range": [ + 5201, + 5209 + ], + "loc": { + "start": { + "line": 163, + "column": 27 + }, + "end": { + "line": 163, + "column": 35 + } + } + }, + "range": [ + 5196, + 5209 + ], + "loc": { + "start": { + "line": 163, + "column": 22 + }, + "end": { + "line": 163, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "asObservable", + "range": [ + 5210, + 5222 + ], + "loc": { + "start": { + "line": 163, + "column": 36 + }, + "end": { + "line": 163, + "column": 48 + } + } + }, + "range": [ + 5196, + 5222 + ], + "loc": { + "start": { + "line": 163, + "column": 22 + }, + "end": { + "line": 163, + "column": 48 + } + } + }, + "arguments": [], + "range": [ + 5196, + 5224 + ], + "loc": { + "start": { + "line": 163, + "column": 22 + }, + "end": { + "line": 163, + "column": 50 + } + } + }, + "range": [ + 5178, + 5224 + ], + "loc": { + "start": { + "line": 163, + "column": 4 + }, + "end": { + "line": 163, + "column": 50 + } + } + }, + "range": [ + 5178, + 5225 + ], + "loc": { + "start": { + "line": 163, + "column": 4 + }, + "end": { + "line": 163, + "column": 51 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n ", + "range": [ + 3805, + 5173 + ], + "loc": { + "start": { + "line": 125, + "column": 4 + }, + "end": { + "line": 162, + "column": 7 + } + } + } + ] + } + ], + "range": [ + 3657, + 5230 + ], + "loc": { + "start": { + "line": 117, + "column": 23 + }, + "end": { + "line": 165, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 3647, + 5230 + ], + "loc": { + "start": { + "line": 117, + "column": 13 + }, + "end": { + "line": 165, + "column": 3 + } + } + }, + "kind": "constructor", + "computed": false, + "range": [ + 3636, + 5230 + ], + "loc": { + "start": { + "line": 117, + "column": 2 + }, + "end": { + "line": 165, + "column": 3 + } + }, + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n ", + "range": [ + 5234, + 5506 + ], + "loc": { + "start": { + "line": 167, + "column": 2 + }, + "end": { + "line": 174, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "add", + "range": [ + 5509, + 5512 + ], + "loc": { + "start": { + "line": 175, + "column": 2 + }, + "end": { + "line": 175, + "column": 5 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 5513, + 5519 + ], + "loc": { + "start": { + "line": 175, + "column": 6 + }, + "end": { + "line": 175, + "column": 12 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "object", + "range": [ + 5531, + 5537 + ], + "loc": { + "start": { + "line": 176, + "column": 8 + }, + "end": { + "line": 176, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5551, + 5557 + ], + "loc": { + "start": { + "line": 177, + "column": 10 + }, + "end": { + "line": 177, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5558, + 5562 + ], + "loc": { + "start": { + "line": 177, + "column": 17 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "range": [ + 5551, + 5562 + ], + "loc": { + "start": { + "line": 177, + "column": 10 + }, + "end": { + "line": 177, + "column": 21 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5566, + 5572 + ], + "loc": { + "start": { + "line": 177, + "column": 25 + }, + "end": { + "line": 177, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 5573, + 5575 + ], + "loc": { + "start": { + "line": 177, + "column": 32 + }, + "end": { + "line": 177, + "column": 34 + } + } + }, + "range": [ + 5566, + 5575 + ], + "loc": { + "start": { + "line": 177, + "column": 25 + }, + "end": { + "line": 177, + "column": 34 + } + } + }, + "range": [ + 5551, + 5575 + ], + "loc": { + "start": { + "line": 177, + "column": 10 + }, + "end": { + "line": 177, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "name", + "range": [ + 5591, + 5595 + ], + "loc": { + "start": { + "line": 178, + "column": 12 + }, + "end": { + "line": 178, + "column": 16 + } + } + }, + "init": { + "type": "ConditionalExpression", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5598, + 5602 + ], + "loc": { + "start": { + "line": 178, + "column": 19 + }, + "end": { + "line": 178, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 5603, + 5608 + ], + "loc": { + "start": { + "line": 178, + "column": 24 + }, + "end": { + "line": 178, + "column": 29 + } + } + }, + "range": [ + 5598, + 5608 + ], + "loc": { + "start": { + "line": 178, + "column": 19 + }, + "end": { + "line": 178, + "column": 29 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5609, + 5615 + ], + "loc": { + "start": { + "line": 178, + "column": 30 + }, + "end": { + "line": 178, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5616, + 5620 + ], + "loc": { + "start": { + "line": 178, + "column": 37 + }, + "end": { + "line": 178, + "column": 41 + } + } + }, + "range": [ + 5609, + 5620 + ], + "loc": { + "start": { + "line": 178, + "column": 30 + }, + "end": { + "line": 178, + "column": 41 + } + } + }, + "range": [ + 5598, + 5621 + ], + "loc": { + "start": { + "line": 178, + "column": 19 + }, + "end": { + "line": 178, + "column": 42 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5625, + 5629 + ], + "loc": { + "start": { + "line": 178, + "column": 46 + }, + "end": { + "line": 178, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 5630, + 5635 + ], + "loc": { + "start": { + "line": 178, + "column": 51 + }, + "end": { + "line": 178, + "column": 56 + } + } + }, + "range": [ + 5625, + 5635 + ], + "loc": { + "start": { + "line": 178, + "column": 46 + }, + "end": { + "line": 178, + "column": 56 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5636, + 5642 + ], + "loc": { + "start": { + "line": 178, + "column": 57 + }, + "end": { + "line": 178, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5643, + 5647 + ], + "loc": { + "start": { + "line": 178, + "column": 64 + }, + "end": { + "line": 178, + "column": 68 + } + } + }, + "range": [ + 5636, + 5647 + ], + "loc": { + "start": { + "line": 178, + "column": 57 + }, + "end": { + "line": 178, + "column": 68 + } + } + }, + "range": [ + 5625, + 5648 + ], + "loc": { + "start": { + "line": 178, + "column": 46 + }, + "end": { + "line": 178, + "column": 69 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5649, + 5655 + ], + "loc": { + "start": { + "line": 178, + "column": 70 + }, + "end": { + "line": 178, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 5656, + 5658 + ], + "loc": { + "start": { + "line": 178, + "column": 77 + }, + "end": { + "line": 178, + "column": 79 + } + } + }, + "range": [ + 5649, + 5658 + ], + "loc": { + "start": { + "line": 178, + "column": 70 + }, + "end": { + "line": 178, + "column": 79 + } + } + }, + "range": [ + 5625, + 5659 + ], + "loc": { + "start": { + "line": 178, + "column": 46 + }, + "end": { + "line": 178, + "column": 80 + } + } + }, + "range": [ + 5598, + 5659 + ], + "loc": { + "start": { + "line": 178, + "column": 19 + }, + "end": { + "line": 178, + "column": 80 + } + } + }, + "consequent": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 5662, + 5671 + ], + "loc": { + "start": { + "line": 178, + "column": 83 + }, + "end": { + "line": 178, + "column": 92 + } + } + }, + "alternate": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 5674, + 5681 + ], + "loc": { + "start": { + "line": 178, + "column": 95 + }, + "end": { + "line": 178, + "column": 102 + } + } + }, + "range": [ + 5598, + 5681 + ], + "loc": { + "start": { + "line": 178, + "column": 19 + }, + "end": { + "line": 178, + "column": 102 + } + } + }, + "range": [ + 5591, + 5681 + ], + "loc": { + "start": { + "line": 178, + "column": 12 + }, + "end": { + "line": 178, + "column": 102 + } + } + } + ], + "kind": "let", + "range": [ + 5587, + 5682 + ], + "loc": { + "start": { + "line": 178, + "column": 8 + }, + "end": { + "line": 178, + "column": 103 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "resource", + "range": [ + 5695, + 5703 + ], + "loc": { + "start": { + "line": 179, + "column": 12 + }, + "end": { + "line": 179, + "column": 20 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5706, + 5710 + ], + "loc": { + "start": { + "line": 179, + "column": 23 + }, + "end": { + "line": 179, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 5711, + 5715 + ], + "loc": { + "start": { + "line": 179, + "column": 28 + }, + "end": { + "line": 179, + "column": 32 + } + } + }, + "range": [ + 5706, + 5715 + ], + "loc": { + "start": { + "line": 179, + "column": 23 + }, + "end": { + "line": 179, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5716, + 5722 + ], + "loc": { + "start": { + "line": 179, + "column": 33 + }, + "end": { + "line": 179, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5723, + 5727 + ], + "loc": { + "start": { + "line": 179, + "column": 40 + }, + "end": { + "line": 179, + "column": 44 + } + } + }, + "range": [ + 5716, + 5727 + ], + "loc": { + "start": { + "line": 179, + "column": 33 + }, + "end": { + "line": 179, + "column": 44 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5729, + 5735 + ], + "loc": { + "start": { + "line": 179, + "column": 46 + }, + "end": { + "line": 179, + "column": 52 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 5736, + 5738 + ], + "loc": { + "start": { + "line": 179, + "column": 53 + }, + "end": { + "line": 179, + "column": 55 + } + } + }, + "range": [ + 5729, + 5738 + ], + "loc": { + "start": { + "line": 179, + "column": 46 + }, + "end": { + "line": 179, + "column": 55 + } + } + } + ], + "range": [ + 5706, + 5739 + ], + "loc": { + "start": { + "line": 179, + "column": 23 + }, + "end": { + "line": 179, + "column": 56 + } + } + }, + "range": [ + 5695, + 5739 + ], + "loc": { + "start": { + "line": 179, + "column": 12 + }, + "end": { + "line": 179, + "column": 56 + } + } + } + ], + "kind": "let", + "range": [ + 5691, + 5740 + ], + "loc": { + "start": { + "line": 179, + "column": 8 + }, + "end": { + "line": 179, + "column": 57 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 5753, + 5763 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 22 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5766, + 5770 + ], + "loc": { + "start": { + "line": 180, + "column": 25 + }, + "end": { + "line": 180, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 5771, + 5777 + ], + "loc": { + "start": { + "line": 180, + "column": 30 + }, + "end": { + "line": 180, + "column": 36 + } + } + }, + "range": [ + 5766, + 5777 + ], + "loc": { + "start": { + "line": 180, + "column": 25 + }, + "end": { + "line": 180, + "column": 36 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 5778, + 5784 + ], + "loc": { + "start": { + "line": 180, + "column": 37 + }, + "end": { + "line": 180, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 5785, + 5789 + ], + "loc": { + "start": { + "line": 180, + "column": 44 + }, + "end": { + "line": 180, + "column": 48 + } + } + }, + "range": [ + 5778, + 5789 + ], + "loc": { + "start": { + "line": 180, + "column": 37 + }, + "end": { + "line": 180, + "column": 48 + } + } + }, + "range": [ + 5766, + 5790 + ], + "loc": { + "start": { + "line": 180, + "column": 25 + }, + "end": { + "line": 180, + "column": 49 + } + } + }, + "range": [ + 5753, + 5790 + ], + "loc": { + "start": { + "line": 180, + "column": 12 + }, + "end": { + "line": 180, + "column": 49 + } + } + } + ], + "kind": "let", + "range": [ + 5749, + 5791 + ], + "loc": { + "start": { + "line": 180, + "column": 8 + }, + "end": { + "line": 180, + "column": 50 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 5800, + 5806 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 181, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 5807, + 5811 + ], + "loc": { + "start": { + "line": 181, + "column": 15 + }, + "end": { + "line": 181, + "column": 19 + } + } + }, + "range": [ + 5800, + 5811 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 181, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 5812, + 5822 + ], + "loc": { + "start": { + "line": 181, + "column": 20 + }, + "end": { + "line": 181, + "column": 30 + } + } + } + ], + "range": [ + 5800, + 5823 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 181, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 5824, + 5831 + ], + "loc": { + "start": { + "line": 181, + "column": 32 + }, + "end": { + "line": 181, + "column": 39 + } + } + }, + "range": [ + 5800, + 5831 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 181, + "column": 39 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 5832, + 5841 + ], + "loc": { + "start": { + "line": 181, + "column": 40 + }, + "end": { + "line": 181, + "column": 49 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 5861, + 5870 + ], + "loc": { + "start": { + "line": 182, + "column": 14 + }, + "end": { + "line": 182, + "column": 23 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 5871, + 5872 + ], + "loc": { + "start": { + "line": 182, + "column": 24 + }, + "end": { + "line": 182, + "column": 25 + } + } + }, + "range": [ + 5861, + 5873 + ], + "loc": { + "start": { + "line": 182, + "column": 14 + }, + "end": { + "line": 182, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 5878, + 5881 + ], + "loc": { + "start": { + "line": 182, + "column": 31 + }, + "end": { + "line": 182, + "column": 34 + } + } + }, + "range": [ + 5861, + 5881 + ], + "loc": { + "start": { + "line": 182, + "column": 14 + }, + "end": { + "line": 182, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5897, + 5901 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addField", + "range": [ + 5902, + 5911 + ], + "loc": { + "start": { + "line": 183, + "column": 17 + }, + "end": { + "line": 183, + "column": 26 + } + } + }, + "range": [ + 5897, + 5911 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 5912, + 5918 + ], + "loc": { + "start": { + "line": 183, + "column": 27 + }, + "end": { + "line": 183, + "column": 33 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 5920, + 5928 + ], + "loc": { + "start": { + "line": 183, + "column": 35 + }, + "end": { + "line": 183, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 5930, + 5940 + ], + "loc": { + "start": { + "line": 183, + "column": 45 + }, + "end": { + "line": 183, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 5942, + 5951 + ], + "loc": { + "start": { + "line": 183, + "column": 57 + }, + "end": { + "line": 183, + "column": 66 + } + } + } + ], + "range": [ + 5897, + 5952 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 67 + } + } + }, + "range": [ + 5897, + 5953 + ], + "loc": { + "start": { + "line": 183, + "column": 12 + }, + "end": { + "line": 183, + "column": 68 + } + } + } + ], + "range": [ + 5883, + 5965 + ], + "loc": { + "start": { + "line": 182, + "column": 36 + }, + "end": { + "line": 184, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 5857, + 5965 + ], + "loc": { + "start": { + "line": 182, + "column": 10 + }, + "end": { + "line": 184, + "column": 11 + } + } + } + ], + "range": [ + 5845, + 5975 + ], + "loc": { + "start": { + "line": 181, + "column": 53 + }, + "end": { + "line": 185, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5832, + 5975 + ], + "loc": { + "start": { + "line": 181, + "column": 40 + }, + "end": { + "line": 185, + "column": 9 + } + } + } + ], + "range": [ + 5800, + 5976 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 185, + "column": 10 + } + } + }, + "range": [ + 5800, + 5977 + ], + "loc": { + "start": { + "line": 181, + "column": 8 + }, + "end": { + "line": 185, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 5986, + 5990 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 186, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subject", + "range": [ + 5991, + 5999 + ], + "loc": { + "start": { + "line": 186, + "column": 13 + }, + "end": { + "line": 186, + "column": 21 + } + } + }, + "range": [ + 5986, + 5999 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 186, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "onNext", + "range": [ + 6000, + 6006 + ], + "loc": { + "start": { + "line": 186, + "column": 22 + }, + "end": { + "line": 186, + "column": 28 + } + } + }, + "range": [ + 5986, + 6006 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 186, + "column": 28 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "name", + "range": [ + 6019, + 6023 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 187, + "column": 14 + } + } + }, + "value": { + "type": "Identifier", + "name": "name", + "range": [ + 6025, + 6029 + ], + "loc": { + "start": { + "line": 187, + "column": 16 + }, + "end": { + "line": 187, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 6019, + 6029 + ], + "loc": { + "start": { + "line": 187, + "column": 10 + }, + "end": { + "line": 187, + "column": 20 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 6041, + 6045 + ], + "loc": { + "start": { + "line": 188, + "column": 10 + }, + "end": { + "line": 188, + "column": 14 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 6047, + 6053 + ], + "loc": { + "start": { + "line": 188, + "column": 16 + }, + "end": { + "line": 188, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 6054, + 6058 + ], + "loc": { + "start": { + "line": 188, + "column": 23 + }, + "end": { + "line": 188, + "column": 27 + } + } + }, + "range": [ + 6047, + 6058 + ], + "loc": { + "start": { + "line": 188, + "column": 16 + }, + "end": { + "line": 188, + "column": 27 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 6041, + 6058 + ], + "loc": { + "start": { + "line": 188, + "column": 10 + }, + "end": { + "line": 188, + "column": 27 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 6070, + 6072 + ], + "loc": { + "start": { + "line": 189, + "column": 10 + }, + "end": { + "line": 189, + "column": 12 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "object", + "range": [ + 6074, + 6080 + ], + "loc": { + "start": { + "line": 189, + "column": 14 + }, + "end": { + "line": 189, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 6081, + 6083 + ], + "loc": { + "start": { + "line": 189, + "column": 21 + }, + "end": { + "line": 189, + "column": 23 + } + } + }, + "range": [ + 6074, + 6083 + ], + "loc": { + "start": { + "line": 189, + "column": 14 + }, + "end": { + "line": 189, + "column": 23 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 6070, + 6083 + ], + "loc": { + "start": { + "line": 189, + "column": 10 + }, + "end": { + "line": 189, + "column": 23 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "resource", + "range": [ + 6095, + 6103 + ], + "loc": { + "start": { + "line": 190, + "column": 10 + }, + "end": { + "line": 190, + "column": 18 + } + } + }, + "value": { + "type": "Identifier", + "name": "resource", + "range": [ + 6105, + 6113 + ], + "loc": { + "start": { + "line": 190, + "column": 20 + }, + "end": { + "line": 190, + "column": 28 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 6095, + 6113 + ], + "loc": { + "start": { + "line": 190, + "column": 10 + }, + "end": { + "line": 190, + "column": 28 + } + } + } + ], + "range": [ + 6007, + 6123 + ], + "loc": { + "start": { + "line": 186, + "column": 29 + }, + "end": { + "line": 191, + "column": 9 + } + } + } + ], + "range": [ + 5986, + 6124 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 191, + "column": 10 + } + } + }, + "range": [ + 5986, + 6125 + ], + "loc": { + "start": { + "line": 186, + "column": 8 + }, + "end": { + "line": 191, + "column": 11 + } + } + } + ], + "range": [ + 5577, + 6133 + ], + "loc": { + "start": { + "line": 177, + "column": 36 + }, + "end": { + "line": 192, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 6159, + 6168 + ], + "loc": { + "start": { + "line": 193, + "column": 18 + }, + "end": { + "line": 193, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The data must have a type and id", + "cooked": "The data must have a type and id" + }, + "tail": true, + "range": [ + 6169, + 6203 + ], + "loc": { + "start": { + "line": 193, + "column": 28 + }, + "end": { + "line": 193, + "column": 62 + } + } + } + ], + "expressions": [], + "range": [ + 6169, + 6203 + ], + "loc": { + "start": { + "line": 193, + "column": 28 + }, + "end": { + "line": 193, + "column": 62 + } + } + } + ], + "range": [ + 6155, + 6204 + ], + "loc": { + "start": { + "line": 193, + "column": 14 + }, + "end": { + "line": 193, + "column": 63 + } + } + }, + "range": [ + 6149, + 6205 + ], + "loc": { + "start": { + "line": 193, + "column": 8 + }, + "end": { + "line": 193, + "column": 64 + } + } + } + ], + "range": [ + 6139, + 6213 + ], + "loc": { + "start": { + "line": 192, + "column": 13 + }, + "end": { + "line": 194, + "column": 7 + } + } + }, + "range": [ + 5547, + 6213 + ], + "loc": { + "start": { + "line": 177, + "column": 6 + }, + "end": { + "line": 194, + "column": 7 + } + } + } + ], + "range": [ + 5539, + 6219 + ], + "loc": { + "start": { + "line": 176, + "column": 16 + }, + "end": { + "line": 195, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 6243, + 6252 + ], + "loc": { + "start": { + "line": 196, + "column": 16 + }, + "end": { + "line": 196, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide data to add", + "cooked": "You must provide data to add" + }, + "tail": true, + "range": [ + 6253, + 6283 + ], + "loc": { + "start": { + "line": 196, + "column": 26 + }, + "end": { + "line": 196, + "column": 56 + } + } + } + ], + "expressions": [], + "range": [ + 6253, + 6283 + ], + "loc": { + "start": { + "line": 196, + "column": 26 + }, + "end": { + "line": 196, + "column": 56 + } + } + } + ], + "range": [ + 6239, + 6284 + ], + "loc": { + "start": { + "line": 196, + "column": 12 + }, + "end": { + "line": 196, + "column": 57 + } + } + }, + "range": [ + 6233, + 6285 + ], + "loc": { + "start": { + "line": 196, + "column": 6 + }, + "end": { + "line": 196, + "column": 58 + } + } + } + ], + "range": [ + 6225, + 6291 + ], + "loc": { + "start": { + "line": 195, + "column": 11 + }, + "end": { + "line": 197, + "column": 5 + } + } + }, + "range": [ + 5527, + 6291 + ], + "loc": { + "start": { + "line": 176, + "column": 4 + }, + "end": { + "line": 197, + "column": 5 + } + } + } + ], + "range": [ + 5521, + 6295 + ], + "loc": { + "start": { + "line": 175, + "column": 14 + }, + "end": { + "line": 198, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 5512, + 6295 + ], + "loc": { + "start": { + "line": 175, + "column": 5 + }, + "end": { + "line": 198, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 5509, + 6295 + ], + "loc": { + "start": { + "line": 175, + "column": 2 + }, + "end": { + "line": 198, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n ", + "range": [ + 5234, + 5506 + ], + "loc": { + "start": { + "line": 167, + "column": 2 + }, + "end": { + "line": 174, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 6299, + 6745 + ], + "loc": { + "start": { + "line": 200, + "column": 2 + }, + "end": { + "line": 208, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "convert", + "range": [ + 6748, + 6755 + ], + "loc": { + "start": { + "line": 209, + "column": 2 + }, + "end": { + "line": 209, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 6756, + 6760 + ], + "loc": { + "start": { + "line": 209, + "column": 10 + }, + "end": { + "line": 209, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 6762, + 6764 + ], + "loc": { + "start": { + "line": 209, + "column": 16 + }, + "end": { + "line": 209, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 6766, + 6773 + ], + "loc": { + "start": { + "line": 209, + "column": 20 + }, + "end": { + "line": 209, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "type", + "range": [ + 6785, + 6789 + ], + "loc": { + "start": { + "line": 210, + "column": 8 + }, + "end": { + "line": 210, + "column": 12 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "type", + "range": [ + 6800, + 6804 + ], + "loc": { + "start": { + "line": 210, + "column": 23 + }, + "end": { + "line": 210, + "column": 27 + } + } + }, + "prefix": true, + "range": [ + 6793, + 6804 + ], + "loc": { + "start": { + "line": 210, + "column": 16 + }, + "end": { + "line": 210, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 6809, + 6817 + ], + "loc": { + "start": { + "line": 210, + "column": 32 + }, + "end": { + "line": 210, + "column": 40 + } + } + }, + "range": [ + 6793, + 6817 + ], + "loc": { + "start": { + "line": 210, + "column": 16 + }, + "end": { + "line": 210, + "column": 40 + } + } + }, + "range": [ + 6785, + 6817 + ], + "loc": { + "start": { + "line": 210, + "column": 8 + }, + "end": { + "line": 210, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 6834, + 6838 + ], + "loc": { + "start": { + "line": 211, + "column": 13 + }, + "end": { + "line": 211, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 6839, + 6846 + ], + "loc": { + "start": { + "line": 211, + "column": 18 + }, + "end": { + "line": 211, + "column": 25 + } + } + }, + "range": [ + 6834, + 6846 + ], + "loc": { + "start": { + "line": 211, + "column": 13 + }, + "end": { + "line": 211, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "type", + "range": [ + 6847, + 6851 + ], + "loc": { + "start": { + "line": 211, + "column": 26 + }, + "end": { + "line": 211, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 6852, + 6856 + ], + "loc": { + "start": { + "line": 211, + "column": 31 + }, + "end": { + "line": 211, + "column": 35 + } + } + }, + "range": [ + 6847, + 6856 + ], + "loc": { + "start": { + "line": 211, + "column": 26 + }, + "end": { + "line": 211, + "column": 35 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "type", + "range": [ + 6858, + 6862 + ], + "loc": { + "start": { + "line": 211, + "column": 37 + }, + "end": { + "line": 211, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 6863, + 6865 + ], + "loc": { + "start": { + "line": 211, + "column": 42 + }, + "end": { + "line": 211, + "column": 44 + } + } + }, + "range": [ + 6858, + 6865 + ], + "loc": { + "start": { + "line": 211, + "column": 37 + }, + "end": { + "line": 211, + "column": 44 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 6867, + 6871 + ], + "loc": { + "start": { + "line": 211, + "column": 46 + }, + "end": { + "line": 211, + "column": 50 + } + } + } + ], + "range": [ + 6834, + 6872 + ], + "loc": { + "start": { + "line": 211, + "column": 13 + }, + "end": { + "line": 211, + "column": 51 + } + } + }, + "range": [ + 6827, + 6873 + ], + "loc": { + "start": { + "line": 211, + "column": 6 + }, + "end": { + "line": 211, + "column": 52 + } + } + } + ], + "range": [ + 6819, + 6879 + ], + "loc": { + "start": { + "line": 210, + "column": 42 + }, + "end": { + "line": 212, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 6889, + 6891 + ], + "loc": { + "start": { + "line": 212, + "column": 15 + }, + "end": { + "line": 212, + "column": 17 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "id", + "range": [ + 6902, + 6904 + ], + "loc": { + "start": { + "line": 212, + "column": 28 + }, + "end": { + "line": 212, + "column": 30 + } + } + }, + "prefix": true, + "range": [ + 6895, + 6904 + ], + "loc": { + "start": { + "line": 212, + "column": 21 + }, + "end": { + "line": 212, + "column": 30 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 6909, + 6917 + ], + "loc": { + "start": { + "line": 212, + "column": 35 + }, + "end": { + "line": 212, + "column": 43 + } + } + }, + "range": [ + 6895, + 6917 + ], + "loc": { + "start": { + "line": 212, + "column": 21 + }, + "end": { + "line": 212, + "column": 43 + } + } + }, + "range": [ + 6889, + 6917 + ], + "loc": { + "start": { + "line": 212, + "column": 15 + }, + "end": { + "line": 212, + "column": 43 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 6934, + 6938 + ], + "loc": { + "start": { + "line": 213, + "column": 13 + }, + "end": { + "line": 213, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "convert", + "range": [ + 6939, + 6946 + ], + "loc": { + "start": { + "line": 213, + "column": 18 + }, + "end": { + "line": 213, + "column": 25 + } + } + }, + "range": [ + 6934, + 6946 + ], + "loc": { + "start": { + "line": 213, + "column": 13 + }, + "end": { + "line": 213, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 6947, + 6951 + ], + "loc": { + "start": { + "line": 213, + "column": 26 + }, + "end": { + "line": 213, + "column": 30 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "id", + "range": [ + 6953, + 6955 + ], + "loc": { + "start": { + "line": 213, + "column": 32 + }, + "end": { + "line": 213, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 6956, + 6958 + ], + "loc": { + "start": { + "line": 213, + "column": 35 + }, + "end": { + "line": 213, + "column": 37 + } + } + }, + "range": [ + 6953, + 6958 + ], + "loc": { + "start": { + "line": 213, + "column": 32 + }, + "end": { + "line": 213, + "column": 37 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 6960, + 6962 + ], + "loc": { + "start": { + "line": 213, + "column": 39 + }, + "end": { + "line": 213, + "column": 41 + } + } + } + ], + "range": [ + 6934, + 6963 + ], + "loc": { + "start": { + "line": 213, + "column": 13 + }, + "end": { + "line": 213, + "column": 42 + } + } + }, + "range": [ + 6927, + 6964 + ], + "loc": { + "start": { + "line": 213, + "column": 6 + }, + "end": { + "line": 213, + "column": 43 + } + } + } + ], + "range": [ + 6919, + 6970 + ], + "loc": { + "start": { + "line": 212, + "column": 45 + }, + "end": { + "line": 214, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "data", + "range": [ + 6988, + 6992 + ], + "loc": { + "start": { + "line": 215, + "column": 10 + }, + "end": { + "line": 215, + "column": 14 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 7005, + 7009 + ], + "loc": { + "start": { + "line": 216, + "column": 8 + }, + "end": { + "line": 216, + "column": 12 + } + } + }, + "value": { + "type": "Identifier", + "name": "type", + "range": [ + 7011, + 7015 + ], + "loc": { + "start": { + "line": 216, + "column": 14 + }, + "end": { + "line": 216, + "column": 18 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 7005, + 7015 + ], + "loc": { + "start": { + "line": 216, + "column": 8 + }, + "end": { + "line": 216, + "column": 18 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "attributes", + "range": [ + 7025, + 7035 + ], + "loc": { + "start": { + "line": 217, + "column": 8 + }, + "end": { + "line": 217, + "column": 18 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 7037, + 7039 + ], + "loc": { + "start": { + "line": 217, + "column": 20 + }, + "end": { + "line": 217, + "column": 22 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 7025, + 7039 + ], + "loc": { + "start": { + "line": 217, + "column": 8 + }, + "end": { + "line": 217, + "column": 22 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "relationships", + "range": [ + 7049, + 7062 + ], + "loc": { + "start": { + "line": 218, + "column": 8 + }, + "end": { + "line": 218, + "column": 21 + } + } + }, + "value": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 7064, + 7066 + ], + "loc": { + "start": { + "line": 218, + "column": 23 + }, + "end": { + "line": 218, + "column": 25 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 7049, + 7066 + ], + "loc": { + "start": { + "line": 218, + "column": 8 + }, + "end": { + "line": 218, + "column": 25 + } + } + } + ], + "range": [ + 6995, + 7074 + ], + "loc": { + "start": { + "line": 215, + "column": 17 + }, + "end": { + "line": 219, + "column": 7 + } + } + }, + "range": [ + 6988, + 7074 + ], + "loc": { + "start": { + "line": 215, + "column": 10 + }, + "end": { + "line": 219, + "column": 7 + } + } + } + ], + "kind": "let", + "range": [ + 6984, + 7075 + ], + "loc": { + "start": { + "line": 215, + "column": 6 + }, + "end": { + "line": 219, + "column": 8 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 7086, + 7088 + ], + "loc": { + "start": { + "line": 220, + "column": 10 + }, + "end": { + "line": 220, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 7100, + 7104 + ], + "loc": { + "start": { + "line": 221, + "column": 8 + }, + "end": { + "line": 221, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 7105, + 7107 + ], + "loc": { + "start": { + "line": 221, + "column": 13 + }, + "end": { + "line": 221, + "column": 15 + } + } + }, + "range": [ + 7100, + 7107 + ], + "loc": { + "start": { + "line": 221, + "column": 8 + }, + "end": { + "line": 221, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "id", + "range": [ + 7110, + 7112 + ], + "loc": { + "start": { + "line": 221, + "column": 18 + }, + "end": { + "line": 221, + "column": 20 + } + } + }, + "range": [ + 7100, + 7112 + ], + "loc": { + "start": { + "line": 221, + "column": 8 + }, + "end": { + "line": 221, + "column": 20 + } + } + }, + "range": [ + 7100, + 7113 + ], + "loc": { + "start": { + "line": 221, + "column": 8 + }, + "end": { + "line": 221, + "column": 21 + } + } + } + ], + "range": [ + 7090, + 7121 + ], + "loc": { + "start": { + "line": 220, + "column": 14 + }, + "end": { + "line": 222, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 7082, + 7121 + ], + "loc": { + "start": { + "line": 220, + "column": 6 + }, + "end": { + "line": 222, + "column": 7 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 7132, + 7142 + ], + "loc": { + "start": { + "line": 223, + "column": 10 + }, + "end": { + "line": 223, + "column": 20 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7145, + 7149 + ], + "loc": { + "start": { + "line": 223, + "column": 23 + }, + "end": { + "line": 223, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 7150, + 7156 + ], + "loc": { + "start": { + "line": 223, + "column": 28 + }, + "end": { + "line": 223, + "column": 34 + } + } + }, + "range": [ + 7145, + 7156 + ], + "loc": { + "start": { + "line": 223, + "column": 23 + }, + "end": { + "line": 223, + "column": 34 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "data", + "range": [ + 7157, + 7161 + ], + "loc": { + "start": { + "line": 223, + "column": 35 + }, + "end": { + "line": 223, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 7162, + 7166 + ], + "loc": { + "start": { + "line": 223, + "column": 40 + }, + "end": { + "line": 223, + "column": 44 + } + } + }, + "range": [ + 7157, + 7166 + ], + "loc": { + "start": { + "line": 223, + "column": 35 + }, + "end": { + "line": 223, + "column": 44 + } + } + }, + "range": [ + 7145, + 7167 + ], + "loc": { + "start": { + "line": 223, + "column": 23 + }, + "end": { + "line": 223, + "column": 45 + } + } + }, + "range": [ + 7132, + 7167 + ], + "loc": { + "start": { + "line": 223, + "column": 10 + }, + "end": { + "line": 223, + "column": 45 + } + } + } + ], + "kind": "let", + "range": [ + 7128, + 7168 + ], + "loc": { + "start": { + "line": 223, + "column": 6 + }, + "end": { + "line": 223, + "column": 46 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 7175, + 7181 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 224, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 7182, + 7186 + ], + "loc": { + "start": { + "line": 224, + "column": 13 + }, + "end": { + "line": 224, + "column": 17 + } + } + }, + "range": [ + 7175, + 7186 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 224, + "column": 17 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 7187, + 7197 + ], + "loc": { + "start": { + "line": 224, + "column": 18 + }, + "end": { + "line": 224, + "column": 28 + } + } + } + ], + "range": [ + 7175, + 7198 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 224, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 7199, + 7206 + ], + "loc": { + "start": { + "line": 224, + "column": 30 + }, + "end": { + "line": 224, + "column": 37 + } + } + }, + "range": [ + 7175, + 7206 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 224, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 7207, + 7216 + ], + "loc": { + "start": { + "line": 224, + "column": 38 + }, + "end": { + "line": 224, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 7234, + 7243 + ], + "loc": { + "start": { + "line": 225, + "column": 12 + }, + "end": { + "line": 225, + "column": 21 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 7244, + 7245 + ], + "loc": { + "start": { + "line": 225, + "column": 22 + }, + "end": { + "line": 225, + "column": 23 + } + } + }, + "range": [ + 7234, + 7246 + ], + "loc": { + "start": { + "line": 225, + "column": 12 + }, + "end": { + "line": 225, + "column": 24 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 7251, + 7254 + ], + "loc": { + "start": { + "line": 225, + "column": 29 + }, + "end": { + "line": 225, + "column": 32 + } + } + }, + "range": [ + 7234, + 7254 + ], + "loc": { + "start": { + "line": 225, + "column": 12 + }, + "end": { + "line": 225, + "column": 32 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 7268, + 7278 + ], + "loc": { + "start": { + "line": 226, + "column": 10 + }, + "end": { + "line": 226, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 7279, + 7288 + ], + "loc": { + "start": { + "line": 226, + "column": 21 + }, + "end": { + "line": 226, + "column": 30 + } + } + }, + "range": [ + 7268, + 7289 + ], + "loc": { + "start": { + "line": 226, + "column": 10 + }, + "end": { + "line": 226, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "serialize", + "range": [ + 7290, + 7299 + ], + "loc": { + "start": { + "line": 226, + "column": 32 + }, + "end": { + "line": 226, + "column": 41 + } + } + }, + "range": [ + 7268, + 7299 + ], + "loc": { + "start": { + "line": 226, + "column": 10 + }, + "end": { + "line": 226, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "partial", + "range": [ + 7300, + 7307 + ], + "loc": { + "start": { + "line": 226, + "column": 42 + }, + "end": { + "line": 226, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "data", + "range": [ + 7309, + 7313 + ], + "loc": { + "start": { + "line": 226, + "column": 51 + }, + "end": { + "line": 226, + "column": 55 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 7315, + 7324 + ], + "loc": { + "start": { + "line": 226, + "column": 57 + }, + "end": { + "line": 226, + "column": 66 + } + } + } + ], + "range": [ + 7268, + 7325 + ], + "loc": { + "start": { + "line": 226, + "column": 10 + }, + "end": { + "line": 226, + "column": 67 + } + } + }, + "range": [ + 7268, + 7326 + ], + "loc": { + "start": { + "line": 226, + "column": 10 + }, + "end": { + "line": 226, + "column": 68 + } + } + } + ], + "range": [ + 7256, + 7336 + ], + "loc": { + "start": { + "line": 225, + "column": 34 + }, + "end": { + "line": 227, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 7230, + 7336 + ], + "loc": { + "start": { + "line": 225, + "column": 8 + }, + "end": { + "line": 227, + "column": 9 + } + } + } + ], + "range": [ + 7220, + 7344 + ], + "loc": { + "start": { + "line": 224, + "column": 51 + }, + "end": { + "line": 228, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 7207, + 7344 + ], + "loc": { + "start": { + "line": 224, + "column": 38 + }, + "end": { + "line": 228, + "column": 7 + } + } + } + ], + "range": [ + 7175, + 7345 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 228, + "column": 8 + } + } + }, + "range": [ + 7175, + 7346 + ], + "loc": { + "start": { + "line": 224, + "column": 6 + }, + "end": { + "line": 228, + "column": 9 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "data", + "range": [ + 7360, + 7364 + ], + "loc": { + "start": { + "line": 229, + "column": 13 + }, + "end": { + "line": 229, + "column": 17 + } + } + }, + "range": [ + 7353, + 7365 + ], + "loc": { + "start": { + "line": 229, + "column": 6 + }, + "end": { + "line": 229, + "column": 18 + } + } + } + ], + "range": [ + 6976, + 7371 + ], + "loc": { + "start": { + "line": 214, + "column": 11 + }, + "end": { + "line": 230, + "column": 5 + } + } + }, + "range": [ + 6885, + 7371 + ], + "loc": { + "start": { + "line": 212, + "column": 11 + }, + "end": { + "line": 230, + "column": 5 + } + } + }, + "range": [ + 6781, + 7371 + ], + "loc": { + "start": { + "line": 210, + "column": 4 + }, + "end": { + "line": 230, + "column": 5 + } + } + } + ], + "range": [ + 6775, + 7375 + ], + "loc": { + "start": { + "line": 209, + "column": 29 + }, + "end": { + "line": 231, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 6755, + 7375 + ], + "loc": { + "start": { + "line": 209, + "column": 9 + }, + "end": { + "line": 231, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 6748, + 7375 + ], + "loc": { + "start": { + "line": 209, + "column": 2 + }, + "end": { + "line": 231, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 6299, + 6745 + ], + "loc": { + "start": { + "line": 200, + "column": 2 + }, + "end": { + "line": 208, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 7379, + 7940 + ], + "loc": { + "start": { + "line": 233, + "column": 2 + }, + "end": { + "line": 249, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "create", + "range": [ + 7943, + 7949 + ], + "loc": { + "start": { + "line": 250, + "column": 2 + }, + "end": { + "line": 250, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 7950, + 7954 + ], + "loc": { + "start": { + "line": 250, + "column": 9 + }, + "end": { + "line": 250, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 7956, + 7963 + ], + "loc": { + "start": { + "line": 250, + "column": 15 + }, + "end": { + "line": 250, + "column": 22 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 7965, + 7972 + ], + "loc": { + "start": { + "line": 250, + "column": 24 + }, + "end": { + "line": 250, + "column": 31 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 7984, + 7988 + ], + "loc": { + "start": { + "line": 251, + "column": 8 + }, + "end": { + "line": 251, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 7989, + 7997 + ], + "loc": { + "start": { + "line": 251, + "column": 13 + }, + "end": { + "line": 251, + "column": 21 + } + } + }, + "range": [ + 7984, + 7997 + ], + "loc": { + "start": { + "line": 251, + "column": 8 + }, + "end": { + "line": 251, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 8014, + 8018 + ], + "loc": { + "start": { + "line": 252, + "column": 13 + }, + "end": { + "line": 252, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 8019, + 8027 + ], + "loc": { + "start": { + "line": 252, + "column": 18 + }, + "end": { + "line": 252, + "column": 26 + } + } + }, + "range": [ + 8014, + 8027 + ], + "loc": { + "start": { + "line": 252, + "column": 13 + }, + "end": { + "line": 252, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "create", + "range": [ + 8028, + 8034 + ], + "loc": { + "start": { + "line": 252, + "column": 27 + }, + "end": { + "line": 252, + "column": 33 + } + } + }, + "range": [ + 8014, + 8034 + ], + "loc": { + "start": { + "line": 252, + "column": 13 + }, + "end": { + "line": 252, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 8035, + 8039 + ], + "loc": { + "start": { + "line": 252, + "column": 34 + }, + "end": { + "line": 252, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 8041, + 8045 + ], + "loc": { + "start": { + "line": 252, + "column": 40 + }, + "end": { + "line": 252, + "column": 44 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 8047, + 8054 + ], + "loc": { + "start": { + "line": 252, + "column": 46 + }, + "end": { + "line": 252, + "column": 53 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 8056, + 8063 + ], + "loc": { + "start": { + "line": 252, + "column": 55 + }, + "end": { + "line": 252, + "column": 62 + } + } + } + ], + "range": [ + 8014, + 8064 + ], + "loc": { + "start": { + "line": 252, + "column": 13 + }, + "end": { + "line": 252, + "column": 63 + } + } + }, + "range": [ + 8007, + 8065 + ], + "loc": { + "start": { + "line": 252, + "column": 6 + }, + "end": { + "line": 252, + "column": 64 + } + } + } + ], + "range": [ + 7999, + 8071 + ], + "loc": { + "start": { + "line": 251, + "column": 23 + }, + "end": { + "line": 253, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 8095, + 8100 + ], + "loc": { + "start": { + "line": 254, + "column": 16 + }, + "end": { + "line": 254, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 8101, + 8197 + ], + "loc": { + "start": { + "line": 254, + "column": 22 + }, + "end": { + "line": 254, + "column": 118 + } + } + } + ], + "range": [ + 8091, + 8198 + ], + "loc": { + "start": { + "line": 254, + "column": 12 + }, + "end": { + "line": 254, + "column": 119 + } + } + }, + "range": [ + 8085, + 8199 + ], + "loc": { + "start": { + "line": 254, + "column": 6 + }, + "end": { + "line": 254, + "column": 120 + } + } + } + ], + "range": [ + 8077, + 8205 + ], + "loc": { + "start": { + "line": 253, + "column": 11 + }, + "end": { + "line": 255, + "column": 5 + } + } + }, + "range": [ + 7980, + 8205 + ], + "loc": { + "start": { + "line": 251, + "column": 4 + }, + "end": { + "line": 255, + "column": 5 + } + } + } + ], + "range": [ + 7974, + 8209 + ], + "loc": { + "start": { + "line": 250, + "column": 33 + }, + "end": { + "line": 256, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 7949, + 8209 + ], + "loc": { + "start": { + "line": 250, + "column": 8 + }, + "end": { + "line": 256, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 7943, + 8209 + ], + "loc": { + "start": { + "line": 250, + "column": 2 + }, + "end": { + "line": 256, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 7379, + 7940 + ], + "loc": { + "start": { + "line": 233, + "column": 2 + }, + "end": { + "line": 249, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n ", + "range": [ + 8213, + 8404 + ], + "loc": { + "start": { + "line": 258, + "column": 2 + }, + "end": { + "line": 264, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "define", + "range": [ + 8407, + 8413 + ], + "loc": { + "start": { + "line": 265, + "column": 2 + }, + "end": { + "line": 265, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "names", + "range": [ + 8414, + 8419 + ], + "loc": { + "start": { + "line": 265, + "column": 9 + }, + "end": { + "line": 265, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 8421, + 8431 + ], + "loc": { + "start": { + "line": 265, + "column": 16 + }, + "end": { + "line": 265, + "column": 26 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "names", + "range": [ + 8439, + 8444 + ], + "loc": { + "start": { + "line": 266, + "column": 4 + }, + "end": { + "line": 266, + "column": 9 + } + } + }, + "right": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 8448, + 8453 + ], + "loc": { + "start": { + "line": 266, + "column": 13 + }, + "end": { + "line": 266, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "constructor", + "range": [ + 8454, + 8465 + ], + "loc": { + "start": { + "line": 266, + "column": 19 + }, + "end": { + "line": 266, + "column": 30 + } + } + }, + "range": [ + 8448, + 8465 + ], + "loc": { + "start": { + "line": 266, + "column": 13 + }, + "end": { + "line": 266, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "Array", + "range": [ + 8470, + 8475 + ], + "loc": { + "start": { + "line": 266, + "column": 35 + }, + "end": { + "line": 266, + "column": 40 + } + } + }, + "range": [ + 8448, + 8475 + ], + "loc": { + "start": { + "line": 266, + "column": 13 + }, + "end": { + "line": 266, + "column": 40 + } + } + }, + "consequent": { + "type": "Identifier", + "name": "names", + "range": [ + 8479, + 8484 + ], + "loc": { + "start": { + "line": 266, + "column": 44 + }, + "end": { + "line": 266, + "column": 49 + } + } + }, + "alternate": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Identifier", + "name": "names", + "range": [ + 8489, + 8494 + ], + "loc": { + "start": { + "line": 266, + "column": 54 + }, + "end": { + "line": 266, + "column": 59 + } + } + } + ], + "range": [ + 8487, + 8496 + ], + "loc": { + "start": { + "line": 266, + "column": 52 + }, + "end": { + "line": 266, + "column": 61 + } + } + }, + "range": [ + 8447, + 8496 + ], + "loc": { + "start": { + "line": 266, + "column": 12 + }, + "end": { + "line": 266, + "column": 61 + } + } + }, + "range": [ + 8439, + 8496 + ], + "loc": { + "start": { + "line": 266, + "column": 4 + }, + "end": { + "line": 266, + "column": 61 + } + } + }, + "range": [ + 8439, + 8497 + ], + "loc": { + "start": { + "line": 266, + "column": 4 + }, + "end": { + "line": 266, + "column": 62 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "definition", + "range": [ + 8506, + 8516 + ], + "loc": { + "start": { + "line": 267, + "column": 8 + }, + "end": { + "line": 267, + "column": 18 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 8526, + 8536 + ], + "loc": { + "start": { + "line": 268, + "column": 6 + }, + "end": { + "line": 268, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 8537, + 8543 + ], + "loc": { + "start": { + "line": 268, + "column": 17 + }, + "end": { + "line": 268, + "column": 23 + } + } + }, + "range": [ + 8526, + 8543 + ], + "loc": { + "start": { + "line": 268, + "column": 6 + }, + "end": { + "line": 268, + "column": 23 + } + } + }, + "right": { + "type": "Identifier", + "name": "names", + "range": [ + 8546, + 8551 + ], + "loc": { + "start": { + "line": 268, + "column": 26 + }, + "end": { + "line": 268, + "column": 31 + } + } + }, + "range": [ + 8526, + 8551 + ], + "loc": { + "start": { + "line": 268, + "column": 6 + }, + "end": { + "line": 268, + "column": 31 + } + } + }, + "range": [ + 8526, + 8552 + ], + "loc": { + "start": { + "line": 268, + "column": 6 + }, + "end": { + "line": 268, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 8559, + 8564 + ], + "loc": { + "start": { + "line": 269, + "column": 6 + }, + "end": { + "line": 269, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 8565, + 8572 + ], + "loc": { + "start": { + "line": 269, + "column": 12 + }, + "end": { + "line": 269, + "column": 19 + } + } + }, + "range": [ + 8559, + 8572 + ], + "loc": { + "start": { + "line": 269, + "column": 6 + }, + "end": { + "line": 269, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 8573, + 8577 + ], + "loc": { + "start": { + "line": 269, + "column": 20 + }, + "end": { + "line": 269, + "column": 24 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 8596, + 8600 + ], + "loc": { + "start": { + "line": 270, + "column": 13 + }, + "end": { + "line": 270, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 8601, + 8607 + ], + "loc": { + "start": { + "line": 270, + "column": 18 + }, + "end": { + "line": 270, + "column": 24 + } + } + }, + "range": [ + 8596, + 8607 + ], + "loc": { + "start": { + "line": 270, + "column": 13 + }, + "end": { + "line": 270, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 8608, + 8612 + ], + "loc": { + "start": { + "line": 270, + "column": 25 + }, + "end": { + "line": 270, + "column": 29 + } + } + }, + "range": [ + 8596, + 8613 + ], + "loc": { + "start": { + "line": 270, + "column": 13 + }, + "end": { + "line": 270, + "column": 30 + } + } + }, + "prefix": true, + "range": [ + 8595, + 8613 + ], + "loc": { + "start": { + "line": 270, + "column": 12 + }, + "end": { + "line": 270, + "column": 30 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 8627, + 8631 + ], + "loc": { + "start": { + "line": 271, + "column": 10 + }, + "end": { + "line": 271, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 8632, + 8638 + ], + "loc": { + "start": { + "line": 271, + "column": 15 + }, + "end": { + "line": 271, + "column": 21 + } + } + }, + "range": [ + 8627, + 8638 + ], + "loc": { + "start": { + "line": 271, + "column": 10 + }, + "end": { + "line": 271, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 8639, + 8643 + ], + "loc": { + "start": { + "line": 271, + "column": 22 + }, + "end": { + "line": 271, + "column": 26 + } + } + }, + "range": [ + 8627, + 8644 + ], + "loc": { + "start": { + "line": 271, + "column": 10 + }, + "end": { + "line": 271, + "column": 27 + } + } + }, + "right": { + "type": "Identifier", + "name": "definition", + "range": [ + 8647, + 8657 + ], + "loc": { + "start": { + "line": 271, + "column": 30 + }, + "end": { + "line": 271, + "column": 40 + } + } + }, + "range": [ + 8627, + 8657 + ], + "loc": { + "start": { + "line": 271, + "column": 10 + }, + "end": { + "line": 271, + "column": 40 + } + } + }, + "range": [ + 8627, + 8658 + ], + "loc": { + "start": { + "line": 271, + "column": 10 + }, + "end": { + "line": 271, + "column": 41 + } + } + } + ], + "range": [ + 8615, + 8668 + ], + "loc": { + "start": { + "line": 270, + "column": 32 + }, + "end": { + "line": 272, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 8696, + 8701 + ], + "loc": { + "start": { + "line": 273, + "column": 20 + }, + "end": { + "line": 273, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The type '", + "cooked": "The type '" + }, + "tail": false, + "range": [ + 8702, + 8715 + ], + "loc": { + "start": { + "line": 273, + "column": 26 + }, + "end": { + "line": 273, + "column": 39 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' has already been defined.", + "cooked": "' has already been defined." + }, + "tail": true, + "range": [ + 8719, + 8748 + ], + "loc": { + "start": { + "line": 273, + "column": 43 + }, + "end": { + "line": 273, + "column": 72 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 8715, + 8719 + ], + "loc": { + "start": { + "line": 273, + "column": 39 + }, + "end": { + "line": 273, + "column": 43 + } + } + } + ], + "range": [ + 8702, + 8748 + ], + "loc": { + "start": { + "line": 273, + "column": 26 + }, + "end": { + "line": 273, + "column": 72 + } + } + } + ], + "range": [ + 8692, + 8749 + ], + "loc": { + "start": { + "line": 273, + "column": 16 + }, + "end": { + "line": 273, + "column": 73 + } + } + }, + "range": [ + 8686, + 8750 + ], + "loc": { + "start": { + "line": 273, + "column": 10 + }, + "end": { + "line": 273, + "column": 74 + } + } + } + ], + "range": [ + 8674, + 8760 + ], + "loc": { + "start": { + "line": 272, + "column": 15 + }, + "end": { + "line": 274, + "column": 9 + } + } + }, + "range": [ + 8591, + 8760 + ], + "loc": { + "start": { + "line": 270, + "column": 8 + }, + "end": { + "line": 274, + "column": 9 + } + } + } + ], + "range": [ + 8581, + 8768 + ], + "loc": { + "start": { + "line": 269, + "column": 28 + }, + "end": { + "line": 275, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 8573, + 8768 + ], + "loc": { + "start": { + "line": 269, + "column": 20 + }, + "end": { + "line": 275, + "column": 7 + } + } + } + ], + "range": [ + 8559, + 8769 + ], + "loc": { + "start": { + "line": 269, + "column": 6 + }, + "end": { + "line": 275, + "column": 8 + } + } + }, + "range": [ + 8559, + 8770 + ], + "loc": { + "start": { + "line": 269, + "column": 6 + }, + "end": { + "line": 275, + "column": 9 + } + } + } + ], + "range": [ + 8518, + 8776 + ], + "loc": { + "start": { + "line": 267, + "column": 20 + }, + "end": { + "line": 276, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 8800, + 8805 + ], + "loc": { + "start": { + "line": 277, + "column": 16 + }, + "end": { + "line": 277, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a definition for the type '", + "cooked": "You must provide a definition for the type '" + }, + "tail": false, + "range": [ + 8806, + 8853 + ], + "loc": { + "start": { + "line": 277, + "column": 22 + }, + "end": { + "line": 277, + "column": 69 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'.", + "cooked": "'." + }, + "tail": true, + "range": [ + 8861, + 8865 + ], + "loc": { + "start": { + "line": 277, + "column": 77 + }, + "end": { + "line": 277, + "column": 81 + } + } + } + ], + "expressions": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "names", + "range": [ + 8853, + 8858 + ], + "loc": { + "start": { + "line": 277, + "column": 69 + }, + "end": { + "line": 277, + "column": 74 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 8859, + 8860 + ], + "loc": { + "start": { + "line": 277, + "column": 75 + }, + "end": { + "line": 277, + "column": 76 + } + } + }, + "range": [ + 8853, + 8861 + ], + "loc": { + "start": { + "line": 277, + "column": 69 + }, + "end": { + "line": 277, + "column": 77 + } + } + } + ], + "range": [ + 8806, + 8865 + ], + "loc": { + "start": { + "line": 277, + "column": 22 + }, + "end": { + "line": 277, + "column": 81 + } + } + } + ], + "range": [ + 8796, + 8866 + ], + "loc": { + "start": { + "line": 277, + "column": 12 + }, + "end": { + "line": 277, + "column": 82 + } + } + }, + "range": [ + 8790, + 8867 + ], + "loc": { + "start": { + "line": 277, + "column": 6 + }, + "end": { + "line": 277, + "column": 83 + } + } + } + ], + "range": [ + 8782, + 8873 + ], + "loc": { + "start": { + "line": 276, + "column": 11 + }, + "end": { + "line": 278, + "column": 5 + } + } + }, + "range": [ + 8502, + 8873 + ], + "loc": { + "start": { + "line": 267, + "column": 4 + }, + "end": { + "line": 278, + "column": 5 + } + } + } + ], + "range": [ + 8433, + 8877 + ], + "loc": { + "start": { + "line": 265, + "column": 28 + }, + "end": { + "line": 279, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 8413, + 8877 + ], + "loc": { + "start": { + "line": 265, + "column": 8 + }, + "end": { + "line": 279, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 8407, + 8877 + ], + "loc": { + "start": { + "line": 265, + "column": 2 + }, + "end": { + "line": 279, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n ", + "range": [ + 8213, + 8404 + ], + "loc": { + "start": { + "line": 258, + "column": 2 + }, + "end": { + "line": 264, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 8881, + 9400 + ], + "loc": { + "start": { + "line": 281, + "column": 2 + }, + "end": { + "line": 297, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "destroy", + "range": [ + 9403, + 9410 + ], + "loc": { + "start": { + "line": 298, + "column": 2 + }, + "end": { + "line": 298, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 9411, + 9415 + ], + "loc": { + "start": { + "line": 298, + "column": 10 + }, + "end": { + "line": 298, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 9417, + 9419 + ], + "loc": { + "start": { + "line": 298, + "column": 16 + }, + "end": { + "line": 298, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 9421, + 9428 + ], + "loc": { + "start": { + "line": 298, + "column": 20 + }, + "end": { + "line": 298, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9440, + 9444 + ], + "loc": { + "start": { + "line": 299, + "column": 8 + }, + "end": { + "line": 299, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 9445, + 9453 + ], + "loc": { + "start": { + "line": 299, + "column": 13 + }, + "end": { + "line": 299, + "column": 21 + } + } + }, + "range": [ + 9440, + 9453 + ], + "loc": { + "start": { + "line": 299, + "column": 8 + }, + "end": { + "line": 299, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 9470, + 9474 + ], + "loc": { + "start": { + "line": 300, + "column": 13 + }, + "end": { + "line": 300, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 9475, + 9483 + ], + "loc": { + "start": { + "line": 300, + "column": 18 + }, + "end": { + "line": 300, + "column": 26 + } + } + }, + "range": [ + 9470, + 9483 + ], + "loc": { + "start": { + "line": 300, + "column": 13 + }, + "end": { + "line": 300, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "destroy", + "range": [ + 9484, + 9491 + ], + "loc": { + "start": { + "line": 300, + "column": 27 + }, + "end": { + "line": 300, + "column": 34 + } + } + }, + "range": [ + 9470, + 9491 + ], + "loc": { + "start": { + "line": 300, + "column": 13 + }, + "end": { + "line": 300, + "column": 34 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 9492, + 9496 + ], + "loc": { + "start": { + "line": 300, + "column": 35 + }, + "end": { + "line": 300, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 9498, + 9502 + ], + "loc": { + "start": { + "line": 300, + "column": 41 + }, + "end": { + "line": 300, + "column": 45 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 9504, + 9506 + ], + "loc": { + "start": { + "line": 300, + "column": 47 + }, + "end": { + "line": 300, + "column": 49 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 9508, + 9515 + ], + "loc": { + "start": { + "line": 300, + "column": 51 + }, + "end": { + "line": 300, + "column": 58 + } + } + } + ], + "range": [ + 9470, + 9516 + ], + "loc": { + "start": { + "line": 300, + "column": 13 + }, + "end": { + "line": 300, + "column": 59 + } + } + }, + "range": [ + 9463, + 9517 + ], + "loc": { + "start": { + "line": 300, + "column": 6 + }, + "end": { + "line": 300, + "column": 60 + } + } + } + ], + "range": [ + 9455, + 9523 + ], + "loc": { + "start": { + "line": 299, + "column": 23 + }, + "end": { + "line": 301, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 9547, + 9552 + ], + "loc": { + "start": { + "line": 302, + "column": 16 + }, + "end": { + "line": 302, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 9553, + 9649 + ], + "loc": { + "start": { + "line": 302, + "column": 22 + }, + "end": { + "line": 302, + "column": 118 + } + } + } + ], + "range": [ + 9543, + 9650 + ], + "loc": { + "start": { + "line": 302, + "column": 12 + }, + "end": { + "line": 302, + "column": 119 + } + } + }, + "range": [ + 9537, + 9651 + ], + "loc": { + "start": { + "line": 302, + "column": 6 + }, + "end": { + "line": 302, + "column": 120 + } + } + } + ], + "range": [ + 9529, + 9657 + ], + "loc": { + "start": { + "line": 301, + "column": 11 + }, + "end": { + "line": 303, + "column": 5 + } + } + }, + "range": [ + 9436, + 9657 + ], + "loc": { + "start": { + "line": 299, + "column": 4 + }, + "end": { + "line": 303, + "column": 5 + } + } + } + ], + "range": [ + 9430, + 9661 + ], + "loc": { + "start": { + "line": 298, + "column": 29 + }, + "end": { + "line": 304, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 9410, + 9661 + ], + "loc": { + "start": { + "line": 298, + "column": 9 + }, + "end": { + "line": 304, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 9403, + 9661 + ], + "loc": { + "start": { + "line": 298, + "column": 2 + }, + "end": { + "line": 304, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 8881, + 9400 + ], + "loc": { + "start": { + "line": 281, + "column": 2 + }, + "end": { + "line": 297, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n ", + "range": [ + 9665, + 10029 + ], + "loc": { + "start": { + "line": 306, + "column": 2 + }, + "end": { + "line": 316, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "find", + "range": [ + 10032, + 10036 + ], + "loc": { + "start": { + "line": 317, + "column": 2 + }, + "end": { + "line": 317, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 10037, + 10041 + ], + "loc": { + "start": { + "line": 317, + "column": 7 + }, + "end": { + "line": 317, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 10043, + 10045 + ], + "loc": { + "start": { + "line": 317, + "column": 13 + }, + "end": { + "line": 317, + "column": 15 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "type", + "range": [ + 10057, + 10061 + ], + "loc": { + "start": { + "line": 318, + "column": 8 + }, + "end": { + "line": 318, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 10075, + 10085 + ], + "loc": { + "start": { + "line": 319, + "column": 10 + }, + "end": { + "line": 319, + "column": 20 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10088, + 10092 + ], + "loc": { + "start": { + "line": 319, + "column": 23 + }, + "end": { + "line": 319, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 10093, + 10099 + ], + "loc": { + "start": { + "line": 319, + "column": 28 + }, + "end": { + "line": 319, + "column": 34 + } + } + }, + "range": [ + 10088, + 10099 + ], + "loc": { + "start": { + "line": 319, + "column": 23 + }, + "end": { + "line": 319, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10100, + 10104 + ], + "loc": { + "start": { + "line": 319, + "column": 35 + }, + "end": { + "line": 319, + "column": 39 + } + } + }, + "range": [ + 10088, + 10105 + ], + "loc": { + "start": { + "line": 319, + "column": 23 + }, + "end": { + "line": 319, + "column": 40 + } + } + }, + "range": [ + 10075, + 10105 + ], + "loc": { + "start": { + "line": 319, + "column": 10 + }, + "end": { + "line": 319, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 10071, + 10106 + ], + "loc": { + "start": { + "line": 319, + "column": 6 + }, + "end": { + "line": 319, + "column": 41 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "definition", + "range": [ + 10117, + 10127 + ], + "loc": { + "start": { + "line": 320, + "column": 10 + }, + "end": { + "line": 320, + "column": 20 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10144, + 10148 + ], + "loc": { + "start": { + "line": 321, + "column": 13 + }, + "end": { + "line": 321, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10149, + 10154 + ], + "loc": { + "start": { + "line": 321, + "column": 18 + }, + "end": { + "line": 321, + "column": 23 + } + } + }, + "range": [ + 10144, + 10154 + ], + "loc": { + "start": { + "line": 321, + "column": 13 + }, + "end": { + "line": 321, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10155, + 10159 + ], + "loc": { + "start": { + "line": 321, + "column": 24 + }, + "end": { + "line": 321, + "column": 28 + } + } + }, + "range": [ + 10144, + 10160 + ], + "loc": { + "start": { + "line": 321, + "column": 13 + }, + "end": { + "line": 321, + "column": 29 + } + } + }, + "prefix": true, + "range": [ + 10143, + 10160 + ], + "loc": { + "start": { + "line": 321, + "column": 12 + }, + "end": { + "line": 321, + "column": 29 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "collection", + "range": [ + 10178, + 10188 + ], + "loc": { + "start": { + "line": 322, + "column": 14 + }, + "end": { + "line": 322, + "column": 24 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 10191, + 10193 + ], + "loc": { + "start": { + "line": 322, + "column": 27 + }, + "end": { + "line": 322, + "column": 29 + } + } + }, + "range": [ + 10178, + 10193 + ], + "loc": { + "start": { + "line": 322, + "column": 14 + }, + "end": { + "line": 322, + "column": 29 + } + } + } + ], + "kind": "let", + "range": [ + 10174, + 10194 + ], + "loc": { + "start": { + "line": 322, + "column": 10 + }, + "end": { + "line": 322, + "column": 30 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 10205, + 10215 + ], + "loc": { + "start": { + "line": 323, + "column": 10 + }, + "end": { + "line": 323, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 10216, + 10222 + ], + "loc": { + "start": { + "line": 323, + "column": 21 + }, + "end": { + "line": 323, + "column": 27 + } + } + }, + "range": [ + 10205, + 10222 + ], + "loc": { + "start": { + "line": 323, + "column": 10 + }, + "end": { + "line": 323, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 10223, + 10230 + ], + "loc": { + "start": { + "line": 323, + "column": 28 + }, + "end": { + "line": 323, + "column": 35 + } + } + }, + "range": [ + 10205, + 10230 + ], + "loc": { + "start": { + "line": 323, + "column": 10 + }, + "end": { + "line": 323, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "t", + "range": [ + 10231, + 10232 + ], + "loc": { + "start": { + "line": 323, + "column": 36 + }, + "end": { + "line": 323, + "column": 37 + } + } + } + ], + "body": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10236, + 10240 + ], + "loc": { + "start": { + "line": 323, + "column": 41 + }, + "end": { + "line": 323, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10241, + 10246 + ], + "loc": { + "start": { + "line": 323, + "column": 46 + }, + "end": { + "line": 323, + "column": 51 + } + } + }, + "range": [ + 10236, + 10246 + ], + "loc": { + "start": { + "line": 323, + "column": 41 + }, + "end": { + "line": 323, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "t", + "range": [ + 10247, + 10248 + ], + "loc": { + "start": { + "line": 323, + "column": 52 + }, + "end": { + "line": 323, + "column": 53 + } + } + }, + "range": [ + 10236, + 10249 + ], + "loc": { + "start": { + "line": 323, + "column": 41 + }, + "end": { + "line": 323, + "column": 54 + } + } + }, + "right": { + "type": "Identifier", + "name": "collection", + "range": [ + 10252, + 10262 + ], + "loc": { + "start": { + "line": 323, + "column": 57 + }, + "end": { + "line": 323, + "column": 67 + } + } + }, + "range": [ + 10236, + 10262 + ], + "loc": { + "start": { + "line": 323, + "column": 41 + }, + "end": { + "line": 323, + "column": 67 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 10231, + 10262 + ], + "loc": { + "start": { + "line": 323, + "column": 36 + }, + "end": { + "line": 323, + "column": 67 + } + } + } + ], + "range": [ + 10205, + 10263 + ], + "loc": { + "start": { + "line": 323, + "column": 10 + }, + "end": { + "line": 323, + "column": 68 + } + } + }, + "range": [ + 10205, + 10264 + ], + "loc": { + "start": { + "line": 323, + "column": 10 + }, + "end": { + "line": 323, + "column": 69 + } + } + } + ], + "range": [ + 10162, + 10274 + ], + "loc": { + "start": { + "line": 321, + "column": 31 + }, + "end": { + "line": 324, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 10139, + 10274 + ], + "loc": { + "start": { + "line": 321, + "column": 8 + }, + "end": { + "line": 324, + "column": 9 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 10287, + 10289 + ], + "loc": { + "start": { + "line": 325, + "column": 12 + }, + "end": { + "line": 325, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10308, + 10312 + ], + "loc": { + "start": { + "line": 326, + "column": 15 + }, + "end": { + "line": 326, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10313, + 10318 + ], + "loc": { + "start": { + "line": 326, + "column": 20 + }, + "end": { + "line": 326, + "column": 25 + } + } + }, + "range": [ + 10308, + 10318 + ], + "loc": { + "start": { + "line": 326, + "column": 15 + }, + "end": { + "line": 326, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10319, + 10323 + ], + "loc": { + "start": { + "line": 326, + "column": 26 + }, + "end": { + "line": 326, + "column": 30 + } + } + }, + "range": [ + 10308, + 10324 + ], + "loc": { + "start": { + "line": 326, + "column": 15 + }, + "end": { + "line": 326, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 10325, + 10327 + ], + "loc": { + "start": { + "line": 326, + "column": 32 + }, + "end": { + "line": 326, + "column": 34 + } + } + }, + "range": [ + 10308, + 10328 + ], + "loc": { + "start": { + "line": 326, + "column": 15 + }, + "end": { + "line": 326, + "column": 35 + } + } + }, + "prefix": true, + "range": [ + 10307, + 10328 + ], + "loc": { + "start": { + "line": 326, + "column": 14 + }, + "end": { + "line": 326, + "column": 35 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10344, + 10348 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 327, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10349, + 10354 + ], + "loc": { + "start": { + "line": 327, + "column": 17 + }, + "end": { + "line": 327, + "column": 22 + } + } + }, + "range": [ + 10344, + 10354 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 327, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10355, + 10359 + ], + "loc": { + "start": { + "line": 327, + "column": 23 + }, + "end": { + "line": 327, + "column": 27 + } + } + }, + "range": [ + 10344, + 10360 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 327, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 10361, + 10363 + ], + "loc": { + "start": { + "line": 327, + "column": 29 + }, + "end": { + "line": 327, + "column": 31 + } + } + }, + "range": [ + 10344, + 10364 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 327, + "column": 32 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 10383, + 10394 + ], + "loc": { + "start": { + "line": 328, + "column": 14 + }, + "end": { + "line": 328, + "column": 25 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [], + "range": [ + 10396, + 10398 + ], + "loc": { + "start": { + "line": 328, + "column": 27 + }, + "end": { + "line": 328, + "column": 29 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 10383, + 10398 + ], + "loc": { + "start": { + "line": 328, + "column": 14 + }, + "end": { + "line": 328, + "column": 29 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 10414, + 10418 + ], + "loc": { + "start": { + "line": 329, + "column": 14 + }, + "end": { + "line": 329, + "column": 18 + } + } + }, + "value": { + "type": "Identifier", + "name": "type", + "range": [ + 10420, + 10424 + ], + "loc": { + "start": { + "line": 329, + "column": 20 + }, + "end": { + "line": 329, + "column": 24 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 10414, + 10424 + ], + "loc": { + "start": { + "line": 329, + "column": 14 + }, + "end": { + "line": 329, + "column": 24 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 10440, + 10442 + ], + "loc": { + "start": { + "line": 330, + "column": 14 + }, + "end": { + "line": 330, + "column": 16 + } + } + }, + "value": { + "type": "Identifier", + "name": "id", + "range": [ + 10444, + 10446 + ], + "loc": { + "start": { + "line": 330, + "column": 18 + }, + "end": { + "line": 330, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 10440, + 10446 + ], + "loc": { + "start": { + "line": 330, + "column": 14 + }, + "end": { + "line": 330, + "column": 20 + } + } + } + ], + "range": [ + 10367, + 10460 + ], + "loc": { + "start": { + "line": 327, + "column": 35 + }, + "end": { + "line": 331, + "column": 13 + } + } + }, + "range": [ + 10344, + 10460 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 331, + "column": 13 + } + } + }, + "range": [ + 10344, + 10461 + ], + "loc": { + "start": { + "line": 327, + "column": 12 + }, + "end": { + "line": 331, + "column": 14 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 10474, + 10480 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 332, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 10481, + 10485 + ], + "loc": { + "start": { + "line": 332, + "column": 19 + }, + "end": { + "line": 332, + "column": 23 + } + } + }, + "range": [ + 10474, + 10485 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 332, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "definition", + "range": [ + 10486, + 10496 + ], + "loc": { + "start": { + "line": 332, + "column": 24 + }, + "end": { + "line": 332, + "column": 34 + } + } + } + ], + "range": [ + 10474, + 10497 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 332, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 10498, + 10505 + ], + "loc": { + "start": { + "line": 332, + "column": 36 + }, + "end": { + "line": 332, + "column": 43 + } + } + }, + "range": [ + 10474, + 10505 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 332, + "column": 43 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "key", + "range": [ + 10506, + 10509 + ], + "loc": { + "start": { + "line": 332, + "column": 44 + }, + "end": { + "line": 332, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "key", + "range": [ + 10533, + 10536 + ], + "loc": { + "start": { + "line": 333, + "column": 18 + }, + "end": { + "line": 333, + "column": 21 + } + } + }, + "property": { + "type": "Literal", + "value": 0, + "raw": "0", + "range": [ + 10537, + 10538 + ], + "loc": { + "start": { + "line": 333, + "column": 22 + }, + "end": { + "line": 333, + "column": 23 + } + } + }, + "range": [ + 10533, + 10539 + ], + "loc": { + "start": { + "line": 333, + "column": 18 + }, + "end": { + "line": 333, + "column": 24 + } + } + }, + "right": { + "type": "Literal", + "value": "_", + "raw": "\"_\"", + "range": [ + 10544, + 10547 + ], + "loc": { + "start": { + "line": 333, + "column": 29 + }, + "end": { + "line": 333, + "column": 32 + } + } + }, + "range": [ + 10533, + 10547 + ], + "loc": { + "start": { + "line": 333, + "column": 18 + }, + "end": { + "line": 333, + "column": 32 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10567, + 10571 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10572, + 10577 + ], + "loc": { + "start": { + "line": 334, + "column": 21 + }, + "end": { + "line": 334, + "column": 26 + } + } + }, + "range": [ + 10567, + 10577 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10578, + 10582 + ], + "loc": { + "start": { + "line": 334, + "column": 27 + }, + "end": { + "line": 334, + "column": 31 + } + } + }, + "range": [ + 10567, + 10583 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 10584, + 10586 + ], + "loc": { + "start": { + "line": 334, + "column": 33 + }, + "end": { + "line": 334, + "column": 35 + } + } + }, + "range": [ + 10567, + 10587 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 10588, + 10591 + ], + "loc": { + "start": { + "line": 334, + "column": 37 + }, + "end": { + "line": 334, + "column": 40 + } + } + }, + "range": [ + 10567, + 10592 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 41 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 10595, + 10605 + ], + "loc": { + "start": { + "line": 334, + "column": 44 + }, + "end": { + "line": 334, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "key", + "range": [ + 10606, + 10609 + ], + "loc": { + "start": { + "line": 334, + "column": 55 + }, + "end": { + "line": 334, + "column": 58 + } + } + }, + "range": [ + 10595, + 10610 + ], + "loc": { + "start": { + "line": 334, + "column": 44 + }, + "end": { + "line": 334, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "default", + "range": [ + 10611, + 10618 + ], + "loc": { + "start": { + "line": 334, + "column": 60 + }, + "end": { + "line": 334, + "column": 67 + } + } + }, + "range": [ + 10595, + 10618 + ], + "loc": { + "start": { + "line": 334, + "column": 44 + }, + "end": { + "line": 334, + "column": 67 + } + } + }, + "range": [ + 10567, + 10618 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 67 + } + } + }, + "range": [ + 10567, + 10619 + ], + "loc": { + "start": { + "line": 334, + "column": 16 + }, + "end": { + "line": 334, + "column": 68 + } + } + } + ], + "range": [ + 10549, + 10635 + ], + "loc": { + "start": { + "line": 333, + "column": 34 + }, + "end": { + "line": 335, + "column": 15 + } + } + }, + "alternate": null, + "range": [ + 10529, + 10635 + ], + "loc": { + "start": { + "line": 333, + "column": 14 + }, + "end": { + "line": 335, + "column": 15 + } + } + } + ], + "range": [ + 10513, + 10649 + ], + "loc": { + "start": { + "line": 332, + "column": 51 + }, + "end": { + "line": 336, + "column": 13 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 10506, + 10649 + ], + "loc": { + "start": { + "line": 332, + "column": 44 + }, + "end": { + "line": 336, + "column": 13 + } + } + } + ], + "range": [ + 10474, + 10650 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 336, + "column": 14 + } + } + }, + "range": [ + 10474, + 10651 + ], + "loc": { + "start": { + "line": 332, + "column": 12 + }, + "end": { + "line": 336, + "column": 15 + } + } + } + ], + "range": [ + 10330, + 10663 + ], + "loc": { + "start": { + "line": 326, + "column": 37 + }, + "end": { + "line": 337, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 10303, + 10663 + ], + "loc": { + "start": { + "line": 326, + "column": 10 + }, + "end": { + "line": 337, + "column": 11 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 10681, + 10685 + ], + "loc": { + "start": { + "line": 338, + "column": 17 + }, + "end": { + "line": 338, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 10686, + 10691 + ], + "loc": { + "start": { + "line": 338, + "column": 22 + }, + "end": { + "line": 338, + "column": 27 + } + } + }, + "range": [ + 10681, + 10691 + ], + "loc": { + "start": { + "line": 338, + "column": 17 + }, + "end": { + "line": 338, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 10692, + 10696 + ], + "loc": { + "start": { + "line": 338, + "column": 28 + }, + "end": { + "line": 338, + "column": 32 + } + } + }, + "range": [ + 10681, + 10697 + ], + "loc": { + "start": { + "line": 338, + "column": 17 + }, + "end": { + "line": 338, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 10698, + 10700 + ], + "loc": { + "start": { + "line": 338, + "column": 34 + }, + "end": { + "line": 338, + "column": 36 + } + } + }, + "range": [ + 10681, + 10701 + ], + "loc": { + "start": { + "line": 338, + "column": 17 + }, + "end": { + "line": 338, + "column": 37 + } + } + }, + "range": [ + 10674, + 10702 + ], + "loc": { + "start": { + "line": 338, + "column": 10 + }, + "end": { + "line": 338, + "column": 38 + } + } + } + ], + "range": [ + 10291, + 10712 + ], + "loc": { + "start": { + "line": 325, + "column": 16 + }, + "end": { + "line": 339, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 10819, + 10826 + ], + "loc": { + "start": { + "line": 342, + "column": 10 + }, + "end": { + "line": 342, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "warn", + "range": [ + 10827, + 10831 + ], + "loc": { + "start": { + "line": 342, + "column": 18 + }, + "end": { + "line": 342, + "column": 22 + } + } + }, + "range": [ + 10819, + 10831 + ], + "loc": { + "start": { + "line": 342, + "column": 10 + }, + "end": { + "line": 342, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Literal", + "value": "Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.", + "raw": "\"Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.\"", + "range": [ + 10846, + 10960 + ], + "loc": { + "start": { + "line": 343, + "column": 12 + }, + "end": { + "line": 343, + "column": 126 + } + } + }, + { + "type": "Literal", + "value": "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0", + "raw": "\"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"", + "range": [ + 10974, + 11061 + ], + "loc": { + "start": { + "line": 344, + "column": 12 + }, + "end": { + "line": 344, + "column": 99 + } + } + } + ], + "range": [ + 10832, + 11073 + ], + "loc": { + "start": { + "line": 342, + "column": 23 + }, + "end": { + "line": 345, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "join", + "range": [ + 11074, + 11078 + ], + "loc": { + "start": { + "line": 345, + "column": 12 + }, + "end": { + "line": 345, + "column": 16 + } + } + }, + "range": [ + 10832, + 11078 + ], + "loc": { + "start": { + "line": 342, + "column": 23 + }, + "end": { + "line": 345, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "\n", + "raw": "\"\\n\"", + "range": [ + 11079, + 11083 + ], + "loc": { + "start": { + "line": 345, + "column": 17 + }, + "end": { + "line": 345, + "column": 21 + } + } + } + ], + "range": [ + 10832, + 11084 + ], + "loc": { + "start": { + "line": 342, + "column": 23 + }, + "end": { + "line": 345, + "column": 22 + } + } + } + ], + "range": [ + 10819, + 11085 + ], + "loc": { + "start": { + "line": 342, + "column": 10 + }, + "end": { + "line": 345, + "column": 23 + } + } + }, + "range": [ + 10819, + 11086 + ], + "loc": { + "start": { + "line": 342, + "column": 10 + }, + "end": { + "line": 345, + "column": 24 + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " throw new TypeError(`You must provide an id`);", + "range": [ + 10730, + 10779 + ], + "loc": { + "start": { + "line": 340, + "column": 10 + }, + "end": { + "line": 340, + "column": 59 + } + } + }, + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 10790, + 10808 + ], + "loc": { + "start": { + "line": 341, + "column": 10 + }, + "end": { + "line": 341, + "column": 28 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 11097, + 11114 + ], + "loc": { + "start": { + "line": 346, + "column": 10 + }, + "end": { + "line": 346, + "column": 27 + } + } + } + ] + }, + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11132, + 11136 + ], + "loc": { + "start": { + "line": 347, + "column": 17 + }, + "end": { + "line": 347, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "findAll", + "range": [ + 11137, + 11144 + ], + "loc": { + "start": { + "line": 347, + "column": 22 + }, + "end": { + "line": 347, + "column": 29 + } + } + }, + "range": [ + 11132, + 11144 + ], + "loc": { + "start": { + "line": 347, + "column": 17 + }, + "end": { + "line": 347, + "column": 29 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 11145, + 11149 + ], + "loc": { + "start": { + "line": 347, + "column": 30 + }, + "end": { + "line": 347, + "column": 34 + } + } + } + ], + "range": [ + 11132, + 11150 + ], + "loc": { + "start": { + "line": 347, + "column": 17 + }, + "end": { + "line": 347, + "column": 35 + } + } + }, + "range": [ + 11125, + 11151 + ], + "loc": { + "start": { + "line": 347, + "column": 10 + }, + "end": { + "line": 347, + "column": 36 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 11097, + 11114 + ], + "loc": { + "start": { + "line": 346, + "column": 10 + }, + "end": { + "line": 346, + "column": 27 + } + } + } + ] + } + ], + "range": [ + 10718, + 11161 + ], + "loc": { + "start": { + "line": 339, + "column": 15 + }, + "end": { + "line": 348, + "column": 9 + } + } + }, + "range": [ + 10283, + 11161 + ], + "loc": { + "start": { + "line": 325, + "column": 8 + }, + "end": { + "line": 348, + "column": 9 + } + } + } + ], + "range": [ + 10129, + 11169 + ], + "loc": { + "start": { + "line": 320, + "column": 22 + }, + "end": { + "line": 349, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 11195, + 11204 + ], + "loc": { + "start": { + "line": 350, + "column": 18 + }, + "end": { + "line": 350, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 11205, + 11222 + ], + "loc": { + "start": { + "line": 350, + "column": 28 + }, + "end": { + "line": 350, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 11226, + 11229 + ], + "loc": { + "start": { + "line": 350, + "column": 49 + }, + "end": { + "line": 350, + "column": 52 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 11222, + 11226 + ], + "loc": { + "start": { + "line": 350, + "column": 45 + }, + "end": { + "line": 350, + "column": 49 + } + } + } + ], + "range": [ + 11205, + 11229 + ], + "loc": { + "start": { + "line": 350, + "column": 28 + }, + "end": { + "line": 350, + "column": 52 + } + } + } + ], + "range": [ + 11191, + 11230 + ], + "loc": { + "start": { + "line": 350, + "column": 14 + }, + "end": { + "line": 350, + "column": 53 + } + } + }, + "range": [ + 11185, + 11231 + ], + "loc": { + "start": { + "line": 350, + "column": 8 + }, + "end": { + "line": 350, + "column": 54 + } + } + } + ], + "range": [ + 11175, + 11239 + ], + "loc": { + "start": { + "line": 349, + "column": 13 + }, + "end": { + "line": 351, + "column": 7 + } + } + }, + "range": [ + 10113, + 11239 + ], + "loc": { + "start": { + "line": 320, + "column": 6 + }, + "end": { + "line": 351, + "column": 7 + } + } + } + ], + "range": [ + 10063, + 11245 + ], + "loc": { + "start": { + "line": 318, + "column": 14 + }, + "end": { + "line": 352, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 11269, + 11278 + ], + "loc": { + "start": { + "line": 353, + "column": 16 + }, + "end": { + "line": 353, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a type", + "cooked": "You must provide a type" + }, + "tail": true, + "range": [ + 11279, + 11304 + ], + "loc": { + "start": { + "line": 353, + "column": 26 + }, + "end": { + "line": 353, + "column": 51 + } + } + } + ], + "expressions": [], + "range": [ + 11279, + 11304 + ], + "loc": { + "start": { + "line": 353, + "column": 26 + }, + "end": { + "line": 353, + "column": 51 + } + } + } + ], + "range": [ + 11265, + 11305 + ], + "loc": { + "start": { + "line": 353, + "column": 12 + }, + "end": { + "line": 353, + "column": 52 + } + } + }, + "range": [ + 11259, + 11306 + ], + "loc": { + "start": { + "line": 353, + "column": 6 + }, + "end": { + "line": 353, + "column": 53 + } + } + } + ], + "range": [ + 11251, + 11312 + ], + "loc": { + "start": { + "line": 352, + "column": 11 + }, + "end": { + "line": 354, + "column": 5 + } + } + }, + "range": [ + 10053, + 11312 + ], + "loc": { + "start": { + "line": 318, + "column": 4 + }, + "end": { + "line": 354, + "column": 5 + } + } + } + ], + "range": [ + 10047, + 11316 + ], + "loc": { + "start": { + "line": 317, + "column": 17 + }, + "end": { + "line": 355, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 10036, + 11316 + ], + "loc": { + "start": { + "line": 317, + "column": 6 + }, + "end": { + "line": 355, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 10032, + 11316 + ], + "loc": { + "start": { + "line": 317, + "column": 2 + }, + "end": { + "line": 355, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n ", + "range": [ + 9665, + 10029 + ], + "loc": { + "start": { + "line": 306, + "column": 2 + }, + "end": { + "line": 316, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n ", + "range": [ + 11320, + 11506 + ], + "loc": { + "start": { + "line": 357, + "column": 2 + }, + "end": { + "line": 363, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "findAll", + "range": [ + 11509, + 11516 + ], + "loc": { + "start": { + "line": 364, + "column": 2 + }, + "end": { + "line": 364, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 11517, + 11521 + ], + "loc": { + "start": { + "line": 364, + "column": 10 + }, + "end": { + "line": 364, + "column": 14 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "type", + "range": [ + 11533, + 11537 + ], + "loc": { + "start": { + "line": 365, + "column": 8 + }, + "end": { + "line": 365, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "definition", + "range": [ + 11551, + 11561 + ], + "loc": { + "start": { + "line": 366, + "column": 10 + }, + "end": { + "line": 366, + "column": 20 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11564, + 11568 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 11569, + 11575 + ], + "loc": { + "start": { + "line": 366, + "column": 28 + }, + "end": { + "line": 366, + "column": 34 + } + } + }, + "range": [ + 11564, + 11575 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 11576, + 11580 + ], + "loc": { + "start": { + "line": 366, + "column": 35 + }, + "end": { + "line": 366, + "column": 39 + } + } + }, + "range": [ + 11564, + 11581 + ], + "loc": { + "start": { + "line": 366, + "column": 23 + }, + "end": { + "line": 366, + "column": 40 + } + } + }, + "range": [ + 11551, + 11581 + ], + "loc": { + "start": { + "line": 366, + "column": 10 + }, + "end": { + "line": 366, + "column": 40 + } + } + } + ], + "kind": "let", + "range": [ + 11547, + 11582 + ], + "loc": { + "start": { + "line": 366, + "column": 6 + }, + "end": { + "line": 366, + "column": 41 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "definition", + "range": [ + 11593, + 11603 + ], + "loc": { + "start": { + "line": 367, + "column": 10 + }, + "end": { + "line": 367, + "column": 20 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11620, + 11624 + ], + "loc": { + "start": { + "line": 368, + "column": 13 + }, + "end": { + "line": 368, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 11625, + 11630 + ], + "loc": { + "start": { + "line": 368, + "column": 18 + }, + "end": { + "line": 368, + "column": 23 + } + } + }, + "range": [ + 11620, + 11630 + ], + "loc": { + "start": { + "line": 368, + "column": 13 + }, + "end": { + "line": 368, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 11631, + 11635 + ], + "loc": { + "start": { + "line": 368, + "column": 24 + }, + "end": { + "line": 368, + "column": 28 + } + } + }, + "range": [ + 11620, + 11636 + ], + "loc": { + "start": { + "line": 368, + "column": 13 + }, + "end": { + "line": 368, + "column": 29 + } + } + }, + "prefix": true, + "range": [ + 11619, + 11636 + ], + "loc": { + "start": { + "line": 368, + "column": 12 + }, + "end": { + "line": 368, + "column": 29 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "collection", + "range": [ + 11654, + 11664 + ], + "loc": { + "start": { + "line": 369, + "column": 14 + }, + "end": { + "line": 369, + "column": 24 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 11667, + 11669 + ], + "loc": { + "start": { + "line": 369, + "column": 27 + }, + "end": { + "line": 369, + "column": 29 + } + } + }, + "range": [ + 11654, + 11669 + ], + "loc": { + "start": { + "line": 369, + "column": 14 + }, + "end": { + "line": 369, + "column": 29 + } + } + } + ], + "kind": "let", + "range": [ + 11650, + 11670 + ], + "loc": { + "start": { + "line": 369, + "column": 10 + }, + "end": { + "line": 369, + "column": 30 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 11681, + 11691 + ], + "loc": { + "start": { + "line": 370, + "column": 10 + }, + "end": { + "line": 370, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 11692, + 11698 + ], + "loc": { + "start": { + "line": 370, + "column": 21 + }, + "end": { + "line": 370, + "column": 27 + } + } + }, + "range": [ + 11681, + 11698 + ], + "loc": { + "start": { + "line": 370, + "column": 10 + }, + "end": { + "line": 370, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 11699, + 11706 + ], + "loc": { + "start": { + "line": 370, + "column": 28 + }, + "end": { + "line": 370, + "column": 35 + } + } + }, + "range": [ + 11681, + 11706 + ], + "loc": { + "start": { + "line": 370, + "column": 10 + }, + "end": { + "line": 370, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "t", + "range": [ + 11707, + 11708 + ], + "loc": { + "start": { + "line": 370, + "column": 36 + }, + "end": { + "line": 370, + "column": 37 + } + } + } + ], + "body": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11712, + 11716 + ], + "loc": { + "start": { + "line": 370, + "column": 41 + }, + "end": { + "line": 370, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 11717, + 11722 + ], + "loc": { + "start": { + "line": 370, + "column": 46 + }, + "end": { + "line": 370, + "column": 51 + } + } + }, + "range": [ + 11712, + 11722 + ], + "loc": { + "start": { + "line": 370, + "column": 41 + }, + "end": { + "line": 370, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "t", + "range": [ + 11723, + 11724 + ], + "loc": { + "start": { + "line": 370, + "column": 52 + }, + "end": { + "line": 370, + "column": 53 + } + } + }, + "range": [ + 11712, + 11725 + ], + "loc": { + "start": { + "line": 370, + "column": 41 + }, + "end": { + "line": 370, + "column": 54 + } + } + }, + "right": { + "type": "Identifier", + "name": "collection", + "range": [ + 11728, + 11738 + ], + "loc": { + "start": { + "line": 370, + "column": 57 + }, + "end": { + "line": 370, + "column": 67 + } + } + }, + "range": [ + 11712, + 11738 + ], + "loc": { + "start": { + "line": 370, + "column": 41 + }, + "end": { + "line": 370, + "column": 67 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 11707, + 11738 + ], + "loc": { + "start": { + "line": 370, + "column": 36 + }, + "end": { + "line": 370, + "column": 67 + } + } + } + ], + "range": [ + 11681, + 11739 + ], + "loc": { + "start": { + "line": 370, + "column": 10 + }, + "end": { + "line": 370, + "column": 68 + } + } + }, + "range": [ + 11681, + 11740 + ], + "loc": { + "start": { + "line": 370, + "column": 10 + }, + "end": { + "line": 370, + "column": 69 + } + } + } + ], + "range": [ + 11638, + 11750 + ], + "loc": { + "start": { + "line": 368, + "column": 31 + }, + "end": { + "line": 371, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 11615, + 11750 + ], + "loc": { + "start": { + "line": 368, + "column": 8 + }, + "end": { + "line": 371, + "column": 9 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 11766, + 11772 + ], + "loc": { + "start": { + "line": 372, + "column": 15 + }, + "end": { + "line": 372, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 11773, + 11777 + ], + "loc": { + "start": { + "line": 372, + "column": 22 + }, + "end": { + "line": 372, + "column": 26 + } + } + }, + "range": [ + 11766, + 11777 + ], + "loc": { + "start": { + "line": 372, + "column": 15 + }, + "end": { + "line": 372, + "column": 26 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11778, + 11782 + ], + "loc": { + "start": { + "line": 372, + "column": 27 + }, + "end": { + "line": 372, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 11783, + 11788 + ], + "loc": { + "start": { + "line": 372, + "column": 32 + }, + "end": { + "line": 372, + "column": 37 + } + } + }, + "range": [ + 11778, + 11788 + ], + "loc": { + "start": { + "line": 372, + "column": 27 + }, + "end": { + "line": 372, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 11789, + 11793 + ], + "loc": { + "start": { + "line": 372, + "column": 38 + }, + "end": { + "line": 372, + "column": 42 + } + } + }, + "range": [ + 11778, + 11794 + ], + "loc": { + "start": { + "line": 372, + "column": 27 + }, + "end": { + "line": 372, + "column": 43 + } + } + } + ], + "range": [ + 11766, + 11795 + ], + "loc": { + "start": { + "line": 372, + "column": 15 + }, + "end": { + "line": 372, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 11796, + 11799 + ], + "loc": { + "start": { + "line": 372, + "column": 45 + }, + "end": { + "line": 372, + "column": 48 + } + } + }, + "range": [ + 11766, + 11799 + ], + "loc": { + "start": { + "line": 372, + "column": 15 + }, + "end": { + "line": 372, + "column": 48 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 11800, + 11801 + ], + "loc": { + "start": { + "line": 372, + "column": 49 + }, + "end": { + "line": 372, + "column": 50 + } + } + } + ], + "body": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 11805, + 11809 + ], + "loc": { + "start": { + "line": 372, + "column": 54 + }, + "end": { + "line": 372, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 11810, + 11815 + ], + "loc": { + "start": { + "line": 372, + "column": 59 + }, + "end": { + "line": 372, + "column": 64 + } + } + }, + "range": [ + 11805, + 11815 + ], + "loc": { + "start": { + "line": 372, + "column": 54 + }, + "end": { + "line": 372, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 11816, + 11820 + ], + "loc": { + "start": { + "line": 372, + "column": 65 + }, + "end": { + "line": 372, + "column": 69 + } + } + }, + "range": [ + 11805, + 11821 + ], + "loc": { + "start": { + "line": 372, + "column": 54 + }, + "end": { + "line": 372, + "column": 70 + } + } + }, + "property": { + "type": "Identifier", + "name": "x", + "range": [ + 11822, + 11823 + ], + "loc": { + "start": { + "line": 372, + "column": 71 + }, + "end": { + "line": 372, + "column": 72 + } + } + }, + "range": [ + 11805, + 11824 + ], + "loc": { + "start": { + "line": 372, + "column": 54 + }, + "end": { + "line": 372, + "column": 73 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 11800, + 11824 + ], + "loc": { + "start": { + "line": 372, + "column": 49 + }, + "end": { + "line": 372, + "column": 73 + } + } + } + ], + "range": [ + 11766, + 11825 + ], + "loc": { + "start": { + "line": 372, + "column": 15 + }, + "end": { + "line": 372, + "column": 74 + } + } + }, + "range": [ + 11759, + 11826 + ], + "loc": { + "start": { + "line": 372, + "column": 8 + }, + "end": { + "line": 372, + "column": 75 + } + } + } + ], + "range": [ + 11605, + 11834 + ], + "loc": { + "start": { + "line": 367, + "column": 22 + }, + "end": { + "line": 373, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 11860, + 11869 + ], + "loc": { + "start": { + "line": 374, + "column": 18 + }, + "end": { + "line": 374, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 11870, + 11887 + ], + "loc": { + "start": { + "line": 374, + "column": 28 + }, + "end": { + "line": 374, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 11891, + 11894 + ], + "loc": { + "start": { + "line": 374, + "column": 49 + }, + "end": { + "line": 374, + "column": 52 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 11887, + 11891 + ], + "loc": { + "start": { + "line": 374, + "column": 45 + }, + "end": { + "line": 374, + "column": 49 + } + } + } + ], + "range": [ + 11870, + 11894 + ], + "loc": { + "start": { + "line": 374, + "column": 28 + }, + "end": { + "line": 374, + "column": 52 + } + } + } + ], + "range": [ + 11856, + 11895 + ], + "loc": { + "start": { + "line": 374, + "column": 14 + }, + "end": { + "line": 374, + "column": 53 + } + } + }, + "range": [ + 11850, + 11896 + ], + "loc": { + "start": { + "line": 374, + "column": 8 + }, + "end": { + "line": 374, + "column": 54 + } + } + } + ], + "range": [ + 11840, + 11904 + ], + "loc": { + "start": { + "line": 373, + "column": 13 + }, + "end": { + "line": 375, + "column": 7 + } + } + }, + "range": [ + 11589, + 11904 + ], + "loc": { + "start": { + "line": 367, + "column": 6 + }, + "end": { + "line": 375, + "column": 7 + } + } + } + ], + "range": [ + 11539, + 11910 + ], + "loc": { + "start": { + "line": 365, + "column": 14 + }, + "end": { + "line": 376, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 11934, + 11943 + ], + "loc": { + "start": { + "line": 377, + "column": 16 + }, + "end": { + "line": 377, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a type", + "cooked": "You must provide a type" + }, + "tail": true, + "range": [ + 11944, + 11969 + ], + "loc": { + "start": { + "line": 377, + "column": 26 + }, + "end": { + "line": 377, + "column": 51 + } + } + } + ], + "expressions": [], + "range": [ + 11944, + 11969 + ], + "loc": { + "start": { + "line": 377, + "column": 26 + }, + "end": { + "line": 377, + "column": 51 + } + } + } + ], + "range": [ + 11930, + 11970 + ], + "loc": { + "start": { + "line": 377, + "column": 12 + }, + "end": { + "line": 377, + "column": 52 + } + } + }, + "range": [ + 11924, + 11971 + ], + "loc": { + "start": { + "line": 377, + "column": 6 + }, + "end": { + "line": 377, + "column": 53 + } + } + } + ], + "range": [ + 11916, + 11977 + ], + "loc": { + "start": { + "line": 376, + "column": 11 + }, + "end": { + "line": 378, + "column": 5 + } + } + }, + "range": [ + 11529, + 11977 + ], + "loc": { + "start": { + "line": 365, + "column": 4 + }, + "end": { + "line": 378, + "column": 5 + } + } + } + ], + "range": [ + 11523, + 11981 + ], + "loc": { + "start": { + "line": 364, + "column": 16 + }, + "end": { + "line": 379, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 11516, + 11981 + ], + "loc": { + "start": { + "line": 364, + "column": 9 + }, + "end": { + "line": 379, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 11509, + 11981 + ], + "loc": { + "start": { + "line": 364, + "column": 2 + }, + "end": { + "line": 379, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n ", + "range": [ + 11320, + 11506 + ], + "loc": { + "start": { + "line": 357, + "column": 2 + }, + "end": { + "line": 363, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 11985, + 12509 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 397, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "load", + "range": [ + 12512, + 12516 + ], + "loc": { + "start": { + "line": 398, + "column": 2 + }, + "end": { + "line": 398, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 12517, + 12521 + ], + "loc": { + "start": { + "line": 398, + "column": 7 + }, + "end": { + "line": 398, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 12523, + 12525 + ], + "loc": { + "start": { + "line": 398, + "column": 13 + }, + "end": { + "line": 398, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 12527, + 12534 + ], + "loc": { + "start": { + "line": 398, + "column": 17 + }, + "end": { + "line": 398, + "column": 24 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "Identifier", + "name": "id", + "range": [ + 12547, + 12549 + ], + "loc": { + "start": { + "line": 399, + "column": 9 + }, + "end": { + "line": 399, + "column": 11 + } + } + }, + "prefix": true, + "range": [ + 12546, + 12549 + ], + "loc": { + "start": { + "line": 399, + "column": 8 + }, + "end": { + "line": 399, + "column": 11 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "id", + "range": [ + 12560, + 12562 + ], + "loc": { + "start": { + "line": 399, + "column": 22 + }, + "end": { + "line": 399, + "column": 24 + } + } + }, + "prefix": true, + "range": [ + 12553, + 12562 + ], + "loc": { + "start": { + "line": 399, + "column": 15 + }, + "end": { + "line": 399, + "column": 24 + } + } + }, + "right": { + "type": "Literal", + "value": "object", + "raw": "\"object\"", + "range": [ + 12567, + 12575 + ], + "loc": { + "start": { + "line": 399, + "column": 29 + }, + "end": { + "line": 399, + "column": 37 + } + } + }, + "range": [ + 12553, + 12575 + ], + "loc": { + "start": { + "line": 399, + "column": 15 + }, + "end": { + "line": 399, + "column": 37 + } + } + }, + "range": [ + 12546, + 12575 + ], + "loc": { + "start": { + "line": 399, + "column": 8 + }, + "end": { + "line": 399, + "column": 37 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 12610, + 12617 + ], + "loc": { + "start": { + "line": 401, + "column": 6 + }, + "end": { + "line": 401, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "warn", + "range": [ + 12618, + 12622 + ], + "loc": { + "start": { + "line": 401, + "column": 14 + }, + "end": { + "line": 401, + "column": 18 + } + } + }, + "range": [ + 12610, + 12622 + ], + "loc": { + "start": { + "line": 401, + "column": 6 + }, + "end": { + "line": 401, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Literal", + "value": "Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.", + "raw": "\"Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.\"", + "range": [ + 12633, + 12747 + ], + "loc": { + "start": { + "line": 402, + "column": 8 + }, + "end": { + "line": 402, + "column": 122 + } + } + }, + { + "type": "Literal", + "value": "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0", + "raw": "\"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"", + "range": [ + 12757, + 12844 + ], + "loc": { + "start": { + "line": 403, + "column": 8 + }, + "end": { + "line": 403, + "column": 95 + } + } + } + ], + "range": [ + 12623, + 12852 + ], + "loc": { + "start": { + "line": 401, + "column": 19 + }, + "end": { + "line": 404, + "column": 7 + } + } + }, + "property": { + "type": "Identifier", + "name": "join", + "range": [ + 12853, + 12857 + ], + "loc": { + "start": { + "line": 404, + "column": 8 + }, + "end": { + "line": 404, + "column": 12 + } + } + }, + "range": [ + 12623, + 12857 + ], + "loc": { + "start": { + "line": 401, + "column": 19 + }, + "end": { + "line": 404, + "column": 12 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "\n", + "raw": "\"\\n\"", + "range": [ + 12858, + 12862 + ], + "loc": { + "start": { + "line": 404, + "column": 13 + }, + "end": { + "line": 404, + "column": 17 + } + } + } + ], + "range": [ + 12623, + 12863 + ], + "loc": { + "start": { + "line": 401, + "column": 19 + }, + "end": { + "line": 404, + "column": 18 + } + } + } + ], + "range": [ + 12610, + 12864 + ], + "loc": { + "start": { + "line": 401, + "column": 6 + }, + "end": { + "line": 404, + "column": 19 + } + } + }, + "range": [ + 12610, + 12865 + ], + "loc": { + "start": { + "line": 401, + "column": 6 + }, + "end": { + "line": 404, + "column": 20 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 12585, + 12603 + ], + "loc": { + "start": { + "line": 400, + "column": 6 + }, + "end": { + "line": 400, + "column": 24 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 12872, + 12889 + ], + "loc": { + "start": { + "line": 405, + "column": 6 + }, + "end": { + "line": 405, + "column": 23 + } + } + } + ] + } + ], + "range": [ + 12577, + 12895 + ], + "loc": { + "start": { + "line": 399, + "column": 39 + }, + "end": { + "line": 406, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 12542, + 12895 + ], + "loc": { + "start": { + "line": 399, + "column": 4 + }, + "end": { + "line": 406, + "column": 5 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12904, + 12908 + ], + "loc": { + "start": { + "line": 407, + "column": 8 + }, + "end": { + "line": 407, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 12909, + 12917 + ], + "loc": { + "start": { + "line": 407, + "column": 13 + }, + "end": { + "line": 407, + "column": 21 + } + } + }, + "range": [ + 12904, + 12917 + ], + "loc": { + "start": { + "line": 407, + "column": 8 + }, + "end": { + "line": 407, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 12934, + 12938 + ], + "loc": { + "start": { + "line": 408, + "column": 13 + }, + "end": { + "line": 408, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 12939, + 12947 + ], + "loc": { + "start": { + "line": 408, + "column": 18 + }, + "end": { + "line": 408, + "column": 26 + } + } + }, + "range": [ + 12934, + 12947 + ], + "loc": { + "start": { + "line": 408, + "column": 13 + }, + "end": { + "line": 408, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 12948, + 12952 + ], + "loc": { + "start": { + "line": 408, + "column": 27 + }, + "end": { + "line": 408, + "column": 31 + } + } + }, + "range": [ + 12934, + 12952 + ], + "loc": { + "start": { + "line": 408, + "column": 13 + }, + "end": { + "line": 408, + "column": 31 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 12953, + 12957 + ], + "loc": { + "start": { + "line": 408, + "column": 32 + }, + "end": { + "line": 408, + "column": 36 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 12959, + 12963 + ], + "loc": { + "start": { + "line": 408, + "column": 38 + }, + "end": { + "line": 408, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 12965, + 12967 + ], + "loc": { + "start": { + "line": 408, + "column": 44 + }, + "end": { + "line": 408, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 12969, + 12976 + ], + "loc": { + "start": { + "line": 408, + "column": 48 + }, + "end": { + "line": 408, + "column": 55 + } + } + } + ], + "range": [ + 12934, + 12977 + ], + "loc": { + "start": { + "line": 408, + "column": 13 + }, + "end": { + "line": 408, + "column": 56 + } + } + }, + "range": [ + 12927, + 12978 + ], + "loc": { + "start": { + "line": 408, + "column": 6 + }, + "end": { + "line": 408, + "column": 57 + } + } + } + ], + "range": [ + 12919, + 12984 + ], + "loc": { + "start": { + "line": 407, + "column": 23 + }, + "end": { + "line": 409, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 13008, + 13013 + ], + "loc": { + "start": { + "line": 410, + "column": 16 + }, + "end": { + "line": 410, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 13014, + 13110 + ], + "loc": { + "start": { + "line": 410, + "column": 22 + }, + "end": { + "line": 410, + "column": 118 + } + } + } + ], + "range": [ + 13004, + 13111 + ], + "loc": { + "start": { + "line": 410, + "column": 12 + }, + "end": { + "line": 410, + "column": 119 + } + } + }, + "range": [ + 12998, + 13112 + ], + "loc": { + "start": { + "line": 410, + "column": 6 + }, + "end": { + "line": 410, + "column": 120 + } + } + } + ], + "range": [ + 12990, + 13118 + ], + "loc": { + "start": { + "line": 409, + "column": 11 + }, + "end": { + "line": 411, + "column": 5 + } + } + }, + "range": [ + 12900, + 13118 + ], + "loc": { + "start": { + "line": 407, + "column": 4 + }, + "end": { + "line": 411, + "column": 5 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 12872, + 12889 + ], + "loc": { + "start": { + "line": 405, + "column": 6 + }, + "end": { + "line": 405, + "column": 23 + } + } + } + ] + } + ], + "range": [ + 12536, + 13122 + ], + "loc": { + "start": { + "line": 398, + "column": 26 + }, + "end": { + "line": 412, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 12516, + 13122 + ], + "loc": { + "start": { + "line": 398, + "column": 6 + }, + "end": { + "line": 412, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 12512, + 13122 + ], + "loc": { + "start": { + "line": 398, + "column": 2 + }, + "end": { + "line": 412, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 11985, + 12509 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 397, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n ", + "range": [ + 13126, + 13620 + ], + "loc": { + "start": { + "line": 414, + "column": 2 + }, + "end": { + "line": 429, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "loadAll", + "range": [ + 13623, + 13630 + ], + "loc": { + "start": { + "line": 430, + "column": 2 + }, + "end": { + "line": 430, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 13631, + 13635 + ], + "loc": { + "start": { + "line": 430, + "column": 10 + }, + "end": { + "line": 430, + "column": 14 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 13637, + 13644 + ], + "loc": { + "start": { + "line": 430, + "column": 16 + }, + "end": { + "line": 430, + "column": 23 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13656, + 13660 + ], + "loc": { + "start": { + "line": 431, + "column": 8 + }, + "end": { + "line": 431, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 13661, + 13669 + ], + "loc": { + "start": { + "line": 431, + "column": 13 + }, + "end": { + "line": 431, + "column": 21 + } + } + }, + "range": [ + 13656, + 13669 + ], + "loc": { + "start": { + "line": 431, + "column": 8 + }, + "end": { + "line": 431, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 13686, + 13690 + ], + "loc": { + "start": { + "line": 432, + "column": 13 + }, + "end": { + "line": 432, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 13691, + 13699 + ], + "loc": { + "start": { + "line": 432, + "column": 18 + }, + "end": { + "line": 432, + "column": 26 + } + } + }, + "range": [ + 13686, + 13699 + ], + "loc": { + "start": { + "line": 432, + "column": 13 + }, + "end": { + "line": 432, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "load", + "range": [ + 13700, + 13704 + ], + "loc": { + "start": { + "line": 432, + "column": 27 + }, + "end": { + "line": 432, + "column": 31 + } + } + }, + "range": [ + 13686, + 13704 + ], + "loc": { + "start": { + "line": 432, + "column": 13 + }, + "end": { + "line": 432, + "column": 31 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 13705, + 13709 + ], + "loc": { + "start": { + "line": 432, + "column": 32 + }, + "end": { + "line": 432, + "column": 36 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 13711, + 13715 + ], + "loc": { + "start": { + "line": 432, + "column": 38 + }, + "end": { + "line": 432, + "column": 42 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 13717, + 13721 + ], + "loc": { + "start": { + "line": 432, + "column": 44 + }, + "end": { + "line": 432, + "column": 48 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 13723, + 13730 + ], + "loc": { + "start": { + "line": 432, + "column": 50 + }, + "end": { + "line": 432, + "column": 57 + } + } + } + ], + "range": [ + 13686, + 13731 + ], + "loc": { + "start": { + "line": 432, + "column": 13 + }, + "end": { + "line": 432, + "column": 58 + } + } + }, + "range": [ + 13679, + 13732 + ], + "loc": { + "start": { + "line": 432, + "column": 6 + }, + "end": { + "line": 432, + "column": 59 + } + } + } + ], + "range": [ + 13671, + 13738 + ], + "loc": { + "start": { + "line": 431, + "column": 23 + }, + "end": { + "line": 433, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 13762, + 13767 + ], + "loc": { + "start": { + "line": 434, + "column": 16 + }, + "end": { + "line": 434, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 13768, + 13864 + ], + "loc": { + "start": { + "line": 434, + "column": 22 + }, + "end": { + "line": 434, + "column": 118 + } + } + } + ], + "range": [ + 13758, + 13865 + ], + "loc": { + "start": { + "line": 434, + "column": 12 + }, + "end": { + "line": 434, + "column": 119 + } + } + }, + "range": [ + 13752, + 13866 + ], + "loc": { + "start": { + "line": 434, + "column": 6 + }, + "end": { + "line": 434, + "column": 120 + } + } + } + ], + "range": [ + 13744, + 13872 + ], + "loc": { + "start": { + "line": 433, + "column": 11 + }, + "end": { + "line": 435, + "column": 5 + } + } + }, + "range": [ + 13652, + 13872 + ], + "loc": { + "start": { + "line": 431, + "column": 4 + }, + "end": { + "line": 435, + "column": 5 + } + } + } + ], + "range": [ + 13646, + 13876 + ], + "loc": { + "start": { + "line": 430, + "column": 25 + }, + "end": { + "line": 436, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 13630, + 13876 + ], + "loc": { + "start": { + "line": 430, + "column": 9 + }, + "end": { + "line": 436, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 13623, + 13876 + ], + "loc": { + "start": { + "line": 430, + "column": 2 + }, + "end": { + "line": 436, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n ", + "range": [ + 13126, + 13620 + ], + "loc": { + "start": { + "line": 414, + "column": 2 + }, + "end": { + "line": 429, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n ", + "range": [ + 13880, + 14328 + ], + "loc": { + "start": { + "line": 438, + "column": 2 + }, + "end": { + "line": 447, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "off", + "range": [ + 14331, + 14334 + ], + "loc": { + "start": { + "line": 448, + "column": 2 + }, + "end": { + "line": 448, + "column": 5 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 14335, + 14340 + ], + "loc": { + "start": { + "line": 448, + "column": 6 + }, + "end": { + "line": 448, + "column": 11 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 14342, + 14346 + ], + "loc": { + "start": { + "line": 448, + "column": 13 + }, + "end": { + "line": 448, + "column": 17 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 14348, + 14350 + ], + "loc": { + "start": { + "line": 448, + "column": 19 + }, + "end": { + "line": 448, + "column": 21 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 14352, + 14360 + ], + "loc": { + "start": { + "line": 448, + "column": 23 + }, + "end": { + "line": 448, + "column": 31 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 14391, + 14398 + ], + "loc": { + "start": { + "line": 450, + "column": 4 + }, + "end": { + "line": 450, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "warn", + "range": [ + 14399, + 14403 + ], + "loc": { + "start": { + "line": 450, + "column": 12 + }, + "end": { + "line": 450, + "column": 16 + } + } + }, + "range": [ + 14391, + 14403 + ], + "loc": { + "start": { + "line": 450, + "column": 4 + }, + "end": { + "line": 450, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Literal", + "value": "The `store.off()` method has been deprecated in favour of `store.observable`.", + "raw": "\"The `store.off()` method has been deprecated in favour of `store.observable`.\"", + "range": [ + 14412, + 14491 + ], + "loc": { + "start": { + "line": 451, + "column": 6 + }, + "end": { + "line": 451, + "column": 85 + } + } + }, + { + "type": "Literal", + "value": "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0", + "raw": "\"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"", + "range": [ + 14499, + 14586 + ], + "loc": { + "start": { + "line": 452, + "column": 6 + }, + "end": { + "line": 452, + "column": 93 + } + } + } + ], + "range": [ + 14404, + 14592 + ], + "loc": { + "start": { + "line": 450, + "column": 17 + }, + "end": { + "line": 453, + "column": 5 + } + } + }, + "property": { + "type": "Identifier", + "name": "join", + "range": [ + 14593, + 14597 + ], + "loc": { + "start": { + "line": 453, + "column": 6 + }, + "end": { + "line": 453, + "column": 10 + } + } + }, + "range": [ + 14404, + 14597 + ], + "loc": { + "start": { + "line": 450, + "column": 17 + }, + "end": { + "line": 453, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "\n", + "raw": "\"\\n\"", + "range": [ + 14598, + 14602 + ], + "loc": { + "start": { + "line": 453, + "column": 11 + }, + "end": { + "line": 453, + "column": 15 + } + } + } + ], + "range": [ + 14404, + 14603 + ], + "loc": { + "start": { + "line": 450, + "column": 17 + }, + "end": { + "line": 453, + "column": 16 + } + } + } + ], + "range": [ + 14391, + 14604 + ], + "loc": { + "start": { + "line": 450, + "column": 4 + }, + "end": { + "line": 453, + "column": 17 + } + } + }, + "range": [ + 14391, + 14605 + ], + "loc": { + "start": { + "line": 450, + "column": 4 + }, + "end": { + "line": 453, + "column": 18 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 14368, + 14386 + ], + "loc": { + "start": { + "line": 449, + "column": 4 + }, + "end": { + "line": 449, + "column": 22 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 14610, + 14627 + ], + "loc": { + "start": { + "line": 454, + "column": 4 + }, + "end": { + "line": 454, + "column": 21 + } + } + } + ] + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 14636, + 14641 + ], + "loc": { + "start": { + "line": 455, + "column": 8 + }, + "end": { + "line": 455, + "column": 13 + } + } + }, + "right": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 14646, + 14653 + ], + "loc": { + "start": { + "line": 455, + "column": 18 + }, + "end": { + "line": 455, + "column": 25 + } + } + }, + "range": [ + 14636, + 14653 + ], + "loc": { + "start": { + "line": 455, + "column": 8 + }, + "end": { + "line": 455, + "column": 25 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 14657, + 14662 + ], + "loc": { + "start": { + "line": 455, + "column": 29 + }, + "end": { + "line": 455, + "column": 34 + } + } + }, + "right": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 14667, + 14676 + ], + "loc": { + "start": { + "line": 455, + "column": 39 + }, + "end": { + "line": 455, + "column": 48 + } + } + }, + "range": [ + 14657, + 14676 + ], + "loc": { + "start": { + "line": 455, + "column": 29 + }, + "end": { + "line": 455, + "column": 48 + } + } + }, + "range": [ + 14636, + 14676 + ], + "loc": { + "start": { + "line": 455, + "column": 8 + }, + "end": { + "line": 455, + "column": 48 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 14680, + 14685 + ], + "loc": { + "start": { + "line": 455, + "column": 52 + }, + "end": { + "line": 455, + "column": 57 + } + } + }, + "right": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 14690, + 14699 + ], + "loc": { + "start": { + "line": 455, + "column": 62 + }, + "end": { + "line": 455, + "column": 71 + } + } + }, + "range": [ + 14680, + 14699 + ], + "loc": { + "start": { + "line": 455, + "column": 52 + }, + "end": { + "line": 455, + "column": 71 + } + } + }, + "range": [ + 14636, + 14699 + ], + "loc": { + "start": { + "line": 455, + "column": 8 + }, + "end": { + "line": 455, + "column": 71 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14713, + 14717 + ], + "loc": { + "start": { + "line": 456, + "column": 10 + }, + "end": { + "line": 456, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 14718, + 14724 + ], + "loc": { + "start": { + "line": 456, + "column": 15 + }, + "end": { + "line": 456, + "column": 21 + } + } + }, + "range": [ + 14713, + 14724 + ], + "loc": { + "start": { + "line": 456, + "column": 10 + }, + "end": { + "line": 456, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14725, + 14729 + ], + "loc": { + "start": { + "line": 456, + "column": 22 + }, + "end": { + "line": 456, + "column": 26 + } + } + }, + "range": [ + 14713, + 14730 + ], + "loc": { + "start": { + "line": 456, + "column": 10 + }, + "end": { + "line": 456, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 14746, + 14748 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 14 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 14753, + 14755 + ], + "loc": { + "start": { + "line": 457, + "column": 19 + }, + "end": { + "line": 457, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 14757, + 14765 + ], + "loc": { + "start": { + "line": 457, + "column": 23 + }, + "end": { + "line": 457, + "column": 31 + } + } + }, + "range": [ + 14752, + 14765 + ], + "loc": { + "start": { + "line": 457, + "column": 18 + }, + "end": { + "line": 457, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 14766, + 14770 + ], + "loc": { + "start": { + "line": 457, + "column": 32 + }, + "end": { + "line": 457, + "column": 36 + } + } + }, + "range": [ + 14752, + 14770 + ], + "loc": { + "start": { + "line": 457, + "column": 18 + }, + "end": { + "line": 457, + "column": 36 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 14771, + 14773 + ], + "loc": { + "start": { + "line": 457, + "column": 37 + }, + "end": { + "line": 457, + "column": 39 + } + } + } + ], + "range": [ + 14752, + 14774 + ], + "loc": { + "start": { + "line": 457, + "column": 18 + }, + "end": { + "line": 457, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 14779, + 14798 + ], + "loc": { + "start": { + "line": 457, + "column": 45 + }, + "end": { + "line": 457, + "column": 64 + } + } + }, + "range": [ + 14752, + 14798 + ], + "loc": { + "start": { + "line": 457, + "column": 18 + }, + "end": { + "line": 457, + "column": 64 + } + } + }, + "range": [ + 14746, + 14798 + ], + "loc": { + "start": { + "line": 457, + "column": 12 + }, + "end": { + "line": 457, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14812, + 14816 + ], + "loc": { + "start": { + "line": 458, + "column": 10 + }, + "end": { + "line": 458, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "off", + "range": [ + 14817, + 14820 + ], + "loc": { + "start": { + "line": 458, + "column": 15 + }, + "end": { + "line": 458, + "column": 18 + } + } + }, + "range": [ + 14812, + 14820 + ], + "loc": { + "start": { + "line": 458, + "column": 10 + }, + "end": { + "line": 458, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 14821, + 14825 + ], + "loc": { + "start": { + "line": 458, + "column": 19 + }, + "end": { + "line": 458, + "column": 23 + } + } + }, + "range": [ + 14812, + 14825 + ], + "loc": { + "start": { + "line": 458, + "column": 10 + }, + "end": { + "line": 458, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 14826, + 14830 + ], + "loc": { + "start": { + "line": 458, + "column": 24 + }, + "end": { + "line": 458, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 14832, + 14837 + ], + "loc": { + "start": { + "line": 458, + "column": 30 + }, + "end": { + "line": 458, + "column": 35 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 14839, + 14843 + ], + "loc": { + "start": { + "line": 458, + "column": 37 + }, + "end": { + "line": 458, + "column": 41 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 14845, + 14849 + ], + "loc": { + "start": { + "line": 458, + "column": 43 + }, + "end": { + "line": 458, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 14851, + 14853 + ], + "loc": { + "start": { + "line": 458, + "column": 49 + }, + "end": { + "line": 458, + "column": 51 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 14855, + 14863 + ], + "loc": { + "start": { + "line": 458, + "column": 53 + }, + "end": { + "line": 458, + "column": 61 + } + } + } + ], + "range": [ + 14812, + 14864 + ], + "loc": { + "start": { + "line": 458, + "column": 10 + }, + "end": { + "line": 458, + "column": 62 + } + } + }, + "range": [ + 14812, + 14865 + ], + "loc": { + "start": { + "line": 458, + "column": 10 + }, + "end": { + "line": 458, + "column": 63 + } + } + } + ], + "range": [ + 14800, + 14875 + ], + "loc": { + "start": { + "line": 457, + "column": 66 + }, + "end": { + "line": 459, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14885, + 14889 + ], + "loc": { + "start": { + "line": 459, + "column": 19 + }, + "end": { + "line": 459, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 14890, + 14904 + ], + "loc": { + "start": { + "line": 459, + "column": 24 + }, + "end": { + "line": 459, + "column": 38 + } + } + }, + "range": [ + 14885, + 14904 + ], + "loc": { + "start": { + "line": 459, + "column": 19 + }, + "end": { + "line": 459, + "column": 38 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14905, + 14910 + ], + "loc": { + "start": { + "line": 459, + "column": 39 + }, + "end": { + "line": 459, + "column": 44 + } + } + }, + "range": [ + 14885, + 14911 + ], + "loc": { + "start": { + "line": 459, + "column": 19 + }, + "end": { + "line": 459, + "column": 45 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14915, + 14919 + ], + "loc": { + "start": { + "line": 459, + "column": 49 + }, + "end": { + "line": 459, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 14920, + 14934 + ], + "loc": { + "start": { + "line": 459, + "column": 54 + }, + "end": { + "line": 459, + "column": 68 + } + } + }, + "range": [ + 14915, + 14934 + ], + "loc": { + "start": { + "line": 459, + "column": 49 + }, + "end": { + "line": 459, + "column": 68 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14935, + 14940 + ], + "loc": { + "start": { + "line": 459, + "column": 69 + }, + "end": { + "line": 459, + "column": 74 + } + } + }, + "range": [ + 14915, + 14941 + ], + "loc": { + "start": { + "line": 459, + "column": 49 + }, + "end": { + "line": 459, + "column": 75 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14942, + 14946 + ], + "loc": { + "start": { + "line": 459, + "column": 76 + }, + "end": { + "line": 459, + "column": 80 + } + } + }, + "range": [ + 14915, + 14947 + ], + "loc": { + "start": { + "line": 459, + "column": 49 + }, + "end": { + "line": 459, + "column": 81 + } + } + }, + "range": [ + 14885, + 14947 + ], + "loc": { + "start": { + "line": 459, + "column": 19 + }, + "end": { + "line": 459, + "column": 81 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 14951, + 14955 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 14956, + 14970 + ], + "loc": { + "start": { + "line": 459, + "column": 90 + }, + "end": { + "line": 459, + "column": 104 + } + } + }, + "range": [ + 14951, + 14970 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 104 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 14971, + 14976 + ], + "loc": { + "start": { + "line": 459, + "column": 105 + }, + "end": { + "line": 459, + "column": 110 + } + } + }, + "range": [ + 14951, + 14977 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 111 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 14978, + 14982 + ], + "loc": { + "start": { + "line": 459, + "column": 112 + }, + "end": { + "line": 459, + "column": 116 + } + } + }, + "range": [ + 14951, + 14983 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 117 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 14984, + 14986 + ], + "loc": { + "start": { + "line": 459, + "column": 118 + }, + "end": { + "line": 459, + "column": 120 + } + } + }, + "right": { + "type": "Literal", + "value": "*", + "raw": "\"*\"", + "range": [ + 14990, + 14993 + ], + "loc": { + "start": { + "line": 459, + "column": 124 + }, + "end": { + "line": 459, + "column": 127 + } + } + }, + "range": [ + 14984, + 14993 + ], + "loc": { + "start": { + "line": 459, + "column": 118 + }, + "end": { + "line": 459, + "column": 127 + } + } + }, + "range": [ + 14951, + 14994 + ], + "loc": { + "start": { + "line": 459, + "column": 85 + }, + "end": { + "line": 459, + "column": 128 + } + } + }, + "range": [ + 14885, + 14994 + ], + "loc": { + "start": { + "line": 459, + "column": 19 + }, + "end": { + "line": 459, + "column": 128 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15008, + 15012 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 15013, + 15027 + ], + "loc": { + "start": { + "line": 460, + "column": 15 + }, + "end": { + "line": 460, + "column": 29 + } + } + }, + "range": [ + 15008, + 15027 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 15028, + 15033 + ], + "loc": { + "start": { + "line": 460, + "column": 30 + }, + "end": { + "line": 460, + "column": 35 + } + } + }, + "range": [ + 15008, + 15034 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15035, + 15039 + ], + "loc": { + "start": { + "line": 460, + "column": 37 + }, + "end": { + "line": 460, + "column": 41 + } + } + }, + "range": [ + 15008, + 15040 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 42 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 15041, + 15043 + ], + "loc": { + "start": { + "line": 460, + "column": 43 + }, + "end": { + "line": 460, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": "*", + "raw": "\"*\"", + "range": [ + 15047, + 15050 + ], + "loc": { + "start": { + "line": 460, + "column": 49 + }, + "end": { + "line": 460, + "column": 52 + } + } + }, + "range": [ + 15041, + 15050 + ], + "loc": { + "start": { + "line": 460, + "column": 43 + }, + "end": { + "line": 460, + "column": 52 + } + } + }, + "range": [ + 15008, + 15051 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "dispose", + "range": [ + 15052, + 15059 + ], + "loc": { + "start": { + "line": 460, + "column": 54 + }, + "end": { + "line": 460, + "column": 61 + } + } + }, + "range": [ + 15008, + 15059 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 61 + } + } + }, + "arguments": [], + "range": [ + 15008, + 15061 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 63 + } + } + }, + "range": [ + 15008, + 15062 + ], + "loc": { + "start": { + "line": 460, + "column": 10 + }, + "end": { + "line": 460, + "column": 64 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UnaryExpression", + "operator": "delete", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 15080, + 15084 + ], + "loc": { + "start": { + "line": 461, + "column": 17 + }, + "end": { + "line": 461, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 15085, + 15099 + ], + "loc": { + "start": { + "line": 461, + "column": 22 + }, + "end": { + "line": 461, + "column": 36 + } + } + }, + "range": [ + 15080, + 15099 + ], + "loc": { + "start": { + "line": 461, + "column": 17 + }, + "end": { + "line": 461, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 15100, + 15105 + ], + "loc": { + "start": { + "line": 461, + "column": 37 + }, + "end": { + "line": 461, + "column": 42 + } + } + }, + "range": [ + 15080, + 15106 + ], + "loc": { + "start": { + "line": 461, + "column": 17 + }, + "end": { + "line": 461, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 15107, + 15111 + ], + "loc": { + "start": { + "line": 461, + "column": 44 + }, + "end": { + "line": 461, + "column": 48 + } + } + }, + "range": [ + 15080, + 15112 + ], + "loc": { + "start": { + "line": 461, + "column": 17 + }, + "end": { + "line": 461, + "column": 49 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 15113, + 15115 + ], + "loc": { + "start": { + "line": 461, + "column": 50 + }, + "end": { + "line": 461, + "column": 52 + } + } + }, + "right": { + "type": "Literal", + "value": "*", + "raw": "\"*\"", + "range": [ + 15119, + 15122 + ], + "loc": { + "start": { + "line": 461, + "column": 56 + }, + "end": { + "line": 461, + "column": 59 + } + } + }, + "range": [ + 15113, + 15122 + ], + "loc": { + "start": { + "line": 461, + "column": 50 + }, + "end": { + "line": 461, + "column": 59 + } + } + }, + "range": [ + 15080, + 15123 + ], + "loc": { + "start": { + "line": 461, + "column": 17 + }, + "end": { + "line": 461, + "column": 60 + } + } + }, + "prefix": true, + "range": [ + 15073, + 15123 + ], + "loc": { + "start": { + "line": 461, + "column": 10 + }, + "end": { + "line": 461, + "column": 60 + } + } + }, + "range": [ + 15073, + 15124 + ], + "loc": { + "start": { + "line": 461, + "column": 10 + }, + "end": { + "line": 461, + "column": 61 + } + } + } + ], + "range": [ + 14996, + 15134 + ], + "loc": { + "start": { + "line": 459, + "column": 130 + }, + "end": { + "line": 462, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 14881, + 15134 + ], + "loc": { + "start": { + "line": 459, + "column": 15 + }, + "end": { + "line": 462, + "column": 9 + } + } + }, + "range": [ + 14742, + 15134 + ], + "loc": { + "start": { + "line": 457, + "column": 8 + }, + "end": { + "line": 462, + "column": 9 + } + } + } + ], + "range": [ + 14732, + 15142 + ], + "loc": { + "start": { + "line": 456, + "column": 29 + }, + "end": { + "line": 463, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 15168, + 15173 + ], + "loc": { + "start": { + "line": 464, + "column": 18 + }, + "end": { + "line": 464, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 15174, + 15191 + ], + "loc": { + "start": { + "line": 464, + "column": 24 + }, + "end": { + "line": 464, + "column": 41 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 15195, + 15198 + ], + "loc": { + "start": { + "line": 464, + "column": 45 + }, + "end": { + "line": 464, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 15191, + 15195 + ], + "loc": { + "start": { + "line": 464, + "column": 41 + }, + "end": { + "line": 464, + "column": 45 + } + } + } + ], + "range": [ + 15174, + 15198 + ], + "loc": { + "start": { + "line": 464, + "column": 24 + }, + "end": { + "line": 464, + "column": 48 + } + } + } + ], + "range": [ + 15164, + 15199 + ], + "loc": { + "start": { + "line": 464, + "column": 14 + }, + "end": { + "line": 464, + "column": 49 + } + } + }, + "range": [ + 15158, + 15200 + ], + "loc": { + "start": { + "line": 464, + "column": 8 + }, + "end": { + "line": 464, + "column": 50 + } + } + } + ], + "range": [ + 15148, + 15208 + ], + "loc": { + "start": { + "line": 463, + "column": 13 + }, + "end": { + "line": 465, + "column": 7 + } + } + }, + "range": [ + 14709, + 15208 + ], + "loc": { + "start": { + "line": 456, + "column": 6 + }, + "end": { + "line": 465, + "column": 7 + } + } + } + ], + "range": [ + 14701, + 15214 + ], + "loc": { + "start": { + "line": 455, + "column": 73 + }, + "end": { + "line": 466, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 15238, + 15243 + ], + "loc": { + "start": { + "line": 467, + "column": 16 + }, + "end": { + "line": 467, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown event '", + "cooked": "Unknown event '" + }, + "tail": false, + "range": [ + 15244, + 15262 + ], + "loc": { + "start": { + "line": 467, + "column": 22 + }, + "end": { + "line": 467, + "column": 40 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 15267, + 15270 + ], + "loc": { + "start": { + "line": 467, + "column": 45 + }, + "end": { + "line": 467, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 15262, + 15267 + ], + "loc": { + "start": { + "line": 467, + "column": 40 + }, + "end": { + "line": 467, + "column": 45 + } + } + } + ], + "range": [ + 15244, + 15270 + ], + "loc": { + "start": { + "line": 467, + "column": 22 + }, + "end": { + "line": 467, + "column": 48 + } + } + } + ], + "range": [ + 15234, + 15271 + ], + "loc": { + "start": { + "line": 467, + "column": 12 + }, + "end": { + "line": 467, + "column": 49 + } + } + }, + "range": [ + 15228, + 15272 + ], + "loc": { + "start": { + "line": 467, + "column": 6 + }, + "end": { + "line": 467, + "column": 50 + } + } + } + ], + "range": [ + 15220, + 15278 + ], + "loc": { + "start": { + "line": 466, + "column": 11 + }, + "end": { + "line": 468, + "column": 5 + } + } + }, + "range": [ + 14632, + 15278 + ], + "loc": { + "start": { + "line": 455, + "column": 4 + }, + "end": { + "line": 468, + "column": 5 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 14610, + 14627 + ], + "loc": { + "start": { + "line": 454, + "column": 4 + }, + "end": { + "line": 454, + "column": 21 + } + } + } + ] + } + ], + "range": [ + 14362, + 15282 + ], + "loc": { + "start": { + "line": 448, + "column": 33 + }, + "end": { + "line": 469, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 14334, + 15282 + ], + "loc": { + "start": { + "line": 448, + "column": 5 + }, + "end": { + "line": 469, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 14331, + 15282 + ], + "loc": { + "start": { + "line": 448, + "column": 2 + }, + "end": { + "line": 469, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n ", + "range": [ + 13880, + 14328 + ], + "loc": { + "start": { + "line": 438, + "column": 2 + }, + "end": { + "line": 447, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n ", + "range": [ + 15286, + 15771 + ], + "loc": { + "start": { + "line": 471, + "column": 2 + }, + "end": { + "line": 481, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "on", + "range": [ + 15774, + 15776 + ], + "loc": { + "start": { + "line": 482, + "column": 2 + }, + "end": { + "line": 482, + "column": 4 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 15777, + 15782 + ], + "loc": { + "start": { + "line": 482, + "column": 5 + }, + "end": { + "line": 482, + "column": 10 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 15784, + 15788 + ], + "loc": { + "start": { + "line": 482, + "column": 12 + }, + "end": { + "line": 482, + "column": 16 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 15790, + 15792 + ], + "loc": { + "start": { + "line": 482, + "column": 18 + }, + "end": { + "line": 482, + "column": 20 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 15794, + 15802 + ], + "loc": { + "start": { + "line": 482, + "column": 22 + }, + "end": { + "line": 482, + "column": 30 + } + } + }, + { + "type": "Identifier", + "name": "context", + "range": [ + 15804, + 15811 + ], + "loc": { + "start": { + "line": 482, + "column": 32 + }, + "end": { + "line": 482, + "column": 39 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 15842, + 15849 + ], + "loc": { + "start": { + "line": 484, + "column": 4 + }, + "end": { + "line": 484, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "warn", + "range": [ + 15850, + 15854 + ], + "loc": { + "start": { + "line": 484, + "column": 12 + }, + "end": { + "line": 484, + "column": 16 + } + } + }, + "range": [ + 15842, + 15854 + ], + "loc": { + "start": { + "line": 484, + "column": 4 + }, + "end": { + "line": 484, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "Literal", + "value": "The `store.on()` method has been deprecated in favour of `store.observable`.", + "raw": "\"The `store.on()` method has been deprecated in favour of `store.observable`.\"", + "range": [ + 15863, + 15941 + ], + "loc": { + "start": { + "line": 485, + "column": 6 + }, + "end": { + "line": 485, + "column": 84 + } + } + }, + { + "type": "Literal", + "value": "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0", + "raw": "\"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"", + "range": [ + 15949, + 16036 + ], + "loc": { + "start": { + "line": 486, + "column": 6 + }, + "end": { + "line": 486, + "column": 93 + } + } + } + ], + "range": [ + 15855, + 16042 + ], + "loc": { + "start": { + "line": 484, + "column": 17 + }, + "end": { + "line": 487, + "column": 5 + } + } + }, + "property": { + "type": "Identifier", + "name": "join", + "range": [ + 16043, + 16047 + ], + "loc": { + "start": { + "line": 487, + "column": 6 + }, + "end": { + "line": 487, + "column": 10 + } + } + }, + "range": [ + 15855, + 16047 + ], + "loc": { + "start": { + "line": 484, + "column": 17 + }, + "end": { + "line": 487, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "\n", + "raw": "\"\\n\"", + "range": [ + 16048, + 16052 + ], + "loc": { + "start": { + "line": 487, + "column": 11 + }, + "end": { + "line": 487, + "column": 15 + } + } + } + ], + "range": [ + 15855, + 16053 + ], + "loc": { + "start": { + "line": 484, + "column": 17 + }, + "end": { + "line": 487, + "column": 16 + } + } + } + ], + "range": [ + 15842, + 16054 + ], + "loc": { + "start": { + "line": 484, + "column": 4 + }, + "end": { + "line": 487, + "column": 17 + } + } + }, + "range": [ + 15842, + 16055 + ], + "loc": { + "start": { + "line": 484, + "column": 4 + }, + "end": { + "line": 487, + "column": 18 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 15819, + 15837 + ], + "loc": { + "start": { + "line": 483, + "column": 4 + }, + "end": { + "line": 483, + "column": 22 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 16060, + 16077 + ], + "loc": { + "start": { + "line": 488, + "column": 4 + }, + "end": { + "line": 488, + "column": 21 + } + } + } + ] + }, + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 16086, + 16091 + ], + "loc": { + "start": { + "line": 489, + "column": 8 + }, + "end": { + "line": 489, + "column": 13 + } + } + }, + "right": { + "type": "Literal", + "value": "added", + "raw": "\"added\"", + "range": [ + 16096, + 16103 + ], + "loc": { + "start": { + "line": 489, + "column": 18 + }, + "end": { + "line": 489, + "column": 25 + } + } + }, + "range": [ + 16086, + 16103 + ], + "loc": { + "start": { + "line": 489, + "column": 8 + }, + "end": { + "line": 489, + "column": 25 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 16107, + 16112 + ], + "loc": { + "start": { + "line": 489, + "column": 29 + }, + "end": { + "line": 489, + "column": 34 + } + } + }, + "right": { + "type": "Literal", + "value": "updated", + "raw": "\"updated\"", + "range": [ + 16117, + 16126 + ], + "loc": { + "start": { + "line": 489, + "column": 39 + }, + "end": { + "line": 489, + "column": 48 + } + } + }, + "range": [ + 16107, + 16126 + ], + "loc": { + "start": { + "line": 489, + "column": 29 + }, + "end": { + "line": 489, + "column": 48 + } + } + }, + "range": [ + 16086, + 16126 + ], + "loc": { + "start": { + "line": 489, + "column": 8 + }, + "end": { + "line": 489, + "column": 48 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "Identifier", + "name": "event", + "range": [ + 16130, + 16135 + ], + "loc": { + "start": { + "line": 489, + "column": 52 + }, + "end": { + "line": 489, + "column": 57 + } + } + }, + "right": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 16140, + 16149 + ], + "loc": { + "start": { + "line": 489, + "column": 62 + }, + "end": { + "line": 489, + "column": 71 + } + } + }, + "range": [ + 16130, + 16149 + ], + "loc": { + "start": { + "line": 489, + "column": 52 + }, + "end": { + "line": 489, + "column": 71 + } + } + }, + "range": [ + 16086, + 16149 + ], + "loc": { + "start": { + "line": 489, + "column": 8 + }, + "end": { + "line": 489, + "column": 71 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16163, + 16167 + ], + "loc": { + "start": { + "line": 490, + "column": 10 + }, + "end": { + "line": 490, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 16168, + 16174 + ], + "loc": { + "start": { + "line": 490, + "column": 15 + }, + "end": { + "line": 490, + "column": 21 + } + } + }, + "range": [ + 16163, + 16174 + ], + "loc": { + "start": { + "line": 490, + "column": 10 + }, + "end": { + "line": 490, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16175, + 16179 + ], + "loc": { + "start": { + "line": 490, + "column": 22 + }, + "end": { + "line": 490, + "column": 26 + } + } + }, + "range": [ + 16163, + 16180 + ], + "loc": { + "start": { + "line": 490, + "column": 10 + }, + "end": { + "line": 490, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 16196, + 16198 + ], + "loc": { + "start": { + "line": 491, + "column": 12 + }, + "end": { + "line": 491, + "column": 14 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 16203, + 16205 + ], + "loc": { + "start": { + "line": 491, + "column": 19 + }, + "end": { + "line": 491, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "toString", + "range": [ + 16207, + 16215 + ], + "loc": { + "start": { + "line": 491, + "column": 23 + }, + "end": { + "line": 491, + "column": 31 + } + } + }, + "range": [ + 16202, + 16215 + ], + "loc": { + "start": { + "line": 491, + "column": 18 + }, + "end": { + "line": 491, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 16216, + 16220 + ], + "loc": { + "start": { + "line": 491, + "column": 32 + }, + "end": { + "line": 491, + "column": 36 + } + } + }, + "range": [ + 16202, + 16220 + ], + "loc": { + "start": { + "line": 491, + "column": 18 + }, + "end": { + "line": 491, + "column": 36 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 16221, + 16223 + ], + "loc": { + "start": { + "line": 491, + "column": 37 + }, + "end": { + "line": 491, + "column": 39 + } + } + } + ], + "range": [ + 16202, + 16224 + ], + "loc": { + "start": { + "line": 491, + "column": 18 + }, + "end": { + "line": 491, + "column": 40 + } + } + }, + "right": { + "type": "Literal", + "value": "[object Function]", + "raw": "'[object Function]'", + "range": [ + 16229, + 16248 + ], + "loc": { + "start": { + "line": 491, + "column": 45 + }, + "end": { + "line": 491, + "column": 64 + } + } + }, + "range": [ + 16202, + 16248 + ], + "loc": { + "start": { + "line": 491, + "column": 18 + }, + "end": { + "line": 491, + "column": 64 + } + } + }, + "range": [ + 16196, + 16248 + ], + "loc": { + "start": { + "line": 491, + "column": 12 + }, + "end": { + "line": 491, + "column": 64 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16262, + 16266 + ], + "loc": { + "start": { + "line": 492, + "column": 10 + }, + "end": { + "line": 492, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "on", + "range": [ + 16267, + 16269 + ], + "loc": { + "start": { + "line": 492, + "column": 15 + }, + "end": { + "line": 492, + "column": 17 + } + } + }, + "range": [ + 16262, + 16269 + ], + "loc": { + "start": { + "line": 492, + "column": 10 + }, + "end": { + "line": 492, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 16270, + 16274 + ], + "loc": { + "start": { + "line": 492, + "column": 18 + }, + "end": { + "line": 492, + "column": 22 + } + } + }, + "range": [ + 16262, + 16274 + ], + "loc": { + "start": { + "line": 492, + "column": 10 + }, + "end": { + "line": 492, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 16275, + 16279 + ], + "loc": { + "start": { + "line": 492, + "column": 23 + }, + "end": { + "line": 492, + "column": 27 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 16281, + 16286 + ], + "loc": { + "start": { + "line": 492, + "column": 29 + }, + "end": { + "line": 492, + "column": 34 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 16288, + 16292 + ], + "loc": { + "start": { + "line": 492, + "column": 36 + }, + "end": { + "line": 492, + "column": 40 + } + } + }, + { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 16294, + 16298 + ], + "loc": { + "start": { + "line": 492, + "column": 42 + }, + "end": { + "line": 492, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 16300, + 16302 + ], + "loc": { + "start": { + "line": 492, + "column": 48 + }, + "end": { + "line": 492, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "callback", + "range": [ + 16304, + 16312 + ], + "loc": { + "start": { + "line": 492, + "column": 52 + }, + "end": { + "line": 492, + "column": 60 + } + } + } + ], + "range": [ + 16262, + 16313 + ], + "loc": { + "start": { + "line": 492, + "column": 10 + }, + "end": { + "line": 492, + "column": 61 + } + } + }, + "range": [ + 16262, + 16314 + ], + "loc": { + "start": { + "line": 492, + "column": 10 + }, + "end": { + "line": 492, + "column": 62 + } + } + } + ], + "range": [ + 16250, + 16324 + ], + "loc": { + "start": { + "line": 491, + "column": 66 + }, + "end": { + "line": 493, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16335, + 16339 + ], + "loc": { + "start": { + "line": 493, + "column": 20 + }, + "end": { + "line": 493, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16340, + 16354 + ], + "loc": { + "start": { + "line": 493, + "column": 25 + }, + "end": { + "line": 493, + "column": 39 + } + } + }, + "range": [ + 16335, + 16354 + ], + "loc": { + "start": { + "line": 493, + "column": 20 + }, + "end": { + "line": 493, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16355, + 16360 + ], + "loc": { + "start": { + "line": 493, + "column": 40 + }, + "end": { + "line": 493, + "column": 45 + } + } + }, + "range": [ + 16335, + 16361 + ], + "loc": { + "start": { + "line": 493, + "column": 20 + }, + "end": { + "line": 493, + "column": 46 + } + } + }, + "prefix": true, + "range": [ + 16334, + 16361 + ], + "loc": { + "start": { + "line": 493, + "column": 19 + }, + "end": { + "line": 493, + "column": 46 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16366, + 16370 + ], + "loc": { + "start": { + "line": 493, + "column": 51 + }, + "end": { + "line": 493, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16371, + 16385 + ], + "loc": { + "start": { + "line": 493, + "column": 56 + }, + "end": { + "line": 493, + "column": 70 + } + } + }, + "range": [ + 16366, + 16385 + ], + "loc": { + "start": { + "line": 493, + "column": 51 + }, + "end": { + "line": 493, + "column": 70 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16386, + 16391 + ], + "loc": { + "start": { + "line": 493, + "column": 71 + }, + "end": { + "line": 493, + "column": 76 + } + } + }, + "range": [ + 16366, + 16392 + ], + "loc": { + "start": { + "line": 493, + "column": 51 + }, + "end": { + "line": 493, + "column": 77 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16393, + 16397 + ], + "loc": { + "start": { + "line": 493, + "column": 78 + }, + "end": { + "line": 493, + "column": 82 + } + } + }, + "range": [ + 16366, + 16398 + ], + "loc": { + "start": { + "line": 493, + "column": 51 + }, + "end": { + "line": 493, + "column": 83 + } + } + }, + "prefix": true, + "range": [ + 16365, + 16398 + ], + "loc": { + "start": { + "line": 493, + "column": 50 + }, + "end": { + "line": 493, + "column": 83 + } + } + }, + "range": [ + 16334, + 16398 + ], + "loc": { + "start": { + "line": 493, + "column": 19 + }, + "end": { + "line": 493, + "column": 83 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16403, + 16407 + ], + "loc": { + "start": { + "line": 493, + "column": 88 + }, + "end": { + "line": 493, + "column": 92 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16408, + 16422 + ], + "loc": { + "start": { + "line": 493, + "column": 93 + }, + "end": { + "line": 493, + "column": 107 + } + } + }, + "range": [ + 16403, + 16422 + ], + "loc": { + "start": { + "line": 493, + "column": 88 + }, + "end": { + "line": 493, + "column": 107 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16423, + 16428 + ], + "loc": { + "start": { + "line": 493, + "column": 108 + }, + "end": { + "line": 493, + "column": 113 + } + } + }, + "range": [ + 16403, + 16429 + ], + "loc": { + "start": { + "line": 493, + "column": 88 + }, + "end": { + "line": 493, + "column": 114 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16430, + 16434 + ], + "loc": { + "start": { + "line": 493, + "column": 115 + }, + "end": { + "line": 493, + "column": 119 + } + } + }, + "range": [ + 16403, + 16435 + ], + "loc": { + "start": { + "line": 493, + "column": 88 + }, + "end": { + "line": 493, + "column": 120 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 16436, + 16438 + ], + "loc": { + "start": { + "line": 493, + "column": 121 + }, + "end": { + "line": 493, + "column": 123 + } + } + }, + "right": { + "type": "Literal", + "value": "*", + "raw": "\"*\"", + "range": [ + 16442, + 16445 + ], + "loc": { + "start": { + "line": 493, + "column": 127 + }, + "end": { + "line": 493, + "column": 130 + } + } + }, + "range": [ + 16436, + 16445 + ], + "loc": { + "start": { + "line": 493, + "column": 121 + }, + "end": { + "line": 493, + "column": 130 + } + } + }, + "range": [ + 16403, + 16446 + ], + "loc": { + "start": { + "line": 493, + "column": 88 + }, + "end": { + "line": 493, + "column": 131 + } + } + }, + "prefix": true, + "range": [ + 16402, + 16446 + ], + "loc": { + "start": { + "line": 493, + "column": 87 + }, + "end": { + "line": 493, + "column": 131 + } + } + }, + "range": [ + 16334, + 16446 + ], + "loc": { + "start": { + "line": 493, + "column": 19 + }, + "end": { + "line": 493, + "column": 131 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16464, + 16476 + ], + "loc": { + "start": { + "line": 494, + "column": 14 + }, + "end": { + "line": 494, + "column": 26 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16479, + 16483 + ], + "loc": { + "start": { + "line": 494, + "column": 29 + }, + "end": { + "line": 494, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subject", + "range": [ + 16484, + 16492 + ], + "loc": { + "start": { + "line": 494, + "column": 34 + }, + "end": { + "line": 494, + "column": 42 + } + } + }, + "range": [ + 16479, + 16492 + ], + "loc": { + "start": { + "line": 494, + "column": 29 + }, + "end": { + "line": 494, + "column": 42 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 16493, + 16499 + ], + "loc": { + "start": { + "line": 494, + "column": 43 + }, + "end": { + "line": 494, + "column": 49 + } + } + }, + "range": [ + 16479, + 16499 + ], + "loc": { + "start": { + "line": 494, + "column": 29 + }, + "end": { + "line": 494, + "column": 49 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 16500, + 16501 + ], + "loc": { + "start": { + "line": 494, + "column": 50 + }, + "end": { + "line": 494, + "column": 51 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "e", + "range": [ + 16505, + 16506 + ], + "loc": { + "start": { + "line": 494, + "column": 55 + }, + "end": { + "line": 494, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 16507, + 16511 + ], + "loc": { + "start": { + "line": 494, + "column": 57 + }, + "end": { + "line": 494, + "column": 61 + } + } + }, + "range": [ + 16505, + 16511 + ], + "loc": { + "start": { + "line": 494, + "column": 55 + }, + "end": { + "line": 494, + "column": 61 + } + } + }, + "right": { + "type": "Identifier", + "name": "event", + "range": [ + 16516, + 16521 + ], + "loc": { + "start": { + "line": 494, + "column": 66 + }, + "end": { + "line": 494, + "column": 71 + } + } + }, + "range": [ + 16505, + 16521 + ], + "loc": { + "start": { + "line": 494, + "column": 55 + }, + "end": { + "line": 494, + "column": 71 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16500, + 16521 + ], + "loc": { + "start": { + "line": 494, + "column": 50 + }, + "end": { + "line": 494, + "column": 71 + } + } + } + ], + "range": [ + 16479, + 16522 + ], + "loc": { + "start": { + "line": 494, + "column": 29 + }, + "end": { + "line": 494, + "column": 72 + } + } + }, + "range": [ + 16464, + 16522 + ], + "loc": { + "start": { + "line": 494, + "column": 14 + }, + "end": { + "line": 494, + "column": 72 + } + } + } + ], + "kind": "let", + "range": [ + 16460, + 16523 + ], + "loc": { + "start": { + "line": 494, + "column": 10 + }, + "end": { + "line": 494, + "column": 73 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16534, + 16546 + ], + "loc": { + "start": { + "line": 495, + "column": 10 + }, + "end": { + "line": 495, + "column": 22 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16549, + 16561 + ], + "loc": { + "start": { + "line": 495, + "column": 25 + }, + "end": { + "line": 495, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 16562, + 16568 + ], + "loc": { + "start": { + "line": 495, + "column": 38 + }, + "end": { + "line": 495, + "column": 44 + } + } + }, + "range": [ + 16549, + 16568 + ], + "loc": { + "start": { + "line": 495, + "column": 25 + }, + "end": { + "line": 495, + "column": 44 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 16569, + 16570 + ], + "loc": { + "start": { + "line": 495, + "column": 45 + }, + "end": { + "line": 495, + "column": 46 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16574, + 16578 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 16579, + 16585 + ], + "loc": { + "start": { + "line": 495, + "column": 55 + }, + "end": { + "line": 495, + "column": 61 + } + } + }, + "range": [ + 16574, + 16585 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 61 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16586, + 16590 + ], + "loc": { + "start": { + "line": 495, + "column": 62 + }, + "end": { + "line": 495, + "column": 66 + } + } + }, + "range": [ + 16574, + 16591 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 67 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 16592, + 16598 + ], + "loc": { + "start": { + "line": 495, + "column": 68 + }, + "end": { + "line": 495, + "column": 74 + } + } + }, + "range": [ + 16574, + 16598 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 74 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 16599, + 16606 + ], + "loc": { + "start": { + "line": 495, + "column": 75 + }, + "end": { + "line": 495, + "column": 82 + } + } + }, + "range": [ + 16574, + 16606 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 82 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "e", + "range": [ + 16607, + 16608 + ], + "loc": { + "start": { + "line": 495, + "column": 83 + }, + "end": { + "line": 495, + "column": 84 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16609, + 16613 + ], + "loc": { + "start": { + "line": 495, + "column": 85 + }, + "end": { + "line": 495, + "column": 89 + } + } + }, + "range": [ + 16607, + 16613 + ], + "loc": { + "start": { + "line": 495, + "column": 83 + }, + "end": { + "line": 495, + "column": 89 + } + } + } + ], + "range": [ + 16574, + 16614 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 90 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 16620, + 16621 + ], + "loc": { + "start": { + "line": 495, + "column": 96 + }, + "end": { + "line": 495, + "column": 97 + } + } + }, + "prefix": true, + "range": [ + 16619, + 16621 + ], + "loc": { + "start": { + "line": 495, + "column": 95 + }, + "end": { + "line": 495, + "column": 97 + } + } + }, + "range": [ + 16574, + 16621 + ], + "loc": { + "start": { + "line": 495, + "column": 50 + }, + "end": { + "line": 495, + "column": 97 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16569, + 16621 + ], + "loc": { + "start": { + "line": 495, + "column": 45 + }, + "end": { + "line": 495, + "column": 97 + } + } + } + ], + "range": [ + 16549, + 16622 + ], + "loc": { + "start": { + "line": 495, + "column": 25 + }, + "end": { + "line": 495, + "column": 98 + } + } + }, + "range": [ + 16534, + 16622 + ], + "loc": { + "start": { + "line": 495, + "column": 10 + }, + "end": { + "line": 495, + "column": 98 + } + } + }, + "range": [ + 16534, + 16623 + ], + "loc": { + "start": { + "line": 495, + "column": 10 + }, + "end": { + "line": 495, + "column": 99 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 16638, + 16640 + ], + "loc": { + "start": { + "line": 496, + "column": 14 + }, + "end": { + "line": 496, + "column": 16 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16656, + 16668 + ], + "loc": { + "start": { + "line": 497, + "column": 12 + }, + "end": { + "line": 497, + "column": 24 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16671, + 16683 + ], + "loc": { + "start": { + "line": 497, + "column": 27 + }, + "end": { + "line": 497, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 16684, + 16690 + ], + "loc": { + "start": { + "line": 497, + "column": 40 + }, + "end": { + "line": 497, + "column": 46 + } + } + }, + "range": [ + 16671, + 16690 + ], + "loc": { + "start": { + "line": 497, + "column": 27 + }, + "end": { + "line": 497, + "column": 46 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 16691, + 16692 + ], + "loc": { + "start": { + "line": 497, + "column": 47 + }, + "end": { + "line": 497, + "column": 48 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "e", + "range": [ + 16696, + 16697 + ], + "loc": { + "start": { + "line": 497, + "column": 52 + }, + "end": { + "line": 497, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 16698, + 16700 + ], + "loc": { + "start": { + "line": 497, + "column": 54 + }, + "end": { + "line": 497, + "column": 56 + } + } + }, + "range": [ + 16696, + 16700 + ], + "loc": { + "start": { + "line": 497, + "column": 52 + }, + "end": { + "line": 497, + "column": 56 + } + } + }, + "right": { + "type": "Identifier", + "name": "id", + "range": [ + 16705, + 16707 + ], + "loc": { + "start": { + "line": 497, + "column": 61 + }, + "end": { + "line": 497, + "column": 63 + } + } + }, + "range": [ + 16696, + 16707 + ], + "loc": { + "start": { + "line": 497, + "column": 52 + }, + "end": { + "line": 497, + "column": 63 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16691, + 16707 + ], + "loc": { + "start": { + "line": 497, + "column": 47 + }, + "end": { + "line": 497, + "column": 63 + } + } + } + ], + "range": [ + 16671, + 16708 + ], + "loc": { + "start": { + "line": 497, + "column": 27 + }, + "end": { + "line": 497, + "column": 64 + } + } + }, + "range": [ + 16656, + 16708 + ], + "loc": { + "start": { + "line": 497, + "column": 12 + }, + "end": { + "line": 497, + "column": 64 + } + } + }, + "range": [ + 16656, + 16709 + ], + "loc": { + "start": { + "line": 497, + "column": 12 + }, + "end": { + "line": 497, + "column": 65 + } + } + } + ], + "range": [ + 16642, + 16721 + ], + "loc": { + "start": { + "line": 496, + "column": 18 + }, + "end": { + "line": 498, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 16634, + 16721 + ], + "loc": { + "start": { + "line": 496, + "column": 10 + }, + "end": { + "line": 498, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16732, + 16744 + ], + "loc": { + "start": { + "line": 499, + "column": 10 + }, + "end": { + "line": 499, + "column": 22 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "subscription", + "range": [ + 16747, + 16759 + ], + "loc": { + "start": { + "line": 499, + "column": 25 + }, + "end": { + "line": 499, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "map", + "range": [ + 16760, + 16763 + ], + "loc": { + "start": { + "line": 499, + "column": 38 + }, + "end": { + "line": 499, + "column": 41 + } + } + }, + "range": [ + 16747, + 16763 + ], + "loc": { + "start": { + "line": 499, + "column": 25 + }, + "end": { + "line": 499, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 16764, + 16765 + ], + "loc": { + "start": { + "line": 499, + "column": 42 + }, + "end": { + "line": 499, + "column": 43 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16769, + 16773 + ], + "loc": { + "start": { + "line": 499, + "column": 47 + }, + "end": { + "line": 499, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 16774, + 16778 + ], + "loc": { + "start": { + "line": 499, + "column": 52 + }, + "end": { + "line": 499, + "column": 56 + } + } + }, + "range": [ + 16769, + 16778 + ], + "loc": { + "start": { + "line": 499, + "column": 47 + }, + "end": { + "line": 499, + "column": 56 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "e", + "range": [ + 16779, + 16780 + ], + "loc": { + "start": { + "line": 499, + "column": 57 + }, + "end": { + "line": 499, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16781, + 16785 + ], + "loc": { + "start": { + "line": 499, + "column": 59 + }, + "end": { + "line": 499, + "column": 63 + } + } + }, + "range": [ + 16779, + 16785 + ], + "loc": { + "start": { + "line": 499, + "column": 57 + }, + "end": { + "line": 499, + "column": 63 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "e", + "range": [ + 16787, + 16788 + ], + "loc": { + "start": { + "line": 499, + "column": 65 + }, + "end": { + "line": 499, + "column": 66 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 16789, + 16791 + ], + "loc": { + "start": { + "line": 499, + "column": 67 + }, + "end": { + "line": 499, + "column": 69 + } + } + }, + "range": [ + 16787, + 16791 + ], + "loc": { + "start": { + "line": 499, + "column": 65 + }, + "end": { + "line": 499, + "column": 69 + } + } + } + ], + "range": [ + 16769, + 16792 + ], + "loc": { + "start": { + "line": 499, + "column": 47 + }, + "end": { + "line": 499, + "column": 70 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 16764, + 16792 + ], + "loc": { + "start": { + "line": 499, + "column": 42 + }, + "end": { + "line": 499, + "column": 70 + } + } + } + ], + "range": [ + 16747, + 16793 + ], + "loc": { + "start": { + "line": 499, + "column": 25 + }, + "end": { + "line": 499, + "column": 71 + } + } + }, + "range": [ + 16732, + 16793 + ], + "loc": { + "start": { + "line": 499, + "column": 10 + }, + "end": { + "line": 499, + "column": 71 + } + } + }, + "range": [ + 16732, + 16794 + ], + "loc": { + "start": { + "line": 499, + "column": 10 + }, + "end": { + "line": 499, + "column": 72 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16805, + 16809 + ], + "loc": { + "start": { + "line": 500, + "column": 10 + }, + "end": { + "line": 500, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16810, + 16824 + ], + "loc": { + "start": { + "line": 500, + "column": 15 + }, + "end": { + "line": 500, + "column": 29 + } + } + }, + "range": [ + 16805, + 16824 + ], + "loc": { + "start": { + "line": 500, + "column": 10 + }, + "end": { + "line": 500, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16825, + 16830 + ], + "loc": { + "start": { + "line": 500, + "column": 30 + }, + "end": { + "line": 500, + "column": 35 + } + } + }, + "range": [ + 16805, + 16831 + ], + "loc": { + "start": { + "line": 500, + "column": 10 + }, + "end": { + "line": 500, + "column": 36 + } + } + }, + "right": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16834, + 16838 + ], + "loc": { + "start": { + "line": 500, + "column": 39 + }, + "end": { + "line": 500, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16839, + 16853 + ], + "loc": { + "start": { + "line": 500, + "column": 44 + }, + "end": { + "line": 500, + "column": 58 + } + } + }, + "range": [ + 16834, + 16853 + ], + "loc": { + "start": { + "line": 500, + "column": 39 + }, + "end": { + "line": 500, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16854, + 16859 + ], + "loc": { + "start": { + "line": 500, + "column": 59 + }, + "end": { + "line": 500, + "column": 64 + } + } + }, + "range": [ + 16834, + 16860 + ], + "loc": { + "start": { + "line": 500, + "column": 39 + }, + "end": { + "line": 500, + "column": 65 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 16864, + 16866 + ], + "loc": { + "start": { + "line": 500, + "column": 69 + }, + "end": { + "line": 500, + "column": 71 + } + } + }, + "range": [ + 16834, + 16866 + ], + "loc": { + "start": { + "line": 500, + "column": 39 + }, + "end": { + "line": 500, + "column": 71 + } + } + }, + "range": [ + 16805, + 16866 + ], + "loc": { + "start": { + "line": 500, + "column": 10 + }, + "end": { + "line": 500, + "column": 71 + } + } + }, + "range": [ + 16805, + 16867 + ], + "loc": { + "start": { + "line": 500, + "column": 10 + }, + "end": { + "line": 500, + "column": 72 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16883, + 16887 + ], + "loc": { + "start": { + "line": 501, + "column": 15 + }, + "end": { + "line": 501, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 16888, + 16902 + ], + "loc": { + "start": { + "line": 501, + "column": 20 + }, + "end": { + "line": 501, + "column": 34 + } + } + }, + "range": [ + 16883, + 16902 + ], + "loc": { + "start": { + "line": 501, + "column": 15 + }, + "end": { + "line": 501, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 16903, + 16908 + ], + "loc": { + "start": { + "line": 501, + "column": 35 + }, + "end": { + "line": 501, + "column": 40 + } + } + }, + "range": [ + 16883, + 16909 + ], + "loc": { + "start": { + "line": 501, + "column": 15 + }, + "end": { + "line": 501, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16910, + 16914 + ], + "loc": { + "start": { + "line": 501, + "column": 42 + }, + "end": { + "line": 501, + "column": 46 + } + } + }, + "range": [ + 16883, + 16915 + ], + "loc": { + "start": { + "line": 501, + "column": 15 + }, + "end": { + "line": 501, + "column": 47 + } + } + }, + "prefix": true, + "range": [ + 16882, + 16915 + ], + "loc": { + "start": { + "line": 501, + "column": 14 + }, + "end": { + "line": 501, + "column": 47 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "obj", + "range": [ + 16935, + 16938 + ], + "loc": { + "start": { + "line": 502, + "column": 16 + }, + "end": { + "line": 502, + "column": 19 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 16941, + 16943 + ], + "loc": { + "start": { + "line": 502, + "column": 22 + }, + "end": { + "line": 502, + "column": 24 + } + } + }, + "range": [ + 16935, + 16943 + ], + "loc": { + "start": { + "line": 502, + "column": 16 + }, + "end": { + "line": 502, + "column": 24 + } + } + } + ], + "kind": "let", + "range": [ + 16931, + 16944 + ], + "loc": { + "start": { + "line": 502, + "column": 12 + }, + "end": { + "line": 502, + "column": 25 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 16957, + 16961 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 503, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 16962, + 16968 + ], + "loc": { + "start": { + "line": 503, + "column": 17 + }, + "end": { + "line": 503, + "column": 23 + } + } + }, + "range": [ + 16957, + 16968 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 503, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 16969, + 16973 + ], + "loc": { + "start": { + "line": 503, + "column": 24 + }, + "end": { + "line": 503, + "column": 28 + } + } + }, + "range": [ + 16957, + 16974 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 503, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 16975, + 16981 + ], + "loc": { + "start": { + "line": 503, + "column": 30 + }, + "end": { + "line": 503, + "column": 36 + } + } + }, + "range": [ + 16957, + 16981 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 503, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 16982, + 16989 + ], + "loc": { + "start": { + "line": 503, + "column": 37 + }, + "end": { + "line": 503, + "column": 44 + } + } + }, + "range": [ + 16957, + 16989 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 503, + "column": 44 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 16990, + 16994 + ], + "loc": { + "start": { + "line": 503, + "column": 45 + }, + "end": { + "line": 503, + "column": 49 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17014, + 17018 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 17019, + 17033 + ], + "loc": { + "start": { + "line": 504, + "column": 19 + }, + "end": { + "line": 504, + "column": 33 + } + } + }, + "range": [ + 17014, + 17033 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 17034, + 17039 + ], + "loc": { + "start": { + "line": 504, + "column": 34 + }, + "end": { + "line": 504, + "column": 39 + } + } + }, + "range": [ + 17014, + 17040 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 17041, + 17045 + ], + "loc": { + "start": { + "line": 504, + "column": 41 + }, + "end": { + "line": 504, + "column": 45 + } + } + }, + "range": [ + 17014, + 17046 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 46 + } + } + }, + "right": { + "type": "Identifier", + "name": "obj", + "range": [ + 17049, + 17052 + ], + "loc": { + "start": { + "line": 504, + "column": 49 + }, + "end": { + "line": 504, + "column": 52 + } + } + }, + "range": [ + 17014, + 17052 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 52 + } + } + }, + "range": [ + 17014, + 17053 + ], + "loc": { + "start": { + "line": 504, + "column": 14 + }, + "end": { + "line": 504, + "column": 53 + } + } + } + ], + "range": [ + 16998, + 17067 + ], + "loc": { + "start": { + "line": 503, + "column": 53 + }, + "end": { + "line": 505, + "column": 13 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 16990, + 17067 + ], + "loc": { + "start": { + "line": 503, + "column": 45 + }, + "end": { + "line": 505, + "column": 13 + } + } + } + ], + "range": [ + 16957, + 17068 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 505, + "column": 14 + } + } + }, + "range": [ + 16957, + 17069 + ], + "loc": { + "start": { + "line": 503, + "column": 12 + }, + "end": { + "line": 505, + "column": 15 + } + } + } + ], + "range": [ + 16917, + 17081 + ], + "loc": { + "start": { + "line": 501, + "column": 49 + }, + "end": { + "line": 506, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 16878, + 17081 + ], + "loc": { + "start": { + "line": 501, + "column": 10 + }, + "end": { + "line": 506, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17092, + 17096 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subscriptions", + "range": [ + 17097, + 17111 + ], + "loc": { + "start": { + "line": 507, + "column": 15 + }, + "end": { + "line": 507, + "column": 29 + } + } + }, + "range": [ + 17092, + 17111 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "event", + "range": [ + 17112, + 17117 + ], + "loc": { + "start": { + "line": 507, + "column": 30 + }, + "end": { + "line": 507, + "column": 35 + } + } + }, + "range": [ + 17092, + 17118 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 17119, + 17123 + ], + "loc": { + "start": { + "line": 507, + "column": 37 + }, + "end": { + "line": 507, + "column": 41 + } + } + }, + "range": [ + 17092, + 17124 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 42 + } + } + }, + "property": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "Identifier", + "name": "id", + "range": [ + 17125, + 17127 + ], + "loc": { + "start": { + "line": 507, + "column": 43 + }, + "end": { + "line": 507, + "column": 45 + } + } + }, + "right": { + "type": "Literal", + "value": "*", + "raw": "\"*\"", + "range": [ + 17131, + 17134 + ], + "loc": { + "start": { + "line": 507, + "column": 49 + }, + "end": { + "line": 507, + "column": 52 + } + } + }, + "range": [ + 17125, + 17134 + ], + "loc": { + "start": { + "line": 507, + "column": 43 + }, + "end": { + "line": 507, + "column": 52 + } + } + }, + "range": [ + 17092, + 17135 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 53 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "subscription", + "range": [ + 17138, + 17150 + ], + "loc": { + "start": { + "line": 507, + "column": 56 + }, + "end": { + "line": 507, + "column": 68 + } + } + }, + "property": { + "type": "Identifier", + "name": "subscribe", + "range": [ + 17151, + 17160 + ], + "loc": { + "start": { + "line": 507, + "column": 69 + }, + "end": { + "line": 507, + "column": 78 + } + } + }, + "range": [ + 17138, + 17160 + ], + "loc": { + "start": { + "line": 507, + "column": 56 + }, + "end": { + "line": 507, + "column": 78 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "callback", + "range": [ + 17161, + 17169 + ], + "loc": { + "start": { + "line": 507, + "column": 79 + }, + "end": { + "line": 507, + "column": 87 + } + } + }, + "property": { + "type": "Identifier", + "name": "bind", + "range": [ + 17170, + 17174 + ], + "loc": { + "start": { + "line": 507, + "column": 88 + }, + "end": { + "line": 507, + "column": 92 + } + } + }, + "range": [ + 17161, + 17174 + ], + "loc": { + "start": { + "line": 507, + "column": 79 + }, + "end": { + "line": 507, + "column": 92 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "context", + "range": [ + 17175, + 17182 + ], + "loc": { + "start": { + "line": 507, + "column": 93 + }, + "end": { + "line": 507, + "column": 100 + } + } + } + ], + "range": [ + 17161, + 17183 + ], + "loc": { + "start": { + "line": 507, + "column": 79 + }, + "end": { + "line": 507, + "column": 101 + } + } + } + ], + "range": [ + 17138, + 17184 + ], + "loc": { + "start": { + "line": 507, + "column": 56 + }, + "end": { + "line": 507, + "column": 102 + } + } + }, + "range": [ + 17092, + 17184 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 102 + } + } + }, + "range": [ + 17092, + 17185 + ], + "loc": { + "start": { + "line": 507, + "column": 10 + }, + "end": { + "line": 507, + "column": 103 + } + } + } + ], + "range": [ + 16448, + 17195 + ], + "loc": { + "start": { + "line": 493, + "column": 133 + }, + "end": { + "line": 508, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 16330, + 17195 + ], + "loc": { + "start": { + "line": 493, + "column": 15 + }, + "end": { + "line": 508, + "column": 9 + } + } + }, + "range": [ + 16192, + 17195 + ], + "loc": { + "start": { + "line": 491, + "column": 8 + }, + "end": { + "line": 508, + "column": 9 + } + } + } + ], + "range": [ + 16182, + 17203 + ], + "loc": { + "start": { + "line": 490, + "column": 29 + }, + "end": { + "line": 509, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 17229, + 17234 + ], + "loc": { + "start": { + "line": 510, + "column": 18 + }, + "end": { + "line": 510, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 17235, + 17252 + ], + "loc": { + "start": { + "line": 510, + "column": 24 + }, + "end": { + "line": 510, + "column": 41 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 17256, + 17259 + ], + "loc": { + "start": { + "line": 510, + "column": 45 + }, + "end": { + "line": 510, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 17252, + 17256 + ], + "loc": { + "start": { + "line": 510, + "column": 41 + }, + "end": { + "line": 510, + "column": 45 + } + } + } + ], + "range": [ + 17235, + 17259 + ], + "loc": { + "start": { + "line": 510, + "column": 24 + }, + "end": { + "line": 510, + "column": 48 + } + } + } + ], + "range": [ + 17225, + 17260 + ], + "loc": { + "start": { + "line": 510, + "column": 14 + }, + "end": { + "line": 510, + "column": 49 + } + } + }, + "range": [ + 17219, + 17261 + ], + "loc": { + "start": { + "line": 510, + "column": 8 + }, + "end": { + "line": 510, + "column": 50 + } + } + } + ], + "range": [ + 17209, + 17269 + ], + "loc": { + "start": { + "line": 509, + "column": 13 + }, + "end": { + "line": 511, + "column": 7 + } + } + }, + "range": [ + 16159, + 17269 + ], + "loc": { + "start": { + "line": 490, + "column": 6 + }, + "end": { + "line": 511, + "column": 7 + } + } + } + ], + "range": [ + 16151, + 17275 + ], + "loc": { + "start": { + "line": 489, + "column": 73 + }, + "end": { + "line": 512, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 17299, + 17304 + ], + "loc": { + "start": { + "line": 513, + "column": 16 + }, + "end": { + "line": 513, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown event '", + "cooked": "Unknown event '" + }, + "tail": false, + "range": [ + 17305, + 17323 + ], + "loc": { + "start": { + "line": 513, + "column": 22 + }, + "end": { + "line": 513, + "column": 40 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 17328, + 17331 + ], + "loc": { + "start": { + "line": 513, + "column": 45 + }, + "end": { + "line": 513, + "column": 48 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 17323, + 17328 + ], + "loc": { + "start": { + "line": 513, + "column": 40 + }, + "end": { + "line": 513, + "column": 45 + } + } + } + ], + "range": [ + 17305, + 17331 + ], + "loc": { + "start": { + "line": 513, + "column": 22 + }, + "end": { + "line": 513, + "column": 48 + } + } + } + ], + "range": [ + 17295, + 17332 + ], + "loc": { + "start": { + "line": 513, + "column": 12 + }, + "end": { + "line": 513, + "column": 49 + } + } + }, + "range": [ + 17289, + 17333 + ], + "loc": { + "start": { + "line": 513, + "column": 6 + }, + "end": { + "line": 513, + "column": 50 + } + } + } + ], + "range": [ + 17281, + 17339 + ], + "loc": { + "start": { + "line": 512, + "column": 11 + }, + "end": { + "line": 514, + "column": 5 + } + } + }, + "range": [ + 16082, + 17339 + ], + "loc": { + "start": { + "line": 489, + "column": 4 + }, + "end": { + "line": 514, + "column": 5 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 16060, + 16077 + ], + "loc": { + "start": { + "line": 488, + "column": 4 + }, + "end": { + "line": 488, + "column": 21 + } + } + } + ] + } + ], + "range": [ + 15813, + 17343 + ], + "loc": { + "start": { + "line": 482, + "column": 41 + }, + "end": { + "line": 515, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 15776, + 17343 + ], + "loc": { + "start": { + "line": 482, + "column": 4 + }, + "end": { + "line": 515, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 15774, + 17343 + ], + "loc": { + "start": { + "line": 482, + "column": 2 + }, + "end": { + "line": 515, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n ", + "range": [ + 15286, + 15771 + ], + "loc": { + "start": { + "line": 471, + "column": 2 + }, + "end": { + "line": 481, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n ", + "range": [ + 17347, + 17645 + ], + "loc": { + "start": { + "line": 517, + "column": 2 + }, + "end": { + "line": 524, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "push", + "range": [ + 17648, + 17652 + ], + "loc": { + "start": { + "line": 525, + "column": 2 + }, + "end": { + "line": 525, + "column": 6 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "root", + "range": [ + 17653, + 17657 + ], + "loc": { + "start": { + "line": 525, + "column": 7 + }, + "end": { + "line": 525, + "column": 11 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 17669, + 17673 + ], + "loc": { + "start": { + "line": 526, + "column": 8 + }, + "end": { + "line": 526, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 17674, + 17678 + ], + "loc": { + "start": { + "line": 526, + "column": 13 + }, + "end": { + "line": 526, + "column": 17 + } + } + }, + "range": [ + 17669, + 17678 + ], + "loc": { + "start": { + "line": 526, + "column": 8 + }, + "end": { + "line": 526, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "constructor", + "range": [ + 17679, + 17690 + ], + "loc": { + "start": { + "line": 526, + "column": 18 + }, + "end": { + "line": 526, + "column": 29 + } + } + }, + "range": [ + 17669, + 17690 + ], + "loc": { + "start": { + "line": 526, + "column": 8 + }, + "end": { + "line": 526, + "column": 29 + } + } + }, + "right": { + "type": "Identifier", + "name": "Array", + "range": [ + 17695, + 17700 + ], + "loc": { + "start": { + "line": 526, + "column": 34 + }, + "end": { + "line": 526, + "column": 39 + } + } + }, + "range": [ + 17669, + 17700 + ], + "loc": { + "start": { + "line": 526, + "column": 8 + }, + "end": { + "line": 526, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 17710, + 17714 + ], + "loc": { + "start": { + "line": 527, + "column": 6 + }, + "end": { + "line": 527, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 17715, + 17719 + ], + "loc": { + "start": { + "line": 527, + "column": 11 + }, + "end": { + "line": 527, + "column": 15 + } + } + }, + "range": [ + 17710, + 17719 + ], + "loc": { + "start": { + "line": 527, + "column": 6 + }, + "end": { + "line": 527, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 17720, + 17727 + ], + "loc": { + "start": { + "line": 527, + "column": 16 + }, + "end": { + "line": 527, + "column": 23 + } + } + }, + "range": [ + 17710, + 17727 + ], + "loc": { + "start": { + "line": 527, + "column": 6 + }, + "end": { + "line": 527, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 17728, + 17729 + ], + "loc": { + "start": { + "line": 527, + "column": 24 + }, + "end": { + "line": 527, + "column": 25 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17733, + 17737 + ], + "loc": { + "start": { + "line": 527, + "column": 29 + }, + "end": { + "line": 527, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 17738, + 17741 + ], + "loc": { + "start": { + "line": 527, + "column": 34 + }, + "end": { + "line": 527, + "column": 37 + } + } + }, + "range": [ + 17733, + 17741 + ], + "loc": { + "start": { + "line": 527, + "column": 29 + }, + "end": { + "line": 527, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 17742, + 17743 + ], + "loc": { + "start": { + "line": 527, + "column": 38 + }, + "end": { + "line": 527, + "column": 39 + } + } + } + ], + "range": [ + 17733, + 17744 + ], + "loc": { + "start": { + "line": 527, + "column": 29 + }, + "end": { + "line": 527, + "column": 40 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 17728, + 17744 + ], + "loc": { + "start": { + "line": 527, + "column": 24 + }, + "end": { + "line": 527, + "column": 40 + } + } + } + ], + "range": [ + 17710, + 17745 + ], + "loc": { + "start": { + "line": 527, + "column": 6 + }, + "end": { + "line": 527, + "column": 41 + } + } + }, + "range": [ + 17710, + 17746 + ], + "loc": { + "start": { + "line": 527, + "column": 6 + }, + "end": { + "line": 527, + "column": 42 + } + } + } + ], + "range": [ + 17702, + 17752 + ], + "loc": { + "start": { + "line": 526, + "column": 41 + }, + "end": { + "line": 528, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17766, + 17770 + ], + "loc": { + "start": { + "line": 529, + "column": 6 + }, + "end": { + "line": 529, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 17771, + 17774 + ], + "loc": { + "start": { + "line": 529, + "column": 11 + }, + "end": { + "line": 529, + "column": 14 + } + } + }, + "range": [ + 17766, + 17774 + ], + "loc": { + "start": { + "line": 529, + "column": 6 + }, + "end": { + "line": 529, + "column": 14 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 17775, + 17779 + ], + "loc": { + "start": { + "line": 529, + "column": 15 + }, + "end": { + "line": 529, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "range": [ + 17780, + 17784 + ], + "loc": { + "start": { + "line": 529, + "column": 20 + }, + "end": { + "line": 529, + "column": 24 + } + } + }, + "range": [ + 17775, + 17784 + ], + "loc": { + "start": { + "line": 529, + "column": 15 + }, + "end": { + "line": 529, + "column": 24 + } + } + } + ], + "range": [ + 17766, + 17785 + ], + "loc": { + "start": { + "line": 529, + "column": 6 + }, + "end": { + "line": 529, + "column": 25 + } + } + }, + "range": [ + 17766, + 17786 + ], + "loc": { + "start": { + "line": 529, + "column": 6 + }, + "end": { + "line": 529, + "column": 26 + } + } + } + ], + "range": [ + 17758, + 17792 + ], + "loc": { + "start": { + "line": 528, + "column": 11 + }, + "end": { + "line": 530, + "column": 5 + } + } + }, + "range": [ + 17665, + 17792 + ], + "loc": { + "start": { + "line": 526, + "column": 4 + }, + "end": { + "line": 530, + "column": 5 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 17801, + 17805 + ], + "loc": { + "start": { + "line": 531, + "column": 8 + }, + "end": { + "line": 531, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "included", + "range": [ + 17806, + 17814 + ], + "loc": { + "start": { + "line": 531, + "column": 13 + }, + "end": { + "line": 531, + "column": 21 + } + } + }, + "range": [ + 17801, + 17814 + ], + "loc": { + "start": { + "line": 531, + "column": 8 + }, + "end": { + "line": 531, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "root", + "range": [ + 17824, + 17828 + ], + "loc": { + "start": { + "line": 532, + "column": 6 + }, + "end": { + "line": 532, + "column": 10 + } + } + }, + "property": { + "type": "Identifier", + "name": "included", + "range": [ + 17829, + 17837 + ], + "loc": { + "start": { + "line": 532, + "column": 11 + }, + "end": { + "line": 532, + "column": 19 + } + } + }, + "range": [ + 17824, + 17837 + ], + "loc": { + "start": { + "line": 532, + "column": 6 + }, + "end": { + "line": 532, + "column": 19 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 17838, + 17845 + ], + "loc": { + "start": { + "line": 532, + "column": 20 + }, + "end": { + "line": 532, + "column": 27 + } + } + }, + "range": [ + 17824, + 17845 + ], + "loc": { + "start": { + "line": 532, + "column": 6 + }, + "end": { + "line": 532, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 17846, + 17847 + ], + "loc": { + "start": { + "line": 532, + "column": 28 + }, + "end": { + "line": 532, + "column": 29 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 17851, + 17855 + ], + "loc": { + "start": { + "line": 532, + "column": 33 + }, + "end": { + "line": 532, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "add", + "range": [ + 17856, + 17859 + ], + "loc": { + "start": { + "line": 532, + "column": 38 + }, + "end": { + "line": 532, + "column": 41 + } + } + }, + "range": [ + 17851, + 17859 + ], + "loc": { + "start": { + "line": 532, + "column": 33 + }, + "end": { + "line": 532, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 17860, + 17861 + ], + "loc": { + "start": { + "line": 532, + "column": 42 + }, + "end": { + "line": 532, + "column": 43 + } + } + } + ], + "range": [ + 17851, + 17862 + ], + "loc": { + "start": { + "line": 532, + "column": 33 + }, + "end": { + "line": 532, + "column": 44 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 17846, + 17862 + ], + "loc": { + "start": { + "line": 532, + "column": 28 + }, + "end": { + "line": 532, + "column": 44 + } + } + } + ], + "range": [ + 17824, + 17863 + ], + "loc": { + "start": { + "line": 532, + "column": 6 + }, + "end": { + "line": 532, + "column": 45 + } + } + }, + "range": [ + 17824, + 17864 + ], + "loc": { + "start": { + "line": 532, + "column": 6 + }, + "end": { + "line": 532, + "column": 46 + } + } + } + ], + "range": [ + 17816, + 17870 + ], + "loc": { + "start": { + "line": 531, + "column": 23 + }, + "end": { + "line": 533, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 17797, + 17870 + ], + "loc": { + "start": { + "line": 531, + "column": 4 + }, + "end": { + "line": 533, + "column": 5 + } + } + } + ], + "range": [ + 17659, + 17874 + ], + "loc": { + "start": { + "line": 525, + "column": 13 + }, + "end": { + "line": 534, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 17652, + 17874 + ], + "loc": { + "start": { + "line": 525, + "column": 6 + }, + "end": { + "line": 534, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 17648, + 17874 + ], + "loc": { + "start": { + "line": 525, + "column": 2 + }, + "end": { + "line": 534, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n ", + "range": [ + 17347, + 17645 + ], + "loc": { + "start": { + "line": 517, + "column": 2 + }, + "end": { + "line": 524, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n ", + "range": [ + 17878, + 18184 + ], + "loc": { + "start": { + "line": 536, + "column": 2 + }, + "end": { + "line": 543, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "remove", + "range": [ + 18187, + 18193 + ], + "loc": { + "start": { + "line": 544, + "column": 2 + }, + "end": { + "line": 544, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 18194, + 18198 + ], + "loc": { + "start": { + "line": 544, + "column": 9 + }, + "end": { + "line": 544, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 18200, + 18202 + ], + "loc": { + "start": { + "line": 544, + "column": 15 + }, + "end": { + "line": 544, + "column": 17 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "type", + "range": [ + 18214, + 18218 + ], + "loc": { + "start": { + "line": 545, + "column": 8 + }, + "end": { + "line": 545, + "column": 12 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18232, + 18236 + ], + "loc": { + "start": { + "line": 546, + "column": 10 + }, + "end": { + "line": 546, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 18237, + 18243 + ], + "loc": { + "start": { + "line": 546, + "column": 15 + }, + "end": { + "line": 546, + "column": 21 + } + } + }, + "range": [ + 18232, + 18243 + ], + "loc": { + "start": { + "line": 546, + "column": 10 + }, + "end": { + "line": 546, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18244, + 18248 + ], + "loc": { + "start": { + "line": 546, + "column": 22 + }, + "end": { + "line": 546, + "column": 26 + } + } + }, + "range": [ + 18232, + 18249 + ], + "loc": { + "start": { + "line": 546, + "column": 10 + }, + "end": { + "line": 546, + "column": 27 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "id", + "range": [ + 18265, + 18267 + ], + "loc": { + "start": { + "line": 547, + "column": 12 + }, + "end": { + "line": 547, + "column": 14 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "resource", + "range": [ + 18285, + 18293 + ], + "loc": { + "start": { + "line": 548, + "column": 14 + }, + "end": { + "line": 548, + "column": 22 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18296, + 18300 + ], + "loc": { + "start": { + "line": 548, + "column": 25 + }, + "end": { + "line": 548, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 18301, + 18306 + ], + "loc": { + "start": { + "line": 548, + "column": 30 + }, + "end": { + "line": 548, + "column": 35 + } + } + }, + "range": [ + 18296, + 18306 + ], + "loc": { + "start": { + "line": 548, + "column": 25 + }, + "end": { + "line": 548, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18307, + 18311 + ], + "loc": { + "start": { + "line": 548, + "column": 36 + }, + "end": { + "line": 548, + "column": 40 + } + } + }, + "range": [ + 18296, + 18312 + ], + "loc": { + "start": { + "line": 548, + "column": 25 + }, + "end": { + "line": 548, + "column": 41 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18316, + 18320 + ], + "loc": { + "start": { + "line": 548, + "column": 45 + }, + "end": { + "line": 548, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 18321, + 18326 + ], + "loc": { + "start": { + "line": 548, + "column": 50 + }, + "end": { + "line": 548, + "column": 55 + } + } + }, + "range": [ + 18316, + 18326 + ], + "loc": { + "start": { + "line": 548, + "column": 45 + }, + "end": { + "line": 548, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18327, + 18331 + ], + "loc": { + "start": { + "line": 548, + "column": 56 + }, + "end": { + "line": 548, + "column": 60 + } + } + }, + "range": [ + 18316, + 18332 + ], + "loc": { + "start": { + "line": 548, + "column": 45 + }, + "end": { + "line": 548, + "column": 61 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 18333, + 18335 + ], + "loc": { + "start": { + "line": 548, + "column": 62 + }, + "end": { + "line": 548, + "column": 64 + } + } + }, + "range": [ + 18316, + 18336 + ], + "loc": { + "start": { + "line": 548, + "column": 45 + }, + "end": { + "line": 548, + "column": 65 + } + } + }, + "range": [ + 18296, + 18336 + ], + "loc": { + "start": { + "line": 548, + "column": 25 + }, + "end": { + "line": 548, + "column": 65 + } + } + }, + "range": [ + 18285, + 18336 + ], + "loc": { + "start": { + "line": 548, + "column": 14 + }, + "end": { + "line": 548, + "column": 65 + } + } + } + ], + "kind": "let", + "range": [ + 18281, + 18337 + ], + "loc": { + "start": { + "line": 548, + "column": 10 + }, + "end": { + "line": 548, + "column": 66 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "resource", + "range": [ + 18352, + 18360 + ], + "loc": { + "start": { + "line": 549, + "column": 14 + }, + "end": { + "line": 549, + "column": 22 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18376, + 18380 + ], + "loc": { + "start": { + "line": 550, + "column": 12 + }, + "end": { + "line": 550, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_remove", + "range": [ + 18381, + 18388 + ], + "loc": { + "start": { + "line": 550, + "column": 17 + }, + "end": { + "line": 550, + "column": 24 + } + } + }, + "range": [ + 18376, + 18388 + ], + "loc": { + "start": { + "line": 550, + "column": 12 + }, + "end": { + "line": 550, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 18389, + 18397 + ], + "loc": { + "start": { + "line": 550, + "column": 25 + }, + "end": { + "line": 550, + "column": 33 + } + } + } + ], + "range": [ + 18376, + 18398 + ], + "loc": { + "start": { + "line": 550, + "column": 12 + }, + "end": { + "line": 550, + "column": 34 + } + } + }, + "range": [ + 18376, + 18399 + ], + "loc": { + "start": { + "line": 550, + "column": 12 + }, + "end": { + "line": 550, + "column": 35 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18412, + 18416 + ], + "loc": { + "start": { + "line": 551, + "column": 12 + }, + "end": { + "line": 551, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_subject", + "range": [ + 18417, + 18425 + ], + "loc": { + "start": { + "line": 551, + "column": 17 + }, + "end": { + "line": 551, + "column": 25 + } + } + }, + "range": [ + 18412, + 18425 + ], + "loc": { + "start": { + "line": 551, + "column": 12 + }, + "end": { + "line": 551, + "column": 25 + } + } + }, + "property": { + "type": "Identifier", + "name": "onNext", + "range": [ + 18426, + 18432 + ], + "loc": { + "start": { + "line": 551, + "column": 26 + }, + "end": { + "line": 551, + "column": 32 + } + } + }, + "range": [ + 18412, + 18432 + ], + "loc": { + "start": { + "line": 551, + "column": 12 + }, + "end": { + "line": 551, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "name", + "range": [ + 18449, + 18453 + ], + "loc": { + "start": { + "line": 552, + "column": 14 + }, + "end": { + "line": 552, + "column": 18 + } + } + }, + "value": { + "type": "Literal", + "value": "removed", + "raw": "\"removed\"", + "range": [ + 18455, + 18464 + ], + "loc": { + "start": { + "line": 552, + "column": 20 + }, + "end": { + "line": 552, + "column": 29 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 18449, + 18464 + ], + "loc": { + "start": { + "line": 552, + "column": 14 + }, + "end": { + "line": 552, + "column": 29 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 18480, + 18484 + ], + "loc": { + "start": { + "line": 553, + "column": 14 + }, + "end": { + "line": 553, + "column": 18 + } + } + }, + "value": { + "type": "Identifier", + "name": "type", + "range": [ + 18486, + 18490 + ], + "loc": { + "start": { + "line": 553, + "column": 20 + }, + "end": { + "line": 553, + "column": 24 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 18480, + 18490 + ], + "loc": { + "start": { + "line": 553, + "column": 14 + }, + "end": { + "line": 553, + "column": 24 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 18506, + 18508 + ], + "loc": { + "start": { + "line": 554, + "column": 14 + }, + "end": { + "line": 554, + "column": 16 + } + } + }, + "value": { + "type": "Identifier", + "name": "id", + "range": [ + 18510, + 18512 + ], + "loc": { + "start": { + "line": 554, + "column": 18 + }, + "end": { + "line": 554, + "column": 20 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 18506, + 18512 + ], + "loc": { + "start": { + "line": 554, + "column": 14 + }, + "end": { + "line": 554, + "column": 20 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "resource", + "range": [ + 18528, + 18536 + ], + "loc": { + "start": { + "line": 555, + "column": 14 + }, + "end": { + "line": 555, + "column": 22 + } + } + }, + "value": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 18538, + 18542 + ], + "loc": { + "start": { + "line": 555, + "column": 24 + }, + "end": { + "line": 555, + "column": 28 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 18528, + 18542 + ], + "loc": { + "start": { + "line": 555, + "column": 14 + }, + "end": { + "line": 555, + "column": 28 + } + } + } + ], + "range": [ + 18433, + 18556 + ], + "loc": { + "start": { + "line": 551, + "column": 33 + }, + "end": { + "line": 556, + "column": 13 + } + } + } + ], + "range": [ + 18412, + 18557 + ], + "loc": { + "start": { + "line": 551, + "column": 12 + }, + "end": { + "line": 556, + "column": 14 + } + } + }, + "range": [ + 18412, + 18558 + ], + "loc": { + "start": { + "line": 551, + "column": 12 + }, + "end": { + "line": 556, + "column": 15 + } + } + } + ], + "range": [ + 18362, + 18570 + ], + "loc": { + "start": { + "line": 549, + "column": 24 + }, + "end": { + "line": 557, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 18348, + 18570 + ], + "loc": { + "start": { + "line": 549, + "column": 10 + }, + "end": { + "line": 557, + "column": 11 + } + } + } + ], + "range": [ + 18269, + 18580 + ], + "loc": { + "start": { + "line": 547, + "column": 16 + }, + "end": { + "line": 558, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Object", + "range": [ + 18598, + 18604 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "keys", + "range": [ + 18605, + 18609 + ], + "loc": { + "start": { + "line": 559, + "column": 17 + }, + "end": { + "line": 559, + "column": 21 + } + } + }, + "range": [ + 18598, + 18609 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18610, + 18614 + ], + "loc": { + "start": { + "line": 559, + "column": 22 + }, + "end": { + "line": 559, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 18615, + 18620 + ], + "loc": { + "start": { + "line": 559, + "column": 27 + }, + "end": { + "line": 559, + "column": 32 + } + } + }, + "range": [ + 18610, + 18620 + ], + "loc": { + "start": { + "line": 559, + "column": 22 + }, + "end": { + "line": 559, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 18621, + 18625 + ], + "loc": { + "start": { + "line": 559, + "column": 33 + }, + "end": { + "line": 559, + "column": 37 + } + } + }, + "range": [ + 18610, + 18626 + ], + "loc": { + "start": { + "line": 559, + "column": 22 + }, + "end": { + "line": 559, + "column": 38 + } + } + } + ], + "range": [ + 18598, + 18627 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 18628, + 18635 + ], + "loc": { + "start": { + "line": 559, + "column": 40 + }, + "end": { + "line": 559, + "column": 47 + } + } + }, + "range": [ + 18598, + 18635 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 47 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "id", + "range": [ + 18636, + 18638 + ], + "loc": { + "start": { + "line": 559, + "column": 48 + }, + "end": { + "line": 559, + "column": 50 + } + } + } + ], + "body": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 18642, + 18646 + ], + "loc": { + "start": { + "line": 559, + "column": 54 + }, + "end": { + "line": 559, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "remove", + "range": [ + 18647, + 18653 + ], + "loc": { + "start": { + "line": 559, + "column": 59 + }, + "end": { + "line": 559, + "column": 65 + } + } + }, + "range": [ + 18642, + 18653 + ], + "loc": { + "start": { + "line": 559, + "column": 54 + }, + "end": { + "line": 559, + "column": 65 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 18654, + 18658 + ], + "loc": { + "start": { + "line": 559, + "column": 66 + }, + "end": { + "line": 559, + "column": 70 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 18660, + 18662 + ], + "loc": { + "start": { + "line": 559, + "column": 72 + }, + "end": { + "line": 559, + "column": 74 + } + } + } + ], + "range": [ + 18642, + 18663 + ], + "loc": { + "start": { + "line": 559, + "column": 54 + }, + "end": { + "line": 559, + "column": 75 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 18636, + 18663 + ], + "loc": { + "start": { + "line": 559, + "column": 48 + }, + "end": { + "line": 559, + "column": 75 + } + } + } + ], + "range": [ + 18598, + 18664 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 76 + } + } + }, + "range": [ + 18598, + 18665 + ], + "loc": { + "start": { + "line": 559, + "column": 10 + }, + "end": { + "line": 559, + "column": 77 + } + } + } + ], + "range": [ + 18586, + 18675 + ], + "loc": { + "start": { + "line": 558, + "column": 15 + }, + "end": { + "line": 560, + "column": 9 + } + } + }, + "range": [ + 18261, + 18675 + ], + "loc": { + "start": { + "line": 547, + "column": 8 + }, + "end": { + "line": 560, + "column": 9 + } + } + } + ], + "range": [ + 18251, + 18683 + ], + "loc": { + "start": { + "line": 546, + "column": 29 + }, + "end": { + "line": 561, + "column": 7 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 18709, + 18718 + ], + "loc": { + "start": { + "line": 562, + "column": 18 + }, + "end": { + "line": 562, + "column": 27 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Unknown type '", + "cooked": "Unknown type '" + }, + "tail": false, + "range": [ + 18719, + 18736 + ], + "loc": { + "start": { + "line": 562, + "column": 28 + }, + "end": { + "line": 562, + "column": 45 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "'", + "cooked": "'" + }, + "tail": true, + "range": [ + 18740, + 18743 + ], + "loc": { + "start": { + "line": 562, + "column": 49 + }, + "end": { + "line": 562, + "column": 52 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 18736, + 18740 + ], + "loc": { + "start": { + "line": 562, + "column": 45 + }, + "end": { + "line": 562, + "column": 49 + } + } + } + ], + "range": [ + 18719, + 18743 + ], + "loc": { + "start": { + "line": 562, + "column": 28 + }, + "end": { + "line": 562, + "column": 52 + } + } + } + ], + "range": [ + 18705, + 18744 + ], + "loc": { + "start": { + "line": 562, + "column": 14 + }, + "end": { + "line": 562, + "column": 53 + } + } + }, + "range": [ + 18699, + 18745 + ], + "loc": { + "start": { + "line": 562, + "column": 8 + }, + "end": { + "line": 562, + "column": 54 + } + } + } + ], + "range": [ + 18689, + 18753 + ], + "loc": { + "start": { + "line": 561, + "column": 13 + }, + "end": { + "line": 563, + "column": 7 + } + } + }, + "range": [ + 18228, + 18753 + ], + "loc": { + "start": { + "line": 546, + "column": 6 + }, + "end": { + "line": 563, + "column": 7 + } + } + } + ], + "range": [ + 18220, + 18759 + ], + "loc": { + "start": { + "line": 545, + "column": 14 + }, + "end": { + "line": 564, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "TypeError", + "range": [ + 18783, + 18792 + ], + "loc": { + "start": { + "line": 565, + "column": 16 + }, + "end": { + "line": 565, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "You must provide a type to remove", + "cooked": "You must provide a type to remove" + }, + "tail": true, + "range": [ + 18793, + 18828 + ], + "loc": { + "start": { + "line": 565, + "column": 26 + }, + "end": { + "line": 565, + "column": 61 + } + } + } + ], + "expressions": [], + "range": [ + 18793, + 18828 + ], + "loc": { + "start": { + "line": 565, + "column": 26 + }, + "end": { + "line": 565, + "column": 61 + } + } + } + ], + "range": [ + 18779, + 18829 + ], + "loc": { + "start": { + "line": 565, + "column": 12 + }, + "end": { + "line": 565, + "column": 62 + } + } + }, + "range": [ + 18773, + 18830 + ], + "loc": { + "start": { + "line": 565, + "column": 6 + }, + "end": { + "line": 565, + "column": 63 + } + } + } + ], + "range": [ + 18765, + 18836 + ], + "loc": { + "start": { + "line": 564, + "column": 11 + }, + "end": { + "line": 566, + "column": 5 + } + } + }, + "range": [ + 18210, + 18836 + ], + "loc": { + "start": { + "line": 545, + "column": 4 + }, + "end": { + "line": 566, + "column": 5 + } + } + } + ], + "range": [ + 18204, + 18840 + ], + "loc": { + "start": { + "line": 544, + "column": 19 + }, + "end": { + "line": 567, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 18193, + 18840 + ], + "loc": { + "start": { + "line": 544, + "column": 8 + }, + "end": { + "line": 567, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 18187, + 18840 + ], + "loc": { + "start": { + "line": 544, + "column": 2 + }, + "end": { + "line": 567, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n ", + "range": [ + 17878, + 18184 + ], + "loc": { + "start": { + "line": 536, + "column": 2 + }, + "end": { + "line": 543, + "column": 5 + } + } + } + ], + "trailingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 18844, + 19453 + ], + "loc": { + "start": { + "line": 569, + "column": 2 + }, + "end": { + "line": 586, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "update", + "range": [ + 19456, + 19462 + ], + "loc": { + "start": { + "line": 587, + "column": 2 + }, + "end": { + "line": 587, + "column": 8 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "type", + "range": [ + 19463, + 19467 + ], + "loc": { + "start": { + "line": 587, + "column": 9 + }, + "end": { + "line": 587, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 19469, + 19471 + ], + "loc": { + "start": { + "line": 587, + "column": 15 + }, + "end": { + "line": 587, + "column": 17 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 19473, + 19480 + ], + "loc": { + "start": { + "line": 587, + "column": 19 + }, + "end": { + "line": 587, + "column": 26 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 19482, + 19489 + ], + "loc": { + "start": { + "line": 587, + "column": 28 + }, + "end": { + "line": 587, + "column": 35 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 19501, + 19505 + ], + "loc": { + "start": { + "line": 588, + "column": 8 + }, + "end": { + "line": 588, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 19506, + 19514 + ], + "loc": { + "start": { + "line": 588, + "column": 13 + }, + "end": { + "line": 588, + "column": 21 + } + } + }, + "range": [ + 19501, + 19514 + ], + "loc": { + "start": { + "line": 588, + "column": 8 + }, + "end": { + "line": 588, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 19531, + 19535 + ], + "loc": { + "start": { + "line": 589, + "column": 13 + }, + "end": { + "line": 589, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "_adapter", + "range": [ + 19536, + 19544 + ], + "loc": { + "start": { + "line": 589, + "column": 18 + }, + "end": { + "line": 589, + "column": 26 + } + } + }, + "range": [ + 19531, + 19544 + ], + "loc": { + "start": { + "line": 589, + "column": 13 + }, + "end": { + "line": 589, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "update", + "range": [ + 19545, + 19551 + ], + "loc": { + "start": { + "line": 589, + "column": 27 + }, + "end": { + "line": 589, + "column": 33 + } + } + }, + "range": [ + 19531, + 19551 + ], + "loc": { + "start": { + "line": 589, + "column": 13 + }, + "end": { + "line": 589, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 19552, + 19556 + ], + "loc": { + "start": { + "line": 589, + "column": 34 + }, + "end": { + "line": 589, + "column": 38 + } + } + }, + { + "type": "Identifier", + "name": "type", + "range": [ + 19558, + 19562 + ], + "loc": { + "start": { + "line": 589, + "column": 40 + }, + "end": { + "line": 589, + "column": 44 + } + } + }, + { + "type": "Identifier", + "name": "id", + "range": [ + 19564, + 19566 + ], + "loc": { + "start": { + "line": 589, + "column": 46 + }, + "end": { + "line": 589, + "column": 48 + } + } + }, + { + "type": "Identifier", + "name": "partial", + "range": [ + 19568, + 19575 + ], + "loc": { + "start": { + "line": 589, + "column": 50 + }, + "end": { + "line": 589, + "column": 57 + } + } + }, + { + "type": "Identifier", + "name": "options", + "range": [ + 19577, + 19584 + ], + "loc": { + "start": { + "line": 589, + "column": 59 + }, + "end": { + "line": 589, + "column": 66 + } + } + } + ], + "range": [ + 19531, + 19585 + ], + "loc": { + "start": { + "line": 589, + "column": 13 + }, + "end": { + "line": 589, + "column": 67 + } + } + }, + "range": [ + 19524, + 19586 + ], + "loc": { + "start": { + "line": 589, + "column": 6 + }, + "end": { + "line": 589, + "column": 68 + } + } + } + ], + "range": [ + 19516, + 19592 + ], + "loc": { + "start": { + "line": 588, + "column": 23 + }, + "end": { + "line": 590, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 19616, + 19621 + ], + "loc": { + "start": { + "line": 591, + "column": 16 + }, + "end": { + "line": 591, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "Literal", + "value": "Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`", + "raw": "\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\"", + "range": [ + 19622, + 19718 + ], + "loc": { + "start": { + "line": 591, + "column": 22 + }, + "end": { + "line": 591, + "column": 118 + } + } + } + ], + "range": [ + 19612, + 19719 + ], + "loc": { + "start": { + "line": 591, + "column": 12 + }, + "end": { + "line": 591, + "column": 119 + } + } + }, + "range": [ + 19606, + 19720 + ], + "loc": { + "start": { + "line": 591, + "column": 6 + }, + "end": { + "line": 591, + "column": 120 + } + } + } + ], + "range": [ + 19598, + 19726 + ], + "loc": { + "start": { + "line": 590, + "column": 11 + }, + "end": { + "line": 592, + "column": 5 + } + } + }, + "range": [ + 19497, + 19726 + ], + "loc": { + "start": { + "line": 588, + "column": 4 + }, + "end": { + "line": 592, + "column": 5 + } + } + } + ], + "range": [ + 19491, + 19730 + ], + "loc": { + "start": { + "line": 587, + "column": 37 + }, + "end": { + "line": 593, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 19462, + 19730 + ], + "loc": { + "start": { + "line": 587, + "column": 8 + }, + "end": { + "line": 593, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 19456, + 19730 + ], + "loc": { + "start": { + "line": 587, + "column": 2 + }, + "end": { + "line": 593, + "column": 3 + } + }, + "leadingComments": [ + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 18844, + 19453 + ], + "loc": { + "start": { + "line": 569, + "column": 2 + }, + "end": { + "line": 586, + "column": 5 + } + } + } + ], + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_addField", + "range": [ + 19734, + 19743 + ], + "loc": { + "start": { + "line": 595, + "column": 2 + }, + "end": { + "line": 595, + "column": 11 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "object", + "range": [ + 19744, + 19750 + ], + "loc": { + "start": { + "line": 595, + "column": 12 + }, + "end": { + "line": 595, + "column": 18 + } + } + }, + { + "type": "Identifier", + "name": "resource", + "range": [ + 19752, + 19760 + ], + "loc": { + "start": { + "line": 595, + "column": 20 + }, + "end": { + "line": 595, + "column": 28 + } + } + }, + { + "type": "Identifier", + "name": "definition", + "range": [ + 19762, + 19772 + ], + "loc": { + "start": { + "line": 595, + "column": 30 + }, + "end": { + "line": 595, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19774, + 19783 + ], + "loc": { + "start": { + "line": 595, + "column": 42 + }, + "end": { + "line": 595, + "column": 51 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "field", + "range": [ + 19795, + 19800 + ], + "loc": { + "start": { + "line": 596, + "column": 8 + }, + "end": { + "line": 596, + "column": 13 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "definition", + "range": [ + 19803, + 19813 + ], + "loc": { + "start": { + "line": 596, + "column": 16 + }, + "end": { + "line": 596, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19814, + 19823 + ], + "loc": { + "start": { + "line": 596, + "column": 27 + }, + "end": { + "line": 596, + "column": 36 + } + } + }, + "range": [ + 19803, + 19824 + ], + "loc": { + "start": { + "line": 596, + "column": 16 + }, + "end": { + "line": 596, + "column": 37 + } + } + }, + "range": [ + 19795, + 19824 + ], + "loc": { + "start": { + "line": 596, + "column": 8 + }, + "end": { + "line": 596, + "column": 37 + } + } + } + ], + "kind": "var", + "range": [ + 19791, + 19825 + ], + "loc": { + "start": { + "line": 596, + "column": 4 + }, + "end": { + "line": 596, + "column": 38 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "newValue", + "range": [ + 19834, + 19842 + ], + "loc": { + "start": { + "line": 597, + "column": 8 + }, + "end": { + "line": 597, + "column": 16 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 19845, + 19850 + ], + "loc": { + "start": { + "line": 597, + "column": 19 + }, + "end": { + "line": 597, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "deserialize", + "range": [ + 19851, + 19862 + ], + "loc": { + "start": { + "line": 597, + "column": 25 + }, + "end": { + "line": 597, + "column": 36 + } + } + }, + "range": [ + 19845, + 19862 + ], + "loc": { + "start": { + "line": 597, + "column": 19 + }, + "end": { + "line": 597, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 19863, + 19867 + ], + "loc": { + "start": { + "line": 597, + "column": 37 + }, + "end": { + "line": 597, + "column": 41 + } + } + }, + "range": [ + 19845, + 19867 + ], + "loc": { + "start": { + "line": 597, + "column": 19 + }, + "end": { + "line": 597, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 19868, + 19872 + ], + "loc": { + "start": { + "line": 597, + "column": 42 + }, + "end": { + "line": 597, + "column": 46 + } + } + }, + { + "type": "Identifier", + "name": "object", + "range": [ + 19874, + 19880 + ], + "loc": { + "start": { + "line": 597, + "column": 48 + }, + "end": { + "line": 597, + "column": 54 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19882, + 19891 + ], + "loc": { + "start": { + "line": 597, + "column": 56 + }, + "end": { + "line": 597, + "column": 65 + } + } + } + ], + "range": [ + 19845, + 19892 + ], + "loc": { + "start": { + "line": 597, + "column": 19 + }, + "end": { + "line": 597, + "column": 66 + } + } + }, + "range": [ + 19834, + 19892 + ], + "loc": { + "start": { + "line": 597, + "column": 8 + }, + "end": { + "line": 597, + "column": 66 + } + } + } + ], + "kind": "var", + "range": [ + 19830, + 19893 + ], + "loc": { + "start": { + "line": 597, + "column": 4 + }, + "end": { + "line": 597, + "column": 67 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "UnaryExpression", + "operator": "typeof", + "argument": { + "type": "Identifier", + "name": "newValue", + "range": [ + 19909, + 19917 + ], + "loc": { + "start": { + "line": 598, + "column": 15 + }, + "end": { + "line": 598, + "column": 23 + } + } + }, + "prefix": true, + "range": [ + 19902, + 19917 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 598, + "column": 23 + } + } + }, + "right": { + "type": "Literal", + "value": "undefined", + "raw": "\"undefined\"", + "range": [ + 19922, + 19933 + ], + "loc": { + "start": { + "line": 598, + "column": 28 + }, + "end": { + "line": 598, + "column": 39 + } + } + }, + "range": [ + 19902, + 19933 + ], + "loc": { + "start": { + "line": 598, + "column": 8 + }, + "end": { + "line": 598, + "column": 39 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 19947, + 19952 + ], + "loc": { + "start": { + "line": 599, + "column": 10 + }, + "end": { + "line": 599, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 19953, + 19957 + ], + "loc": { + "start": { + "line": 599, + "column": 16 + }, + "end": { + "line": 599, + "column": 20 + } + } + }, + "range": [ + 19947, + 19957 + ], + "loc": { + "start": { + "line": 599, + "column": 10 + }, + "end": { + "line": 599, + "column": 20 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 19962, + 19971 + ], + "loc": { + "start": { + "line": 599, + "column": 25 + }, + "end": { + "line": 599, + "column": 34 + } + } + }, + "range": [ + 19947, + 19971 + ], + "loc": { + "start": { + "line": 599, + "column": 10 + }, + "end": { + "line": 599, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 19987, + 19995 + ], + "loc": { + "start": { + "line": 600, + "column": 12 + }, + "end": { + "line": 600, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 19996, + 20005 + ], + "loc": { + "start": { + "line": 600, + "column": 21 + }, + "end": { + "line": 600, + "column": 30 + } + } + }, + "range": [ + 19987, + 20006 + ], + "loc": { + "start": { + "line": 600, + "column": 12 + }, + "end": { + "line": 600, + "column": 31 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20020, + 20024 + ], + "loc": { + "start": { + "line": 601, + "column": 10 + }, + "end": { + "line": 601, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 20025, + 20051 + ], + "loc": { + "start": { + "line": 601, + "column": 15 + }, + "end": { + "line": 601, + "column": 41 + } + } + }, + "range": [ + 20020, + 20051 + ], + "loc": { + "start": { + "line": 601, + "column": 10 + }, + "end": { + "line": 601, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20052, + 20060 + ], + "loc": { + "start": { + "line": 601, + "column": 42 + }, + "end": { + "line": 601, + "column": 50 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20062, + 20071 + ], + "loc": { + "start": { + "line": 601, + "column": 52 + }, + "end": { + "line": 601, + "column": 61 + } + } + }, + { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20073, + 20081 + ], + "loc": { + "start": { + "line": 601, + "column": 63 + }, + "end": { + "line": 601, + "column": 71 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20082, + 20091 + ], + "loc": { + "start": { + "line": 601, + "column": 72 + }, + "end": { + "line": 601, + "column": 81 + } + } + }, + "range": [ + 20073, + 20092 + ], + "loc": { + "start": { + "line": 601, + "column": 63 + }, + "end": { + "line": 601, + "column": 82 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 20094, + 20099 + ], + "loc": { + "start": { + "line": 601, + "column": 84 + }, + "end": { + "line": 601, + "column": 89 + } + } + } + ], + "range": [ + 20020, + 20100 + ], + "loc": { + "start": { + "line": 601, + "column": 10 + }, + "end": { + "line": 601, + "column": 90 + } + } + }, + "range": [ + 20020, + 20101 + ], + "loc": { + "start": { + "line": 601, + "column": 10 + }, + "end": { + "line": 601, + "column": 91 + } + } + } + ], + "range": [ + 20008, + 20111 + ], + "loc": { + "start": { + "line": 600, + "column": 33 + }, + "end": { + "line": 602, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 19983, + 20111 + ], + "loc": { + "start": { + "line": 600, + "column": 8 + }, + "end": { + "line": 602, + "column": 9 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "newValue", + "range": [ + 20124, + 20132 + ], + "loc": { + "start": { + "line": 603, + "column": 12 + }, + "end": { + "line": 603, + "column": 20 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20146, + 20150 + ], + "loc": { + "start": { + "line": 604, + "column": 10 + }, + "end": { + "line": 604, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 20151, + 20174 + ], + "loc": { + "start": { + "line": 604, + "column": 15 + }, + "end": { + "line": 604, + "column": 38 + } + } + }, + "range": [ + 20146, + 20174 + ], + "loc": { + "start": { + "line": 604, + "column": 10 + }, + "end": { + "line": 604, + "column": 38 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20175, + 20183 + ], + "loc": { + "start": { + "line": 604, + "column": 39 + }, + "end": { + "line": 604, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20185, + 20194 + ], + "loc": { + "start": { + "line": 604, + "column": 49 + }, + "end": { + "line": 604, + "column": 58 + } + } + }, + { + "type": "Identifier", + "name": "newValue", + "range": [ + 20196, + 20204 + ], + "loc": { + "start": { + "line": 604, + "column": 60 + }, + "end": { + "line": 604, + "column": 68 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 20206, + 20211 + ], + "loc": { + "start": { + "line": 604, + "column": 70 + }, + "end": { + "line": 604, + "column": 75 + } + } + } + ], + "range": [ + 20146, + 20212 + ], + "loc": { + "start": { + "line": 604, + "column": 10 + }, + "end": { + "line": 604, + "column": 76 + } + } + }, + "range": [ + 20146, + 20213 + ], + "loc": { + "start": { + "line": 604, + "column": 10 + }, + "end": { + "line": 604, + "column": 77 + } + } + } + ], + "range": [ + 20134, + 20223 + ], + "loc": { + "start": { + "line": 603, + "column": 22 + }, + "end": { + "line": 605, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 20120, + 20223 + ], + "loc": { + "start": { + "line": 603, + "column": 8 + }, + "end": { + "line": 605, + "column": 9 + } + } + } + ], + "range": [ + 19973, + 20231 + ], + "loc": { + "start": { + "line": 599, + "column": 36 + }, + "end": { + "line": 606, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "field", + "range": [ + 20241, + 20246 + ], + "loc": { + "start": { + "line": 606, + "column": 17 + }, + "end": { + "line": 606, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20247, + 20251 + ], + "loc": { + "start": { + "line": 606, + "column": 23 + }, + "end": { + "line": 606, + "column": 27 + } + } + }, + "range": [ + 20241, + 20251 + ], + "loc": { + "start": { + "line": 606, + "column": 17 + }, + "end": { + "line": 606, + "column": 27 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 20256, + 20266 + ], + "loc": { + "start": { + "line": 606, + "column": 32 + }, + "end": { + "line": 606, + "column": 42 + } + } + }, + "range": [ + 20241, + 20266 + ], + "loc": { + "start": { + "line": 606, + "column": 17 + }, + "end": { + "line": 606, + "column": 42 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20278, + 20286 + ], + "loc": { + "start": { + "line": 607, + "column": 8 + }, + "end": { + "line": 607, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20287, + 20296 + ], + "loc": { + "start": { + "line": 607, + "column": 17 + }, + "end": { + "line": 607, + "column": 26 + } + } + }, + "range": [ + 20278, + 20297 + ], + "loc": { + "start": { + "line": 607, + "column": 8 + }, + "end": { + "line": 607, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 20298, + 20305 + ], + "loc": { + "start": { + "line": 607, + "column": 28 + }, + "end": { + "line": 607, + "column": 35 + } + } + }, + "range": [ + 20278, + 20305 + ], + "loc": { + "start": { + "line": 607, + "column": 8 + }, + "end": { + "line": 607, + "column": 35 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 20306, + 20307 + ], + "loc": { + "start": { + "line": 607, + "column": 36 + }, + "end": { + "line": 607, + "column": 37 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20327, + 20335 + ], + "loc": { + "start": { + "line": 608, + "column": 14 + }, + "end": { + "line": 608, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20336, + 20345 + ], + "loc": { + "start": { + "line": 608, + "column": 23 + }, + "end": { + "line": 608, + "column": 32 + } + } + }, + "range": [ + 20327, + 20346 + ], + "loc": { + "start": { + "line": 608, + "column": 14 + }, + "end": { + "line": 608, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 20347, + 20354 + ], + "loc": { + "start": { + "line": 608, + "column": 34 + }, + "end": { + "line": 608, + "column": 41 + } + } + }, + "range": [ + 20327, + 20354 + ], + "loc": { + "start": { + "line": 608, + "column": 14 + }, + "end": { + "line": 608, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 20355, + 20356 + ], + "loc": { + "start": { + "line": 608, + "column": 42 + }, + "end": { + "line": 608, + "column": 43 + } + } + } + ], + "range": [ + 20327, + 20357 + ], + "loc": { + "start": { + "line": 608, + "column": 14 + }, + "end": { + "line": 608, + "column": 44 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 20363, + 20364 + ], + "loc": { + "start": { + "line": 608, + "column": 50 + }, + "end": { + "line": 608, + "column": 51 + } + } + }, + "prefix": true, + "range": [ + 20362, + 20364 + ], + "loc": { + "start": { + "line": 608, + "column": 49 + }, + "end": { + "line": 608, + "column": 51 + } + } + }, + "range": [ + 20327, + 20364 + ], + "loc": { + "start": { + "line": 608, + "column": 14 + }, + "end": { + "line": 608, + "column": 51 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20380, + 20384 + ], + "loc": { + "start": { + "line": 609, + "column": 12 + }, + "end": { + "line": 609, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 20385, + 20411 + ], + "loc": { + "start": { + "line": 609, + "column": 17 + }, + "end": { + "line": 609, + "column": 43 + } + } + }, + "range": [ + 20380, + 20411 + ], + "loc": { + "start": { + "line": 609, + "column": 12 + }, + "end": { + "line": 609, + "column": 43 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20412, + 20420 + ], + "loc": { + "start": { + "line": 609, + "column": 44 + }, + "end": { + "line": 609, + "column": 52 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20422, + 20431 + ], + "loc": { + "start": { + "line": 609, + "column": 54 + }, + "end": { + "line": 609, + "column": 63 + } + } + }, + { + "type": "Identifier", + "name": "r", + "range": [ + 20433, + 20434 + ], + "loc": { + "start": { + "line": 609, + "column": 65 + }, + "end": { + "line": 609, + "column": 66 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 20436, + 20441 + ], + "loc": { + "start": { + "line": 609, + "column": 68 + }, + "end": { + "line": 609, + "column": 73 + } + } + } + ], + "range": [ + 20380, + 20442 + ], + "loc": { + "start": { + "line": 609, + "column": 12 + }, + "end": { + "line": 609, + "column": 74 + } + } + }, + "range": [ + 20380, + 20443 + ], + "loc": { + "start": { + "line": 609, + "column": 12 + }, + "end": { + "line": 609, + "column": 75 + } + } + } + ], + "range": [ + 20366, + 20455 + ], + "loc": { + "start": { + "line": 608, + "column": 53 + }, + "end": { + "line": 610, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 20323, + 20455 + ], + "loc": { + "start": { + "line": 608, + "column": 10 + }, + "end": { + "line": 610, + "column": 11 + } + } + } + ], + "range": [ + 20311, + 20465 + ], + "loc": { + "start": { + "line": 607, + "column": 41 + }, + "end": { + "line": 611, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20306, + 20465 + ], + "loc": { + "start": { + "line": 607, + "column": 36 + }, + "end": { + "line": 611, + "column": 9 + } + } + } + ], + "range": [ + 20278, + 20466 + ], + "loc": { + "start": { + "line": 607, + "column": 8 + }, + "end": { + "line": 611, + "column": 10 + } + } + }, + "range": [ + 20278, + 20467 + ], + "loc": { + "start": { + "line": 607, + "column": 8 + }, + "end": { + "line": 611, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "newValue", + "range": [ + 20476, + 20484 + ], + "loc": { + "start": { + "line": 612, + "column": 8 + }, + "end": { + "line": 612, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 20485, + 20492 + ], + "loc": { + "start": { + "line": 612, + "column": 17 + }, + "end": { + "line": 612, + "column": 24 + } + } + }, + "range": [ + 20476, + 20492 + ], + "loc": { + "start": { + "line": 612, + "column": 8 + }, + "end": { + "line": 612, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 20493, + 20494 + ], + "loc": { + "start": { + "line": 612, + "column": 25 + }, + "end": { + "line": 612, + "column": 26 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20510, + 20514 + ], + "loc": { + "start": { + "line": 613, + "column": 10 + }, + "end": { + "line": 613, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 20515, + 20538 + ], + "loc": { + "start": { + "line": 613, + "column": 15 + }, + "end": { + "line": 613, + "column": 38 + } + } + }, + "range": [ + 20510, + 20538 + ], + "loc": { + "start": { + "line": 613, + "column": 10 + }, + "end": { + "line": 613, + "column": 38 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 20539, + 20547 + ], + "loc": { + "start": { + "line": 613, + "column": 39 + }, + "end": { + "line": 613, + "column": 47 + } + } + }, + { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20549, + 20558 + ], + "loc": { + "start": { + "line": 613, + "column": 49 + }, + "end": { + "line": 613, + "column": 58 + } + } + }, + { + "type": "Identifier", + "name": "r", + "range": [ + 20560, + 20561 + ], + "loc": { + "start": { + "line": 613, + "column": 60 + }, + "end": { + "line": 613, + "column": 61 + } + } + }, + { + "type": "Identifier", + "name": "field", + "range": [ + 20563, + 20568 + ], + "loc": { + "start": { + "line": 613, + "column": 63 + }, + "end": { + "line": 613, + "column": 68 + } + } + } + ], + "range": [ + 20510, + 20569 + ], + "loc": { + "start": { + "line": 613, + "column": 10 + }, + "end": { + "line": 613, + "column": 69 + } + } + }, + "range": [ + 20510, + 20570 + ], + "loc": { + "start": { + "line": 613, + "column": 10 + }, + "end": { + "line": 613, + "column": 70 + } + } + } + ], + "range": [ + 20498, + 20580 + ], + "loc": { + "start": { + "line": 612, + "column": 30 + }, + "end": { + "line": 614, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20493, + 20580 + ], + "loc": { + "start": { + "line": 612, + "column": 25 + }, + "end": { + "line": 614, + "column": 9 + } + } + } + ], + "range": [ + 20476, + 20581 + ], + "loc": { + "start": { + "line": 612, + "column": 8 + }, + "end": { + "line": 614, + "column": 10 + } + } + }, + "range": [ + 20476, + 20582 + ], + "loc": { + "start": { + "line": 612, + "column": 8 + }, + "end": { + "line": 614, + "column": 11 + } + } + } + ], + "range": [ + 20268, + 20590 + ], + "loc": { + "start": { + "line": 606, + "column": 44 + }, + "end": { + "line": 615, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 20237, + 20590 + ], + "loc": { + "start": { + "line": 606, + "column": 13 + }, + "end": { + "line": 615, + "column": 7 + } + } + }, + "range": [ + 19943, + 20590 + ], + "loc": { + "start": { + "line": 599, + "column": 6 + }, + "end": { + "line": 615, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 20597, + 20605 + ], + "loc": { + "start": { + "line": 616, + "column": 6 + }, + "end": { + "line": 616, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 20606, + 20615 + ], + "loc": { + "start": { + "line": 616, + "column": 15 + }, + "end": { + "line": 616, + "column": 24 + } + } + }, + "range": [ + 20597, + 20616 + ], + "loc": { + "start": { + "line": 616, + "column": 6 + }, + "end": { + "line": 616, + "column": 25 + } + } + }, + "right": { + "type": "Identifier", + "name": "newValue", + "range": [ + 20619, + 20627 + ], + "loc": { + "start": { + "line": 616, + "column": 28 + }, + "end": { + "line": 616, + "column": 36 + } + } + }, + "range": [ + 20597, + 20627 + ], + "loc": { + "start": { + "line": 616, + "column": 6 + }, + "end": { + "line": 616, + "column": 36 + } + } + }, + "range": [ + 20597, + 20628 + ], + "loc": { + "start": { + "line": 616, + "column": 6 + }, + "end": { + "line": 616, + "column": 37 + } + } + } + ], + "range": [ + 19935, + 20634 + ], + "loc": { + "start": { + "line": 598, + "column": 41 + }, + "end": { + "line": 617, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 19898, + 20634 + ], + "loc": { + "start": { + "line": 598, + "column": 4 + }, + "end": { + "line": 617, + "column": 5 + } + } + } + ], + "range": [ + 19785, + 20638 + ], + "loc": { + "start": { + "line": 595, + "column": 53 + }, + "end": { + "line": 618, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 19743, + 20638 + ], + "loc": { + "start": { + "line": 595, + "column": 11 + }, + "end": { + "line": 618, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 19734, + 20638 + ], + "loc": { + "start": { + "line": 595, + "column": 2 + }, + "end": { + "line": 618, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_addInverseRelationship", + "range": [ + 20642, + 20665 + ], + "loc": { + "start": { + "line": 620, + "column": 2 + }, + "end": { + "line": 620, + "column": 25 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 20666, + 20680 + ], + "loc": { + "start": { + "line": 620, + "column": 26 + }, + "end": { + "line": 620, + "column": 40 + } + } + }, + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 20682, + 20697 + ], + "loc": { + "start": { + "line": 620, + "column": 42 + }, + "end": { + "line": 620, + "column": 57 + } + } + }, + { + "type": "Identifier", + "name": "targetResource", + "range": [ + 20699, + 20713 + ], + "loc": { + "start": { + "line": 620, + "column": 59 + }, + "end": { + "line": 620, + "column": 73 + } + } + }, + { + "type": "Identifier", + "name": "sourceField", + "range": [ + 20715, + 20726 + ], + "loc": { + "start": { + "line": 620, + "column": 75 + }, + "end": { + "line": 620, + "column": 86 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 20738, + 20754 + ], + "loc": { + "start": { + "line": 621, + "column": 8 + }, + "end": { + "line": 621, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20757, + 20761 + ], + "loc": { + "start": { + "line": 621, + "column": 27 + }, + "end": { + "line": 621, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 20762, + 20768 + ], + "loc": { + "start": { + "line": 621, + "column": 32 + }, + "end": { + "line": 621, + "column": 38 + } + } + }, + "range": [ + 20757, + 20768 + ], + "loc": { + "start": { + "line": 621, + "column": 27 + }, + "end": { + "line": 621, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 20769, + 20783 + ], + "loc": { + "start": { + "line": 621, + "column": 39 + }, + "end": { + "line": 621, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20784, + 20788 + ], + "loc": { + "start": { + "line": 621, + "column": 54 + }, + "end": { + "line": 621, + "column": 58 + } + } + }, + "range": [ + 20769, + 20788 + ], + "loc": { + "start": { + "line": 621, + "column": 39 + }, + "end": { + "line": 621, + "column": 58 + } + } + }, + "range": [ + 20757, + 20789 + ], + "loc": { + "start": { + "line": 621, + "column": 27 + }, + "end": { + "line": 621, + "column": 59 + } + } + }, + "range": [ + 20738, + 20789 + ], + "loc": { + "start": { + "line": 621, + "column": 8 + }, + "end": { + "line": 621, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 20734, + 20790 + ], + "loc": { + "start": { + "line": 621, + "column": 4 + }, + "end": { + "line": 621, + "column": 60 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "sourceDefinition", + "range": [ + 20799, + 20815 + ], + "loc": { + "start": { + "line": 622, + "column": 8 + }, + "end": { + "line": 622, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 20818, + 20822 + ], + "loc": { + "start": { + "line": 622, + "column": 27 + }, + "end": { + "line": 622, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 20823, + 20829 + ], + "loc": { + "start": { + "line": 622, + "column": 32 + }, + "end": { + "line": 622, + "column": 38 + } + } + }, + "range": [ + 20818, + 20829 + ], + "loc": { + "start": { + "line": 622, + "column": 27 + }, + "end": { + "line": 622, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 20830, + 20844 + ], + "loc": { + "start": { + "line": 622, + "column": 39 + }, + "end": { + "line": 622, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 20845, + 20849 + ], + "loc": { + "start": { + "line": 622, + "column": 54 + }, + "end": { + "line": 622, + "column": 58 + } + } + }, + "range": [ + 20830, + 20849 + ], + "loc": { + "start": { + "line": 622, + "column": 39 + }, + "end": { + "line": 622, + "column": 58 + } + } + }, + "range": [ + 20818, + 20850 + ], + "loc": { + "start": { + "line": 622, + "column": 27 + }, + "end": { + "line": 622, + "column": 59 + } + } + }, + "range": [ + 20799, + 20850 + ], + "loc": { + "start": { + "line": 622, + "column": 8 + }, + "end": { + "line": 622, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 20795, + 20851 + ], + "loc": { + "start": { + "line": 622, + "column": 4 + }, + "end": { + "line": 622, + "column": 60 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 20860, + 20876 + ], + "loc": { + "start": { + "line": 623, + "column": 8 + }, + "end": { + "line": 623, + "column": 24 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 20890, + 20905 + ], + "loc": { + "start": { + "line": 624, + "column": 10 + }, + "end": { + "line": 624, + "column": 25 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 20910, + 20921 + ], + "loc": { + "start": { + "line": 624, + "column": 30 + }, + "end": { + "line": 624, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 20922, + 20929 + ], + "loc": { + "start": { + "line": 624, + "column": 42 + }, + "end": { + "line": 624, + "column": 49 + } + } + }, + "range": [ + 20910, + 20929 + ], + "loc": { + "start": { + "line": 624, + "column": 30 + }, + "end": { + "line": 624, + "column": 49 + } + } + } + ], + "range": [ + 20908, + 20931 + ], + "loc": { + "start": { + "line": 624, + "column": 28 + }, + "end": { + "line": 624, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "concat", + "range": [ + 20932, + 20938 + ], + "loc": { + "start": { + "line": 624, + "column": 52 + }, + "end": { + "line": 624, + "column": 58 + } + } + }, + "range": [ + 20908, + 20938 + ], + "loc": { + "start": { + "line": 624, + "column": 28 + }, + "end": { + "line": 624, + "column": 58 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceDefinition", + "range": [ + 20939, + 20955 + ], + "loc": { + "start": { + "line": 624, + "column": 59 + }, + "end": { + "line": 624, + "column": 75 + } + } + }, + "property": { + "type": "Identifier", + "name": "_names", + "range": [ + 20956, + 20962 + ], + "loc": { + "start": { + "line": 624, + "column": 76 + }, + "end": { + "line": 624, + "column": 82 + } + } + }, + "range": [ + 20939, + 20962 + ], + "loc": { + "start": { + "line": 624, + "column": 59 + }, + "end": { + "line": 624, + "column": 82 + } + } + } + ], + "range": [ + 20908, + 20963 + ], + "loc": { + "start": { + "line": 624, + "column": 28 + }, + "end": { + "line": 624, + "column": 83 + } + } + }, + "property": { + "type": "Identifier", + "name": "find", + "range": [ + 20964, + 20968 + ], + "loc": { + "start": { + "line": 624, + "column": 84 + }, + "end": { + "line": 624, + "column": 88 + } + } + }, + "range": [ + 20908, + 20968 + ], + "loc": { + "start": { + "line": 624, + "column": 28 + }, + "end": { + "line": 624, + "column": 88 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "x", + "range": [ + 20969, + 20970 + ], + "loc": { + "start": { + "line": 624, + "column": 89 + }, + "end": { + "line": 624, + "column": 90 + } + } + } + ], + "body": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 20974, + 20990 + ], + "loc": { + "start": { + "line": 624, + "column": 94 + }, + "end": { + "line": 624, + "column": 110 + } + } + }, + "property": { + "type": "Identifier", + "name": "x", + "range": [ + 20991, + 20992 + ], + "loc": { + "start": { + "line": 624, + "column": 111 + }, + "end": { + "line": 624, + "column": 112 + } + } + }, + "range": [ + 20974, + 20993 + ], + "loc": { + "start": { + "line": 624, + "column": 94 + }, + "end": { + "line": 624, + "column": 113 + } + } + }, + "generator": false, + "expression": true, + "range": [ + 20969, + 20993 + ], + "loc": { + "start": { + "line": 624, + "column": 89 + }, + "end": { + "line": 624, + "column": 113 + } + } + } + ], + "range": [ + 20908, + 20994 + ], + "loc": { + "start": { + "line": 624, + "column": 28 + }, + "end": { + "line": 624, + "column": 114 + } + } + }, + "range": [ + 20890, + 20994 + ], + "loc": { + "start": { + "line": 624, + "column": 10 + }, + "end": { + "line": 624, + "column": 114 + } + } + } + ], + "kind": "let", + "range": [ + 20886, + 20995 + ], + "loc": { + "start": { + "line": 624, + "column": 6 + }, + "end": { + "line": 624, + "column": 115 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21006, + 21017 + ], + "loc": { + "start": { + "line": 625, + "column": 10 + }, + "end": { + "line": 625, + "column": 21 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 21020, + 21036 + ], + "loc": { + "start": { + "line": 625, + "column": 24 + }, + "end": { + "line": 625, + "column": 40 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 21040, + 21056 + ], + "loc": { + "start": { + "line": 625, + "column": 44 + }, + "end": { + "line": 625, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21057, + 21072 + ], + "loc": { + "start": { + "line": 625, + "column": 61 + }, + "end": { + "line": 625, + "column": 76 + } + } + }, + "range": [ + 21040, + 21073 + ], + "loc": { + "start": { + "line": 625, + "column": 44 + }, + "end": { + "line": 625, + "column": 77 + } + } + }, + "range": [ + 21020, + 21073 + ], + "loc": { + "start": { + "line": 625, + "column": 24 + }, + "end": { + "line": 625, + "column": 77 + } + } + }, + "range": [ + 21006, + 21073 + ], + "loc": { + "start": { + "line": 625, + "column": 10 + }, + "end": { + "line": 625, + "column": 77 + } + } + } + ], + "kind": "let", + "range": [ + 21002, + 21074 + ], + "loc": { + "start": { + "line": 625, + "column": 6 + }, + "end": { + "line": 625, + "column": 78 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21081, + 21095 + ], + "loc": { + "start": { + "line": 626, + "column": 6 + }, + "end": { + "line": 626, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21096, + 21107 + ], + "loc": { + "start": { + "line": 626, + "column": 21 + }, + "end": { + "line": 626, + "column": 32 + } + } + }, + "range": [ + 21081, + 21107 + ], + "loc": { + "start": { + "line": 626, + "column": 6 + }, + "end": { + "line": 626, + "column": 32 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 21108, + 21112 + ], + "loc": { + "start": { + "line": 626, + "column": 33 + }, + "end": { + "line": 626, + "column": 37 + } + } + }, + "range": [ + 21081, + 21112 + ], + "loc": { + "start": { + "line": 626, + "column": 6 + }, + "end": { + "line": 626, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 21115, + 21119 + ], + "loc": { + "start": { + "line": 626, + "column": 40 + }, + "end": { + "line": 626, + "column": 44 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21121, + 21135 + ], + "loc": { + "start": { + "line": 626, + "column": 46 + }, + "end": { + "line": 626, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21136, + 21140 + ], + "loc": { + "start": { + "line": 626, + "column": 61 + }, + "end": { + "line": 626, + "column": 65 + } + } + }, + "range": [ + 21121, + 21140 + ], + "loc": { + "start": { + "line": 626, + "column": 46 + }, + "end": { + "line": 626, + "column": 65 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21115, + 21140 + ], + "loc": { + "start": { + "line": 626, + "column": 40 + }, + "end": { + "line": 626, + "column": 65 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 21142, + 21144 + ], + "loc": { + "start": { + "line": 626, + "column": 67 + }, + "end": { + "line": 626, + "column": 69 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21146, + 21160 + ], + "loc": { + "start": { + "line": 626, + "column": 71 + }, + "end": { + "line": 626, + "column": 85 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21161, + 21163 + ], + "loc": { + "start": { + "line": 626, + "column": 86 + }, + "end": { + "line": 626, + "column": 88 + } + } + }, + "range": [ + 21146, + 21163 + ], + "loc": { + "start": { + "line": 626, + "column": 71 + }, + "end": { + "line": 626, + "column": 88 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21142, + 21163 + ], + "loc": { + "start": { + "line": 626, + "column": 67 + }, + "end": { + "line": 626, + "column": 88 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21165, + 21174 + ], + "loc": { + "start": { + "line": 626, + "column": 90 + }, + "end": { + "line": 626, + "column": 99 + } + } + }, + "value": { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 21176, + 21191 + ], + "loc": { + "start": { + "line": 626, + "column": 101 + }, + "end": { + "line": 626, + "column": 116 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21165, + 21191 + ], + "loc": { + "start": { + "line": 626, + "column": 90 + }, + "end": { + "line": 626, + "column": 116 + } + } + } + ], + "range": [ + 21113, + 21193 + ], + "loc": { + "start": { + "line": 626, + "column": 38 + }, + "end": { + "line": 626, + "column": 118 + } + } + } + ], + "range": [ + 21081, + 21194 + ], + "loc": { + "start": { + "line": 626, + "column": 6 + }, + "end": { + "line": 626, + "column": 119 + } + } + }, + "range": [ + 21081, + 21195 + ], + "loc": { + "start": { + "line": 626, + "column": 6 + }, + "end": { + "line": 626, + "column": 120 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21206, + 21217 + ], + "loc": { + "start": { + "line": 627, + "column": 10 + }, + "end": { + "line": 627, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21233, + 21244 + ], + "loc": { + "start": { + "line": 628, + "column": 12 + }, + "end": { + "line": 628, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21245, + 21249 + ], + "loc": { + "start": { + "line": 628, + "column": 24 + }, + "end": { + "line": 628, + "column": 28 + } + } + }, + "range": [ + 21233, + 21249 + ], + "loc": { + "start": { + "line": 628, + "column": 12 + }, + "end": { + "line": 628, + "column": 28 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 21254, + 21263 + ], + "loc": { + "start": { + "line": 628, + "column": 33 + }, + "end": { + "line": 628, + "column": 42 + } + } + }, + "range": [ + 21233, + 21263 + ], + "loc": { + "start": { + "line": 628, + "column": 12 + }, + "end": { + "line": 628, + "column": 42 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21277, + 21291 + ], + "loc": { + "start": { + "line": 629, + "column": 10 + }, + "end": { + "line": 629, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21292, + 21303 + ], + "loc": { + "start": { + "line": 629, + "column": 25 + }, + "end": { + "line": 629, + "column": 36 + } + } + }, + "range": [ + 21277, + 21303 + ], + "loc": { + "start": { + "line": 629, + "column": 10 + }, + "end": { + "line": 629, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 21304, + 21308 + ], + "loc": { + "start": { + "line": 629, + "column": 37 + }, + "end": { + "line": 629, + "column": 41 + } + } + }, + "range": [ + 21277, + 21308 + ], + "loc": { + "start": { + "line": 629, + "column": 10 + }, + "end": { + "line": 629, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 21311, + 21315 + ], + "loc": { + "start": { + "line": 629, + "column": 44 + }, + "end": { + "line": 629, + "column": 48 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21317, + 21331 + ], + "loc": { + "start": { + "line": 629, + "column": 50 + }, + "end": { + "line": 629, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21332, + 21336 + ], + "loc": { + "start": { + "line": 629, + "column": 65 + }, + "end": { + "line": 629, + "column": 69 + } + } + }, + "range": [ + 21317, + 21336 + ], + "loc": { + "start": { + "line": 629, + "column": 50 + }, + "end": { + "line": 629, + "column": 69 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21311, + 21336 + ], + "loc": { + "start": { + "line": 629, + "column": 44 + }, + "end": { + "line": 629, + "column": 69 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 21338, + 21340 + ], + "loc": { + "start": { + "line": 629, + "column": 71 + }, + "end": { + "line": 629, + "column": 73 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21342, + 21356 + ], + "loc": { + "start": { + "line": 629, + "column": 75 + }, + "end": { + "line": 629, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21357, + 21359 + ], + "loc": { + "start": { + "line": 629, + "column": 90 + }, + "end": { + "line": 629, + "column": 92 + } + } + }, + "range": [ + 21342, + 21359 + ], + "loc": { + "start": { + "line": 629, + "column": 75 + }, + "end": { + "line": 629, + "column": 92 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21338, + 21359 + ], + "loc": { + "start": { + "line": 629, + "column": 71 + }, + "end": { + "line": 629, + "column": 92 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21361, + 21370 + ], + "loc": { + "start": { + "line": 629, + "column": 94 + }, + "end": { + "line": 629, + "column": 103 + } + } + }, + "value": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21372, + 21387 + ], + "loc": { + "start": { + "line": 629, + "column": 105 + }, + "end": { + "line": 629, + "column": 120 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21361, + 21387 + ], + "loc": { + "start": { + "line": 629, + "column": 94 + }, + "end": { + "line": 629, + "column": 120 + } + } + } + ], + "range": [ + 21309, + 21389 + ], + "loc": { + "start": { + "line": 629, + "column": 42 + }, + "end": { + "line": 629, + "column": 122 + } + } + } + ], + "range": [ + 21277, + 21390 + ], + "loc": { + "start": { + "line": 629, + "column": 10 + }, + "end": { + "line": 629, + "column": 123 + } + } + }, + "range": [ + 21277, + 21391 + ], + "loc": { + "start": { + "line": 629, + "column": 10 + }, + "end": { + "line": 629, + "column": 124 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21402, + 21416 + ], + "loc": { + "start": { + "line": 630, + "column": 10 + }, + "end": { + "line": 630, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21417, + 21432 + ], + "loc": { + "start": { + "line": 630, + "column": 25 + }, + "end": { + "line": 630, + "column": 40 + } + } + }, + "range": [ + 21402, + 21433 + ], + "loc": { + "start": { + "line": 630, + "column": 10 + }, + "end": { + "line": 630, + "column": 41 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21436, + 21450 + ], + "loc": { + "start": { + "line": 630, + "column": 44 + }, + "end": { + "line": 630, + "column": 58 + } + } + }, + "range": [ + 21402, + 21450 + ], + "loc": { + "start": { + "line": 630, + "column": 10 + }, + "end": { + "line": 630, + "column": 58 + } + } + }, + "range": [ + 21402, + 21451 + ], + "loc": { + "start": { + "line": 630, + "column": 10 + }, + "end": { + "line": 630, + "column": 59 + } + } + } + ], + "range": [ + 21265, + 21461 + ], + "loc": { + "start": { + "line": 628, + "column": 44 + }, + "end": { + "line": 631, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21471, + 21482 + ], + "loc": { + "start": { + "line": 631, + "column": 19 + }, + "end": { + "line": 631, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21483, + 21487 + ], + "loc": { + "start": { + "line": 631, + "column": 31 + }, + "end": { + "line": 631, + "column": 35 + } + } + }, + "range": [ + 21471, + 21487 + ], + "loc": { + "start": { + "line": 631, + "column": 19 + }, + "end": { + "line": 631, + "column": 35 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 21492, + 21502 + ], + "loc": { + "start": { + "line": 631, + "column": 40 + }, + "end": { + "line": 631, + "column": 50 + } + } + }, + "range": [ + 21471, + 21502 + ], + "loc": { + "start": { + "line": 631, + "column": 19 + }, + "end": { + "line": 631, + "column": 50 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21516, + 21530 + ], + "loc": { + "start": { + "line": 632, + "column": 10 + }, + "end": { + "line": 632, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 21531, + 21542 + ], + "loc": { + "start": { + "line": 632, + "column": 25 + }, + "end": { + "line": 632, + "column": 36 + } + } + }, + "range": [ + 21516, + 21542 + ], + "loc": { + "start": { + "line": 632, + "column": 10 + }, + "end": { + "line": 632, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 21543, + 21547 + ], + "loc": { + "start": { + "line": 632, + "column": 37 + }, + "end": { + "line": 632, + "column": 41 + } + } + }, + "range": [ + 21516, + 21547 + ], + "loc": { + "start": { + "line": 632, + "column": 10 + }, + "end": { + "line": 632, + "column": 41 + } + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "type", + "range": [ + 21550, + 21554 + ], + "loc": { + "start": { + "line": 632, + "column": 44 + }, + "end": { + "line": 632, + "column": 48 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21556, + 21570 + ], + "loc": { + "start": { + "line": 632, + "column": 50 + }, + "end": { + "line": 632, + "column": 64 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21571, + 21575 + ], + "loc": { + "start": { + "line": 632, + "column": 65 + }, + "end": { + "line": 632, + "column": 69 + } + } + }, + "range": [ + 21556, + 21575 + ], + "loc": { + "start": { + "line": 632, + "column": 50 + }, + "end": { + "line": 632, + "column": 69 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21550, + 21575 + ], + "loc": { + "start": { + "line": 632, + "column": 44 + }, + "end": { + "line": 632, + "column": 69 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "id", + "range": [ + 21577, + 21579 + ], + "loc": { + "start": { + "line": 632, + "column": 71 + }, + "end": { + "line": 632, + "column": 73 + } + } + }, + "value": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21581, + 21595 + ], + "loc": { + "start": { + "line": 632, + "column": 75 + }, + "end": { + "line": 632, + "column": 89 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 21596, + 21598 + ], + "loc": { + "start": { + "line": 632, + "column": 90 + }, + "end": { + "line": 632, + "column": 92 + } + } + }, + "range": [ + 21581, + 21598 + ], + "loc": { + "start": { + "line": 632, + "column": 75 + }, + "end": { + "line": 632, + "column": 92 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21577, + 21598 + ], + "loc": { + "start": { + "line": 632, + "column": 71 + }, + "end": { + "line": 632, + "column": 92 + } + } + }, + { + "type": "Property", + "key": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 21600, + 21609 + ], + "loc": { + "start": { + "line": 632, + "column": 94 + }, + "end": { + "line": 632, + "column": 103 + } + } + }, + "value": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21611, + 21626 + ], + "loc": { + "start": { + "line": 632, + "column": 105 + }, + "end": { + "line": 632, + "column": 120 + } + } + }, + "kind": "init", + "method": false, + "shorthand": false, + "computed": false, + "range": [ + 21600, + 21626 + ], + "loc": { + "start": { + "line": 632, + "column": 94 + }, + "end": { + "line": 632, + "column": 120 + } + } + } + ], + "range": [ + 21548, + 21628 + ], + "loc": { + "start": { + "line": 632, + "column": 42 + }, + "end": { + "line": 632, + "column": 122 + } + } + } + ], + "range": [ + 21516, + 21629 + ], + "loc": { + "start": { + "line": 632, + "column": 10 + }, + "end": { + "line": 632, + "column": 123 + } + } + }, + "range": [ + 21516, + 21630 + ], + "loc": { + "start": { + "line": 632, + "column": 10 + }, + "end": { + "line": 632, + "column": 124 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21645, + 21659 + ], + "loc": { + "start": { + "line": 633, + "column": 14 + }, + "end": { + "line": 633, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21660, + 21675 + ], + "loc": { + "start": { + "line": 633, + "column": 29 + }, + "end": { + "line": 633, + "column": 44 + } + } + }, + "range": [ + 21645, + 21676 + ], + "loc": { + "start": { + "line": 633, + "column": 14 + }, + "end": { + "line": 633, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 21677, + 21684 + ], + "loc": { + "start": { + "line": 633, + "column": 46 + }, + "end": { + "line": 633, + "column": 53 + } + } + }, + "range": [ + 21645, + 21684 + ], + "loc": { + "start": { + "line": 633, + "column": 14 + }, + "end": { + "line": 633, + "column": 53 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21685, + 21699 + ], + "loc": { + "start": { + "line": 633, + "column": 54 + }, + "end": { + "line": 633, + "column": 68 + } + } + } + ], + "range": [ + 21645, + 21700 + ], + "loc": { + "start": { + "line": 633, + "column": 14 + }, + "end": { + "line": 633, + "column": 69 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 21706, + 21707 + ], + "loc": { + "start": { + "line": 633, + "column": 75 + }, + "end": { + "line": 633, + "column": 76 + } + } + }, + "prefix": true, + "range": [ + 21705, + 21707 + ], + "loc": { + "start": { + "line": 633, + "column": 74 + }, + "end": { + "line": 633, + "column": 76 + } + } + }, + "range": [ + 21645, + 21707 + ], + "loc": { + "start": { + "line": 633, + "column": 14 + }, + "end": { + "line": 633, + "column": 76 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 21723, + 21737 + ], + "loc": { + "start": { + "line": 634, + "column": 12 + }, + "end": { + "line": 634, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21738, + 21753 + ], + "loc": { + "start": { + "line": 634, + "column": 27 + }, + "end": { + "line": 634, + "column": 42 + } + } + }, + "range": [ + 21723, + 21754 + ], + "loc": { + "start": { + "line": 634, + "column": 12 + }, + "end": { + "line": 634, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "push", + "range": [ + 21755, + 21759 + ], + "loc": { + "start": { + "line": 634, + "column": 44 + }, + "end": { + "line": 634, + "column": 48 + } + } + }, + "range": [ + 21723, + 21759 + ], + "loc": { + "start": { + "line": 634, + "column": 12 + }, + "end": { + "line": 634, + "column": 48 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 21760, + 21774 + ], + "loc": { + "start": { + "line": 634, + "column": 49 + }, + "end": { + "line": 634, + "column": 63 + } + } + } + ], + "range": [ + 21723, + 21775 + ], + "loc": { + "start": { + "line": 634, + "column": 12 + }, + "end": { + "line": 634, + "column": 64 + } + } + }, + "range": [ + 21723, + 21776 + ], + "loc": { + "start": { + "line": 634, + "column": 12 + }, + "end": { + "line": 634, + "column": 65 + } + } + } + ], + "range": [ + 21709, + 21788 + ], + "loc": { + "start": { + "line": 633, + "column": 78 + }, + "end": { + "line": 635, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 21641, + 21788 + ], + "loc": { + "start": { + "line": 633, + "column": 10 + }, + "end": { + "line": 635, + "column": 11 + } + } + } + ], + "range": [ + 21504, + 21798 + ], + "loc": { + "start": { + "line": 631, + "column": 52 + }, + "end": { + "line": 636, + "column": 9 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 21808, + 21819 + ], + "loc": { + "start": { + "line": 636, + "column": 19 + }, + "end": { + "line": 636, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 21820, + 21824 + ], + "loc": { + "start": { + "line": 636, + "column": 31 + }, + "end": { + "line": 636, + "column": 35 + } + } + }, + "range": [ + 21808, + 21824 + ], + "loc": { + "start": { + "line": 636, + "column": 19 + }, + "end": { + "line": 636, + "column": 35 + } + } + }, + "right": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 21829, + 21835 + ], + "loc": { + "start": { + "line": 636, + "column": 40 + }, + "end": { + "line": 636, + "column": 46 + } + } + }, + "range": [ + 21808, + 21835 + ], + "loc": { + "start": { + "line": 636, + "column": 19 + }, + "end": { + "line": 636, + "column": 46 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 21859, + 21864 + ], + "loc": { + "start": { + "line": 637, + "column": 20 + }, + "end": { + "line": 637, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 21865, + 21902 + ], + "loc": { + "start": { + "line": 637, + "column": 26 + }, + "end": { + "line": 637, + "column": 63 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is an attribute ('", + "cooked": "' is an attribute ('" + }, + "tail": false, + "range": [ + 21917, + 21940 + ], + "loc": { + "start": { + "line": 637, + "column": 78 + }, + "end": { + "line": 637, + "column": 101 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 21955, + 21959 + ], + "loc": { + "start": { + "line": 637, + "column": 116 + }, + "end": { + "line": 637, + "column": 120 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 21902, + 21917 + ], + "loc": { + "start": { + "line": 637, + "column": 63 + }, + "end": { + "line": 637, + "column": 78 + } + } + }, + { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 21940, + 21955 + ], + "loc": { + "start": { + "line": 637, + "column": 101 + }, + "end": { + "line": 637, + "column": 116 + } + } + } + ], + "range": [ + 21865, + 21959 + ], + "loc": { + "start": { + "line": 637, + "column": 26 + }, + "end": { + "line": 637, + "column": 120 + } + } + } + ], + "range": [ + 21855, + 21960 + ], + "loc": { + "start": { + "line": 637, + "column": 16 + }, + "end": { + "line": 637, + "column": 121 + } + } + }, + "range": [ + 21849, + 21961 + ], + "loc": { + "start": { + "line": 637, + "column": 10 + }, + "end": { + "line": 637, + "column": 122 + } + } + } + ], + "range": [ + 21837, + 21971 + ], + "loc": { + "start": { + "line": 636, + "column": 48 + }, + "end": { + "line": 638, + "column": 9 + } + } + }, + "alternate": null, + "range": [ + 21804, + 21971 + ], + "loc": { + "start": { + "line": 636, + "column": 15 + }, + "end": { + "line": 638, + "column": 9 + } + } + }, + "range": [ + 21467, + 21971 + ], + "loc": { + "start": { + "line": 631, + "column": 15 + }, + "end": { + "line": 638, + "column": 9 + } + } + }, + "range": [ + 21229, + 21971 + ], + "loc": { + "start": { + "line": 628, + "column": 8 + }, + "end": { + "line": 638, + "column": 9 + } + } + } + ], + "range": [ + 21219, + 21979 + ], + "loc": { + "start": { + "line": 627, + "column": 23 + }, + "end": { + "line": 639, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 21989, + 22000 + ], + "loc": { + "start": { + "line": 639, + "column": 17 + }, + "end": { + "line": 639, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 22001, + 22008 + ], + "loc": { + "start": { + "line": 639, + "column": 29 + }, + "end": { + "line": 639, + "column": 36 + } + } + }, + "range": [ + 21989, + 22008 + ], + "loc": { + "start": { + "line": 639, + "column": 17 + }, + "end": { + "line": 639, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 22030, + 22035 + ], + "loc": { + "start": { + "line": 640, + "column": 18 + }, + "end": { + "line": 640, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 22036, + 22073 + ], + "loc": { + "start": { + "line": 640, + "column": 24 + }, + "end": { + "line": 640, + "column": 61 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is missing ('", + "cooked": "' is missing ('" + }, + "tail": false, + "range": [ + 22088, + 22106 + ], + "loc": { + "start": { + "line": 640, + "column": 76 + }, + "end": { + "line": 640, + "column": 94 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 22125, + 22129 + ], + "loc": { + "start": { + "line": 640, + "column": 113 + }, + "end": { + "line": 640, + "column": 117 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 22073, + 22088 + ], + "loc": { + "start": { + "line": 640, + "column": 61 + }, + "end": { + "line": 640, + "column": 76 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 22106, + 22117 + ], + "loc": { + "start": { + "line": 640, + "column": 94 + }, + "end": { + "line": 640, + "column": 105 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 22118, + 22125 + ], + "loc": { + "start": { + "line": 640, + "column": 106 + }, + "end": { + "line": 640, + "column": 113 + } + } + }, + "range": [ + 22106, + 22125 + ], + "loc": { + "start": { + "line": 640, + "column": 94 + }, + "end": { + "line": 640, + "column": 113 + } + } + } + ], + "range": [ + 22036, + 22129 + ], + "loc": { + "start": { + "line": 640, + "column": 24 + }, + "end": { + "line": 640, + "column": 117 + } + } + } + ], + "range": [ + 22026, + 22130 + ], + "loc": { + "start": { + "line": 640, + "column": 14 + }, + "end": { + "line": 640, + "column": 118 + } + } + }, + "range": [ + 22020, + 22131 + ], + "loc": { + "start": { + "line": 640, + "column": 8 + }, + "end": { + "line": 640, + "column": 119 + } + } + } + ], + "range": [ + 22010, + 22139 + ], + "loc": { + "start": { + "line": 639, + "column": 38 + }, + "end": { + "line": 641, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 21985, + 22139 + ], + "loc": { + "start": { + "line": 639, + "column": 13 + }, + "end": { + "line": 641, + "column": 7 + } + } + }, + "range": [ + 21202, + 22139 + ], + "loc": { + "start": { + "line": 627, + "column": 6 + }, + "end": { + "line": 641, + "column": 7 + } + } + } + ], + "range": [ + 20878, + 22145 + ], + "loc": { + "start": { + "line": 623, + "column": 26 + }, + "end": { + "line": 642, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 20856, + 22145 + ], + "loc": { + "start": { + "line": 623, + "column": 4 + }, + "end": { + "line": 642, + "column": 5 + } + } + } + ], + "range": [ + 20728, + 22149 + ], + "loc": { + "start": { + "line": 620, + "column": 88 + }, + "end": { + "line": 643, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 20665, + 22149 + ], + "loc": { + "start": { + "line": 620, + "column": 25 + }, + "end": { + "line": 643, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 20642, + 22149 + ], + "loc": { + "start": { + "line": 620, + "column": 2 + }, + "end": { + "line": 643, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_remove", + "range": [ + 22153, + 22160 + ], + "loc": { + "start": { + "line": 645, + "column": 2 + }, + "end": { + "line": 645, + "column": 9 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 22161, + 22169 + ], + "loc": { + "start": { + "line": 645, + "column": 10 + }, + "end": { + "line": 645, + "column": 18 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 22177, + 22185 + ], + "loc": { + "start": { + "line": 646, + "column": 4 + }, + "end": { + "line": 646, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 22186, + 22197 + ], + "loc": { + "start": { + "line": 646, + "column": 13 + }, + "end": { + "line": 646, + "column": 24 + } + } + }, + "range": [ + 22177, + 22197 + ], + "loc": { + "start": { + "line": 646, + "column": 4 + }, + "end": { + "line": 646, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "forEach", + "range": [ + 22198, + 22205 + ], + "loc": { + "start": { + "line": 646, + "column": 25 + }, + "end": { + "line": 646, + "column": 32 + } + } + }, + "range": [ + 22177, + 22205 + ], + "loc": { + "start": { + "line": 646, + "column": 4 + }, + "end": { + "line": 646, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "dependent", + "range": [ + 22206, + 22215 + ], + "loc": { + "start": { + "line": 646, + "column": 33 + }, + "end": { + "line": 646, + "column": 42 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22231, + 22248 + ], + "loc": { + "start": { + "line": 647, + "column": 10 + }, + "end": { + "line": 647, + "column": 27 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 22251, + 22255 + ], + "loc": { + "start": { + "line": 647, + "column": 30 + }, + "end": { + "line": 647, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 22256, + 22261 + ], + "loc": { + "start": { + "line": 647, + "column": 35 + }, + "end": { + "line": 647, + "column": 40 + } + } + }, + "range": [ + 22251, + 22261 + ], + "loc": { + "start": { + "line": 647, + "column": 30 + }, + "end": { + "line": 647, + "column": 40 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22262, + 22271 + ], + "loc": { + "start": { + "line": 647, + "column": 41 + }, + "end": { + "line": 647, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22272, + 22276 + ], + "loc": { + "start": { + "line": 647, + "column": 51 + }, + "end": { + "line": 647, + "column": 55 + } + } + }, + "range": [ + 22262, + 22276 + ], + "loc": { + "start": { + "line": 647, + "column": 41 + }, + "end": { + "line": 647, + "column": 55 + } + } + }, + "range": [ + 22251, + 22277 + ], + "loc": { + "start": { + "line": 647, + "column": 30 + }, + "end": { + "line": 647, + "column": 56 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22278, + 22287 + ], + "loc": { + "start": { + "line": 647, + "column": 57 + }, + "end": { + "line": 647, + "column": 66 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 22288, + 22290 + ], + "loc": { + "start": { + "line": 647, + "column": 67 + }, + "end": { + "line": 647, + "column": 69 + } + } + }, + "range": [ + 22278, + 22290 + ], + "loc": { + "start": { + "line": 647, + "column": 57 + }, + "end": { + "line": 647, + "column": 69 + } + } + }, + "range": [ + 22251, + 22291 + ], + "loc": { + "start": { + "line": 647, + "column": 30 + }, + "end": { + "line": 647, + "column": 70 + } + } + }, + "range": [ + 22231, + 22291 + ], + "loc": { + "start": { + "line": 647, + "column": 10 + }, + "end": { + "line": 647, + "column": 70 + } + } + } + ], + "kind": "let", + "range": [ + 22227, + 22292 + ], + "loc": { + "start": { + "line": 647, + "column": 6 + }, + "end": { + "line": 647, + "column": 71 + } + } + }, + { + "type": "SwitchStatement", + "discriminant": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 22307, + 22311 + ], + "loc": { + "start": { + "line": 648, + "column": 14 + }, + "end": { + "line": 648, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 22312, + 22318 + ], + "loc": { + "start": { + "line": 648, + "column": 19 + }, + "end": { + "line": 648, + "column": 25 + } + } + }, + "range": [ + 22307, + 22318 + ], + "loc": { + "start": { + "line": 648, + "column": 14 + }, + "end": { + "line": 648, + "column": 25 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22319, + 22328 + ], + "loc": { + "start": { + "line": 648, + "column": 26 + }, + "end": { + "line": 648, + "column": 35 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22329, + 22333 + ], + "loc": { + "start": { + "line": 648, + "column": 36 + }, + "end": { + "line": 648, + "column": 40 + } + } + }, + "range": [ + 22319, + 22333 + ], + "loc": { + "start": { + "line": 648, + "column": 26 + }, + "end": { + "line": 648, + "column": 40 + } + } + }, + "range": [ + 22307, + 22334 + ], + "loc": { + "start": { + "line": 648, + "column": 14 + }, + "end": { + "line": 648, + "column": 41 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22335, + 22344 + ], + "loc": { + "start": { + "line": 648, + "column": 42 + }, + "end": { + "line": 648, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 22345, + 22354 + ], + "loc": { + "start": { + "line": 648, + "column": 52 + }, + "end": { + "line": 648, + "column": 61 + } + } + }, + "range": [ + 22335, + 22354 + ], + "loc": { + "start": { + "line": 648, + "column": 42 + }, + "end": { + "line": 648, + "column": 61 + } + } + }, + "range": [ + 22307, + 22355 + ], + "loc": { + "start": { + "line": 648, + "column": 14 + }, + "end": { + "line": 648, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22356, + 22360 + ], + "loc": { + "start": { + "line": 648, + "column": 63 + }, + "end": { + "line": 648, + "column": 67 + } + } + }, + "range": [ + 22307, + 22360 + ], + "loc": { + "start": { + "line": 648, + "column": 14 + }, + "end": { + "line": 648, + "column": 67 + } + } + }, + "cases": [ + { + "type": "SwitchCase", + "test": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 22377, + 22386 + ], + "loc": { + "start": { + "line": 649, + "column": 13 + }, + "end": { + "line": 649, + "column": 22 + } + } + }, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22400, + 22417 + ], + "loc": { + "start": { + "line": 650, + "column": 10 + }, + "end": { + "line": 650, + "column": 27 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22418, + 22427 + ], + "loc": { + "start": { + "line": 650, + "column": 28 + }, + "end": { + "line": 650, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 22428, + 22437 + ], + "loc": { + "start": { + "line": 650, + "column": 38 + }, + "end": { + "line": 650, + "column": 47 + } + } + }, + "range": [ + 22418, + 22437 + ], + "loc": { + "start": { + "line": 650, + "column": 28 + }, + "end": { + "line": 650, + "column": 47 + } + } + }, + "range": [ + 22400, + 22438 + ], + "loc": { + "start": { + "line": 650, + "column": 10 + }, + "end": { + "line": 650, + "column": 48 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 22441, + 22445 + ], + "loc": { + "start": { + "line": 650, + "column": 51 + }, + "end": { + "line": 650, + "column": 55 + } + } + }, + "range": [ + 22400, + 22445 + ], + "loc": { + "start": { + "line": 650, + "column": 10 + }, + "end": { + "line": 650, + "column": 55 + } + } + }, + "range": [ + 22400, + 22446 + ], + "loc": { + "start": { + "line": 650, + "column": 10 + }, + "end": { + "line": 650, + "column": 56 + } + } + }, + { + "type": "BreakStatement", + "label": null, + "range": [ + 22457, + 22463 + ], + "loc": { + "start": { + "line": 651, + "column": 10 + }, + "end": { + "line": 651, + "column": 16 + } + } + } + ], + "range": [ + 22388, + 22473 + ], + "loc": { + "start": { + "line": 649, + "column": 24 + }, + "end": { + "line": 652, + "column": 9 + } + } + } + ], + "range": [ + 22372, + 22473 + ], + "loc": { + "start": { + "line": 649, + "column": 8 + }, + "end": { + "line": 652, + "column": 9 + } + } + }, + { + "type": "SwitchCase", + "test": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 22487, + 22497 + ], + "loc": { + "start": { + "line": 653, + "column": 13 + }, + "end": { + "line": 653, + "column": 23 + } + } + }, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "index", + "range": [ + 22515, + 22520 + ], + "loc": { + "start": { + "line": 654, + "column": 14 + }, + "end": { + "line": 654, + "column": 19 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22523, + 22540 + ], + "loc": { + "start": { + "line": 654, + "column": 22 + }, + "end": { + "line": 654, + "column": 39 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22541, + 22550 + ], + "loc": { + "start": { + "line": 654, + "column": 40 + }, + "end": { + "line": 654, + "column": 49 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 22551, + 22560 + ], + "loc": { + "start": { + "line": 654, + "column": 50 + }, + "end": { + "line": 654, + "column": 59 + } + } + }, + "range": [ + 22541, + 22560 + ], + "loc": { + "start": { + "line": 654, + "column": 40 + }, + "end": { + "line": 654, + "column": 59 + } + } + }, + "range": [ + 22523, + 22561 + ], + "loc": { + "start": { + "line": 654, + "column": 22 + }, + "end": { + "line": 654, + "column": 60 + } + } + }, + "property": { + "type": "Identifier", + "name": "indexOf", + "range": [ + 22562, + 22569 + ], + "loc": { + "start": { + "line": 654, + "column": 61 + }, + "end": { + "line": 654, + "column": 68 + } + } + }, + "range": [ + 22523, + 22569 + ], + "loc": { + "start": { + "line": 654, + "column": 22 + }, + "end": { + "line": 654, + "column": 68 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "resource", + "range": [ + 22570, + 22578 + ], + "loc": { + "start": { + "line": 654, + "column": 69 + }, + "end": { + "line": 654, + "column": 77 + } + } + } + ], + "range": [ + 22523, + 22579 + ], + "loc": { + "start": { + "line": 654, + "column": 22 + }, + "end": { + "line": 654, + "column": 78 + } + } + }, + "range": [ + 22515, + 22579 + ], + "loc": { + "start": { + "line": 654, + "column": 14 + }, + "end": { + "line": 654, + "column": 78 + } + } + } + ], + "kind": "let", + "range": [ + 22511, + 22580 + ], + "loc": { + "start": { + "line": 654, + "column": 10 + }, + "end": { + "line": 654, + "column": 79 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "Identifier", + "name": "index", + "range": [ + 22595, + 22600 + ], + "loc": { + "start": { + "line": 655, + "column": 14 + }, + "end": { + "line": 655, + "column": 19 + } + } + }, + "right": { + "type": "UnaryExpression", + "operator": "-", + "argument": { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 22606, + 22607 + ], + "loc": { + "start": { + "line": 655, + "column": 25 + }, + "end": { + "line": 655, + "column": 26 + } + } + }, + "prefix": true, + "range": [ + 22605, + 22607 + ], + "loc": { + "start": { + "line": 655, + "column": 24 + }, + "end": { + "line": 655, + "column": 26 + } + } + }, + "range": [ + 22595, + 22607 + ], + "loc": { + "start": { + "line": 655, + "column": 14 + }, + "end": { + "line": 655, + "column": 26 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22623, + 22640 + ], + "loc": { + "start": { + "line": 656, + "column": 12 + }, + "end": { + "line": 656, + "column": 29 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependent", + "range": [ + 22641, + 22650 + ], + "loc": { + "start": { + "line": 656, + "column": 30 + }, + "end": { + "line": 656, + "column": 39 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 22651, + 22660 + ], + "loc": { + "start": { + "line": 656, + "column": 40 + }, + "end": { + "line": 656, + "column": 49 + } + } + }, + "range": [ + 22641, + 22660 + ], + "loc": { + "start": { + "line": 656, + "column": 30 + }, + "end": { + "line": 656, + "column": 49 + } + } + }, + "range": [ + 22623, + 22661 + ], + "loc": { + "start": { + "line": 656, + "column": 12 + }, + "end": { + "line": 656, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "splice", + "range": [ + 22662, + 22668 + ], + "loc": { + "start": { + "line": 656, + "column": 51 + }, + "end": { + "line": 656, + "column": 57 + } + } + }, + "range": [ + 22623, + 22668 + ], + "loc": { + "start": { + "line": 656, + "column": 12 + }, + "end": { + "line": 656, + "column": 57 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "index", + "range": [ + 22669, + 22674 + ], + "loc": { + "start": { + "line": 656, + "column": 58 + }, + "end": { + "line": 656, + "column": 63 + } + } + }, + { + "type": "Literal", + "value": 1, + "raw": "1", + "range": [ + 22676, + 22677 + ], + "loc": { + "start": { + "line": 656, + "column": 65 + }, + "end": { + "line": 656, + "column": 66 + } + } + } + ], + "range": [ + 22623, + 22678 + ], + "loc": { + "start": { + "line": 656, + "column": 12 + }, + "end": { + "line": 656, + "column": 67 + } + } + }, + "range": [ + 22623, + 22679 + ], + "loc": { + "start": { + "line": 656, + "column": 12 + }, + "end": { + "line": 656, + "column": 68 + } + } + } + ], + "range": [ + 22609, + 22691 + ], + "loc": { + "start": { + "line": 655, + "column": 28 + }, + "end": { + "line": 657, + "column": 11 + } + } + }, + "alternate": null, + "range": [ + 22591, + 22691 + ], + "loc": { + "start": { + "line": 655, + "column": 10 + }, + "end": { + "line": 657, + "column": 11 + } + } + }, + { + "type": "BreakStatement", + "label": null, + "range": [ + 22702, + 22708 + ], + "loc": { + "start": { + "line": 658, + "column": 10 + }, + "end": { + "line": 658, + "column": 16 + } + } + } + ], + "range": [ + 22499, + 22718 + ], + "loc": { + "start": { + "line": 653, + "column": 25 + }, + "end": { + "line": 659, + "column": 9 + } + } + } + ], + "range": [ + 22482, + 22718 + ], + "loc": { + "start": { + "line": 653, + "column": 8 + }, + "end": { + "line": 659, + "column": 9 + } + } + }, + { + "type": "SwitchCase", + "test": null, + "consequent": [ + { + "type": "BlockStatement", + "body": [ + { + "type": "BreakStatement", + "label": null, + "range": [ + 22748, + 22754 + ], + "loc": { + "start": { + "line": 661, + "column": 10 + }, + "end": { + "line": 661, + "column": 16 + } + } + } + ], + "range": [ + 22736, + 22764 + ], + "loc": { + "start": { + "line": 660, + "column": 17 + }, + "end": { + "line": 662, + "column": 9 + } + } + } + ], + "range": [ + 22727, + 22764 + ], + "loc": { + "start": { + "line": 660, + "column": 8 + }, + "end": { + "line": 662, + "column": 9 + } + } + } + ], + "range": [ + 22299, + 22772 + ], + "loc": { + "start": { + "line": 648, + "column": 6 + }, + "end": { + "line": 663, + "column": 7 + } + }, + "trailingComments": [ + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 22779, + 22838 + ], + "loc": { + "start": { + "line": 664, + "column": 6 + }, + "end": { + "line": 664, + "column": 65 + } + } + } + ] + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22845, + 22862 + ], + "loc": { + "start": { + "line": 665, + "column": 6 + }, + "end": { + "line": 665, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 22863, + 22874 + ], + "loc": { + "start": { + "line": 665, + "column": 24 + }, + "end": { + "line": 665, + "column": 35 + } + } + }, + "range": [ + 22845, + 22874 + ], + "loc": { + "start": { + "line": 665, + "column": 6 + }, + "end": { + "line": 665, + "column": 35 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "dependentResource", + "range": [ + 22877, + 22894 + ], + "loc": { + "start": { + "line": 665, + "column": 38 + }, + "end": { + "line": 665, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 22895, + 22906 + ], + "loc": { + "start": { + "line": 665, + "column": 56 + }, + "end": { + "line": 665, + "column": 67 + } + } + }, + "range": [ + 22877, + 22906 + ], + "loc": { + "start": { + "line": 665, + "column": 38 + }, + "end": { + "line": 665, + "column": 67 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 22907, + 22913 + ], + "loc": { + "start": { + "line": 665, + "column": 68 + }, + "end": { + "line": 665, + "column": 74 + } + } + }, + "range": [ + 22877, + 22913 + ], + "loc": { + "start": { + "line": 665, + "column": 38 + }, + "end": { + "line": 665, + "column": 74 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 22914, + 22915 + ], + "loc": { + "start": { + "line": 665, + "column": 75 + }, + "end": { + "line": 665, + "column": 76 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 22938, + 22939 + ], + "loc": { + "start": { + "line": 666, + "column": 17 + }, + "end": { + "line": 666, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22940, + 22944 + ], + "loc": { + "start": { + "line": 666, + "column": 19 + }, + "end": { + "line": 666, + "column": 23 + } + } + }, + "range": [ + 22938, + 22944 + ], + "loc": { + "start": { + "line": 666, + "column": 17 + }, + "end": { + "line": 666, + "column": 23 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 22949, + 22957 + ], + "loc": { + "start": { + "line": 666, + "column": 28 + }, + "end": { + "line": 666, + "column": 36 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 22958, + 22962 + ], + "loc": { + "start": { + "line": 666, + "column": 37 + }, + "end": { + "line": 666, + "column": 41 + } + } + }, + "range": [ + 22949, + 22962 + ], + "loc": { + "start": { + "line": 666, + "column": 28 + }, + "end": { + "line": 666, + "column": 41 + } + } + }, + "range": [ + 22938, + 22962 + ], + "loc": { + "start": { + "line": 666, + "column": 17 + }, + "end": { + "line": 666, + "column": 41 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 22966, + 22967 + ], + "loc": { + "start": { + "line": 666, + "column": 45 + }, + "end": { + "line": 666, + "column": 46 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 22968, + 22970 + ], + "loc": { + "start": { + "line": 666, + "column": 47 + }, + "end": { + "line": 666, + "column": 49 + } + } + }, + "range": [ + 22966, + 22970 + ], + "loc": { + "start": { + "line": 666, + "column": 45 + }, + "end": { + "line": 666, + "column": 49 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 22975, + 22983 + ], + "loc": { + "start": { + "line": 666, + "column": 54 + }, + "end": { + "line": 666, + "column": 62 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 22984, + 22986 + ], + "loc": { + "start": { + "line": 666, + "column": 63 + }, + "end": { + "line": 666, + "column": 65 + } + } + }, + "range": [ + 22975, + 22986 + ], + "loc": { + "start": { + "line": 666, + "column": 54 + }, + "end": { + "line": 666, + "column": 65 + } + } + }, + "range": [ + 22966, + 22986 + ], + "loc": { + "start": { + "line": 666, + "column": 45 + }, + "end": { + "line": 666, + "column": 65 + } + } + }, + "range": [ + 22938, + 22986 + ], + "loc": { + "start": { + "line": 666, + "column": 17 + }, + "end": { + "line": 666, + "column": 65 + } + } + }, + "prefix": true, + "range": [ + 22936, + 22987 + ], + "loc": { + "start": { + "line": 666, + "column": 15 + }, + "end": { + "line": 666, + "column": 66 + } + } + }, + "range": [ + 22929, + 22988 + ], + "loc": { + "start": { + "line": 666, + "column": 8 + }, + "end": { + "line": 666, + "column": 67 + } + } + } + ], + "range": [ + 22919, + 22996 + ], + "loc": { + "start": { + "line": 665, + "column": 80 + }, + "end": { + "line": 667, + "column": 7 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 22914, + 22996 + ], + "loc": { + "start": { + "line": 665, + "column": 75 + }, + "end": { + "line": 667, + "column": 7 + } + } + } + ], + "range": [ + 22877, + 22997 + ], + "loc": { + "start": { + "line": 665, + "column": 38 + }, + "end": { + "line": 667, + "column": 8 + } + } + }, + "range": [ + 22845, + 22997 + ], + "loc": { + "start": { + "line": 665, + "column": 6 + }, + "end": { + "line": 667, + "column": 8 + } + } + }, + "range": [ + 22845, + 22998 + ], + "loc": { + "start": { + "line": 665, + "column": 6 + }, + "end": { + "line": 667, + "column": 9 + } + }, + "leadingComments": [ + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 22779, + 22838 + ], + "loc": { + "start": { + "line": 664, + "column": 6 + }, + "end": { + "line": 664, + "column": 65 + } + } + } + ] + } + ], + "range": [ + 22219, + 23004 + ], + "loc": { + "start": { + "line": 646, + "column": 46 + }, + "end": { + "line": 668, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 22206, + 23004 + ], + "loc": { + "start": { + "line": 646, + "column": 33 + }, + "end": { + "line": 668, + "column": 5 + } + } + } + ], + "range": [ + 22177, + 23005 + ], + "loc": { + "start": { + "line": 646, + "column": 4 + }, + "end": { + "line": 668, + "column": 6 + } + } + }, + "range": [ + 22177, + 23006 + ], + "loc": { + "start": { + "line": 646, + "column": 4 + }, + "end": { + "line": 668, + "column": 7 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UnaryExpression", + "operator": "delete", + "argument": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 23018, + 23022 + ], + "loc": { + "start": { + "line": 669, + "column": 11 + }, + "end": { + "line": 669, + "column": 15 + } + } + }, + "property": { + "type": "Identifier", + "name": "_data", + "range": [ + 23023, + 23028 + ], + "loc": { + "start": { + "line": 669, + "column": 16 + }, + "end": { + "line": 669, + "column": 21 + } + } + }, + "range": [ + 23018, + 23028 + ], + "loc": { + "start": { + "line": 669, + "column": 11 + }, + "end": { + "line": 669, + "column": 21 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 23029, + 23037 + ], + "loc": { + "start": { + "line": 669, + "column": 22 + }, + "end": { + "line": 669, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23038, + 23042 + ], + "loc": { + "start": { + "line": 669, + "column": 31 + }, + "end": { + "line": 669, + "column": 35 + } + } + }, + "range": [ + 23029, + 23042 + ], + "loc": { + "start": { + "line": 669, + "column": 22 + }, + "end": { + "line": 669, + "column": 35 + } + } + }, + "range": [ + 23018, + 23043 + ], + "loc": { + "start": { + "line": 669, + "column": 11 + }, + "end": { + "line": 669, + "column": 36 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "resource", + "range": [ + 23044, + 23052 + ], + "loc": { + "start": { + "line": 669, + "column": 37 + }, + "end": { + "line": 669, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 23053, + 23055 + ], + "loc": { + "start": { + "line": 669, + "column": 46 + }, + "end": { + "line": 669, + "column": 48 + } + } + }, + "range": [ + 23044, + 23055 + ], + "loc": { + "start": { + "line": 669, + "column": 37 + }, + "end": { + "line": 669, + "column": 48 + } + } + }, + "range": [ + 23018, + 23056 + ], + "loc": { + "start": { + "line": 669, + "column": 11 + }, + "end": { + "line": 669, + "column": 49 + } + } + }, + "prefix": true, + "range": [ + 23011, + 23056 + ], + "loc": { + "start": { + "line": 669, + "column": 4 + }, + "end": { + "line": 669, + "column": 49 + } + } + }, + "range": [ + 23011, + 23057 + ], + "loc": { + "start": { + "line": 669, + "column": 4 + }, + "end": { + "line": 669, + "column": 50 + } + } + } + ], + "range": [ + 22171, + 23061 + ], + "loc": { + "start": { + "line": 645, + "column": 20 + }, + "end": { + "line": 670, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 22160, + 23061 + ], + "loc": { + "start": { + "line": 645, + "column": 9 + }, + "end": { + "line": 670, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 22153, + 23061 + ], + "loc": { + "start": { + "line": 645, + "column": 2 + }, + "end": { + "line": 670, + "column": 3 + } + }, + "static": false + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_removeInverseRelationship", + "range": [ + 23065, + 23091 + ], + "loc": { + "start": { + "line": 672, + "column": 2 + }, + "end": { + "line": 672, + "column": 28 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23092, + 23106 + ], + "loc": { + "start": { + "line": 672, + "column": 29 + }, + "end": { + "line": 672, + "column": 43 + } + } + }, + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 23108, + 23123 + ], + "loc": { + "start": { + "line": 672, + "column": 45 + }, + "end": { + "line": 672, + "column": 60 + } + } + }, + { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23125, + 23139 + ], + "loc": { + "start": { + "line": 672, + "column": 62 + }, + "end": { + "line": 672, + "column": 76 + } + } + }, + { + "type": "Identifier", + "name": "sourceField", + "range": [ + 23141, + 23152 + ], + "loc": { + "start": { + "line": 672, + "column": 78 + }, + "end": { + "line": 672, + "column": 89 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 23164, + 23180 + ], + "loc": { + "start": { + "line": 673, + "column": 8 + }, + "end": { + "line": 673, + "column": 24 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "ThisExpression", + "range": [ + 23183, + 23187 + ], + "loc": { + "start": { + "line": 673, + "column": 27 + }, + "end": { + "line": 673, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "_types", + "range": [ + 23188, + 23194 + ], + "loc": { + "start": { + "line": 673, + "column": 32 + }, + "end": { + "line": 673, + "column": 38 + } + } + }, + "range": [ + 23183, + 23194 + ], + "loc": { + "start": { + "line": 673, + "column": 27 + }, + "end": { + "line": 673, + "column": 38 + } + } + }, + "property": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23195, + 23209 + ], + "loc": { + "start": { + "line": 673, + "column": 39 + }, + "end": { + "line": 673, + "column": 53 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23210, + 23214 + ], + "loc": { + "start": { + "line": 673, + "column": 54 + }, + "end": { + "line": 673, + "column": 58 + } + } + }, + "range": [ + 23195, + 23214 + ], + "loc": { + "start": { + "line": 673, + "column": 39 + }, + "end": { + "line": 673, + "column": 58 + } + } + }, + "range": [ + 23183, + 23215 + ], + "loc": { + "start": { + "line": 673, + "column": 27 + }, + "end": { + "line": 673, + "column": 59 + } + } + }, + "range": [ + 23164, + 23215 + ], + "loc": { + "start": { + "line": 673, + "column": 8 + }, + "end": { + "line": 673, + "column": 59 + } + } + } + ], + "kind": "var", + "range": [ + 23160, + 23216 + ], + "loc": { + "start": { + "line": 673, + "column": 4 + }, + "end": { + "line": 673, + "column": 60 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 23225, + 23240 + ], + "loc": { + "start": { + "line": 674, + "column": 8 + }, + "end": { + "line": 674, + "column": 23 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 23243, + 23254 + ], + "loc": { + "start": { + "line": 674, + "column": 26 + }, + "end": { + "line": 674, + "column": 37 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 23255, + 23262 + ], + "loc": { + "start": { + "line": 674, + "column": 38 + }, + "end": { + "line": 674, + "column": 45 + } + } + }, + "range": [ + 23243, + 23262 + ], + "loc": { + "start": { + "line": 674, + "column": 26 + }, + "end": { + "line": 674, + "column": 45 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23266, + 23280 + ], + "loc": { + "start": { + "line": 674, + "column": 49 + }, + "end": { + "line": 674, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23281, + 23285 + ], + "loc": { + "start": { + "line": 674, + "column": 64 + }, + "end": { + "line": 674, + "column": 68 + } + } + }, + "range": [ + 23266, + 23285 + ], + "loc": { + "start": { + "line": 674, + "column": 49 + }, + "end": { + "line": 674, + "column": 68 + } + } + }, + "range": [ + 23243, + 23285 + ], + "loc": { + "start": { + "line": 674, + "column": 26 + }, + "end": { + "line": 674, + "column": 68 + } + } + }, + "range": [ + 23225, + 23285 + ], + "loc": { + "start": { + "line": 674, + "column": 8 + }, + "end": { + "line": 674, + "column": 68 + } + } + } + ], + "kind": "var", + "range": [ + 23221, + 23286 + ], + "loc": { + "start": { + "line": 674, + "column": 4 + }, + "end": { + "line": 674, + "column": 69 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "targetField", + "range": [ + 23295, + 23306 + ], + "loc": { + "start": { + "line": 675, + "column": 8 + }, + "end": { + "line": 675, + "column": 19 + } + } + }, + "init": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 23309, + 23325 + ], + "loc": { + "start": { + "line": 675, + "column": 22 + }, + "end": { + "line": 675, + "column": 38 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetDefinition", + "range": [ + 23329, + 23345 + ], + "loc": { + "start": { + "line": 675, + "column": 42 + }, + "end": { + "line": 675, + "column": 58 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 23346, + 23361 + ], + "loc": { + "start": { + "line": 675, + "column": 59 + }, + "end": { + "line": 675, + "column": 74 + } + } + }, + "range": [ + 23329, + 23362 + ], + "loc": { + "start": { + "line": 675, + "column": 42 + }, + "end": { + "line": 675, + "column": 75 + } + } + }, + "range": [ + 23309, + 23362 + ], + "loc": { + "start": { + "line": 675, + "column": 22 + }, + "end": { + "line": 675, + "column": 75 + } + } + }, + "range": [ + 23295, + 23362 + ], + "loc": { + "start": { + "line": 675, + "column": 8 + }, + "end": { + "line": 675, + "column": 75 + } + } + } + ], + "kind": "var", + "range": [ + 23291, + 23363 + ], + "loc": { + "start": { + "line": 675, + "column": 4 + }, + "end": { + "line": 675, + "column": 76 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23368, + 23382 + ], + "loc": { + "start": { + "line": 676, + "column": 4 + }, + "end": { + "line": 676, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23383, + 23394 + ], + "loc": { + "start": { + "line": 676, + "column": 19 + }, + "end": { + "line": 676, + "column": 30 + } + } + }, + "range": [ + 23368, + 23394 + ], + "loc": { + "start": { + "line": 676, + "column": 4 + }, + "end": { + "line": 676, + "column": 30 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23397, + 23411 + ], + "loc": { + "start": { + "line": 676, + "column": 33 + }, + "end": { + "line": 676, + "column": 47 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23412, + 23423 + ], + "loc": { + "start": { + "line": 676, + "column": 48 + }, + "end": { + "line": 676, + "column": 59 + } + } + }, + "range": [ + 23397, + 23423 + ], + "loc": { + "start": { + "line": 676, + "column": 33 + }, + "end": { + "line": 676, + "column": 59 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 23424, + 23430 + ], + "loc": { + "start": { + "line": 676, + "column": 60 + }, + "end": { + "line": 676, + "column": 66 + } + } + }, + "range": [ + 23397, + 23430 + ], + "loc": { + "start": { + "line": 676, + "column": 33 + }, + "end": { + "line": 676, + "column": 66 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 23431, + 23432 + ], + "loc": { + "start": { + "line": 676, + "column": 67 + }, + "end": { + "line": 676, + "column": 68 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23453, + 23454 + ], + "loc": { + "start": { + "line": 677, + "column": 15 + }, + "end": { + "line": 677, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23455, + 23459 + ], + "loc": { + "start": { + "line": 677, + "column": 17 + }, + "end": { + "line": 677, + "column": 21 + } + } + }, + "range": [ + 23453, + 23459 + ], + "loc": { + "start": { + "line": 677, + "column": 15 + }, + "end": { + "line": 677, + "column": 21 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23464, + 23478 + ], + "loc": { + "start": { + "line": 677, + "column": 26 + }, + "end": { + "line": 677, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23479, + 23483 + ], + "loc": { + "start": { + "line": 677, + "column": 41 + }, + "end": { + "line": 677, + "column": 45 + } + } + }, + "range": [ + 23464, + 23483 + ], + "loc": { + "start": { + "line": 677, + "column": 26 + }, + "end": { + "line": 677, + "column": 45 + } + } + }, + "range": [ + 23453, + 23483 + ], + "loc": { + "start": { + "line": 677, + "column": 15 + }, + "end": { + "line": 677, + "column": 45 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23487, + 23488 + ], + "loc": { + "start": { + "line": 677, + "column": 49 + }, + "end": { + "line": 677, + "column": 50 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 23489, + 23491 + ], + "loc": { + "start": { + "line": 677, + "column": 51 + }, + "end": { + "line": 677, + "column": 53 + } + } + }, + "range": [ + 23487, + 23491 + ], + "loc": { + "start": { + "line": 677, + "column": 49 + }, + "end": { + "line": 677, + "column": 53 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23496, + 23510 + ], + "loc": { + "start": { + "line": 677, + "column": 58 + }, + "end": { + "line": 677, + "column": 72 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 23511, + 23513 + ], + "loc": { + "start": { + "line": 677, + "column": 73 + }, + "end": { + "line": 677, + "column": 75 + } + } + }, + "range": [ + 23496, + 23513 + ], + "loc": { + "start": { + "line": 677, + "column": 58 + }, + "end": { + "line": 677, + "column": 75 + } + } + }, + "range": [ + 23487, + 23513 + ], + "loc": { + "start": { + "line": 677, + "column": 49 + }, + "end": { + "line": 677, + "column": 75 + } + } + }, + "range": [ + 23453, + 23513 + ], + "loc": { + "start": { + "line": 677, + "column": 15 + }, + "end": { + "line": 677, + "column": 75 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23517, + 23518 + ], + "loc": { + "start": { + "line": 677, + "column": 79 + }, + "end": { + "line": 677, + "column": 80 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 23519, + 23528 + ], + "loc": { + "start": { + "line": 677, + "column": 81 + }, + "end": { + "line": 677, + "column": 90 + } + } + }, + "range": [ + 23517, + 23528 + ], + "loc": { + "start": { + "line": 677, + "column": 79 + }, + "end": { + "line": 677, + "column": 90 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 23533, + 23548 + ], + "loc": { + "start": { + "line": 677, + "column": 95 + }, + "end": { + "line": 677, + "column": 110 + } + } + }, + "range": [ + 23517, + 23548 + ], + "loc": { + "start": { + "line": 677, + "column": 79 + }, + "end": { + "line": 677, + "column": 110 + } + } + }, + "range": [ + 23453, + 23548 + ], + "loc": { + "start": { + "line": 677, + "column": 15 + }, + "end": { + "line": 677, + "column": 110 + } + } + }, + "prefix": true, + "range": [ + 23451, + 23549 + ], + "loc": { + "start": { + "line": 677, + "column": 13 + }, + "end": { + "line": 677, + "column": 111 + } + } + }, + "range": [ + 23444, + 23550 + ], + "loc": { + "start": { + "line": 677, + "column": 6 + }, + "end": { + "line": 677, + "column": 112 + } + } + } + ], + "range": [ + 23436, + 23556 + ], + "loc": { + "start": { + "line": 676, + "column": 72 + }, + "end": { + "line": 678, + "column": 5 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 23431, + 23556 + ], + "loc": { + "start": { + "line": 676, + "column": 67 + }, + "end": { + "line": 678, + "column": 5 + } + } + } + ], + "range": [ + 23397, + 23557 + ], + "loc": { + "start": { + "line": 676, + "column": 33 + }, + "end": { + "line": 678, + "column": 6 + } + } + }, + "range": [ + 23368, + 23557 + ], + "loc": { + "start": { + "line": 676, + "column": 4 + }, + "end": { + "line": 678, + "column": 6 + } + } + }, + "range": [ + 23368, + 23558 + ], + "loc": { + "start": { + "line": 676, + "column": 4 + }, + "end": { + "line": 678, + "column": 7 + } + } + }, + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "targetField", + "range": [ + 23567, + 23578 + ], + "loc": { + "start": { + "line": 679, + "column": 8 + }, + "end": { + "line": 679, + "column": 19 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 23592, + 23603 + ], + "loc": { + "start": { + "line": 680, + "column": 10 + }, + "end": { + "line": 680, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23604, + 23608 + ], + "loc": { + "start": { + "line": 680, + "column": 22 + }, + "end": { + "line": 680, + "column": 26 + } + } + }, + "range": [ + 23592, + 23608 + ], + "loc": { + "start": { + "line": 680, + "column": 10 + }, + "end": { + "line": 680, + "column": 26 + } + } + }, + "right": { + "type": "Literal", + "value": "has-one", + "raw": "\"has-one\"", + "range": [ + 23613, + 23622 + ], + "loc": { + "start": { + "line": 680, + "column": 31 + }, + "end": { + "line": 680, + "column": 40 + } + } + }, + "range": [ + 23592, + 23622 + ], + "loc": { + "start": { + "line": 680, + "column": 10 + }, + "end": { + "line": 680, + "column": 40 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23634, + 23648 + ], + "loc": { + "start": { + "line": 681, + "column": 8 + }, + "end": { + "line": 681, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23649, + 23660 + ], + "loc": { + "start": { + "line": 681, + "column": 23 + }, + "end": { + "line": 681, + "column": 34 + } + } + }, + "range": [ + 23634, + 23660 + ], + "loc": { + "start": { + "line": 681, + "column": 8 + }, + "end": { + "line": 681, + "column": 34 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23663, + 23677 + ], + "loc": { + "start": { + "line": 681, + "column": 37 + }, + "end": { + "line": 681, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23678, + 23689 + ], + "loc": { + "start": { + "line": 681, + "column": 52 + }, + "end": { + "line": 681, + "column": 63 + } + } + }, + "range": [ + 23663, + 23689 + ], + "loc": { + "start": { + "line": 681, + "column": 37 + }, + "end": { + "line": 681, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 23690, + 23696 + ], + "loc": { + "start": { + "line": 681, + "column": 64 + }, + "end": { + "line": 681, + "column": 70 + } + } + }, + "range": [ + 23663, + 23696 + ], + "loc": { + "start": { + "line": 681, + "column": 37 + }, + "end": { + "line": 681, + "column": 70 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 23697, + 23698 + ], + "loc": { + "start": { + "line": 681, + "column": 71 + }, + "end": { + "line": 681, + "column": 72 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23723, + 23724 + ], + "loc": { + "start": { + "line": 682, + "column": 19 + }, + "end": { + "line": 682, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23725, + 23729 + ], + "loc": { + "start": { + "line": 682, + "column": 21 + }, + "end": { + "line": 682, + "column": 25 + } + } + }, + "range": [ + 23723, + 23729 + ], + "loc": { + "start": { + "line": 682, + "column": 19 + }, + "end": { + "line": 682, + "column": 25 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23734, + 23748 + ], + "loc": { + "start": { + "line": 682, + "column": 30 + }, + "end": { + "line": 682, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23749, + 23753 + ], + "loc": { + "start": { + "line": 682, + "column": 45 + }, + "end": { + "line": 682, + "column": 49 + } + } + }, + "range": [ + 23734, + 23753 + ], + "loc": { + "start": { + "line": 682, + "column": 30 + }, + "end": { + "line": 682, + "column": 49 + } + } + }, + "range": [ + 23723, + 23753 + ], + "loc": { + "start": { + "line": 682, + "column": 19 + }, + "end": { + "line": 682, + "column": 49 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23757, + 23758 + ], + "loc": { + "start": { + "line": 682, + "column": 53 + }, + "end": { + "line": 682, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 23759, + 23761 + ], + "loc": { + "start": { + "line": 682, + "column": 55 + }, + "end": { + "line": 682, + "column": 57 + } + } + }, + "range": [ + 23757, + 23761 + ], + "loc": { + "start": { + "line": 682, + "column": 53 + }, + "end": { + "line": 682, + "column": 57 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23766, + 23780 + ], + "loc": { + "start": { + "line": 682, + "column": 62 + }, + "end": { + "line": 682, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 23781, + 23783 + ], + "loc": { + "start": { + "line": 682, + "column": 77 + }, + "end": { + "line": 682, + "column": 79 + } + } + }, + "range": [ + 23766, + 23783 + ], + "loc": { + "start": { + "line": 682, + "column": 62 + }, + "end": { + "line": 682, + "column": 79 + } + } + }, + "range": [ + 23757, + 23783 + ], + "loc": { + "start": { + "line": 682, + "column": 53 + }, + "end": { + "line": 682, + "column": 79 + } + } + }, + "range": [ + 23723, + 23783 + ], + "loc": { + "start": { + "line": 682, + "column": 19 + }, + "end": { + "line": 682, + "column": 79 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 23787, + 23788 + ], + "loc": { + "start": { + "line": 682, + "column": 83 + }, + "end": { + "line": 682, + "column": 84 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 23789, + 23798 + ], + "loc": { + "start": { + "line": 682, + "column": 85 + }, + "end": { + "line": 682, + "column": 94 + } + } + }, + "range": [ + 23787, + 23798 + ], + "loc": { + "start": { + "line": 682, + "column": 83 + }, + "end": { + "line": 682, + "column": 94 + } + } + }, + "right": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 23803, + 23818 + ], + "loc": { + "start": { + "line": 682, + "column": 99 + }, + "end": { + "line": 682, + "column": 114 + } + } + }, + "range": [ + 23787, + 23818 + ], + "loc": { + "start": { + "line": 682, + "column": 83 + }, + "end": { + "line": 682, + "column": 114 + } + } + }, + "range": [ + 23723, + 23818 + ], + "loc": { + "start": { + "line": 682, + "column": 19 + }, + "end": { + "line": 682, + "column": 114 + } + } + }, + "prefix": true, + "range": [ + 23721, + 23819 + ], + "loc": { + "start": { + "line": 682, + "column": 17 + }, + "end": { + "line": 682, + "column": 115 + } + } + }, + "range": [ + 23714, + 23820 + ], + "loc": { + "start": { + "line": 682, + "column": 10 + }, + "end": { + "line": 682, + "column": 116 + } + } + } + ], + "range": [ + 23702, + 23830 + ], + "loc": { + "start": { + "line": 681, + "column": 76 + }, + "end": { + "line": 683, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 23697, + 23830 + ], + "loc": { + "start": { + "line": 681, + "column": 71 + }, + "end": { + "line": 683, + "column": 9 + } + } + } + ], + "range": [ + 23663, + 23831 + ], + "loc": { + "start": { + "line": 681, + "column": 37 + }, + "end": { + "line": 683, + "column": 10 + } + } + }, + "range": [ + 23634, + 23831 + ], + "loc": { + "start": { + "line": 681, + "column": 8 + }, + "end": { + "line": 683, + "column": 10 + } + } + }, + "range": [ + 23634, + 23832 + ], + "loc": { + "start": { + "line": 681, + "column": 8 + }, + "end": { + "line": 683, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 23841, + 23855 + ], + "loc": { + "start": { + "line": 684, + "column": 8 + }, + "end": { + "line": 684, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 23856, + 23871 + ], + "loc": { + "start": { + "line": 684, + "column": 23 + }, + "end": { + "line": 684, + "column": 38 + } + } + }, + "range": [ + 23841, + 23872 + ], + "loc": { + "start": { + "line": 684, + "column": 8 + }, + "end": { + "line": 684, + "column": 39 + } + } + }, + "right": { + "type": "Literal", + "value": null, + "raw": "null", + "range": [ + 23875, + 23879 + ], + "loc": { + "start": { + "line": 684, + "column": 42 + }, + "end": { + "line": 684, + "column": 46 + } + } + }, + "range": [ + 23841, + 23879 + ], + "loc": { + "start": { + "line": 684, + "column": 8 + }, + "end": { + "line": 684, + "column": 46 + } + } + }, + "range": [ + 23841, + 23880 + ], + "loc": { + "start": { + "line": 684, + "column": 8 + }, + "end": { + "line": 684, + "column": 47 + } + } + } + ], + "range": [ + 23624, + 23888 + ], + "loc": { + "start": { + "line": 680, + "column": 42 + }, + "end": { + "line": 685, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 23898, + 23909 + ], + "loc": { + "start": { + "line": 685, + "column": 17 + }, + "end": { + "line": 685, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 23910, + 23914 + ], + "loc": { + "start": { + "line": 685, + "column": 29 + }, + "end": { + "line": 685, + "column": 33 + } + } + }, + "range": [ + 23898, + 23914 + ], + "loc": { + "start": { + "line": 685, + "column": 17 + }, + "end": { + "line": 685, + "column": 33 + } + } + }, + "right": { + "type": "Literal", + "value": "has-many", + "raw": "\"has-many\"", + "range": [ + 23919, + 23929 + ], + "loc": { + "start": { + "line": 685, + "column": 38 + }, + "end": { + "line": 685, + "column": 48 + } + } + }, + "range": [ + 23898, + 23929 + ], + "loc": { + "start": { + "line": 685, + "column": 17 + }, + "end": { + "line": 685, + "column": 48 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23941, + 23955 + ], + "loc": { + "start": { + "line": 686, + "column": 8 + }, + "end": { + "line": 686, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23956, + 23967 + ], + "loc": { + "start": { + "line": 686, + "column": 23 + }, + "end": { + "line": 686, + "column": 34 + } + } + }, + "range": [ + 23941, + 23967 + ], + "loc": { + "start": { + "line": 686, + "column": 8 + }, + "end": { + "line": 686, + "column": 34 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 23970, + 23984 + ], + "loc": { + "start": { + "line": 686, + "column": 37 + }, + "end": { + "line": 686, + "column": 51 + } + } + }, + "property": { + "type": "Identifier", + "name": "_dependents", + "range": [ + 23985, + 23996 + ], + "loc": { + "start": { + "line": 686, + "column": 52 + }, + "end": { + "line": 686, + "column": 63 + } + } + }, + "range": [ + 23970, + 23996 + ], + "loc": { + "start": { + "line": 686, + "column": 37 + }, + "end": { + "line": 686, + "column": 63 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 23997, + 24003 + ], + "loc": { + "start": { + "line": 686, + "column": 64 + }, + "end": { + "line": 686, + "column": 70 + } + } + }, + "range": [ + 23970, + 24003 + ], + "loc": { + "start": { + "line": 686, + "column": 37 + }, + "end": { + "line": 686, + "column": 70 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 24004, + 24005 + ], + "loc": { + "start": { + "line": 686, + "column": 71 + }, + "end": { + "line": 686, + "column": 72 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "UnaryExpression", + "operator": "!", + "argument": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "LogicalExpression", + "operator": "&&", + "left": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 24030, + 24031 + ], + "loc": { + "start": { + "line": 687, + "column": 19 + }, + "end": { + "line": 687, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 24032, + 24036 + ], + "loc": { + "start": { + "line": 687, + "column": 21 + }, + "end": { + "line": 687, + "column": 25 + } + } + }, + "range": [ + 24030, + 24036 + ], + "loc": { + "start": { + "line": 687, + "column": 19 + }, + "end": { + "line": 687, + "column": 25 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 24041, + 24055 + ], + "loc": { + "start": { + "line": 687, + "column": 30 + }, + "end": { + "line": 687, + "column": 44 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 24056, + 24060 + ], + "loc": { + "start": { + "line": 687, + "column": 45 + }, + "end": { + "line": 687, + "column": 49 + } + } + }, + "range": [ + 24041, + 24060 + ], + "loc": { + "start": { + "line": 687, + "column": 30 + }, + "end": { + "line": 687, + "column": 49 + } + } + }, + "range": [ + 24030, + 24060 + ], + "loc": { + "start": { + "line": 687, + "column": 19 + }, + "end": { + "line": 687, + "column": 49 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 24064, + 24065 + ], + "loc": { + "start": { + "line": 687, + "column": 53 + }, + "end": { + "line": 687, + "column": 54 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 24066, + 24068 + ], + "loc": { + "start": { + "line": 687, + "column": 55 + }, + "end": { + "line": 687, + "column": 57 + } + } + }, + "range": [ + 24064, + 24068 + ], + "loc": { + "start": { + "line": 687, + "column": 53 + }, + "end": { + "line": 687, + "column": 57 + } + } + }, + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 24073, + 24087 + ], + "loc": { + "start": { + "line": 687, + "column": 62 + }, + "end": { + "line": 687, + "column": 76 + } + } + }, + "property": { + "type": "Identifier", + "name": "id", + "range": [ + 24088, + 24090 + ], + "loc": { + "start": { + "line": 687, + "column": 77 + }, + "end": { + "line": 687, + "column": 79 + } + } + }, + "range": [ + 24073, + 24090 + ], + "loc": { + "start": { + "line": 687, + "column": 62 + }, + "end": { + "line": 687, + "column": 79 + } + } + }, + "range": [ + 24064, + 24090 + ], + "loc": { + "start": { + "line": 687, + "column": 53 + }, + "end": { + "line": 687, + "column": 79 + } + } + }, + "range": [ + 24030, + 24090 + ], + "loc": { + "start": { + "line": 687, + "column": 19 + }, + "end": { + "line": 687, + "column": 79 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "r", + "range": [ + 24094, + 24095 + ], + "loc": { + "start": { + "line": 687, + "column": 83 + }, + "end": { + "line": 687, + "column": 84 + } + } + }, + "property": { + "type": "Identifier", + "name": "fieldName", + "range": [ + 24096, + 24105 + ], + "loc": { + "start": { + "line": 687, + "column": 85 + }, + "end": { + "line": 687, + "column": 94 + } + } + }, + "range": [ + 24094, + 24105 + ], + "loc": { + "start": { + "line": 687, + "column": 83 + }, + "end": { + "line": 687, + "column": 94 + } + } + }, + "right": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 24110, + 24125 + ], + "loc": { + "start": { + "line": 687, + "column": 99 + }, + "end": { + "line": 687, + "column": 114 + } + } + }, + "range": [ + 24094, + 24125 + ], + "loc": { + "start": { + "line": 687, + "column": 83 + }, + "end": { + "line": 687, + "column": 114 + } + } + }, + "range": [ + 24030, + 24125 + ], + "loc": { + "start": { + "line": 687, + "column": 19 + }, + "end": { + "line": 687, + "column": 114 + } + } + }, + "prefix": true, + "range": [ + 24028, + 24126 + ], + "loc": { + "start": { + "line": 687, + "column": 17 + }, + "end": { + "line": 687, + "column": 115 + } + } + }, + "range": [ + 24021, + 24127 + ], + "loc": { + "start": { + "line": 687, + "column": 10 + }, + "end": { + "line": 687, + "column": 116 + } + } + } + ], + "range": [ + 24009, + 24137 + ], + "loc": { + "start": { + "line": 686, + "column": 76 + }, + "end": { + "line": 688, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 24004, + 24137 + ], + "loc": { + "start": { + "line": 686, + "column": 71 + }, + "end": { + "line": 688, + "column": 9 + } + } + } + ], + "range": [ + 23970, + 24138 + ], + "loc": { + "start": { + "line": 686, + "column": 37 + }, + "end": { + "line": 688, + "column": 10 + } + } + }, + "range": [ + 23941, + 24138 + ], + "loc": { + "start": { + "line": 686, + "column": 8 + }, + "end": { + "line": 688, + "column": 10 + } + } + }, + "range": [ + 23941, + 24139 + ], + "loc": { + "start": { + "line": 686, + "column": 8 + }, + "end": { + "line": 688, + "column": 11 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 24148, + 24162 + ], + "loc": { + "start": { + "line": 689, + "column": 8 + }, + "end": { + "line": 689, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 24163, + 24178 + ], + "loc": { + "start": { + "line": 689, + "column": 23 + }, + "end": { + "line": 689, + "column": 38 + } + } + }, + "range": [ + 24148, + 24179 + ], + "loc": { + "start": { + "line": 689, + "column": 8 + }, + "end": { + "line": 689, + "column": 39 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "MemberExpression", + "computed": true, + "object": { + "type": "Identifier", + "name": "targetResource", + "range": [ + 24182, + 24196 + ], + "loc": { + "start": { + "line": 689, + "column": 42 + }, + "end": { + "line": 689, + "column": 56 + } + } + }, + "property": { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 24197, + 24212 + ], + "loc": { + "start": { + "line": 689, + "column": 57 + }, + "end": { + "line": 689, + "column": 72 + } + } + }, + "range": [ + 24182, + 24213 + ], + "loc": { + "start": { + "line": 689, + "column": 42 + }, + "end": { + "line": 689, + "column": 73 + } + } + }, + "property": { + "type": "Identifier", + "name": "filter", + "range": [ + 24214, + 24220 + ], + "loc": { + "start": { + "line": 689, + "column": 74 + }, + "end": { + "line": 689, + "column": 80 + } + } + }, + "range": [ + 24182, + 24220 + ], + "loc": { + "start": { + "line": 689, + "column": 42 + }, + "end": { + "line": 689, + "column": 80 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "name": "r", + "range": [ + 24221, + 24222 + ], + "loc": { + "start": { + "line": 689, + "column": 81 + }, + "end": { + "line": 689, + "column": 82 + } + } + } + ], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "!==", + "left": { + "type": "Identifier", + "name": "r", + "range": [ + 24245, + 24246 + ], + "loc": { + "start": { + "line": 690, + "column": 17 + }, + "end": { + "line": 690, + "column": 18 + } + } + }, + "right": { + "type": "Identifier", + "name": "sourceResource", + "range": [ + 24251, + 24265 + ], + "loc": { + "start": { + "line": 690, + "column": 23 + }, + "end": { + "line": 690, + "column": 37 + } + } + }, + "range": [ + 24245, + 24265 + ], + "loc": { + "start": { + "line": 690, + "column": 17 + }, + "end": { + "line": 690, + "column": 37 + } + } + }, + "range": [ + 24238, + 24266 + ], + "loc": { + "start": { + "line": 690, + "column": 10 + }, + "end": { + "line": 690, + "column": 38 + } + } + } + ], + "range": [ + 24226, + 24276 + ], + "loc": { + "start": { + "line": 689, + "column": 86 + }, + "end": { + "line": 691, + "column": 9 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 24221, + 24276 + ], + "loc": { + "start": { + "line": 689, + "column": 81 + }, + "end": { + "line": 691, + "column": 9 + } + } + } + ], + "range": [ + 24182, + 24277 + ], + "loc": { + "start": { + "line": 689, + "column": 42 + }, + "end": { + "line": 691, + "column": 10 + } + } + }, + "range": [ + 24148, + 24277 + ], + "loc": { + "start": { + "line": 689, + "column": 8 + }, + "end": { + "line": 691, + "column": 10 + } + } + }, + "range": [ + 24148, + 24278 + ], + "loc": { + "start": { + "line": 689, + "column": 8 + }, + "end": { + "line": 691, + "column": 11 + } + } + } + ], + "range": [ + 23931, + 24286 + ], + "loc": { + "start": { + "line": 685, + "column": 50 + }, + "end": { + "line": 692, + "column": 7 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "===", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "targetField", + "range": [ + 24296, + 24307 + ], + "loc": { + "start": { + "line": 692, + "column": 17 + }, + "end": { + "line": 692, + "column": 28 + } + } + }, + "property": { + "type": "Identifier", + "name": "type", + "range": [ + 24308, + 24312 + ], + "loc": { + "start": { + "line": 692, + "column": 29 + }, + "end": { + "line": 692, + "column": 33 + } + } + }, + "range": [ + 24296, + 24312 + ], + "loc": { + "start": { + "line": 692, + "column": 17 + }, + "end": { + "line": 692, + "column": 33 + } + } + }, + "right": { + "type": "Literal", + "value": "attr", + "raw": "\"attr\"", + "range": [ + 24317, + 24323 + ], + "loc": { + "start": { + "line": 692, + "column": 38 + }, + "end": { + "line": 692, + "column": 44 + } + } + }, + "range": [ + 24296, + 24323 + ], + "loc": { + "start": { + "line": 692, + "column": 17 + }, + "end": { + "line": 692, + "column": 44 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 24345, + 24350 + ], + "loc": { + "start": { + "line": 693, + "column": 18 + }, + "end": { + "line": 693, + "column": 23 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 24351, + 24388 + ], + "loc": { + "start": { + "line": 693, + "column": 24 + }, + "end": { + "line": 693, + "column": 61 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is an attribute ('", + "cooked": "' is an attribute ('" + }, + "tail": false, + "range": [ + 24403, + 24426 + ], + "loc": { + "start": { + "line": 693, + "column": 76 + }, + "end": { + "line": 693, + "column": 99 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 24441, + 24445 + ], + "loc": { + "start": { + "line": 693, + "column": 114 + }, + "end": { + "line": 693, + "column": 118 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 24388, + 24403 + ], + "loc": { + "start": { + "line": 693, + "column": 61 + }, + "end": { + "line": 693, + "column": 76 + } + } + }, + { + "type": "Identifier", + "name": "targetFieldName", + "range": [ + 24426, + 24441 + ], + "loc": { + "start": { + "line": 693, + "column": 99 + }, + "end": { + "line": 693, + "column": 114 + } + } + } + ], + "range": [ + 24351, + 24445 + ], + "loc": { + "start": { + "line": 693, + "column": 24 + }, + "end": { + "line": 693, + "column": 118 + } + } + } + ], + "range": [ + 24341, + 24446 + ], + "loc": { + "start": { + "line": 693, + "column": 14 + }, + "end": { + "line": 693, + "column": 119 + } + } + }, + "range": [ + 24335, + 24447 + ], + "loc": { + "start": { + "line": 693, + "column": 8 + }, + "end": { + "line": 693, + "column": 120 + } + } + } + ], + "range": [ + 24325, + 24455 + ], + "loc": { + "start": { + "line": 692, + "column": 46 + }, + "end": { + "line": 694, + "column": 7 + } + } + }, + "alternate": null, + "range": [ + 24292, + 24455 + ], + "loc": { + "start": { + "line": 692, + "column": 13 + }, + "end": { + "line": 694, + "column": 7 + } + } + }, + "range": [ + 23894, + 24455 + ], + "loc": { + "start": { + "line": 685, + "column": 13 + }, + "end": { + "line": 694, + "column": 7 + } + } + }, + "range": [ + 23588, + 24455 + ], + "loc": { + "start": { + "line": 680, + "column": 6 + }, + "end": { + "line": 694, + "column": 7 + } + } + } + ], + "range": [ + 23580, + 24461 + ], + "loc": { + "start": { + "line": 679, + "column": 21 + }, + "end": { + "line": 695, + "column": 5 + } + } + }, + "alternate": { + "type": "IfStatement", + "test": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 24471, + 24482 + ], + "loc": { + "start": { + "line": 695, + "column": 15 + }, + "end": { + "line": 695, + "column": 26 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 24483, + 24490 + ], + "loc": { + "start": { + "line": 695, + "column": 27 + }, + "end": { + "line": 695, + "column": 34 + } + } + }, + "range": [ + 24471, + 24490 + ], + "loc": { + "start": { + "line": 695, + "column": 15 + }, + "end": { + "line": 695, + "column": 34 + } + } + }, + "consequent": { + "type": "BlockStatement", + "body": [ + { + "type": "ThrowStatement", + "argument": { + "type": "NewExpression", + "callee": { + "type": "Identifier", + "name": "Error", + "range": [ + 24510, + 24515 + ], + "loc": { + "start": { + "line": 696, + "column": 16 + }, + "end": { + "line": 696, + "column": 21 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "The the inverse relationship for '", + "cooked": "The the inverse relationship for '" + }, + "tail": false, + "range": [ + 24516, + 24553 + ], + "loc": { + "start": { + "line": 696, + "column": 22 + }, + "end": { + "line": 696, + "column": 59 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "' is missing ('", + "cooked": "' is missing ('" + }, + "tail": false, + "range": [ + 24568, + 24586 + ], + "loc": { + "start": { + "line": 696, + "column": 74 + }, + "end": { + "line": 696, + "column": 92 + } + } + }, + { + "type": "TemplateElement", + "value": { + "raw": "')", + "cooked": "')" + }, + "tail": true, + "range": [ + 24605, + 24609 + ], + "loc": { + "start": { + "line": 696, + "column": 111 + }, + "end": { + "line": 696, + "column": 115 + } + } + } + ], + "expressions": [ + { + "type": "Identifier", + "name": "sourceFieldName", + "range": [ + 24553, + 24568 + ], + "loc": { + "start": { + "line": 696, + "column": 59 + }, + "end": { + "line": 696, + "column": 74 + } + } + }, + { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "sourceField", + "range": [ + 24586, + 24597 + ], + "loc": { + "start": { + "line": 696, + "column": 92 + }, + "end": { + "line": 696, + "column": 103 + } + } + }, + "property": { + "type": "Identifier", + "name": "inverse", + "range": [ + 24598, + 24605 + ], + "loc": { + "start": { + "line": 696, + "column": 104 + }, + "end": { + "line": 696, + "column": 111 + } + } + }, + "range": [ + 24586, + 24605 + ], + "loc": { + "start": { + "line": 696, + "column": 92 + }, + "end": { + "line": 696, + "column": 111 + } + } + } + ], + "range": [ + 24516, + 24609 + ], + "loc": { + "start": { + "line": 696, + "column": 22 + }, + "end": { + "line": 696, + "column": 115 + } + } + } + ], + "range": [ + 24506, + 24610 + ], + "loc": { + "start": { + "line": 696, + "column": 12 + }, + "end": { + "line": 696, + "column": 116 + } + } + }, + "range": [ + 24500, + 24611 + ], + "loc": { + "start": { + "line": 696, + "column": 6 + }, + "end": { + "line": 696, + "column": 117 + } + } + } + ], + "range": [ + 24492, + 24617 + ], + "loc": { + "start": { + "line": 695, + "column": 36 + }, + "end": { + "line": 697, + "column": 5 + } + } + }, + "alternate": null, + "range": [ + 24467, + 24617 + ], + "loc": { + "start": { + "line": 695, + "column": 11 + }, + "end": { + "line": 697, + "column": 5 + } + } + }, + "range": [ + 23563, + 24617 + ], + "loc": { + "start": { + "line": 679, + "column": 4 + }, + "end": { + "line": 697, + "column": 5 + } + } + } + ], + "range": [ + 23154, + 24621 + ], + "loc": { + "start": { + "line": 672, + "column": 91 + }, + "end": { + "line": 698, + "column": 3 + } + } + }, + "generator": false, + "expression": false, + "range": [ + 23091, + 24621 + ], + "loc": { + "start": { + "line": 672, + "column": 28 + }, + "end": { + "line": 698, + "column": 3 + } + } + }, + "kind": "method", + "computed": false, + "range": [ + 23065, + 24621 + ], + "loc": { + "start": { + "line": 672, + "column": 2 + }, + "end": { + "line": 698, + "column": 3 + } + }, + "static": false + } + ], + "range": [ + 122, + 24624 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 700, + "column": 1 + } + } + }, + "range": [ + 110, + 24624 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 700, + "column": 1 + } + }, + "leadingComments": [], + "trailingComments": [] + }, + "range": [ + 95, + 24624 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 700, + "column": 1 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 24626, + 24631 + ], + "loc": { + "start": { + "line": 702, + "column": 0 + }, + "end": { + "line": 702, + "column": 5 + } + } + }, + "property": { + "type": "Identifier", + "name": "Rx", + "range": [ + 24632, + 24634 + ], + "loc": { + "start": { + "line": 702, + "column": 6 + }, + "end": { + "line": 702, + "column": 8 + } + } + }, + "range": [ + 24626, + 24634 + ], + "loc": { + "start": { + "line": 702, + "column": 0 + }, + "end": { + "line": 702, + "column": 8 + } + } + }, + "right": { + "type": "Identifier", + "name": "Rx", + "range": [ + 24637, + 24639 + ], + "loc": { + "start": { + "line": 702, + "column": 11 + }, + "end": { + "line": 702, + "column": 13 + } + } + }, + "range": [ + 24626, + 24639 + ], + "loc": { + "start": { + "line": 702, + "column": 0 + }, + "end": { + "line": 702, + "column": 13 + } + } + }, + "range": [ + 24626, + 24640 + ], + "loc": { + "start": { + "line": 702, + "column": 0 + }, + "end": { + "line": 702, + "column": 14 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "Store", + "range": [ + 24641, + 24646 + ], + "loc": { + "start": { + "line": 703, + "column": 0 + }, + "end": { + "line": 703, + "column": 5 + } + } + }, + "property": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 24647, + 24658 + ], + "loc": { + "start": { + "line": 703, + "column": 6 + }, + "end": { + "line": 703, + "column": 17 + } + } + }, + "range": [ + 24641, + 24658 + ], + "loc": { + "start": { + "line": 703, + "column": 0 + }, + "end": { + "line": 703, + "column": 17 + } + } + }, + "right": { + "type": "Identifier", + "name": "AjaxAdapter", + "range": [ + 24661, + 24672 + ], + "loc": { + "start": { + "line": 703, + "column": 20 + }, + "end": { + "line": 703, + "column": 31 + } + } + }, + "range": [ + 24641, + 24672 + ], + "loc": { + "start": { + "line": 703, + "column": 0 + }, + "end": { + "line": 703, + "column": 31 + } + } + }, + "range": [ + 24641, + 24673 + ], + "loc": { + "start": { + "line": 703, + "column": 0 + }, + "end": { + "line": 703, + "column": 32 + } + } + } + ], + "sourceType": "module", + "range": [ + 0, + 24673 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 703, + "column": 32 + } + }, + "comments": [ + { + "type": "Block", + "value": "*\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n ", + "range": [ + 127, + 449 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 15, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 918, + 1255 + ], + "loc": { + "start": { + "line": 33, + "column": 2 + }, + "end": { + "line": 41, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n ", + "range": [ + 2303, + 2641 + ], + "loc": { + "start": { + "line": 75, + "column": 2 + }, + "end": { + "line": 83, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n ", + "range": [ + 3805, + 5173 + ], + "loc": { + "start": { + "line": 125, + "column": 4 + }, + "end": { + "line": 162, + "column": 7 + } + } + }, + { + "type": "Block", + "value": "*\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n ", + "range": [ + 5234, + 5506 + ], + "loc": { + "start": { + "line": 167, + "column": 2 + }, + "end": { + "line": 174, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n ", + "range": [ + 6299, + 6745 + ], + "loc": { + "start": { + "line": 200, + "column": 2 + }, + "end": { + "line": 208, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 7379, + 7940 + ], + "loc": { + "start": { + "line": 233, + "column": 2 + }, + "end": { + "line": 249, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n ", + "range": [ + 8213, + 8404 + ], + "loc": { + "start": { + "line": 258, + "column": 2 + }, + "end": { + "line": 264, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n ", + "range": [ + 8881, + 9400 + ], + "loc": { + "start": { + "line": 281, + "column": 2 + }, + "end": { + "line": 297, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n ", + "range": [ + 9665, + 10029 + ], + "loc": { + "start": { + "line": 306, + "column": 2 + }, + "end": { + "line": 316, + "column": 5 + } + } + }, + { + "type": "Line", + "value": " throw new TypeError(`You must provide an id`);", + "range": [ + 10730, + 10779 + ], + "loc": { + "start": { + "line": 340, + "column": 10 + }, + "end": { + "line": 340, + "column": 59 + } + } + }, + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 10790, + 10808 + ], + "loc": { + "start": { + "line": 341, + "column": 10 + }, + "end": { + "line": 341, + "column": 28 + } + } + }, + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 11097, + 11114 + ], + "loc": { + "start": { + "line": 346, + "column": 10 + }, + "end": { + "line": 346, + "column": 27 + } + } + }, + { + "type": "Block", + "value": "*\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n ", + "range": [ + 11320, + 11506 + ], + "loc": { + "start": { + "line": 357, + "column": 2 + }, + "end": { + "line": 363, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 11985, + 12509 + ], + "loc": { + "start": { + "line": 381, + "column": 2 + }, + "end": { + "line": 397, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 12585, + 12603 + ], + "loc": { + "start": { + "line": 400, + "column": 6 + }, + "end": { + "line": 400, + "column": 24 + } + } + }, + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 12872, + 12889 + ], + "loc": { + "start": { + "line": 405, + "column": 6 + }, + "end": { + "line": 405, + "column": 23 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n ", + "range": [ + 13126, + 13620 + ], + "loc": { + "start": { + "line": 414, + "column": 2 + }, + "end": { + "line": 429, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n ", + "range": [ + 13880, + 14328 + ], + "loc": { + "start": { + "line": 438, + "column": 2 + }, + "end": { + "line": 447, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 14368, + 14386 + ], + "loc": { + "start": { + "line": 449, + "column": 4 + }, + "end": { + "line": 449, + "column": 22 + } + } + }, + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 14610, + 14627 + ], + "loc": { + "start": { + "line": 454, + "column": 4 + }, + "end": { + "line": 454, + "column": 21 + } + } + }, + { + "type": "Block", + "value": "*\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n ", + "range": [ + 15286, + 15771 + ], + "loc": { + "start": { + "line": 471, + "column": 2 + }, + "end": { + "line": 481, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "eslint-disable", + "range": [ + 15819, + 15837 + ], + "loc": { + "start": { + "line": 483, + "column": 4 + }, + "end": { + "line": 483, + "column": 22 + } + } + }, + { + "type": "Block", + "value": "eslint-enable", + "range": [ + 16060, + 16077 + ], + "loc": { + "start": { + "line": 488, + "column": 4 + }, + "end": { + "line": 488, + "column": 21 + } + } + }, + { + "type": "Block", + "value": "*\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n ", + "range": [ + 17347, + 17645 + ], + "loc": { + "start": { + "line": 517, + "column": 2 + }, + "end": { + "line": 524, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n ", + "range": [ + 17878, + 18184 + ], + "loc": { + "start": { + "line": 536, + "column": 2 + }, + "end": { + "line": 543, + "column": 5 + } + } + }, + { + "type": "Block", + "value": "*\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n ", + "range": [ + 18844, + 19453 + ], + "loc": { + "start": { + "line": 569, + "column": 2 + }, + "end": { + "line": 586, + "column": 5 + } + } + }, + { + "type": "Line", + "value": " TODO: This only needs to be run once for each dependent.", + "range": [ + 22779, + 22838 + ], + "loc": { + "start": { + "line": 664, + "column": 6 + }, + "end": { + "line": 664, + "column": 65 + } + } + } + ] +} \ No newline at end of file diff --git a/docs/v0.7.0/badge.svg b/docs/v0.7.0/badge.svg new file mode 100644 index 0000000..a9dc035 --- /dev/null +++ b/docs/v0.7.0/badge.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + document + document + 70% + 70% + + diff --git a/docs/v0.7.0/class/src/ajax-adapter.js~AjaxAdapter.html b/docs/v0.7.0/class/src/ajax-adapter.js~AjaxAdapter.html new file mode 100644 index 0000000..6067f77 --- /dev/null +++ b/docs/v0.7.0/class/src/ajax-adapter.js~AjaxAdapter.html @@ -0,0 +1,660 @@ + + + + + + AjaxAdapter | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +
+
import AjaxAdapter from 'json-api-store/src/ajax-adapter.js'
+ public + class + + + + | source +
+ +
+

AjaxAdapter

+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +

Constructor Summary

+ + + + + + + + + +
Public Constructor
+ public + + + + + +
+

+ constructor(options: *) +

+
+
+ + + +
+
+ + +
+
+ +

Method Summary

+ + + + + + + + + + + + + + + + + + + + + + + + +
Public Methods
+ public + + + + + +
+

+ create(store: *, type: *, partial: *, options: *): * +

+
+
+ + + +
+
+ + +
+ public + + + + + +
+

+ destroy(store: *, type: *, id: *, options: *): * +

+
+
+ + + +
+
+ + +
+ public + + + + + +
+

+ load(store: *, type: *, id: *, options: *): * +

+
+
+ + + +
+
+ + +
+ public + + + + + +
+

+ update(store: *, type: *, id: *, partial: *, options: *): * +

+
+
+ + + +
+
+ + +
+
+ + + + + +

Public Constructors

+ +
+

+ public + + + + + constructor(options: *) + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
options*
+
+
+ + + + + + + + + + + + + + + +
+
+ +

Public Methods

+ +
+

+ public + + + + + create(store: *, type: *, partial: *, options: *): * + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
store*
type*
partial*
options*
+
+
+ +
+

Return:

+ + + + + +
*
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + destroy(store: *, type: *, id: *, options: *): * + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
store*
type*
id*
options*
+
+
+ +
+

Return:

+ + + + + +
*
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + load(store: *, type: *, id: *, options: *): * + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
store*
type*
id*
options*
+
+
+ +
+

Return:

+ + + + + +
*
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + update(store: *, type: *, id: *, partial: *, options: *): * + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
store*
type*
id*
partial*
options*
+
+
+ +
+

Return:

+ + + + + +
*
+
+
+
+ + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/class/src/store.js~Store.html b/docs/v0.7.0/class/src/store.js~Store.html new file mode 100644 index 0000000..55aec3d --- /dev/null +++ b/docs/v0.7.0/class/src/store.js~Store.html @@ -0,0 +1,2133 @@ + + + + + + Store | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +
+
import Store from 'json-api-store/src/store.js'
+ public + class + + + + | source +
+ +
+

Store

+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

Static Method Summary

+ + + + + + + + + + + + + + + + + + + +
Static Public Methods
+ public + static + + + + +
+

+ attr(name: string, options: Object): Object +

+
+
+ + +

Creates a field definition for an attribute.

+
+
+ + since 0.1.0 +
+ public + static + + + + +
+

+ hasMany(name: string, options: Object): Object +

+
+
+ + +

Creates a field definition for an has-many relationship.

+
+
+ + since 0.1.0 +
+ public + static + + + + +
+

+ hasOne(name: string, options: Object): Object +

+
+
+ + +

Creates a field definition for an has-one relationship.

+
+
+ + since 0.1.0 +
+
+

Constructor Summary

+ + + + + + + + + +
Public Constructor
+ public + + + + + +
+

+ constructor(adapter: *) +

+
+
+ + + +
+
+ + +
+
+

Member Summary

+ + + + + + + + + +
Public Members
+ public + + + + + +
+

+ observable: Rx.Observable +

+
+
+ + +

An observable that will emit events when any resource in added, updated +

+
+
+ + since 0.6.0 +
+
+

Method Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Public Methods
+ public + + + + + +
+

+ add(object: Object) +

+
+
+ + +

Add an individual resource to the store.

+
+
+ + since 0.1.0 +
+ public + + + + + +
+

+ convert(type: string, id: string, partial: object): object +

+
+
+ + +

Converts the given partial into a JSON API compliant representation.

+
+
+ + since 0.5.0 +
+ public + + + + + +
+

+ create(type: string, partial: Object, options: Object): Rx.Observable +

+
+
+ + +

Attempts to create the resource through the adapter and adds it to the +

+
+
+ + since 0.5.0 +
+ public + + + + + +
+

+ define(names: string | string[], definition: Object) +

+
+
+ + +

Defines a type of resource.

+
+
+ + since 0.2.0 +
+ public + + + + + +
+

+ destroy(type: string, id: string, options: Object): Rx.Observable +

+
+
+ + +

Attempts to delete the resource through the adapter and removes it from +

+
+
+ + since 0.5.0 +
+ public + + + + + +
+

+ find(type: string, id: string): Object +

+
+
+ + +

Finds a resource by type and id.

+
+
+ + since 0.1.0 +
+ public + + + + + +
+

+ findAll(type: string): Object[] +

+
+
+ + +

Finds all the resources of a given type.

+
+
+ + since 0.7.0 +
+ public + + + + + +
+

+ load(type: string, id: string, options: Object): Rx.Observable +

+
+
+ + +

Attempts to load the given resource through the adapter and adds it to the +

+
+
+ + since 0.5.0 +
+ public + + + + + +
+

+ loadAll(type: string, options: Object): Rx.Observable +

+
+
+ + +

Attempts to load all the resources of the given type through the adapter +

+
+
+ + since 0.7.0 +
+ public + + + + + +
+

+ off(event: string, type: string, id: string, callback: function) +

+
+
+
this method was deprecated. Use the store.observable property instead of this.
+ +

Unregister an event listener that was registered with on().

+
+
+ + since 0.4.0 +
+ public + + + + + +
+

+ on(event: string, type: string, id: string, callback: function, context: Object) +

+
+
+
this method was deprecated. Use the store.observable property instead of this.
+ +

Register an event listener: "added", "updated" or "removed".

+
+
+ + since 0.4.0 +
+ public + + + + + +
+

+ push(root: Object) +

+
+
+ + +

Add a JSON API response to the store.

+
+
+ + since 0.1.0 +
+ public + + + + + +
+

+ remove(type: string, id: string) +

+
+
+ + +

Remove a resource or collection of resources from the store.

+
+
+ + since 0.1.0 +
+ public + + + + + +
+

+ update(type: string, id: string, partial: Object, options: Object): Rx.Observable +

+
+
+ + +

Attempts to update the resource through the adapter and updates it in the +

+
+
+ + since 0.5.0 +
+
+ + + + +

Static Public Methods

+ +
+

+ public + static + + + + attr(name: string, options: Object): Object + + + since 0.1.0 + source + +

+ + + + +

Creates a field definition for an attribute.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
namestring
  • optional

Name of the property to map this field from.

+
optionsObject
  • optional

An options object.

+
options.defaultstring
  • optional

Default value for this field.

+
+
+
+ +
+

Return:

+ + + + + +
Object

Field definition.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + static + + + + hasMany(name: string, options: Object): Object + + + since 0.1.0 + source + +

+ + + + +

Creates a field definition for an has-many relationship.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
namestring
  • optional

Name of the property to map this field from.

+
optionsObject
  • optional

An options object.

+
options.inversestring
  • optional

Name of the inverse relationship.

+
+
+
+ +
+

Return:

+ + + + + +
Object

Field definition.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + static + + + + hasOne(name: string, options: Object): Object + + + since 0.1.0 + source + +

+ + + + +

Creates a field definition for an has-one relationship.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
namestring
  • optional

Name of the property to map this field from.

+
optionsObject
  • optional

An options object.

+
options.inversestring
  • optional

Name of the inverse relationship.

+
+
+
+ +
+

Return:

+ + + + + +
Object

Field definition.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

Public Constructors

+ +
+

+ public + + + + + constructor(adapter: *) + + + + source + +

+ + + + + + + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
adapter*
+
+
+ + + + + + + + + + + + + + + +
+
+

Public Members

+ +
+

+ public + + + + + observable: Rx.Observable + + + since 0.6.0 + source + +

+ + + + +

An observable that will emit events when any resource in added, updated +or removed. The object passed to listeners will be in this format:

+

+{ name: string, type: string, id: string, resource: object }
+

+ +

You can learn more about RxJS observables at the GitHub repo: +https://github.com/Reactive-Extensions/RxJS

+
+ + + +
+
+ + + + + + + + + +
+

Example:

+ +
+ +
let store = new Store();
+
+store.observable.filter(e => e.name === "added").subscribe(event => {
+  console.log(event.name); // "added"
+  console.log(event.type); // "products"
+  console.log(event.id); // "1"
+  console.log(event.resource); // Map {...}
+});
+
+store.observable.filter(e => e.name === "updated").subscribe(event => {
+  console.log(event.name); // "updated"
+  console.log(event.type); // "products"
+  console.log(event.id); // "1"
+  console.log(event.resource); // Map {...}
+});
+
+store.observable.filter(e => e.name === "removed").subscribe(event => {
+  console.log(event.name); // "removed"
+  console.log(event.type); // "products"
+  console.log(event.id); // "1"
+  console.log(event.resource); // null
+});
+
+
+ + + + + +
+
+

Public Methods

+ +
+

+ public + + + + + add(object: Object) + + + since 0.1.0 + source + +

+ + + + +

Add an individual resource to the store. This is used internally by the +push() method.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
objectObject
  • nullable: false

A JSON API Resource Object to be added. See: + http://jsonapi.org/format/#document-resource-objects

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + convert(type: string, id: string, partial: object): object + + + since 0.5.0 + source + +

+ + + + +

Converts the given partial into a JSON API compliant representation.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • optional
  • +
  • nullable: false

The type of the resource. This can be omitted if the partial includes a type property.

+
idstring
  • optional
  • +
  • nullable: false

The id of the resource. This can be omitted if the partial includes an id property.

+
partialobject
  • nullable: false

The data to convert.

+
+
+
+ +
+

Return:

+ + + + + +
object

JSON API version of the object.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + create(type: string, partial: Object, options: Object): Rx.Observable + + + since 0.5.0 + source + +

+ + + + +

Attempts to create the resource through the adapter and adds it to the +store if successful.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of resource.

+
partialObject
  • nullable: false

Data to create the resource with.

+
optionsObject
  • optional

Options to pass to the adapter.

+
+
+
+ +
+

Return:

+ + + + + +
Rx.Observable
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
let adapter = new Store.AjaxAdapter();
+let store = new Store(adpater);
+store.create("product", { title: "A Book" }).subscribe((product) => {
+  console.log(product.title);
+});
+
+
+ + + + + +
+
+

+ public + + + + + define(names: string | string[], definition: Object) + + + since 0.2.0 + source + +

+ + + + +

Defines a type of resource.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
namesstring | string[]
  • nullable: false

Name(s) of the resource.

+
definitionObject
  • nullable: false

The resource's definition.

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + destroy(type: string, id: string, options: Object): Rx.Observable + + + since 0.5.0 + source + +

+ + + + +

Attempts to delete the resource through the adapter and removes it from +the store if successful.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of resource.

+
idstring
  • nullable: false

ID of resource.

+
optionsObject
  • optional

Options to pass to the adapter.

+
+
+
+ +
+

Return:

+ + + + + +
Rx.Observable
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
let adapter = new Store.AjaxAdapter();
+let store = new Store(adpater);
+store.destroy("product", "1").subscribe(() => {
+  console.log("Destroyed!");
+});
+
+
+ + + + + +
+
+

+ public + + + + + find(type: string, id: string): Object + + + since 0.1.0 + source + +

+ + + + +

Finds a resource by type and id.

+

NOTE: If the resource hasn't been loaded via an add() or push() call it +will be automatically created when find is called.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of the resource to find.

+
idstring
  • nullable: false

The id of the resource to find.

+
+
+
+ +
+

Return:

+ + + + + +
Object

The resource.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + findAll(type: string): Object[] + + + since 0.7.0 + source + +

+ + + + +

Finds all the resources of a given type.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of the resource to find.

+
+
+
+ +
+

Return:

+ + + + + +
Object[]

An array of resources.

+
+
+
+
+ + + + + + + + + + + + + +
+
+

+ public + + + + + load(type: string, id: string, options: Object): Rx.Observable + + + since 0.5.0 + source + +

+ + + + +

Attempts to load the given resource through the adapter and adds it to the +store if successful.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of resource.

+
idstring
  • nullable: false

ID of resource.

+
optionsObject
  • optional

Options to pass to the adapter.

+
+
+
+ +
+

Return:

+ + + + + +
Rx.Observable
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
let adapter = new Store.AjaxAdapter();
+let store = new Store(adpater);
+store.load("products", "1").subscribe((product) => {
+  console.log(product.title);
+});
+
+
+ + + + + +
+
+

+ public + + + + + loadAll(type: string, options: Object): Rx.Observable + + + since 0.7.0 + source + +

+ + + + +

Attempts to load all the resources of the given type through the adapter +and adds them to the store if successful.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of resource.

+
optionsObject
  • optional

Options to pass to the adapter.

+
+
+
+ +
+

Return:

+ + + + + +
Rx.Observable
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
let adapter = new Store.AjaxAdapter();
+let store = new Store(adpater);
+store.loadAll("products").subscribe((products) => {
+  console.log(products);
+});
+
+
+ + + + + +
+
+

+ public + + + + + off(event: string, type: string, id: string, callback: function) + + + since 0.4.0 + source + +

+ + +
this method was deprecated. Use the store.observable property instead of this.
+ +

Unregister an event listener that was registered with on().

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
eventstring

Name of the event.

+
typestring

Name of resource to originally passed to on().

+
idstring
  • optional

ID of the resource to originally passed to on().

+
callbackfunction

Function originally passed to on().

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + on(event: string, type: string, id: string, callback: function, context: Object) + + + since 0.4.0 + source + +

+ + +
this method was deprecated. Use the store.observable property instead of this.
+ +

Register an event listener: "added", "updated" or "removed".

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
eventstring

Name of the event.

+
typestring

Name of resource to watch.

+
idstring
  • optional

ID of the resource to watch.

+
callbackfunction

Function to call when the event occurs.

+
contextObject
  • optional

Context in which to call the callback.

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + push(root: Object) + + + since 0.1.0 + source + +

+ + + + +

Add a JSON API response to the store. This method can be used to handle a +successful GET or POST response from the server.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
rootObject

Top Level Object to push. See: + http://jsonapi.org/format/#document-top-level

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + remove(type: string, id: string) + + + since 0.1.0 + source + +

+ + + + +

Remove a resource or collection of resources from the store.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of the resource(s) to remove.

+
idstring
  • optional

The id of the resource to remove. If omitted all + resources of the type will be removed.

+
+
+
+ + + + + + + + + + + + + + + +
+
+

+ public + + + + + update(type: string, id: string, partial: Object, options: Object): Rx.Observable + + + since 0.5.0 + source + +

+ + + + +

Attempts to update the resource through the adapter and updates it in the +store if successful.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributeDescription
typestring
  • nullable: false

Type of resource.

+
idstring
  • nullable: false

ID of resource.

+
partialObject
  • nullable: false

Data to update the resource with.

+
optionsObject
  • optional

Options to pass to the adapter.

+
+
+
+ +
+

Return:

+ + + + + +
Rx.Observable
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
let adapter = new Store.AjaxAdapter();
+let store = new Store(adpater);
+store.update("product", "1", { title: "foo" }).subscribe((product) => {
+  console.log(product.title);
+});
+
+
+ + + + + +
+
+
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/coverage.json b/docs/v0.7.0/coverage.json new file mode 100644 index 0000000..781aa3d --- /dev/null +++ b/docs/v0.7.0/coverage.json @@ -0,0 +1,32 @@ +{ + "coverage": "70.37%", + "expectCount": 27, + "actualCount": 19, + "files": { + "src/ajax-adapter.js": { + "expectCount": 6, + "actualCount": 0, + "undocumentLines": [ + 3, + 5, + 9, + 36, + 59, + 87 + ] + }, + "src/store.js": { + "expectCount": 20, + "actualCount": 18, + "undocumentLines": [ + 5, + 117 + ] + }, + "src/ajax.js": { + "expectCount": 1, + "actualCount": 1, + "undocumentLines": [] + } + } +} \ No newline at end of file diff --git a/docs/v0.7.0/css/prettify-tomorrow.css b/docs/v0.7.0/css/prettify-tomorrow.css new file mode 100644 index 0000000..b6f92a7 --- /dev/null +++ b/docs/v0.7.0/css/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: #718c00; } + + /* a keyword */ + .kwd { + color: #8959a8; } + + /* a comment */ + .com { + color: #8e908c; } + + /* a type name */ + .typ { + color: #4271ae; } + + /* a literal value */ + .lit { + color: #f5871f; } + + /* punctuation */ + .pun { + color: #4d4d4c; } + + /* lisp open bracket */ + .opn { + color: #4d4d4c; } + + /* lisp close bracket */ + .clo { + color: #4d4d4c; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/docs/v0.7.0/css/style.css b/docs/v0.7.0/css/style.css new file mode 100644 index 0000000..39b3682 --- /dev/null +++ b/docs/v0.7.0/css/style.css @@ -0,0 +1,822 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,700); + +* { + margin: 0; + padding: 0; + text-decoration: none; +} + +html +{ + font-family: 'Roboto', sans-serif; + overflow: auto; + font-size: 14px; + /*color: #4d4e53;*/ + color: rgba(0, 0, 0, .68); + background-color: #fff; +} + +a { + /*color: #0095dd;*/ + /*color:rgb(37, 138, 175);*/ + color: #039BE5; +} + +code a:hover { + text-decoration: underline; +} + +ul, ol { + padding-left: 20px; +} + +ul li { + list-style: disc; + margin: 4px 0; +} + +ol li { + margin: 4px 0; +} + +h1 { + margin-bottom: 10px; + font-size: 34px; + font-weight: 300; + border-bottom: solid 1px #ddd; +} + +h2 { + margin-top: 24px; + margin-bottom: 10px; + font-size: 20px; + border-bottom: solid 1px #ddd; + font-weight: 300; +} + +h3 { + position: relative; + font-size: 16px; + margin-bottom: 12px; + background-color: #E2E2E2; + padding: 4px; + font-weight: 300; +} + +del { + text-decoration: line-through; +} + +p { + margin-bottom: 15px; + line-height: 19px; +} + +p > code { + background-color: #f5f5f5; + border-radius: 3px; +} + +pre > code { + display: block; +} + +pre.prettyprint, pre > code { + padding: 4px; + margin: 1em 0; + background-color: #f5f5f5; + border-radius: 3px; +} + +pre.prettyprint > code { + margin: 0; +} + +p > code, +li > code { + padding: 0 4px; + border-radius: 3px; +} + +.import-path pre.prettyprint, +.import-path pre.prettyprint code { + margin: 0; + padding: 0; + border: none; + background: white; +} + +.layout-container { + /*display: flex;*/ + /*flex-direction: row;*/ + /*justify-content: flex-start;*/ + /*align-items: stretch;*/ +} + +.layout-container > header { + height: 40px; + line-height: 40px; + font-size: 16px; + padding: 0 10px; + margin: 0; + position: fixed; + width: 100%; + z-index: 1; + background-color: white; + top: 0; + border-bottom: solid 1px #E02130; +} +.layout-container > header > a{ + margin: 0 5px; +} + +.layout-container > header > a.repo-url-github { + font-size: 0; + display: inline-block; + width: 20px; + height: 38px; + background: url("../image/github.png") no-repeat center; + background-size: 20px; + vertical-align: top; +} + +.navigation { + position: fixed; + top: 0; + left: 0; + box-sizing: border-box; + width: 200px; + height: 100%; + padding-top: 40px; + padding-left: 15px; + padding-bottom: 20px; + overflow-x: scroll; + box-shadow: rgba(255, 255, 255, 1) -1px 0 0 inset; + border-right: 1px solid rgba(0, 0, 0, 0.1); +} + +.navigation h1 { + border: none; + font-size: 18px; +} + +.navigation h2 { + margin: 15px 0 4px; + font-size: 16px; + border: none; +} + +.navigation h2 a { + color: inherit; +} + +.navigation ul { + padding: 0; +} + +.navigation li { + list-style: none; + margin: 4px 0; +} + +h1 .version, +h1 .url a { + font-size: 14px; + color: #aaa; +} + +.content { + margin-top: 40px; + margin-left: 200px; + padding: 10px 50px 10px 20px; +} + +.header-notice { + font-size: 14px; + color: #aaa; + margin: 0; +} + +.expression-extends .prettyprint { + margin-left: 10px; + background: white; +} + +.extends-chain { + border-bottom: 1px solid#ddd; + padding-bottom: 10px; + margin-bottom: 10px; +} + +.extends-chain span:nth-of-type(1) { + padding-left: 10px; +} + +.extends-chain > div { + margin: 5px 0; +} + +.description table { + font-size: 14px; + border-spacing: 0; + border: 0; + border-collapse: collapse; +} + +.description thead { + background: #999; + color: white; +} + +.description table td, +.description table th { + border: solid 1px #ddd; + padding: 4px; + font-weight: normal; +} + +.flat-list ul { + padding-left: 0; +} + +.flat-list li { + display: inline; + list-style: none; +} + +table.summary { + width: 100%; + margin: 10px 0; + border-spacing: 0; + border: 0; + border-collapse: collapse; +} + +table.summary thead { + background: #999; + color: white; +} + +table.summary td { + border: solid 1px #ddd; + padding: 4px 10px; +} + +table.summary tbody td:nth-child(1) { + text-align: right; + white-space: nowrap; + min-width: 64px; + vertical-align: top; +} + +table.summary tbody td:nth-child(2) { + width: 100%; + border-right: none; +} + +table.summary tbody td:nth-child(3) { + white-space: nowrap; + border-left: none; + vertical-align: top; +} + +table.summary td > div:nth-of-type(2) { + padding-top: 4px; + padding-left: 15px; +} + +table.summary td p { + margin-bottom: 0; +} + +.inherited-summary thead td { + padding-left: 2px; +} + +.inherited-summary thead a { + color: white; +} + +.inherited-summary .summary tbody { + display: none; +} + +.inherited-summary .summary .toggle { + padding: 0 4px; + font-size: 12px; + cursor: pointer; +} +.inherited-summary .summary .toggle.closed:before { + content: "â–¶"; +} +.inherited-summary .summary .toggle.opened:before { + content: "â–¼"; +} + +.member, .method { + margin-bottom: 24px; +} + +table.params { + width: 100%; + margin: 10px 0; + border-spacing: 0; + border: 0; + border-collapse: collapse; +} + +table.params thead { + background: #eee; + color: #aaa; +} + +table.params td { + padding: 4px; + border: solid 1px #ddd; +} + +table.params td p { + margin: 0; +} + +.content .detail > * { + margin: 15px 0; +} + +.content .detail > h3 { + color: black; +} + +.content .detail > div { + margin-left: 10px; +} + +.content .detail > .import-path { + margin-top: -8px; +} + +.content .detail + .detail { + margin-top: 30px; +} + +.content .detail .throw td:first-child { + padding-right: 10px; +} + +.content .detail h4 + :not(pre) { + padding-left: 0; + margin-left: 10px; +} + +.content .detail h4 + ul li { + list-style: none; +} + +.return-param * { + display: inline; +} + +.argument-params { + margin-bottom: 20px; +} + +.return-type { + padding-right: 10px; + font-weight: normal; +} + +.return-desc { + margin-left: 10px; + margin-top: 4px; +} + +.return-desc p { + margin: 0; +} + +.deprecated, .experimental, .instance-docs { + border-left: solid 5px orange; + padding-left: 4px; + margin: 4px 0; +} + +tr.listen p, +tr.throw p, +tr.emit p{ + margin-bottom: 10px; +} + +.version, .since { + color: #aaa; +} + +h3 .right-info { + position: absolute; + right: 4px; + font-size: 14px; +} + +.version + .since:before { + content: '| '; +} + +.see { + margin-top: 10px; +} + +.see h4 { + margin: 4px 0; +} + +.content .detail h4 + .example-doc { + margin: 6px 0; +} + +.example-caption { + position: relative; + bottom: -1px; + display: inline-block; + padding: 4px; + font-style: italic; + background-color: #f5f5f5; + font-weight: bold; + border-radius: 3px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.example-caption + pre.source-code { + margin-top: 0; + border-top-left-radius: 0; +} + +footer, .file-footer { + text-align: right; + font-style: italic; + font-weight: 100; + font-size: 13px; + margin-right: 50px; + margin-left: 220px; + border-top: 1px solid #ddd; + padding-top: 30px; + margin-top: 20px; + padding-bottom: 10px; +} + +pre.source-code { + background: #f5f5f5; + padding: 4px; +} + +pre.raw-source-code > code { + padding: 0; + margin: 0; +} + +pre.source-code.line-number { + padding: 0; +} + +pre.source-code ol { + background: #eee; + padding-left: 40px; +} + +pre.source-code li { + background: white; + padding-left: 4px; + list-style: decimal; + margin: 0; +} + +pre.source-code.line-number li.active { + background: rgb(255, 255, 150); +} + +pre.source-code.line-number li.error-line { + background: #ffb8bf; +} + +table.files-summary { + width: 100%; + margin: 10px 0; + border-spacing: 0; + border: 0; + border-collapse: collapse; + text-align: right; +} + +table.files-summary tbody tr:hover { + background: #eee; +} + +table.files-summary td:first-child, +table.files-summary td:nth-of-type(2) { + text-align: left; +} + +table.files-summary[data-use-coverage="false"] td.coverage { + display: none; +} + +table.files-summary thead { + background: #999; + color: white; +} + +table.files-summary td { + border: solid 1px #ddd; + padding: 4px 10px; + vertical-align: top; +} + +table.files-summary td.identifiers > span { + display: block; + margin-top: 4px; +} +table.files-summary td.identifiers > span:first-child { + margin-top: 0; +} + +table.files-summary .coverage-count { + font-size: 12px; + color: #aaa; + display: inline-block; + min-width: 40px; +} + +.total-coverage-count { + position: relative; + bottom: 2px; + font-size: 12px; + color: #666; + font-weight: 500; + padding-left: 5px; +} + +table.test-summary thead { + background: #999; + color: white; +} + +table.test-summary thead .test-description { + width: 50%; +} + +table.test-summary { + width: 100%; + margin: 10px 0; + border-spacing: 0; + border: 0; + border-collapse: collapse; +} + +table.test-summary thead .test-count { + width: 3em; +} + +table.test-summary tbody tr:hover { + background-color: #eee; +} + +table.test-summary td { + border: solid 1px #ddd; + padding: 4px 10px; + vertical-align: top; +} + +table.test-summary td p { + margin: 0; +} + +table.test-summary tr.test-describe .toggle { + display: inline-block; + float: left; + margin-right: 4px; + cursor: pointer; +} + +table.test-summary tr.test-describe .toggle.opened:before { + content: 'â–¼'; +} + +table.test-summary tr.test-describe .toggle.closed:before { + content: 'â–¶'; +} + +table.test-summary .test-target > span { + display: block; + margin-top: 4px; +} +table.test-summary .test-target > span:first-child { + margin-top: 0; +} + +.inner-link-active { + background: rgb(255, 255, 150); +} + +/* search box */ +.search-box { + position: absolute; + top: 10px; + right: 50px; + padding-right: 8px; + padding-bottom: 10px; + line-height: normal; + font-size: 12px; +} + +.search-box img { + width: 20px; + vertical-align: top; +} + +.search-input { + display: inline; + visibility: hidden; + width: 0; + padding: 2px; + height: 1.5em; + outline: none; + background: transparent; + border: 1px #0af; + border-style: none none solid none; + vertical-align: bottom; +} + +.search-input-edge { + display: none; + width: 1px; + height: 5px; + background-color: #0af; + vertical-align: bottom; +} + +.search-result { + position: absolute; + display: none; + height: 600px; + width: 100%; + padding: 0; + margin-top: 5px; + margin-left: 24px; + background: white; + box-shadow: 1px 1px 4px rgb(0,0,0); + white-space: nowrap; + overflow-y: scroll; +} + +.search-result-import-path { + color: #aaa; + font-size: 12px; +} + +.search-result li { + list-style: none; + padding: 2px 4px; +} + +.search-result li a { + display: block; +} + +.search-result li.selected { + background: #ddd; +} + +.search-result li.search-separator { + background: rgb(37, 138, 175); + color: white; +} + +.search-box.active .search-input { + visibility: visible; + transition: width 0.2s ease-out; + width: 300px; +} + +.search-box.active .search-input-edge { + display: inline-block; +} + +/* coverage badge */ +.esdoc-coverage { + display: inline-block; + height: 20px; + vertical-align: top; +} + +h1 .esdoc-coverage { + position: relative; + top: -4px; +} + +.esdoc-coverage-wrap { + color: white; + font-size: 12px; + font-weight: 500; +} + +.esdoc-coverage-label { + padding: 3px 4px 3px 6px; + background: linear-gradient(to bottom, #5e5e5e 0%,#4c4c4c 100%); + border-radius: 4px 0 0 4px; + display: inline-block; + height: 20px; + box-sizing: border-box; + line-height: 14px; +} + +.esdoc-coverage-ratio { + padding: 3px 6px 3px 4px; + border-radius: 0 4px 4px 0; + display: inline-block; + height: 20px; + box-sizing: border-box; + line-height: 14px; +} + +.esdoc-coverage-low { + background: linear-gradient(to bottom, #db654f 0%,#c9533d 100%); +} + +.esdoc-coverage-middle { + background: linear-gradient(to bottom, #dab226 0%,#c9a179 100%); +} + +.esdoc-coverage-high { + background: linear-gradient(to bottom, #4fc921 0%,#3eb810 100%); +} + +/* github markdown */ +.github-markdown { + font-size: 16px; +} + +.github-markdown h1, +.github-markdown h2, +.github-markdown h3, +.github-markdown h4, +.github-markdown h5 { + margin-top: 1em; + margin-bottom: 16px; + font-weight: bold; + padding: 0; +} + +.github-markdown h1:nth-of-type(1) { + margin-top: 0; +} + +.github-markdown h1 { + font-size: 2em; + padding-bottom: 0.3em; +} + +.github-markdown h2 { + font-size: 1.75em; + padding-bottom: 0.3em; +} + +.github-markdown h3 { + font-size: 1.5em; + background-color: transparent; +} + +.github-markdown h4 { + font-size: 1.25em; +} + +.github-markdown h5 { + font-size: 1em; +} + +.github-markdown ul, .github-markdown ol { + padding-left: 2em; +} + +.github-markdown pre > code { + font-size: 0.85em; +} + +.github-markdown table { + margin-bottom: 1em; + border-collapse: collapse; + border-spacing: 0; +} + +.github-markdown table tr { + background-color: #fff; + border-top: 1px solid #ccc; +} + +.github-markdown table th, +.github-markdown table td { + padding: 6px 13px; + border: 1px solid #ddd; +} + +.github-markdown table tr:nth-child(2n) { + background-color: #f8f8f8; +} diff --git a/docs/v0.7.0/dump.json b/docs/v0.7.0/dump.json new file mode 100644 index 0000000..c4135d1 --- /dev/null +++ b/docs/v0.7.0/dump.json @@ -0,0 +1,2243 @@ +[ + { + "kind": "file", + "static": true, + "variation": null, + "name": "src/ajax-adapter.js", + "memberof": null, + "longname": "src/ajax-adapter.js", + "access": null, + "description": null, + "lineNumber": 1, + "content": "import ajax from \"./ajax\";\n\nexport default class AjaxAdapter {\n\n constructor(options) {\n this._base = (options && options.base) || \"\";\n };\n\n create(store, type, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n body: JSON.stringify({\n data: store.convert(type, partial)\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"POST\",\n responseType: \"auto\",\n url: this._getUrl(type, null, options)\n }).do(e => store.push(e.response))\n .map(e => store.find(e.response.data.type, e.response.data.id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n destroy(store, type, id, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"DELETE\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.remove(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n load(store, type, id, options) {\n\n if (id && typeof id === \"object\") {\n return this.load(store, type, null, id);\n }\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"GET\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(e => store.push(e.response))\n .map(() => id ? store.find(type, id) : store.findAll(type))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n update(store, type, id, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let data = store.convert(type, id, partial);\n\n let source = ajax({\n body: JSON.stringify({\n data: data\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"PATCH\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.add(data))\n .map(() => store.find(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n _getUrl(type, id, options) {\n\n let params = [];\n let url = id ? `${this._base}/${type}/${id}` : `${this._base}/${type}`;\n\n if (options) {\n\n if (options.fields) {\n Object.keys(options.fields).forEach(field => {\n options[`fields[${field}]`] = options.fields[field];\n });\n delete options.fields;\n }\n\n params = Object.keys(options).map(key => {\n return key + \"=\" + encodeURIComponent(options[key]);\n }).sort();\n\n if (params.length) {\n url = `${url}?${params.join(\"&\")}`;\n }\n\n }\n\n return url;\n\n }\n\n}\n" + }, + { + "kind": "class", + "static": true, + "variation": null, + "name": "AjaxAdapter", + "memberof": "src/ajax-adapter.js", + "longname": "src/ajax-adapter.js~AjaxAdapter", + "access": null, + "export": true, + "importPath": "json-api-store/src/ajax-adapter.js", + "importStyle": "AjaxAdapter", + "description": null, + "lineNumber": 3, + "undocument": true, + "interface": false + }, + { + "kind": "constructor", + "static": false, + "variation": null, + "name": "constructor", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#constructor", + "access": null, + "description": null, + "lineNumber": 5, + "undocument": true, + "params": [ + { + "name": "options", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_base", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#_base", + "access": null, + "description": null, + "lineNumber": 6, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "create", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#create", + "access": null, + "description": null, + "lineNumber": 9, + "undocument": true, + "params": [ + { + "name": "store", + "types": [ + "*" + ] + }, + { + "name": "type", + "types": [ + "*" + ] + }, + { + "name": "partial", + "types": [ + "*" + ] + }, + { + "name": "options", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "destroy", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#destroy", + "access": null, + "description": null, + "lineNumber": 36, + "undocument": true, + "params": [ + { + "name": "store", + "types": [ + "*" + ] + }, + { + "name": "type", + "types": [ + "*" + ] + }, + { + "name": "id", + "types": [ + "*" + ] + }, + { + "name": "options", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "load", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#load", + "access": null, + "description": null, + "lineNumber": 59, + "undocument": true, + "params": [ + { + "name": "store", + "types": [ + "*" + ] + }, + { + "name": "type", + "types": [ + "*" + ] + }, + { + "name": "id", + "types": [ + "*" + ] + }, + { + "name": "options", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "update", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#update", + "access": null, + "description": null, + "lineNumber": 87, + "undocument": true, + "params": [ + { + "name": "store", + "types": [ + "*" + ] + }, + { + "name": "type", + "types": [ + "*" + ] + }, + { + "name": "id", + "types": [ + "*" + ] + }, + { + "name": "partial", + "types": [ + "*" + ] + }, + { + "name": "options", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "_getUrl", + "memberof": "src/ajax-adapter.js~AjaxAdapter", + "longname": "src/ajax-adapter.js~AjaxAdapter#_getUrl", + "access": null, + "description": null, + "lineNumber": 116, + "undocument": true, + "params": [ + { + "name": "type", + "types": [ + "*" + ] + }, + { + "name": "id", + "types": [ + "*" + ] + }, + { + "name": "options", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "file", + "static": true, + "variation": null, + "name": "src/ajax.js", + "memberof": null, + "longname": "src/ajax.js", + "access": null, + "description": null, + "lineNumber": 1, + "content": "import Rx from \"rx\";\n\n/**\n *\n * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM\n *\n * The original source file can be viewed here:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js\n *\n * Licensed under the Apache License, Version 2.0:\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Modifications from original:\n *\n * - extracted from \"Rx.DOM\" namespace\n * - minor eslinter cleanup (\"var\" to \"let\" etc)\n * - addition of \"auto\" responseType\n *\n */\n\nvar root = (typeof window !== \"undefined\" && window) || this;\n\n// Gets the proper XMLHttpRequest for support for older IE\nfunction getXMLHttpRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n } else {\n let progId;\n try {\n let progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n for(let i = 0; i < 3; i++) {\n try {\n progId = progIds[i];\n if (new root.ActiveXObject(progId)) {\n break;\n }\n } catch(e) { }\n }\n return new root.ActiveXObject(progId);\n } catch (e) {\n throw new Error('XMLHttpRequest is not supported by your browser');\n }\n }\n}\n\n// Get CORS support even for older IE\nfunction getCORSRequest() {\n var xhr = new root.XMLHttpRequest();\n if ('withCredentials' in xhr) {\n return xhr;\n } else if (!!root.XDomainRequest) {\n return new XDomainRequest();\n } else {\n throw new Error('CORS is not supported by your browser');\n }\n}\n\nfunction normalizeAjaxSuccessEvent(e, xhr, settings) {\n var response = ('response' in xhr) ? xhr.response : xhr.responseText;\n if (settings.responseType === 'auto') {\n try {\n response = JSON.parse(response);\n } catch (e) {}\n } else {\n response = settings.responseType === 'json' ? JSON.parse(response) : response;\n }\n return {\n response: response,\n status: xhr.status,\n responseType: xhr.responseType,\n xhr: xhr,\n originalEvent: e\n };\n}\n\nfunction normalizeAjaxErrorEvent(e, xhr, type) {\n return {\n type: type,\n status: xhr.status,\n xhr: xhr,\n originalEvent: e\n };\n}\n\n/**\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n*/\nexport default function (options) {\n var settings = {\n method: 'GET',\n crossDomain: false,\n async: true,\n headers: {},\n responseType: 'text',\n createXHR: function(){\n return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();\n },\n normalizeError: normalizeAjaxErrorEvent,\n normalizeSuccess: normalizeAjaxSuccessEvent\n };\n\n if(typeof options === 'string') {\n settings.url = options;\n } else {\n for(let prop in options) {\n if(hasOwnProperty.call(options, prop)) {\n settings[prop] = options[prop];\n }\n }\n }\n\n let normalizeError = settings.normalizeError;\n let normalizeSuccess = settings.normalizeSuccess;\n\n if (!settings.crossDomain && !settings.headers['X-Requested-With']) {\n settings.headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n settings.hasContent = settings.body !== undefined;\n\n return new Rx.AnonymousObservable(function (observer) {\n var isDone = false;\n var xhr;\n\n var processResponse = function(xhr, e){\n var status = xhr.status === 1223 ? 204 : xhr.status;\n if ((status >= 200 && status <= 300) || status === 0 || status === '') {\n observer.onNext(normalizeSuccess(e, xhr, settings));\n observer.onCompleted();\n } else {\n observer.onError(normalizeError(e, xhr, 'error'));\n }\n isDone = true;\n };\n\n try {\n xhr = settings.createXHR();;\n } catch (err) {\n observer.onError(err);\n }\n\n try {\n if (settings.user) {\n xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password);\n } else {\n xhr.open(settings.method, settings.url, settings.async);\n }\n\n let headers = settings.headers;\n for (let header in headers) {\n if (hasOwnProperty.call(headers, header)) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n\n if(!!xhr.upload || (!('withCredentials' in xhr) && !!root.XDomainRequest)) {\n xhr.onload = function(e) {\n if(settings.progressObserver) {\n settings.progressObserver.onNext(e);\n settings.progressObserver.onCompleted();\n }\n processResponse(xhr, e);\n };\n\n if(settings.progressObserver) {\n xhr.onprogress = function(e) {\n settings.progressObserver.onNext(e);\n };\n }\n\n xhr.onerror = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'error'));\n isDone = true;\n };\n\n xhr.onabort = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'abort'));\n isDone = true;\n };\n } else {\n\n xhr.onreadystatechange = function (e) {\n if (xhr.readyState === 4) {\n processResponse(xhr, e);\n }\n };\n }\n\n xhr.send(settings.hasContent && settings.body || null);\n } catch (e) {\n observer.onError(e);\n }\n\n return function () {\n if (!isDone && xhr.readyState !== 4) { xhr.abort(); }\n };\n });\n};\n" + }, + { + "kind": "variable", + "static": true, + "variation": null, + "name": "root", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~root", + "access": null, + "export": false, + "importPath": "json-api-store/src/ajax.js", + "importStyle": null, + "description": "Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:\n\nhttps://github.com/Reactive-Extensions/RxJS-DOM\n\nThe original source file can be viewed here:\n\nhttps://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js\n\nLicensed under the Apache License, Version 2.0:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nModifications from original:\n\n- extracted from \"Rx.DOM\" namespace\n- minor eslinter cleanup (\"var\" to \"let\" etc)\n- addition of \"auto\" responseType", + "lineNumber": 25, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "function", + "static": true, + "variation": null, + "name": "getXMLHttpRequest", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~getXMLHttpRequest", + "access": null, + "export": false, + "importPath": "json-api-store/src/ajax.js", + "importStyle": null, + "description": null, + "lineNumber": 28, + "undocument": true, + "params": [], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "function", + "static": true, + "variation": null, + "name": "getCORSRequest", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~getCORSRequest", + "access": null, + "export": false, + "importPath": "json-api-store/src/ajax.js", + "importStyle": null, + "description": null, + "lineNumber": 51, + "undocument": true, + "params": [], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "function", + "static": true, + "variation": null, + "name": "normalizeAjaxSuccessEvent", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~normalizeAjaxSuccessEvent", + "access": null, + "export": false, + "importPath": "json-api-store/src/ajax.js", + "importStyle": null, + "description": null, + "lineNumber": 62, + "undocument": true, + "params": [ + { + "name": "e", + "types": [ + "*" + ] + }, + { + "name": "xhr", + "types": [ + "*" + ] + }, + { + "name": "settings", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "function", + "static": true, + "variation": null, + "name": "normalizeAjaxErrorEvent", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~normalizeAjaxErrorEvent", + "access": null, + "export": false, + "importPath": "json-api-store/src/ajax.js", + "importStyle": null, + "description": null, + "lineNumber": 80, + "undocument": true, + "params": [ + { + "name": "e", + "types": [ + "*" + ] + }, + { + "name": "xhr", + "types": [ + "*" + ] + }, + { + "name": "type", + "types": [ + "*" + ] + } + ], + "return": { + "types": [ + "*" + ] + }, + "generator": false + }, + { + "kind": "function", + "static": true, + "variation": null, + "name": "ajax", + "memberof": "src/ajax.js", + "longname": "src/ajax.js~ajax", + "access": null, + "export": true, + "importPath": "json-api-store/src/ajax.js", + "importStyle": "ajax", + "description": "Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.", + "examples": [ + " source = ajax('/products');\n source = ajax({ url: 'products', method: 'GET' });" + ], + "lineNumber": 110, + "unknown": [ + { + "tagName": "@returns", + "tagValue": "{Observable} An observable sequence containing the XMLHttpRequest." + } + ], + "params": [ + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "settings", + "description": "Can be one of the following:\n\n A string of the URL to make the Ajax call.\n An object with the following properties\n - url: URL of the request\n - body: The body of the request\n - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n - async: Whether the request is async\n - headers: Optional headers\n - crossDomain: true if a cross domain request, else false\n - responseType: \"text\" (default), \"json\" or \"auto\"" + } + ], + "return": { + "nullable": null, + "types": [ + "Observable" + ], + "spread": false, + "description": "An observable sequence containing the XMLHttpRequest." + }, + "generator": false + }, + { + "kind": "file", + "static": true, + "variation": null, + "name": "src/store.js", + "memberof": null, + "longname": "src/store.js", + "access": null, + "description": null, + "lineNumber": 1, + "content": "import \"array.prototype.find\";\nimport Rx from \"rx\";\nimport AjaxAdapter from \"./ajax-adapter\";\n\nexport default class Store {\n\n /**\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n */\n static attr(name, options) {\n if (name && typeof name === 'object') {\n return Store.attr(null, name);\n } else {\n return {\n type: \"attr\",\n default: options && options.default,\n deserialize: function (data, key) {\n return data.attributes && data.attributes[name || key];\n },\n serialize: function (resource, data, key) {\n data.attributes[name || key] = resource[key];\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasOne(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasOne(null, name);\n } else {\n return {\n type: \"has-one\",\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return null;\n } else if (data.relationships[name].data) {\n return this.find(data.relationships[name].data.type, data.relationships[name].data.id);\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key] === null) {\n data.relationships[name || key] = null;\n } else if (resource[key]) {\n data.relationships[name || key] = {\n data: {\n type: resource[key].type,\n id: resource[key].id\n }\n };\n }\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasMany(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasMany(null, name);\n } else {\n return {\n type: \"has-many\",\n default: [],\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return [];\n } else if (data.relationships[name].data) {\n return data.relationships[name].data.map((c) => {\n return this.find(c.type, c.id);\n });\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key]) {\n data.relationships[name || key] = {\n data: resource[key].map(x => {\n return { type: x.type, id: x.id };\n })\n };\n }\n }\n };\n }\n }\n\n constructor(adapter) {\n\n this._adapter = adapter;\n this._data = {};\n this._subject = new Rx.Subject();\n this._subscriptions = {};\n this._types = {};\n\n /**\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

\n     * { name: string, type: string, id: string, resource: object }\n     * 

\n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n */\n this.observable = this._subject.asObservable();\n\n }\n\n /**\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n */\n add(object) {\n if (object) {\n if (object.type && object.id) {\n let name = this._data[object.type] && this._data[object.type][object.id] ? \"updated\" : \"added\";\n let resource = this.find(object.type, object.id);\n let definition = this._types[object.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n this._addField(object, resource, definition, fieldName);\n }\n });\n this._subject.onNext({\n name: name,\n type: object.type,\n id: object.id,\n resource: resource\n });\n } else {\n throw new TypeError(`The data must have a type and id`);\n }\n } else {\n throw new TypeError(`You must provide data to add`);\n }\n }\n\n /**\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n */\n convert(type, id, partial) {\n if (type && typeof type === \"object\") {\n return this.convert(type.type, type.id, type);\n } else if (id && typeof id === \"object\") {\n return this.convert(type, id.id, id);\n } else {\n let data = {\n type: type,\n attributes: {},\n relationships: {}\n };\n if (id) {\n data.id = id;\n }\n let definition = this._types[data.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n definition[fieldName].serialize(partial, data, fieldName);\n }\n });\n return data;\n }\n }\n\n /**\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n create(type, partial, options) {\n if (this._adapter) {\n return this._adapter.create(this, type, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n */\n define(names, definition) {\n names = (names.constructor === Array) ? names : [ names ];\n if (definition) {\n definition._names = names;\n names.forEach(name => {\n if (!this._types[name]) {\n this._types[name] = definition;\n } else {\n throw new Error(`The type '${name}' has already been defined.`);\n }\n });\n } else {\n throw new Error(`You must provide a definition for the type '${names[0]}'.`);\n }\n }\n\n /**\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n */\n destroy(type, id, options) {\n if (this._adapter) {\n return this._adapter.destroy(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n */\n find(type, id) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n if (id) {\n if (!this._data[type][id]) {\n this._data[type][id] = {\n _dependents: [],\n type: type,\n id: id\n };\n Object.keys(definition).forEach(key => {\n if (key[0] !== \"_\") {\n this._data[type][id][key] = definition[key].default;\n }\n });\n }\n return this._data[type][id];\n } else {\n // throw new TypeError(`You must provide an id`);\n /*eslint-disable*/\n console.warn([\n \"Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n return this.findAll(type);\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n */\n findAll(type) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n return Object.keys(this._data[type]).map(x => this._data[type][x]);\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n */\n load(type, id, options) {\n if (!id || typeof id === \"object\") {\n /*eslint-disable*/\n console.warn([\n \"Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n }\n if (this._adapter) {\n return this._adapter.load(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n */\n loadAll(type, options) {\n if (this._adapter) {\n return this._adapter.load(this, type, null, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n */\n off(event, type, id, callback) {\n /*eslint-disable*/\n console.warn([\n \"The `store.off()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.off.call(this, event, type, null, id, callback);\n } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || \"*\"]) {\n this._subscriptions[event][type][id || \"*\"].dispose();\n delete this._subscriptions[event][type][id || \"*\"];\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n */\n on(event, type, id, callback, context) {\n /*eslint-disable*/\n console.warn([\n \"The `store.on()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.on.call(this, event, type, null, id, callback);\n } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || \"*\"]) {\n let subscription = this._subject.filter(e => e.name === event);\n subscription = subscription.filter(e => this._types[type]._names.indexOf(e.type) !== -1);\n if (id) {\n subscription = subscription.filter(e => e.id === id);\n }\n subscription = subscription.map(e => this.find(e.type, e.id));\n this._subscriptions[event] = this._subscriptions[event] || {};\n if (!this._subscriptions[event][type]) {\n let obj = {};\n this._types[type]._names.forEach(type => {\n this._subscriptions[event][type] = obj;\n });\n }\n this._subscriptions[event][type][id || \"*\"] = subscription.subscribe(callback.bind(context));\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n */\n push(root) {\n if (root.data.constructor === Array) {\n root.data.forEach(x => this.add(x));\n } else {\n this.add(root.data);\n }\n if (root.included) {\n root.included.forEach(x => this.add(x));\n }\n }\n\n /**\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n */\n remove(type, id) {\n if (type) {\n if (this._types[type]) {\n if (id) {\n let resource = this._data[type] && this._data[type][id];\n if (resource) {\n this._remove(resource);\n this._subject.onNext({\n name: \"removed\",\n type: type,\n id: id,\n resource: null\n });\n }\n } else {\n Object.keys(this._data[type]).forEach(id => this.remove(type, id));\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type to remove`);\n }\n }\n\n /**\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n update(type, id, partial, options) {\n if (this._adapter) {\n return this._adapter.update(this, type, id, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n _addField(object, resource, definition, fieldName) {\n var field = definition[fieldName];\n var newValue = field.deserialize.call(this, object, fieldName);\n if (typeof newValue !== \"undefined\") {\n if (field.type === \"has-one\") {\n if (resource[fieldName]) {\n this._removeInverseRelationship(resource, fieldName, resource[fieldName], field);\n }\n if (newValue) {\n this._addInverseRelationship(resource, fieldName, newValue, field);\n }\n } else if (field.type === \"has-many\") {\n resource[fieldName].forEach(r => {\n if (resource[fieldName].indexOf(r) !== -1) {\n this._removeInverseRelationship(resource, fieldName, r, field);\n }\n });\n newValue.forEach(r => {\n this._addInverseRelationship(resource, fieldName, r, field);\n });\n }\n resource[fieldName] = newValue;\n }\n }\n\n _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var sourceDefinition = this._types[sourceResource.type];\n if (targetDefinition) {\n let targetFieldName = [ sourceField.inverse ].concat(sourceDefinition._names).find(x => targetDefinition[x]);\n let targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n targetResource[targetFieldName] = sourceResource;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n if (targetResource[targetFieldName].indexOf(sourceResource) === -1) {\n targetResource[targetFieldName].push(sourceResource);\n }\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n }\n\n _remove(resource) {\n resource._dependents.forEach(dependent => {\n let dependentResource = this._data[dependent.type][dependent.id];\n switch (this._types[dependent.type][dependent.fieldName].type) {\n case \"has-one\": {\n dependentResource[dependent.fieldName] = null;\n break;\n }\n case \"has-many\": {\n let index = dependentResource[dependent.fieldName].indexOf(resource);\n if (index !== -1) {\n dependentResource[dependent.fieldName].splice(index, 1);\n }\n break;\n }\n default: {\n break;\n }\n }\n // TODO: This only needs to be run once for each dependent.\n dependentResource._dependents = dependentResource._dependents.filter(d => {\n return !(d.type === resource.type && d.id === resource.id);\n });\n });\n delete this._data[resource.type][resource.id];\n }\n\n _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var targetFieldName = sourceField.inverse || sourceResource.type;\n var targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents = targetResource._dependents.filter(r => {\n return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName);\n });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = null;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = targetResource[targetFieldName].filter(r => {\n return r !== sourceResource;\n });\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n\n}\n\nStore.Rx = Rx;\nStore.AjaxAdapter = AjaxAdapter;\n" + }, + { + "kind": "class", + "static": true, + "variation": null, + "name": "Store", + "memberof": "src/store.js", + "longname": "src/store.js~Store", + "access": null, + "export": true, + "importPath": "json-api-store/src/store.js", + "importStyle": "Store", + "description": null, + "lineNumber": 5, + "undocument": true, + "interface": false + }, + { + "kind": "method", + "static": true, + "variation": null, + "name": "attr", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store.attr", + "access": null, + "description": "Creates a field definition for an attribute.", + "lineNumber": 16, + "since": "0.1.0", + "params": [ + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "name", + "description": "Name of the property to map this field from." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "An options object." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "options.default", + "description": "Default value for this field." + } + ], + "return": { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "description": "Field definition." + }, + "generator": false + }, + { + "kind": "method", + "static": true, + "variation": null, + "name": "hasOne", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store.hasOne", + "access": null, + "description": "Creates a field definition for an has-one relationship.", + "lineNumber": 42, + "since": "0.1.0", + "params": [ + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "name", + "description": "Name of the property to map this field from." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "An options object." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "options.inverse", + "description": "Name of the inverse relationship." + } + ], + "return": { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "description": "Field definition." + }, + "generator": false + }, + { + "kind": "method", + "static": true, + "variation": null, + "name": "hasMany", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store.hasMany", + "access": null, + "description": "Creates a field definition for an has-many relationship.", + "lineNumber": 84, + "since": "0.1.0", + "params": [ + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "name", + "description": "Name of the property to map this field from." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "An options object." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "options.inverse", + "description": "Name of the inverse relationship." + } + ], + "return": { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "description": "Field definition." + }, + "generator": false + }, + { + "kind": "constructor", + "static": false, + "variation": null, + "name": "constructor", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#constructor", + "access": null, + "description": null, + "lineNumber": 117, + "undocument": true, + "params": [ + { + "name": "adapter", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_adapter", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_adapter", + "access": null, + "description": null, + "lineNumber": 119, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_data", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_data", + "access": null, + "description": null, + "lineNumber": 120, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_subject", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_subject", + "access": null, + "description": null, + "lineNumber": 121, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_subscriptions", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_subscriptions", + "access": null, + "description": null, + "lineNumber": 122, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "_types", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_types", + "access": null, + "description": null, + "lineNumber": 123, + "undocument": true, + "type": { + "types": [ + "*" + ] + } + }, + { + "kind": "member", + "static": false, + "variation": null, + "name": "observable", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#observable", + "access": null, + "description": "An observable that will emit events when any resource in added, updated\nor removed. The object passed to listeners will be in this format:\n\n

\n{ name: string, type: string, id: string, resource: object }\n

\n\nYou can learn more about RxJS observables at the GitHub repo:\nhttps://github.com/Reactive-Extensions/RxJS", + "examples": [ + "let store = new Store();\n\nstore.observable.filter(e => e.name === \"added\").subscribe(event => {\n console.log(event.name); // \"added\"\n console.log(event.type); // \"products\"\n console.log(event.id); // \"1\"\n console.log(event.resource); // Map {...}\n});\n\nstore.observable.filter(e => e.name === \"updated\").subscribe(event => {\n console.log(event.name); // \"updated\"\n console.log(event.type); // \"products\"\n console.log(event.id); // \"1\"\n console.log(event.resource); // Map {...}\n});\n\nstore.observable.filter(e => e.name === \"removed\").subscribe(event => {\n console.log(event.name); // \"removed\"\n console.log(event.type); // \"products\"\n console.log(event.id); // \"1\"\n console.log(event.resource); // null\n});" + ], + "lineNumber": 163, + "since": "0.6.0", + "type": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": null + } + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "add", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#add", + "access": null, + "description": "Add an individual resource to the store. This is used internally by the\n`push()` method.", + "lineNumber": 175, + "since": "0.1.0", + "params": [ + { + "nullable": false, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "object", + "description": "A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects" + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "convert", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#convert", + "access": null, + "description": "Converts the given partial into a JSON API compliant representation.", + "lineNumber": 209, + "since": "0.5.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "type", + "description": "The type of the resource. This can be omitted if the partial includes a type property." + }, + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "id", + "description": "The id of the resource. This can be omitted if the partial includes an id property." + }, + { + "nullable": false, + "types": [ + "object" + ], + "spread": false, + "optional": false, + "name": "partial", + "description": "The data to convert." + } + ], + "return": { + "nullable": null, + "types": [ + "object" + ], + "spread": false, + "description": "JSON API version of the object." + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "create", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#create", + "access": null, + "description": "Attempts to create the resource through the adapter and adds it to the\nstore if successful.", + "examples": [ + "let adapter = new Store.AjaxAdapter();\nlet store = new Store(adpater);\nstore.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n console.log(product.title);\n});" + ], + "lineNumber": 250, + "since": "0.5.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of resource." + }, + { + "nullable": false, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "partial", + "description": "Data to create the resource with." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "Options to pass to the adapter." + } + ], + "return": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": "" + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "define", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#define", + "access": null, + "description": "Defines a type of resource.", + "lineNumber": 265, + "since": "0.2.0", + "params": [ + { + "nullable": false, + "types": [ + "string", + "string[]" + ], + "spread": false, + "optional": false, + "name": "names", + "description": "Name(s) of the resource." + }, + { + "nullable": false, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "definition", + "description": "The resource's definition." + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "destroy", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#destroy", + "access": null, + "description": "Attempts to delete the resource through the adapter and removes it from\nthe store if successful.", + "examples": [ + "let adapter = new Store.AjaxAdapter();\nlet store = new Store(adpater);\nstore.destroy(\"product\", \"1\").subscribe(() => {\n console.log(\"Destroyed!\");\n});" + ], + "lineNumber": 298, + "since": "0.5.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of resource." + }, + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "id", + "description": "ID of resource." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "Options to pass to the adapter." + } + ], + "return": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": "" + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "find", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#find", + "access": null, + "description": "Finds a resource by type and id.\n\nNOTE: If the resource hasn't been loaded via an add() or push() call it\nwill be automatically created when find is called.", + "lineNumber": 317, + "since": "0.1.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of the resource to find." + }, + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "id", + "description": "The id of the resource to find." + } + ], + "return": { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "description": "The resource." + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "findAll", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#findAll", + "access": null, + "description": "Finds all the resources of a given type.", + "lineNumber": 364, + "since": "0.7.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of the resource to find." + } + ], + "return": { + "nullable": null, + "types": [ + "Object[]" + ], + "spread": false, + "description": "An array of resources." + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "load", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#load", + "access": null, + "description": "Attempts to load the given resource through the adapter and adds it to the\nstore if successful.", + "examples": [ + "let adapter = new Store.AjaxAdapter();\nlet store = new Store(adpater);\nstore.load(\"products\", \"1\").subscribe((product) => {\n console.log(product.title);\n});" + ], + "lineNumber": 398, + "since": "0.5.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of resource." + }, + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "id", + "description": "ID of resource." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "Options to pass to the adapter." + } + ], + "return": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": "" + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "loadAll", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#loadAll", + "access": null, + "description": "Attempts to load all the resources of the given type through the adapter\nand adds them to the store if successful.", + "examples": [ + "let adapter = new Store.AjaxAdapter();\nlet store = new Store(adpater);\nstore.loadAll(\"products\").subscribe((products) => {\n console.log(products);\n});" + ], + "lineNumber": 430, + "since": "0.7.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of resource." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "Options to pass to the adapter." + } + ], + "return": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": "" + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "off", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#off", + "access": null, + "description": "Unregister an event listener that was registered with on().", + "lineNumber": 448, + "deprecated": "Use the store.observable property instead of this.", + "since": "0.4.0", + "params": [ + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "event", + "description": "Name of the event." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Name of resource to originally passed to on()." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "id", + "description": "ID of the resource to originally passed to on()." + }, + { + "nullable": null, + "types": [ + "function" + ], + "spread": false, + "optional": false, + "name": "callback", + "description": "Function originally passed to on()." + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "on", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#on", + "access": null, + "description": "Register an event listener: \"added\", \"updated\" or \"removed\".", + "lineNumber": 482, + "deprecated": "Use the store.observable property instead of this.", + "since": "0.4.0", + "params": [ + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "event", + "description": "Name of the event." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Name of resource to watch." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "id", + "description": "ID of the resource to watch." + }, + { + "nullable": null, + "types": [ + "function" + ], + "spread": false, + "optional": false, + "name": "callback", + "description": "Function to call when the event occurs." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "context", + "description": "Context in which to call the callback." + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "push", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#push", + "access": null, + "description": "Add a JSON API response to the store. This method can be used to handle a\nsuccessful GET or POST response from the server.", + "lineNumber": 525, + "since": "0.1.0", + "params": [ + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "root", + "description": "Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level" + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "remove", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#remove", + "access": null, + "description": "Remove a resource or collection of resources from the store.", + "lineNumber": 544, + "since": "0.1.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of the resource(s) to remove." + }, + { + "nullable": null, + "types": [ + "string" + ], + "spread": false, + "optional": true, + "name": "id", + "description": "The id of the resource to remove. If omitted all\n resources of the type will be removed." + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "update", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#update", + "access": null, + "description": "Attempts to update the resource through the adapter and updates it in the\nstore if successful.", + "examples": [ + "let adapter = new Store.AjaxAdapter();\nlet store = new Store(adpater);\nstore.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n console.log(product.title);\n});" + ], + "lineNumber": 587, + "since": "0.5.0", + "params": [ + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "type", + "description": "Type of resource." + }, + { + "nullable": false, + "types": [ + "string" + ], + "spread": false, + "optional": false, + "name": "id", + "description": "ID of resource." + }, + { + "nullable": false, + "types": [ + "Object" + ], + "spread": false, + "optional": false, + "name": "partial", + "description": "Data to update the resource with." + }, + { + "nullable": null, + "types": [ + "Object" + ], + "spread": false, + "optional": true, + "name": "options", + "description": "Options to pass to the adapter." + } + ], + "return": { + "nullable": null, + "types": [ + "Rx.Observable" + ], + "spread": false, + "description": "" + }, + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "_addField", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_addField", + "access": null, + "description": null, + "lineNumber": 595, + "undocument": true, + "params": [ + { + "name": "object", + "types": [ + "*" + ] + }, + { + "name": "resource", + "types": [ + "*" + ] + }, + { + "name": "definition", + "types": [ + "*" + ] + }, + { + "name": "fieldName", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "_addInverseRelationship", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_addInverseRelationship", + "access": null, + "description": null, + "lineNumber": 620, + "undocument": true, + "params": [ + { + "name": "sourceResource", + "types": [ + "*" + ] + }, + { + "name": "sourceFieldName", + "types": [ + "*" + ] + }, + { + "name": "targetResource", + "types": [ + "*" + ] + }, + { + "name": "sourceField", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "_remove", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_remove", + "access": null, + "description": null, + "lineNumber": 645, + "undocument": true, + "params": [ + { + "name": "resource", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "method", + "static": false, + "variation": null, + "name": "_removeInverseRelationship", + "memberof": "src/store.js~Store", + "longname": "src/store.js~Store#_removeInverseRelationship", + "access": null, + "description": null, + "lineNumber": 672, + "undocument": true, + "params": [ + { + "name": "sourceResource", + "types": [ + "*" + ] + }, + { + "name": "sourceFieldName", + "types": [ + "*" + ] + }, + { + "name": "targetResource", + "types": [ + "*" + ] + }, + { + "name": "sourceField", + "types": [ + "*" + ] + } + ], + "generator": false + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Infinity", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Infinity", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "NaN", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~NaN", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "undefined", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~undefined", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "null", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~null", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Object", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Object", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "object", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~object", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Function", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Function", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "function", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~function", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Boolean", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Boolean", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "boolean", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~boolean", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Symbol", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Symbol", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Error", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Error", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "EvalError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~EvalError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "InternalError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~InternalError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "RangeError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~RangeError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "ReferenceError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~ReferenceError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "SyntaxError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~SyntaxError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "TypeError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~TypeError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "URIError", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~URIError", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Number", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Number", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "number", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~number", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Date", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Date", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "String", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~String", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "string", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~string", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "RegExp", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~RegExp", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Int8Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Int8Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Uint8Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Uint8Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Uint8ClampedArray", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Uint8ClampedArray", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Int16Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Int16Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Uint16Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Uint16Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Int32Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Int32Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Uint32Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Uint32Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Float32Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Float32Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Float64Array", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Float64Array", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Map", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Map", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Set", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Set", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "WeakMap", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~WeakMap", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "WeakSet", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~WeakSet", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "ArrayBuffer", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~ArrayBuffer", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "DataView", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~DataView", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "JSON", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~JSON", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Promise", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Promise", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Generator", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Generator", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "GeneratorFunction", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~GeneratorFunction", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Reflect", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Reflect", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Proxy", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy", + "memberof": "BuiltinExternal/ECMAScriptExternal.js", + "longname": "BuiltinExternal/ECMAScriptExternal.js~Proxy", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "CanvasRenderingContext2D", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~CanvasRenderingContext2D", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "DocumentFragment", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~DocumentFragment", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Element", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/Element", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~Element", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Event", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/Event", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~Event", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "Node", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/Node", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~Node", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "NodeList", + "externalLink": "https://developer.mozilla.org/en-US/docs/Web/API/NodeList", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~NodeList", + "access": null, + "description": null, + "builtinExternal": true + }, + { + "kind": "external", + "static": true, + "variation": null, + "name": "XMLHttpRequest", + "externalLink": "https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest", + "memberof": "BuiltinExternal/WebAPIExternal.js", + "longname": "BuiltinExternal/WebAPIExternal.js~XMLHttpRequest", + "access": null, + "description": null, + "builtinExternal": true + } +] \ No newline at end of file diff --git a/docs/v0.7.0/file/src/ajax-adapter.js.html b/docs/v0.7.0/file/src/ajax-adapter.js.html new file mode 100644 index 0000000..e27501e --- /dev/null +++ b/docs/v0.7.0/file/src/ajax-adapter.js.html @@ -0,0 +1,217 @@ + + + + + + src/ajax-adapter.js | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

src/ajax-adapter.js

+
import ajax from "./ajax";
+
+export default class AjaxAdapter {
+
+  constructor(options) {
+    this._base = (options && options.base) || "";
+  };
+
+  create(store, type, partial, options) {
+
+    if (!store._types[type]) {
+      throw new Error(`Unknown type '${type}'`);
+    }
+
+    let source = ajax({
+      body: JSON.stringify({
+        data: store.convert(type, partial)
+      }),
+      crossDomain: true,
+      headers: {
+        "Content-Type": "application/vnd.api+json"
+      },
+      method: "POST",
+      responseType: "auto",
+      url: this._getUrl(type, null, options)
+    }).do(e => store.push(e.response))
+      .map(e => store.find(e.response.data.type, e.response.data.id))
+      .publish();
+
+    source.connect();
+
+    return source;
+
+  }
+
+  destroy(store, type, id, options) {
+
+    if (!store._types[type]) {
+      throw new Error(`Unknown type '${type}'`);
+    }
+
+    let source = ajax({
+      crossDomain: true,
+      headers: {
+        "Content-Type": "application/vnd.api+json"
+      },
+      method: "DELETE",
+      responseType: "auto",
+      url: this._getUrl(type, id, options)
+    }).do(() => store.remove(type, id))
+      .publish();
+
+    source.connect();
+
+    return source;
+
+  }
+
+  load(store, type, id, options) {
+
+    if (id && typeof id === "object") {
+      return this.load(store, type, null, id);
+    }
+
+    if (!store._types[type]) {
+      throw new Error(`Unknown type '${type}'`);
+    }
+
+    let source = ajax({
+      crossDomain: true,
+      headers: {
+        "Content-Type": "application/vnd.api+json"
+      },
+      method: "GET",
+      responseType: "auto",
+      url: this._getUrl(type, id, options)
+    }).do(e => store.push(e.response))
+      .map(() => id ? store.find(type, id) : store.findAll(type))
+      .publish();
+
+    source.connect();
+
+    return source;
+
+  }
+
+  update(store, type, id, partial, options) {
+
+    if (!store._types[type]) {
+      throw new Error(`Unknown type '${type}'`);
+    }
+
+    let data = store.convert(type, id, partial);
+
+    let source = ajax({
+      body: JSON.stringify({
+        data: data
+      }),
+      crossDomain: true,
+      headers: {
+        "Content-Type": "application/vnd.api+json"
+      },
+      method: "PATCH",
+      responseType: "auto",
+      url: this._getUrl(type, id, options)
+    }).do(() => store.add(data))
+      .map(() => store.find(type, id))
+      .publish();
+
+    source.connect();
+
+    return source;
+
+  }
+
+  _getUrl(type, id, options) {
+
+    let params = [];
+    let url = id ? `${this._base}/${type}/${id}` : `${this._base}/${type}`;
+
+    if (options) {
+
+      if (options.fields) {
+        Object.keys(options.fields).forEach(field => {
+          options[`fields[${field}]`] = options.fields[field];
+        });
+        delete options.fields;
+      }
+
+      params = Object.keys(options).map(key => {
+        return key + "=" + encodeURIComponent(options[key]);
+      }).sort();
+
+      if (params.length) {
+        url = `${url}?${params.join("&")}`;
+      }
+
+    }
+
+    return url;
+
+  }
+
+}
+
+ +
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/file/src/ajax.js.html b/docs/v0.7.0/file/src/ajax.js.html new file mode 100644 index 0000000..3e48f34 --- /dev/null +++ b/docs/v0.7.0/file/src/ajax.js.html @@ -0,0 +1,298 @@ + + + + + + src/ajax.js | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

src/ajax.js

+
import Rx from "rx";
+
+/**
+ *
+ * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:
+ *
+ * https://github.com/Reactive-Extensions/RxJS-DOM
+ *
+ * The original source file can be viewed here:
+ *
+ * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js
+ *
+ * Licensed under the Apache License, Version 2.0:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Modifications from original:
+ *
+ * - extracted from "Rx.DOM" namespace
+ * - minor eslinter cleanup ("var" to "let" etc)
+ * - addition of "auto" responseType
+ *
+ */
+
+var root = (typeof window !== "undefined" && window) || this;
+
+// Gets the proper XMLHttpRequest for support for older IE
+function getXMLHttpRequest() {
+  if (root.XMLHttpRequest) {
+    return new root.XMLHttpRequest();
+  } else {
+    let progId;
+    try {
+      let progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
+      for(let i = 0; i < 3; i++) {
+        try {
+          progId = progIds[i];
+          if (new root.ActiveXObject(progId)) {
+            break;
+          }
+        } catch(e) { }
+      }
+      return new root.ActiveXObject(progId);
+    } catch (e) {
+      throw new Error('XMLHttpRequest is not supported by your browser');
+    }
+  }
+}
+
+// Get CORS support even for older IE
+function getCORSRequest() {
+  var xhr = new root.XMLHttpRequest();
+  if ('withCredentials' in xhr) {
+    return xhr;
+  } else if (!!root.XDomainRequest) {
+    return new XDomainRequest();
+  } else {
+    throw new Error('CORS is not supported by your browser');
+  }
+}
+
+function normalizeAjaxSuccessEvent(e, xhr, settings) {
+  var response = ('response' in xhr) ? xhr.response : xhr.responseText;
+  if (settings.responseType === 'auto') {
+    try {
+      response = JSON.parse(response);
+    } catch (e) {}
+  } else {
+    response = settings.responseType === 'json' ? JSON.parse(response) : response;
+  }
+  return {
+    response: response,
+    status: xhr.status,
+    responseType: xhr.responseType,
+    xhr: xhr,
+    originalEvent: e
+  };
+}
+
+function normalizeAjaxErrorEvent(e, xhr, type) {
+  return {
+    type: type,
+    status: xhr.status,
+    xhr: xhr,
+    originalEvent: e
+  };
+}
+
+/**
+ * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.
+ *
+ * @example
+ *   source = ajax('/products');
+ *   source = ajax({ url: 'products', method: 'GET' });
+ *
+ * @param {Object} settings Can be one of the following:
+ *
+ *  A string of the URL to make the Ajax call.
+ *  An object with the following properties
+ *   - url: URL of the request
+ *   - body: The body of the request
+ *   - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE
+ *   - async: Whether the request is async
+ *   - headers: Optional headers
+ *   - crossDomain: true if a cross domain request, else false
+ *   - responseType: "text" (default), "json" or "auto"
+ *
+ * @returns {Observable} An observable sequence containing the XMLHttpRequest.
+*/
+export default function (options) {
+  var settings = {
+    method: 'GET',
+    crossDomain: false,
+    async: true,
+    headers: {},
+    responseType: 'text',
+    createXHR: function(){
+      return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
+    },
+    normalizeError: normalizeAjaxErrorEvent,
+    normalizeSuccess: normalizeAjaxSuccessEvent
+  };
+
+  if(typeof options === 'string') {
+    settings.url = options;
+  } else {
+    for(let prop in options) {
+      if(hasOwnProperty.call(options, prop)) {
+        settings[prop] = options[prop];
+      }
+    }
+  }
+
+  let normalizeError = settings.normalizeError;
+  let normalizeSuccess = settings.normalizeSuccess;
+
+  if (!settings.crossDomain && !settings.headers['X-Requested-With']) {
+    settings.headers['X-Requested-With'] = 'XMLHttpRequest';
+  }
+  settings.hasContent = settings.body !== undefined;
+
+  return new Rx.AnonymousObservable(function (observer) {
+    var isDone = false;
+    var xhr;
+
+    var processResponse = function(xhr, e){
+      var status = xhr.status === 1223 ? 204 : xhr.status;
+      if ((status >= 200 && status <= 300) || status === 0 || status === '') {
+        observer.onNext(normalizeSuccess(e, xhr, settings));
+        observer.onCompleted();
+      } else {
+        observer.onError(normalizeError(e, xhr, 'error'));
+      }
+      isDone = true;
+    };
+
+    try {
+      xhr = settings.createXHR();;
+    } catch (err) {
+      observer.onError(err);
+    }
+
+    try {
+      if (settings.user) {
+        xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password);
+      } else {
+        xhr.open(settings.method, settings.url, settings.async);
+      }
+
+      let headers = settings.headers;
+      for (let header in headers) {
+        if (hasOwnProperty.call(headers, header)) {
+          xhr.setRequestHeader(header, headers[header]);
+        }
+      }
+
+      if(!!xhr.upload || (!('withCredentials' in xhr) && !!root.XDomainRequest)) {
+        xhr.onload = function(e) {
+          if(settings.progressObserver) {
+            settings.progressObserver.onNext(e);
+            settings.progressObserver.onCompleted();
+          }
+          processResponse(xhr, e);
+        };
+
+        if(settings.progressObserver) {
+          xhr.onprogress = function(e) {
+            settings.progressObserver.onNext(e);
+          };
+        }
+
+        xhr.onerror = function(e) {
+          if (settings.progressObserver) {
+            settings.progressObserver.onError(e);
+          }
+          observer.onError(normalizeError(e, xhr, 'error'));
+          isDone = true;
+        };
+
+        xhr.onabort = function(e) {
+          if (settings.progressObserver) {
+            settings.progressObserver.onError(e);
+          }
+          observer.onError(normalizeError(e, xhr, 'abort'));
+          isDone = true;
+        };
+      } else {
+
+        xhr.onreadystatechange = function (e) {
+          if (xhr.readyState === 4) {
+            processResponse(xhr, e);
+          }
+        };
+      }
+
+      xhr.send(settings.hasContent && settings.body || null);
+    } catch (e) {
+      observer.onError(e);
+    }
+
+    return function () {
+      if (!isDone && xhr.readyState !== 4) { xhr.abort(); }
+    };
+  });
+};
+
+ +
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/file/src/store.js.html b/docs/v0.7.0/file/src/store.js.html new file mode 100644 index 0000000..17efaea --- /dev/null +++ b/docs/v0.7.0/file/src/store.js.html @@ -0,0 +1,776 @@ + + + + + + src/store.js | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

src/store.js

+
import "array.prototype.find";
+import Rx from "rx";
+import AjaxAdapter from "./ajax-adapter";
+
+export default class Store {
+
+  /**
+   * Creates a field definition for an attribute.
+   *
+   * @since 0.1.0
+   * @param {string} [name] - Name of the property to map this field from.
+   * @param {Object} [options] - An options object.
+   * @param {string} [options.default] - Default value for this field.
+   * @return {Object} - Field definition.
+   */
+  static attr(name, options) {
+    if (name && typeof name === 'object') {
+      return Store.attr(null, name);
+    } else {
+      return {
+        type: "attr",
+        default: options && options.default,
+        deserialize: function (data, key) {
+          return data.attributes && data.attributes[name || key];
+        },
+        serialize: function (resource, data, key) {
+          data.attributes[name || key] = resource[key];
+        }
+      };
+    }
+  }
+
+  /**
+   * Creates a field definition for an has-one relationship.
+   *
+   * @since 0.1.0
+   * @param {string} [name] - Name of the property to map this field from.
+   * @param {Object} [options] - An options object.
+   * @param {string} [options.inverse] - Name of the inverse relationship.
+   * @return {Object} - Field definition.
+   */
+  static hasOne(name, options) {
+    if (name && typeof name === 'object') {
+      return Store.hasOne(null, name);
+    } else {
+      return {
+        type: "has-one",
+        inverse: options && options.inverse,
+        deserialize: function (data, key) {
+          name = name || key;
+          if (data.relationships && data.relationships[name]) {
+            if (data.relationships[name].data === null) {
+              return null;
+            } else if (data.relationships[name].data) {
+              return this.find(data.relationships[name].data.type, data.relationships[name].data.id);
+            }
+          }
+        },
+        serialize: function serialize(resource, data, key) {
+          if (resource[key] === null) {
+            data.relationships[name || key] = null;
+          } else if (resource[key]) {
+            data.relationships[name || key] = {
+              data: {
+                type: resource[key].type,
+                id: resource[key].id
+              }
+            };
+          }
+        }
+      };
+    }
+  }
+
+  /**
+   * Creates a field definition for an has-many relationship.
+   *
+   * @since 0.1.0
+   * @param {string} [name] - Name of the property to map this field from.
+   * @param {Object} [options] - An options object.
+   * @param {string} [options.inverse] - Name of the inverse relationship.
+   * @return {Object} - Field definition.
+   */
+  static hasMany(name, options) {
+    if (name && typeof name === 'object') {
+      return Store.hasMany(null, name);
+    } else {
+      return {
+        type: "has-many",
+        default: [],
+        inverse: options && options.inverse,
+        deserialize: function (data, key) {
+          name = name || key;
+          if (data.relationships && data.relationships[name]) {
+            if (data.relationships[name].data === null) {
+              return [];
+            } else if (data.relationships[name].data) {
+              return data.relationships[name].data.map((c) => {
+                return this.find(c.type, c.id);
+              });
+            }
+          }
+        },
+        serialize: function serialize(resource, data, key) {
+          if (resource[key]) {
+            data.relationships[name || key] = {
+              data: resource[key].map(x => {
+                return { type: x.type, id: x.id };
+              })
+            };
+          }
+        }
+      };
+    }
+  }
+
+  constructor(adapter) {
+
+    this._adapter = adapter;
+    this._data = {};
+    this._subject = new Rx.Subject();
+    this._subscriptions = {};
+    this._types = {};
+
+    /**
+     * An observable that will emit events when any resource in added, updated
+     * or removed. The object passed to listeners will be in this format:
+     *
+     * <p><pre class="source-code">
+     * { name: string, type: string, id: string, resource: object }
+     * </pre></p>
+     *
+     * You can learn more about RxJS observables at the GitHub repo:
+     * https://github.com/Reactive-Extensions/RxJS
+     *
+     * @type {Rx.Observable}
+     * @since 0.6.0
+     *
+     * @example
+     * let store = new Store();
+     *
+     * store.observable.filter(e => e.name === "added").subscribe(event => {
+     *   console.log(event.name); // "added"
+     *   console.log(event.type); // "products"
+     *   console.log(event.id); // "1"
+     *   console.log(event.resource); // Map {...}
+     * });
+     *
+     * store.observable.filter(e => e.name === "updated").subscribe(event => {
+     *   console.log(event.name); // "updated"
+     *   console.log(event.type); // "products"
+     *   console.log(event.id); // "1"
+     *   console.log(event.resource); // Map {...}
+     * });
+     *
+     * store.observable.filter(e => e.name === "removed").subscribe(event => {
+     *   console.log(event.name); // "removed"
+     *   console.log(event.type); // "products"
+     *   console.log(event.id); // "1"
+     *   console.log(event.resource); // null
+     * });
+     */
+    this.observable = this._subject.asObservable();
+
+  }
+
+  /**
+   * Add an individual resource to the store. This is used internally by the
+   * `push()` method.
+   *
+   * @since 0.1.0
+   * @param {!Object} object - A JSON API Resource Object to be added. See:
+            http://jsonapi.org/format/#document-resource-objects
+   */
+  add(object) {
+    if (object) {
+      if (object.type && object.id) {
+        let name = this._data[object.type] && this._data[object.type][object.id] ? "updated" : "added";
+        let resource = this.find(object.type, object.id);
+        let definition = this._types[object.type];
+        Object.keys(definition).forEach(fieldName => {
+          if (fieldName[0] !== "_") {
+            this._addField(object, resource, definition, fieldName);
+          }
+        });
+        this._subject.onNext({
+          name: name,
+          type: object.type,
+          id: object.id,
+          resource: resource
+        });
+      } else {
+        throw new TypeError(`The data must have a type and id`);
+      }
+    } else {
+      throw new TypeError(`You must provide data to add`);
+    }
+  }
+
+  /**
+   * Converts the given partial into a JSON API compliant representation.
+   *
+   * @since 0.5.0
+   * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.
+   * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.
+   * @param {!object} partial - The data to convert.
+   * @return {object} - JSON API version of the object.
+   */
+  convert(type, id, partial) {
+    if (type && typeof type === "object") {
+      return this.convert(type.type, type.id, type);
+    } else if (id && typeof id === "object") {
+      return this.convert(type, id.id, id);
+    } else {
+      let data = {
+        type: type,
+        attributes: {},
+        relationships: {}
+      };
+      if (id) {
+        data.id = id;
+      }
+      let definition = this._types[data.type];
+      Object.keys(definition).forEach(fieldName => {
+        if (fieldName[0] !== "_") {
+          definition[fieldName].serialize(partial, data, fieldName);
+        }
+      });
+      return data;
+    }
+  }
+
+  /**
+   * Attempts to create the resource through the adapter and adds it to  the
+   * store if successful.
+   *
+   * @since 0.5.0
+   * @param {!string} type - Type of resource.
+   * @param {!Object} partial - Data to create the resource with.
+   * @param {Object} [options] - Options to pass to the adapter.
+   * @return {Rx.Observable}
+   *
+   * @example
+   * let adapter = new Store.AjaxAdapter();
+   * let store = new Store(adpater);
+   * store.create("product", { title: "A Book" }).subscribe((product) => {
+   *   console.log(product.title);
+   * });
+   */
+  create(type, partial, options) {
+    if (this._adapter) {
+      return this._adapter.create(this, type, partial, options);
+    } else {
+      throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`");
+    }
+  }
+
+  /**
+   * Defines a type of resource.
+   *
+   * @since 0.2.0
+   * @param {!string|string[]} names - Name(s) of the resource.
+   * @param {!Object} definition - The resource's definition.
+   */
+  define(names, definition) {
+    names = (names.constructor === Array) ? names : [ names ];
+    if (definition) {
+      definition._names = names;
+      names.forEach(name => {
+        if (!this._types[name]) {
+          this._types[name] = definition;
+        } else {
+          throw new Error(`The type '${name}' has already been defined.`);
+        }
+      });
+    } else {
+      throw new Error(`You must provide a definition for the type '${names[0]}'.`);
+    }
+  }
+
+  /**
+   * Attempts to delete the resource through the adapter and removes it from
+   * the store if successful.
+   *
+   * @since 0.5.0
+   * @param {!string} type - Type of resource.
+   * @param {!string} id - ID of resource.
+   * @param {Object} [options] - Options to pass to the adapter.
+   * @return {Rx.Observable}
+   *
+   * @example
+   * let adapter = new Store.AjaxAdapter();
+   * let store = new Store(adpater);
+   * store.destroy("product", "1").subscribe(() => {
+   *   console.log("Destroyed!");
+   * });
+   */
+  destroy(type, id, options) {
+    if (this._adapter) {
+      return this._adapter.destroy(this, type, id, options);
+    } else {
+      throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`");
+    }
+  }
+
+  /**
+   * Finds a resource by type and id.
+   *
+   * NOTE: If the resource hasn't been loaded via an add() or push() call it
+   * will be automatically created when find is called.
+   *
+   * @since 0.1.0
+   * @param {!string} type - Type of the resource to find.
+   * @param {!string} id - The id of the resource to find.
+   * @return {Object} - The resource.
+   */
+  find(type, id) {
+    if (type) {
+      let definition = this._types[type];
+      if (definition) {
+        if (!this._data[type]) {
+          let collection = {};
+          definition._names.forEach(t => this._data[t] = collection);
+        }
+        if (id) {
+          if (!this._data[type][id]) {
+            this._data[type][id] = {
+              _dependents: [],
+              type: type,
+              id: id
+            };
+            Object.keys(definition).forEach(key => {
+              if (key[0] !== "_") {
+                this._data[type][id][key] = definition[key].default;
+              }
+            });
+          }
+          return this._data[type][id];
+        } else {
+          // throw new TypeError(`You must provide an id`);
+          /*eslint-disable*/
+          console.warn([
+            "Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.",
+            "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"
+          ].join("\n"));
+          /*eslint-enable*/
+          return this.findAll(type);
+        }
+      } else {
+        throw new TypeError(`Unknown type '${type}'`);
+      }
+    } else {
+      throw new TypeError(`You must provide a type`);
+    }
+  }
+
+  /**
+   * Finds all the resources of a given type.
+   *
+   * @since 0.7.0
+   * @param {!string} type - Type of the resource to find.
+   * @return {Object[]} - An array of resources.
+   */
+  findAll(type) {
+    if (type) {
+      let definition = this._types[type];
+      if (definition) {
+        if (!this._data[type]) {
+          let collection = {};
+          definition._names.forEach(t => this._data[t] = collection);
+        }
+        return Object.keys(this._data[type]).map(x => this._data[type][x]);
+      } else {
+        throw new TypeError(`Unknown type '${type}'`);
+      }
+    } else {
+      throw new TypeError(`You must provide a type`);
+    }
+  }
+
+  /**
+   * Attempts to load the given resource through the adapter and adds it to the
+   * store if successful.
+   *
+   * @since 0.5.0
+   * @param {!string} type - Type of resource.
+   * @param {!string} id - ID of resource.
+   * @param {Object} [options] - Options to pass to the adapter.
+   * @return {Rx.Observable}
+   *
+   * @example
+   * let adapter = new Store.AjaxAdapter();
+   * let store = new Store(adpater);
+   * store.load("products", "1").subscribe((product) => {
+   *   console.log(product.title);
+   * });
+   */
+  load(type, id, options) {
+    if (!id || typeof id === "object") {
+      /*eslint-disable*/
+      console.warn([
+        "Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.",
+        "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"
+      ].join("\n"));
+      /*eslint-enable*/
+    }
+    if (this._adapter) {
+      return this._adapter.load(this, type, id, options);
+    } else {
+      throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`");
+    }
+  }
+
+  /**
+   * Attempts to load all the resources of the given type through the adapter
+   * and adds them to the store if successful.
+   *
+   * @since 0.7.0
+   * @param {!string} type - Type of resource.
+   * @param {Object} [options] - Options to pass to the adapter.
+   * @return {Rx.Observable}
+   *
+   * @example
+   * let adapter = new Store.AjaxAdapter();
+   * let store = new Store(adpater);
+   * store.loadAll("products").subscribe((products) => {
+   *   console.log(products);
+   * });
+   */
+  loadAll(type, options) {
+    if (this._adapter) {
+      return this._adapter.load(this, type, null, options);
+    } else {
+      throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`");
+    }
+  }
+
+  /**
+   * Unregister an event listener that was registered with on().
+   *
+   * @deprecated Use the <code>store.observable</code> property instead of this.
+   * @since 0.4.0
+   * @param {string} event - Name of the event.
+   * @param {string} type - Name of resource to originally passed to on().
+   * @param {string} [id] - ID of the resource to originally passed to on().
+   * @param {function} callback - Function originally passed to on().
+   */
+  off(event, type, id, callback) {
+    /*eslint-disable*/
+    console.warn([
+      "The `store.off()` method has been deprecated in favour of `store.observable`.",
+      "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"
+    ].join("\n"));
+    /*eslint-enable*/
+    if (event === "added" || event === "updated" || event === "removed") {
+      if (this._types[type]) {
+        if (id && ({}).toString.call(id) === '[object Function]') {
+          this.off.call(this, event, type, null, id, callback);
+        } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || "*"]) {
+          this._subscriptions[event][type][id || "*"].dispose();
+          delete this._subscriptions[event][type][id || "*"];
+        }
+      } else {
+        throw new Error(`Unknown type '${type}'`);
+      }
+    } else {
+      throw new Error(`Unknown event '${event}'`);
+    }
+  }
+
+  /**
+   * Register an event listener: "added", "updated" or "removed".
+   *
+   * @deprecated Use the <code>store.observable</code> property instead of this.
+   * @since 0.4.0
+   * @param {string} event - Name of the event.
+   * @param {string} type - Name of resource to watch.
+   * @param {string} [id] - ID of the resource to watch.
+   * @param {function} callback - Function to call when the event occurs.
+   * @param {Object} [context] - Context in which to call the callback.
+   */
+  on(event, type, id, callback, context) {
+    /*eslint-disable*/
+    console.warn([
+      "The `store.on()` method has been deprecated in favour of `store.observable`.",
+      "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"
+    ].join("\n"));
+    /*eslint-enable*/
+    if (event === "added" || event === "updated" || event === "removed") {
+      if (this._types[type]) {
+        if (id && ({}).toString.call(id) === '[object Function]') {
+          this.on.call(this, event, type, null, id, callback);
+        } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || "*"]) {
+          let subscription = this._subject.filter(e => e.name === event);
+          subscription = subscription.filter(e => this._types[type]._names.indexOf(e.type) !== -1);
+          if (id) {
+            subscription = subscription.filter(e => e.id === id);
+          }
+          subscription = subscription.map(e => this.find(e.type, e.id));
+          this._subscriptions[event] = this._subscriptions[event] || {};
+          if (!this._subscriptions[event][type]) {
+            let obj = {};
+            this._types[type]._names.forEach(type => {
+              this._subscriptions[event][type] = obj;
+            });
+          }
+          this._subscriptions[event][type][id || "*"] = subscription.subscribe(callback.bind(context));
+        }
+      } else {
+        throw new Error(`Unknown type '${type}'`);
+      }
+    } else {
+      throw new Error(`Unknown event '${event}'`);
+    }
+  }
+
+  /**
+   * Add a JSON API response to the store. This method can be used to handle a
+   * successful GET or POST response from the server.
+   *
+   * @since 0.1.0
+   * @param {Object} root - Top Level Object to push. See:
+                            http://jsonapi.org/format/#document-top-level
+   */
+  push(root) {
+    if (root.data.constructor === Array) {
+      root.data.forEach(x => this.add(x));
+    } else {
+      this.add(root.data);
+    }
+    if (root.included) {
+      root.included.forEach(x => this.add(x));
+    }
+  }
+
+  /**
+   * Remove a resource or collection of resources from the store.
+   *
+   * @since 0.1.0
+   * @param {!string} type - Type of the resource(s) to remove.
+   * @param {string} [id] - The id of the resource to remove. If omitted all
+   *                        resources of the type will be removed.
+   */
+  remove(type, id) {
+    if (type) {
+      if (this._types[type]) {
+        if (id) {
+          let resource = this._data[type] && this._data[type][id];
+          if (resource) {
+            this._remove(resource);
+            this._subject.onNext({
+              name: "removed",
+              type: type,
+              id: id,
+              resource: null
+            });
+          }
+        } else {
+          Object.keys(this._data[type]).forEach(id => this.remove(type, id));
+        }
+      } else {
+        throw new TypeError(`Unknown type '${type}'`);
+      }
+    } else {
+      throw new TypeError(`You must provide a type to remove`);
+    }
+  }
+
+  /**
+   * Attempts to update the resource through the adapter and updates it in  the
+   * store if successful.
+   *
+   * @since 0.5.0
+   * @param {!string} type - Type of resource.
+   * @param {!string} id - ID of resource.
+   * @param {!Object} partial - Data to update the resource with.
+   * @param {Object} [options] - Options to pass to the adapter.
+   * @return {Rx.Observable}
+   *
+   * @example
+   * let adapter = new Store.AjaxAdapter();
+   * let store = new Store(adpater);
+   * store.update("product", "1", { title: "foo" }).subscribe((product) => {
+   *   console.log(product.title);
+   * });
+   */
+  update(type, id, partial, options) {
+    if (this._adapter) {
+      return this._adapter.update(this, type, id, partial, options);
+    } else {
+      throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`");
+    }
+  }
+
+  _addField(object, resource, definition, fieldName) {
+    var field = definition[fieldName];
+    var newValue = field.deserialize.call(this, object, fieldName);
+    if (typeof newValue !== "undefined") {
+      if (field.type === "has-one") {
+        if (resource[fieldName]) {
+          this._removeInverseRelationship(resource, fieldName, resource[fieldName], field);
+        }
+        if (newValue) {
+          this._addInverseRelationship(resource, fieldName, newValue, field);
+        }
+      } else if (field.type === "has-many") {
+        resource[fieldName].forEach(r => {
+          if (resource[fieldName].indexOf(r) !== -1) {
+            this._removeInverseRelationship(resource, fieldName, r, field);
+          }
+        });
+        newValue.forEach(r => {
+          this._addInverseRelationship(resource, fieldName, r, field);
+        });
+      }
+      resource[fieldName] = newValue;
+    }
+  }
+
+  _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {
+    var targetDefinition = this._types[targetResource.type];
+    var sourceDefinition = this._types[sourceResource.type];
+    if (targetDefinition) {
+      let targetFieldName = [ sourceField.inverse ].concat(sourceDefinition._names).find(x => targetDefinition[x]);
+      let targetField = targetDefinition && targetDefinition[targetFieldName];
+      targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName });
+      if (targetField) {
+        if (targetField.type === "has-one") {
+          sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });
+          targetResource[targetFieldName] = sourceResource;
+        } else if (targetField.type === "has-many") {
+          sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });
+          if (targetResource[targetFieldName].indexOf(sourceResource) === -1) {
+            targetResource[targetFieldName].push(sourceResource);
+          }
+        } else if (targetField.type === "attr") {
+          throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);
+        }
+      } else if (sourceField.inverse) {
+        throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);
+      }
+    }
+  }
+
+  _remove(resource) {
+    resource._dependents.forEach(dependent => {
+      let dependentResource = this._data[dependent.type][dependent.id];
+      switch (this._types[dependent.type][dependent.fieldName].type) {
+        case "has-one": {
+          dependentResource[dependent.fieldName] = null;
+          break;
+        }
+        case "has-many": {
+          let index = dependentResource[dependent.fieldName].indexOf(resource);
+          if (index !== -1) {
+            dependentResource[dependent.fieldName].splice(index, 1);
+          }
+          break;
+        }
+        default: {
+          break;
+        }
+      }
+      // TODO: This only needs to be run once for each dependent.
+      dependentResource._dependents = dependentResource._dependents.filter(d => {
+        return !(d.type === resource.type && d.id === resource.id);
+      });
+    });
+    delete this._data[resource.type][resource.id];
+  }
+
+  _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {
+    var targetDefinition = this._types[targetResource.type];
+    var targetFieldName = sourceField.inverse || sourceResource.type;
+    var targetField = targetDefinition && targetDefinition[targetFieldName];
+    targetResource._dependents = targetResource._dependents.filter(r => {
+      return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName);
+    });
+    if (targetField) {
+      if (targetField.type === "has-one") {
+        sourceResource._dependents = sourceResource._dependents.filter(r => {
+          return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);
+        });
+        targetResource[targetFieldName] = null;
+      } else if (targetField.type === "has-many") {
+        sourceResource._dependents = sourceResource._dependents.filter(r => {
+          return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);
+        });
+        targetResource[targetFieldName] = targetResource[targetFieldName].filter(r => {
+          return r !== sourceResource;
+        });
+      } else if (targetField.type === "attr") {
+        throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);
+      }
+    } else if (sourceField.inverse) {
+      throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);
+    }
+  }
+
+}
+
+Store.Rx = Rx;
+Store.AjaxAdapter = AjaxAdapter;
+
+ +
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/function/index.html b/docs/v0.7.0/function/index.html new file mode 100644 index 0000000..5b77cab --- /dev/null +++ b/docs/v0.7.0/function/index.html @@ -0,0 +1,194 @@ + + + + + + Function | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

Function

+
+ + + + + + + + + +
Static Public Summary
+ public + + + + + +
+

+ ajax(settings: Object): Observable +

+
+
+ + +

Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

+
+
+ + +
+
+

Static Public

+ +
+

+ public + + + + + ajax(settings: Object): Observable + + + + source + +

+ +
import ajax from 'json-api-store/src/ajax.js'
+ + +

Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

+
+ + + +
+

Params:

+ + + + + + + + + + + + + +
NameTypeAttributeDescription
settingsObject

Can be one of the following:

+

A string of the URL to make the Ajax call. + An object with the following properties

+
    +
  • url: URL of the request
  • +
  • body: The body of the request
  • +
  • method: Method of the request, such as GET, POST, PUT, PATCH, DELETE
  • +
  • async: Whether the request is async
  • +
  • headers: Optional headers
  • +
  • crossDomain: true if a cross domain request, else false
  • +
  • responseType: "text" (default), "json" or "auto"
  • +
+
+
+
+ +
+

Return:

+ + + + + +
Observable

An observable sequence containing the XMLHttpRequest.

+
+
+
+
+ + + + + + + +
+

Example:

+ +
+ +
  source = ajax('/products');
+  source = ajax({ url: 'products', method: 'GET' });
+
+
+ + + + + +
+
+
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/identifiers.html b/docs/v0.7.0/identifiers.html new file mode 100644 index 0000000..2b5ab21 --- /dev/null +++ b/docs/v0.7.0/identifiers.html @@ -0,0 +1,163 @@ + + + + + + Index | API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

Identifier

+

Class Summary

+ + + + + + + + + + + + + + +
Static Public Class Summary
+ public + + + + + +
+

+ AjaxAdapter +

+
+
+ + + +
+
+ + +
+ public + + + + + +
+

+ Store +

+
+
+ + + +
+
+ + +
+
+ +

Function Summary

+ + + + + + + + + +
Static Public Function Summary
+ public + + + + + +
+

+ ajax(settings: Object): Observable +

+
+
+ + +

Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.

+
+
+ + +
+
+ + +
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/image/badge.svg b/docs/v0.7.0/image/badge.svg new file mode 100644 index 0000000..324db4c --- /dev/null +++ b/docs/v0.7.0/image/badge.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + document + document + @ratio@ + @ratio@ + + diff --git a/docs/v0.7.0/image/github.png b/docs/v0.7.0/image/github.png new file mode 100644 index 0000000000000000000000000000000000000000..ea6ff545a246caa64074ba809bbc86fcb8589071 GIT binary patch literal 4268 zcmeAS@N?(olHy`uVBq!ia0y~yV5k6L4mJh`2Fnz)OAHJQk|nMYCBgY=CFO}lsSJ)O z`AMk?p1FzXsX?iUDV2pMQ*9U+m{l@EB1$5BeXNr6bM+EIYV;~{3m8Da#=fE;F*!T6 zL?J0PJu}Z%>HY5gN(z}Nwo2iqz6QPp&Z!xh9#uuD!Bu`C$yM3OmMKd1b_zBXRu#Dg zxv3?I3Kh9IdBs*0wn|`gt@4VkK*IV;3ScEA*|tg$M@9GsC^+XAr7D=}8S5q+7#b>= znduptn3|ax>L?f)7#ist80j0B=^C0?nVMM{nJYknlAVH0QA(Oskc%7CuA-DQTcwPW zk^(Dz{qpj1y>er{{GxPyLrY6bkQqisxCgqow*eWSOjjhNnfE$}v3=O8_{9OHt!~%UoJp+)JAb!m)@b$&7G&dKny0|1L z72#g21{a4^7NqJ2r55Lx7A2}6#Z40`Tsp!z zltV&xG&#&-oVK7NaS>zC6t`)YIXL_}k9Az?X8cr@J z4p(R_U}}ol`}hBw(!Aes=Pb+L7k|4|J->LL>E^WJnbrG`|9bn^_WJgHE}@}QHwNvP zq|xHFCFkBEQ@Obdjwazhn~j zr!%JWZ)KHpUU=PU_wg+=v=?k%=+E>`j{Ao64ZDh-mN?ej3F^8J4PSh|(9T%Z$XcUx zoFZ^EM&sdfk$Sk(u@Pfw+-*V@)eae4v_fk!`m~6s?F`$x=YE;JKV|2&3Cfoi`Le!PwTGE!N6i0Po~qu| znSt{f`xu@yS29Z!SU)gizjgA{XBFuM%#1(dH?s5WxNmfBm0$4bv(w)QpXhG(*`kuL zqxoY*!oxJxEjO7qCME>wJM2*YFoSb#e&o|5k6#^Iy40Fa)^3ZMSp(yDHJfEKnF=1v{O#3jOlU{vOcUt$6p(x{9ek zT26~6?P`_oyzuODYvVZuZrOilEAGrncI0=k%vhjrw4Il`R=DYF>g8R`QL~b3cYgWJ z$QG;3oWCgb^n2dPzvJGC=DlZIa=WdWTe|v!8blTt7YTy6H@QFn&z5T|`Zn?y9_wKlA`jY;xr+DLvQs{8Q>VsMhBmvd-*W<-#4Dr@t`I+;`^t$MSBbQ}uf` zoYaUjW0NyE_%q;VRJ5pndwSr+oklx$D?3Ntn|$#0?hA7-e0Q~+VXad8IPm9Pw@cTH zFC0Fcxz=@mnvDMW%?p;NzhG8(eDC_RFD0@0I`gJf<;2f>*ZfW>%>C=`z?$?qWLEd) znK~P6xNN0&g+#H`3BGRn)-mDdKg)o1H)3<-R zJHGO6J;$>`;da1;%ghEgr{_3C#kbs)Q@$^h8M=={VeQ+BEu1Sd<}{UhJ&&2cvQth> zA?DON1)+&))?b2OGwu)g&nr;Co@jdbvx4`mi66N>J8So`)E=9`ysoXz?V=6GwR=S; zq!m|Z|7F-0x=`Sn{;&UwHb$9W6HcgkRoi<`>(a|<*;}`SdVH2i41X^Er+96n23JAR z#>t}6TSC14E$eAe%{esHYi4oP<)d|bj^{3T`pCpVV%guOcFDUNIBRv|L#0gw+Ad%((?Nu5c;x-Z|$-BdfweCf86@|Hu-=PZ7B_HM$?Ycn<$L{ExSkV@aV zW9iK)iQ<#v3-lL@nfiCtI#%a{7EZ}aXL`3_%8#Vex<%2Y3J;8y9tn@in|OPb54S;V^7hEQ zd9B-4U17T8rTFlzL_%%e&dPaug75rVmqZH|7`L|AZ@f`+nz7Ynb|&M$6Q4fmvTtR` z{^5Cb^PZaSW6KVoWLYDqx_sl)r_m;Nx}>LRh;F;`>67mA43$-^H;$d_>O8xJVf!a( z-eogf{q(k7V2WA!#cbQQ7dG6vOCPR_iCko{)beoAXPviGF8y8MlG(I2@`aPg+WvOJz=9Je{`Sb?DVq49=j!_2LHAQ zb+-Ll7{sRYBcR)8El+66?*5#~-cwhLY8zTfx}5RqT|fPH^J3A>7IJ1rnLn0xNq(Gg zwO{9w@RO>=)xUolnLkiHHFc)S#szCho;#nIq4?+7;zf761@vCqoNp<9d18(*!{f2 zyz0WYrYzlH^N@SlAJZjPn-__$_`#B~mx(Q!|I`N0Vo`CEtkXK*`L{CuKWp*4>yW^+ zztJz8Bp%*jYPs#YZ2tDyAM(;|)p&xLk1gMO{cc^micH0tHphP~xzP*>=NtYVwb1rV z>^FUOg>U9WkH7=oA1bas@8WdN^_g*zX-DN*-3`AY_cgvz``6R7?u_z^EstG~bzV6g z&=go|y*F`txG~c-rq5ivKijIDxb5t>wsw+0{e7AKzzc?I)%EdhaaCS%^Gu7vo!9&d ze|+clkp;;;6Xdr}ei*&sV&&HV#uF2b-kJV7oj>8j`>elzl_EW7YQ{hLX(=}E`oX7i{d^{xlb;>UDPHP9_ znv_H0NgPIzkG-1jac%byKKAU}qXz9`dXJRK=P^3J(^7uurgqPW$!x~Nyj7F@Zn&)f zJdtzzzG(+E-mSj&g6~Ln=1p@Rql4|)Qj1x`(?sv6%ZnH9c)e8HN3%3G_qeFU{)ZDP z?1SPZ(lfih{5rkFeu5+GmhNx78AdZ6b<16kKL2~O_L(g=CcNZbXYlX6-jk@;_wSao zZ;)>*TG>~79eTd)w?g_{O?j^1rxGnTh&6qeH(dc0T^-{#a($ET+F_+-J$m+%M7?_*m%5 z9G)$xB^u*##Gf!Rl^)vP5eEZbPyiaXAW1j7feKu$7+$Z)1eb$1%-*cxr z{ZC_QyDKGpV6jTn9`%oVdt23}oldNqd$W2`!0Ag%+;?0~S(u_z+xem1w`X(xE_wTU zrTyW0+-mxpR`TCobz(nH|9=;ra;v82Cc-PfPy-_vj0c#Nxd(@*~Y zm{poru}0vATO89iHgmU>JI#WJW7W5ruWIk~ zWnYbNKk4@LyI3K9A@#z1my`#mI38}Ay(`G=^FEbqf98*UF$sSxC;k;`tvT^z;evg4 zEN{tQT%h&z)PgYKxqm)Q^PK-8-855+$277m>yz&y4dYyEmFOLojAAGB9~jy7f zL~ullakwP}Y`v*w{r>N_W4qZs@0dR*mJEnhkBwIldT}sEq$j%jzF}Yc(q(f(8VWKu z+c_TMmD%91tUtv3#q48U;SUc5ZZBC~yOBv}LZw;TY_9(3vQnzuho3bb62YD*+f2qAt}xC2J#S{J_)I&t;ucLK6Tg Cd!TIq literal 0 HcmV?d00001 diff --git a/docs/v0.7.0/image/search.png b/docs/v0.7.0/image/search.png new file mode 100644 index 0000000000000000000000000000000000000000..f5d84b697dad0c856a822c2df0a0da46ee3e9be3 GIT binary patch literal 12704 zcmeAS@N?(olHy`uVBq!ia0y~yV6iFfq_LO)7d$|)7e=epeR2r zGbfdS!9uV#^nU*B5D~l1{GcUb_6ia1?OjLLhXzOQl$Kh1jLmcM(zjk>OJCm5Qh8!! z-nmkm{r1aktNg1Q&Ds7iI^1OD_pnjqWlO5Q`R%|K&){~gRh}NzFOKjls=Z|meYm?U zNj>;T%-3J1E$>@Cw|*XX+r>6MbL%Y0(2i-V*UdezGIjEDu_^O>yDn|M;>~Kl|?= zncLa!e3toe*^Gs0HPiIkIYJc|kE`4IDcW=PUC??hx|U-Po6VjZY5Lm}|cKNNdtR>{g$mHsm}ncJ~ff|9l^ zKH&bs#YNdqOgHK3N-ygr0rQNe9NFt;W}|9!qNVll=|n>%|4TwScPlOXA0Kb&*(APK zcTwO{>*MPS_MhAsVIO>x@sE7c<~Ih?>B37knBSQFhQs@y)j>X1uA*EkQLW3h8ec!} z@h=S#v+@i0^v9uAqa*O#&G%Bj&i4Ono3+7P`-`&w1w)hQx55hS!WpIJm+Y2jXWPHw zvpL1K`^UMr`?9l3{uF-hz1y98+-yVMv2BNb+*rR+_fKvRlXXH>*R+MFK9n8etWcJ< zjbXg3%KJM1LF9#7LAN$8Ui#{1;{|24gZ3xv&Rp90@WQHpi~g<5TM@rP{K|dntQJY@ zWh%8=wc39*YSnA?|N3;5MD9}hs}ehP-$XrD%iZty&R4xry*@rs_-dWbKb`Vt&!0^;(i=o}#>-7!{$%fmH=N(j^8A(ED^bF=Im>rzweCk22@`%*wz+KA zkA)mYeV`@B6r;(n-Y zSjPPI-(+C}E2{^&IzFl=j33RlDhzY|!c{W+!r9n5w)=dGJXe=pGdm?3esle*^_rYD zr*;^{UUhF5J!>L*{;7sp`HsDZx)-bLYgX!e;dt-&KG(9lJh|_pUE2R2vVI+w5xqjV z_N~Cz{ZhBuKKRu8C@j-16JEZk@Yk?b_ULtQOje%wmQU(kALQ&NfOv zH>Yst&Yk9tE7Y8?tYcijDX=>G!+(~X$~-2Qo#`87-FCiTbmy?Z;qs6F4?cVL%=Y#5 z_4x&x^`^P9#VJ-;yd^fcYwQjt-be*0M;l?mJBxBTcSh?ui_x#JJ1zz1<159AW6 zWp~6y?ksxxdtKO}Lnj&+ENmE3A#<#tO?O`YoC}$%0c1to&yd?*5fp68_xrMOtETq5Qd(&cU|)i>`O% zD(~9+`oi14wX2?ftT9^9*?58L-l0}*^|Z9KbFIeDlqT;En;g6)!SUI5z71DON=mM* ziQN3GKdL~GU9#Ym!wnYwxBq^>-!GkF+u@Vf7JTVYh1{lnZ#Vp2zB+8}FJ8Odhfgr( zn$2(Az!CRrlB#!_;^b-xr}D)=^SIA3am@EAugv-S>Z)|(B5ezmH8Xis&Np0bGB15~ zWzC{Ri++EYa_GL(3pI6r{_`D28Cu>eJX8FaaeZB^|MlzFPcLBqf1;s^ZH>sDNs}hc z@tmxt>*V%bU>nodI0FfVO?#DZ$k~^?2)KG}ZFDq`S?dMo0}Z)N(>vF_E>|qFcW^5Y z<@mGwm`h5Hyu**Wo^|iI8eRo3_c)wzkY`&XXw$Q+PBhqi-V@thcK3K6tiJR3@RVs! zC9c+*HoS^dm6Vvm_?XpS?&l#bmHx#G&$_3j@3C#JIz2&t;>(khW&9IEr?>y$n62o? z&3T5W`K`}!k;%Ue6+SXaU7x-o@XZv9;F`w$PCwEt6ozd#?q**~7_X?=33-=+IW@npf$2*L3r6Ft0MUd3mT$#`07AMGvuy zvEK|Ea@N1PvNHI7viNno`&nB();>5p*ZTYCiic<2I_~mDom5_TMY7?=+r!T%K=Ul_7OwDd_{dw&>OJ^H!S?3k}_;a;{t-w*b`L^iOif20$pP!ri|9(kz zN4z=nEf)VU)1RzT2a+>5ZthyCY_(lNApY^AZ_@?#8Vc;Kci%Z@^K-GCI?LsmvvzIS zw5Q6^@!(~Sf7QPfpV%)YwolhJ2v}57qgSK$(_s9?6<=$s#f0( zw)*&U(!-NByH7B%9`#F?k!bePn<3;a6nv~fEx?qg!tP_lyagRTTK^_Vt>!$E!FFM< zZ1>5N+mnhuZJsgbPUaRvmiOAsGv%&NldFt*Q`Z05a9PEjntZor+n)268EVDmr%&8E z=jfI0dH#khvD*?)B(X4;%f2I6`N&GSMWqb$*+0BG#H_2U%Wjr)qktvFqSnGL_uHGBtd^FR zn|^&3xnjtgTFduTJXu=MYEt3`9qIn^hjr#X+b%zQBKg7R!!*5Et@XY!vu#w2&o}&- zb9kHVZLyB?)4IC4?ru1;{*1D0jrgK>L05Ed^W;pQeKO_Kio!rm_WS;-^=juiq?zY& z%+t9ybN1}tY%K4MrwRX(le&F*hWxkaJ&Pam-ng~!$UUDu%qdpStnYEkp9p$2KeXwz zu*8RhKc78&_AJG6C8(!!Y~N8EbZw#v?I z*^^ctT~F%dUd?OsdB1jn z!G^fKJUfIQO#EH8-dUli-qTF#|Fmn@uCZTR7rQ%r{p~yMVR3PF%5ihPu(-T0`|kaH zyUULP{ddo6FJ6h}|F=nW-L06J6?5j#|G(p9Qu~<)7Tee_me#7pD1PYND%hy+y39_x zx{m3gbhZ}1P`A+J1OIJIz-@s{l$ z>x?+1$t^#{6BU&H+&^A2Eh|P~m10#Z+a%?UKUE6ucb#3&`GD<`h~5d!*u4|)-t9lO z;fl*CgHO9YJvi8$dfxtjO>^guzXy8CkJK6D+}N<(tw*Ae^^eWjeyh7{n8hEhUhX&d zmt$@1-mA?1c|~c}k$t+W_F>NM~#k(%2Hz^AanQXk>di=n$pf{8F!yfwVXl{`B zY9!kk*m?Dd?lVa=EIK%&`K7jc!NK40f9pbi^~cOmO=DayF?$-T+>}kJ=4+O)>lWxgujW|rbJ>Na zgPrY$umAm@(R5v8js(Y#?~4{KGCOieRxRP!*PmVwY+D;8W;z|+Kf!3ilm}C%OnK5H zXZy>NrT^E~YbkZI|E47=eLU~{D*F7{wu(Jb5fK`T@02U4$=v7vCX=y*DM9DRiqBn# z+xd-8f9@_x{i-6mWU`uXRLg>$UNd=_A9UPEoXxs%wbTdY@*Srd3Up$)pRW^pFVF#%(%JpY}TJoEyWM*{!Kh6r)a3N zQAUUBnw$u8CzsqKmA~wcjXqoAd~7S3J|C@{^5Ub-xmdQA>XO{6_lC~Q!Xs`1oteqcCLP<>vR~z} zL(IX$zZlB1_eCvEoO@8`S7c3-lH~U4>NP){YLxbU+@|(?ske`Jj8IOP_vJplBgvT`aPYA4X5m8BISa2E^>D3w;=~ZO z*Epr)hg;1O(S=909oZ39bL6QVb2FEm7)OA0P5+xj^J|+YKTrO-dYmWb#`}=K@!m2reQ(xKlvL^);>0UvH9BA-DT_bO*aaim+1IWFgab+LcbzS<=fop2aK;88#sLU z^!fAtwu!5Ca!(Yp)`du`Jt{ob;1=(7#`}%+=8p84hYm0tY<}#$wefiE{OKEnxZ;Z%leOzMr{KQMaPuK_h!J>8@BAd3v zU6o3dxH$QH=cn^dY+HVYCB@%rXbri%goF7n3xBvpsHW|QIhk2mmn;??XDDi9{J8eV zjn+jm+D_5Z1!oP!t{ir-KX~}XOtXX4>$Yv%Hgn&m$&4R$S)N(?Udzm8p0#5m<7wA} z(c5xvUiEmn{&I?l)L|>%ijJeTY+HUt+-lgu`dv4*Q%YioMumiF@YK7FbG~mlbs`V4 z>`j58(HC5LUPkC~$p!tKZ6et`{lK3vVY#G_eT=#Lu3Zz`lWbR`8ZTlqW8E{`MLX6P z=bfEpn%{C>_TiR@8eO~al)baIE$9%|UhswE-WTKg-kq-J5D+DKY04=*{WCP9?d(ay)NqHp)1A<&OX0&tEGxvifM!UhXU8x zYdG~ktcX?#61F!>y7;U(H}{a+eD=iP{s#}$-kLgw$gTCeb2@X)iWLvIs}@a6{%H4c z=a0DV&RMrw#Qbs&TvV)O@2b*{pXz%_gf(X!y8PSVLN$NB)BM`TI@dP$gWOk`4~DKg z`Tc;AqJ>(-=5U@R$+G`rEX>cZ=9;9teed46P1AKUr^&28`TdgGlH3R<-LoAA6Xs2v zSlFs&78MnxQ87#Ak+N9szU$Y_YD!wShA!ooHp`hJ_PXHylFGwvyzW~bDDu@y3f%YR z`4OG{=9bCU-WwV}y^VO5B&TxtO5WSeaGsTU(#Hj{$IBLLS4MPup1Rd07S(gC@ul0# zSw?#WfB*z znE8B|%PDdBVyna|R*gKN;163Yloe!VB{>A&<~SjHE%Y?cd8_HOas`ZSHve5NTYG+S z>Mchhc}WH4lmonMOT2GCb92m_(x}OK_>M+<>WtG3U^CBrU7`2n($d_kOq~6n0`MET zcNGtREJs?!E#+g$HM5c$B)6dTfRj$~v>-o8Pw!057#bq`zvmN;^#LVaS^~n@&alI8U|5hX= zaBxrk`XR*9R9!vYi{r1u?##rwvBD;Jb2&YnG6Z8Ed_cg6PXL(V$) zj2qtgU3K+~p8eq-^TQPj-9KDgAAi3=J8H4gz)Ya+zGrwoT%UyTiFNSpGld7T24zj+MW#;&j80sG4`Vx}Hr9GQI~nd zC8d4emX)wC&C2HH^Le0Y2r3s}1nm)eJYzvwec8!Lszv(!^&RnrUH)GN9 z3>|US{HLd;zE_@FA3fQWV^8I*4+7o4c``n4+`^d2{Vw{Hkf}jI;0G2Sx8>V17_N3R z_CB1qX_JxZY1Xfg9xb=#>Bv8N{N0pieww##HCTsjoD#?Oi&L)2fA)i?PoF=pUoEa< z|2D~?rhCTe%PCX0nJws)mfrA1c+an81^*ALRjTIl0OeY7K7A6~seO&n?Y%;IV?@MeZiArMSpn7QH zqR`T8R^hm1pE`D@ZQim#GT>Ek=|=f2^K(|$H#|^W8~(f`rgDGb|G(e;H~0S8a7%fg z$o#C$@yTzpAD<|(VP;vsa^=hNf|}iChYhNZ>G;nMmU(pXg?DFVXKlOMM-yiW35AM? zzfe3$-Y>(jp%n;zTqJ*<6w+lr>^7cP8IVsf}#6lgo|VD0>%H9gkW zHF=v3CxIIhrpOJ6J-c@83S&9w_I-8n(j)WF%&`o}LEp^T)aMzb378&t9XR%-rwW z)9Cnq=>qN|4#%q8B-fwiB5qf#3Pa~@tNQxt?!T+2X3a5b5Dk37YHKavE$Mgq!z-I3 zm#jraMJMmkn*a1wl0sUWcw^*Z?sw`LOCBy@44pn@%9D&E?mqL46zqiJGevfDcuh6@ zr`i1HnHqC5SDd?h`>g~AX016km7mVvQE5)ydA{L?N6pi^lkcXiusn8mUx}>WIA=7nSZcdrtM3eqMZjM}CanwYQH#j&HktY||b^=SN)kR)wyvYt~+P zYrDn6e*toFOq&HS%e7rvXeA*K-{F76+)9AgMbS`qqwNRrcN=Fm?r36vyxVZn*BNO- z7dCWpadE9`EW8kye%36aMc21R(e7eSu*$N~wSQO4)Q{evswMC;;^8A*mX9fC+a9m_ z%d+kkf5x#4YqKLK_bd4ATYuB<$jQhfCp8j6wtKXt-OD*J&7)1d>`~K=ugP!OyqypC ze%gPv?{Zkpp}l1rh2J$6-q@6S`r6~{Wo!2>h`lIzqGMn6gE*Fx`!*&YKX?53hsOP{ zZZ=ClEf*0JGkbGqXYq8okZ;NdxsG)g+<(W}th2Z7)|Slq_ctaVU*EX%w8EX1Sxn5F z-1j~{KEAuFtLv7c#(kfKcKiMI3P*f*{BrNh>O%(CnK%BP-_c#VLqhFV@&zYxSO0GH znnM#eJm8$SXV0F!i`{yodJgQnqh8aus?%gowL;Z<u7I^sI}!xmotUT`@6NpQqG$-CSd-p6 z*l5t|GF}J$7n=I|`vc=9@ybuD3f!lfx~V#QhjOf-&BKI;hgySEMEGYOOy_y-GOcZ5 z=_Rv;AMLwRTgqnSolp2-xHm(}B~DGCo_k-ht{mIy%OCD*RIyoKxXR%EcqhM7V6uTc z^8#m{xL0r9)NI+bspxluJny~6b+37P_SiAi*B(wVZff$o$ldi*@X+nZOeY+1Q&+qOvA11t~A#^uQ_15s4}C#|7TvHgQ(JD>-JUK9U0;s z#kMY8v?$5^-}h|Q*qID*96U<}cH9nJpHi~wx(?3?-?&iki=Vq9r=R}n^MOTuSCDo= za?Q@uGkP`n9$n_RxU!u=?!fcLZ{NNl23pxH-m)z}JI{8v0;p*h7IsYpG18jIV)(6T z$qUH`(f+Lb-%j5?SJ!#0qMtG52a}-ERUSJ&XO7t)D#iZKcMdBPQ$CpfG}z(6_QV|l zJd^!piY@yj+wOn*Xvz5h`7fp^Q!Nr37CmncbPmr3)V)?_b|tvbDyfH*{j7 zgT#UttWMQQQcf>_|GmmH-2rnoXatT@WxdR{wCcFODQ>D%<}_6RKF2-Z*eGVSi|eMdg*Udywgdi8%~CQ^E4q>*N=MR8^k*!(EU0{>d=0Wfgiq zpD*xUIpy%$xiv@rKi#ptmht}i$B*jy?w_A$U;poJ`uy5$j5QXuTIwtzYWYbIn$#ye zmF1c-=MU4I+UiegA9#!s)R|`-E0vojd*GYcw(A@B_M~rlYW-ivXo1rQmfbcJ0|Np+ zn5?U+;W@j|xH3vZ!lKLPLu$k>&eetgrR}Vp6SsQ1trFbRVf!+oz~Nq_)G1c>m`|GB zoSe)8`@Sb;U440Zx%S1swo*cygN=e`Klm!qytMDxNcf^(5Ox^n8QJnn_&OcLmCNL&4EKBCFc+H2-rMi`TjK}^?vV-p8A{H&)bEC%1S+q%h_D@-t^%5dd3D3 z+x|T&;-WeAy!*6mR~=fBbhRu~KXv22eQ~>XWN*B6svw2s@`v4qNwq6=760z%7S0Mc zF*B>%y=>XD<~Y6w*S9b8o2#YtBYejUN#XvzKepC4UCzlVU)*gi7IU33f5q+{Ze47< zc3i&TFt6oUN+?!YRD*{EqyB#V;z~yZm^*dw$_t zOJ83TTmIC=x_^;)uW0%AR^KmcME2a9aG<1Jhv)eD-jtfj)!#oGm$F?5;PY~8zxl^> z#=8sisyZ)vFL>el{OH-ei9)ukS=ajqoY2zQtWd-MSuS2aOs2;5@eS^U)jYA+do66= zomkzh#Wu(3qO?QjYwJTwRf&Ro?lE{C4w<(5uq)*Z{ zzw9cfE)u`*zEVz*?IQQ=2eCbzJ+J)EoH;Y6TlUh^z26@3|0$Ztm{RnKCyh7k{)&Su zUd!wM6SyGWHShb8+j>49nR9rot|(r(Zfat(Cn7xj z`mJ`c(s<3Pd%KT>U0nR&Xvf@5n>IcC`SWLd^NXpECIqn@fGi`hs1!<)e{-wpee|qZ zv+Ba5qpPjhM77F;zw9aR?p>7b%KYu#SLe19$~iB-O;h0TQWRS%u>bX+71!5VDdglc z{}xNQ-}LU)wG{cEMcnPPp9XxnlVV&Ixvf)6va>{H*8n*|U2& z51C6URq%GrYe?A1_TT@&wC72o&H?WvbJ_#n?bi5iaO7?5pZX0ucUGSN_4V~r)^iJg zf>M3fk!hmbd;uT!^iQ29Rp4(RKJ%LB;Wl3B)-xZtI38*IDX_HLEaxDa{}E z^4^brD(rNvE%y0`N}=cVHQ(OcoNVzw`A%{6wB(=PIhjRl-zy(vySVs4rM&u@gX(M= zRriE*cfAPwu%}<}+5=^f{7JLOFB%p1juY%eKGb|!2}&hDC0N#IS+HGTXlDzrw#dGwQ6;jc;8@a&HODv}wO){1dmtfq zk^8}50g;vmw#*Sh-A&JJ&jw~+P^l8xvqJBY-))Hl3s_n89hPSa+H%D;I38G4n|ffy zbdjH@di?ty^09qR--+>{rAAKr8+M;UW4OYB(ifcH@UeS22LDiNFg zd(Zr0N@n1Fv-N;h`q4ni57D47xO-r(nNdUew}0&K9+%$En0?ahr)HIi&1B`)8{{hVK!82=u472{84^F}?`ME{uA73a)6oB0A zSTV6QE8#)AfUTb7(u2Z<20JvXBnw|XI-hdDi|y6x*XMob+x;~*$ZMO*7L_LAl5est zUrbc=Z`Sj3bDz(hb)4tCX0grr3O2uaHa{&k?U{T`T1bfb&WSG?6^fieKd< zQ;zZIOKz)JGnFSHuu(O`K|V5b&QdqavtKkSrm?Y{^_s&N8N%SM@ArpCZe?R*$BVrt z#m~;{arsy<#Vl}H#hj}=30J2#{+pG)x{_qF z==GkpolAG0Wcc%y^~}ZB2W0l>NH z4rz6l&zj%=^J!h|ZnixYb0y~~`l*~rkVsf2&hvidm9BNUQE6$<^aGAD)F!u0=h|#z zF2ZAQ+4%g~6DN*~iHYrN54?T1_9B14fqnL$tR)qg=NlaGIlsrlVVOF&^OwsOX%)|Y zPV8V#YM2@4aKw6zSmZs8l*;M}Pxs!8cCr8Z`tC`8BL}uc#s_@#t@NY5E1j-hp>M_& z7jO1sE|1Cq23LK?NmFE)4*pK6to+%#w?Ly}ug{0cJSqnnT=h9OG1-}@tEZRgvv9@f z3;$7J_B3+1=sjse1K;sId#VFV&nF!h+0!uRK-SxYhDFQo_e<=Vu_5Q?rk71qnwH;> zcUduqv1?utJ7ZjUc=*Z%OCG%ZE-EN>fWg&&@8mq;77?4TbxIDw5({3u{3^0*YdqsF zo_$+=*7tXu31Hh`bMa}!#>ITSITyCxHMj~Cm3Ay4c5*U5CJON)G6+by9Sh1z2={eg( zoo1dTrx;xIL)jkBpFeS8;e^x9N1u1PPhh++@!(R>y@1{~>;C@u`1t3WOI3&Uy;Yg} zBodZA@7U(zcWYzi=V#m^dt6pLGE6z(&ZbfIZgMYUcW#gt>-pNeNF_;+nT%a=r$oMK zGsNCnyQ#V9dcW8|XSOc}4i}4$iwo?&e7sM#+SP0EgPn&py%m|~fy7&{#b3R8b*q=B zh)wv96vdPS)@&M8D+_O5y!g>4pL5Q%OQ%`vPc{^>S){5~vM;o*Ub1LWlG3?1Q#Q|h zsCr)UyaID0D1i#TwLctbo1~r|{6VJh#N-nW20Q^@gr3XZyu0$*vu9Up&o6lJHMRNv z$p%J{c-f_{S+iz+uI*n26;e@a4tD`7u=@tnY)|e%MPIv@mwX<+zuY zmHp#gwrI}IFC2ZB;!bh=S7&ZBJaF;$Kfc3zcmF?f;!XI5?YsZ$%WT;(h5w&FTTgPs z%zMlAoWr-V-n<+1MpB`yNM!ex`9(+bQw~J1X;jVM!PoTNAvE;rzKFh*>1JZacl_CS zQWVbIjqbQxygF>Hmh_q2GauNJ+xJgoJS@Rcxa|A0mBGu!ju(f!?P2}_%9Uw`8|wf6 z+tw+pe(l+_XZPC7OGRh2+Es3mSdw8;`|HbFY4f~48uxCB?5W`SSZ*(Taqjt z9Uc8XVt?J=g)Vno4tlq!$~m*~q%7!vaktCoy%e*rgvh22S+|t^k+HFRvoA3J{^N1* zwKLoPNsPB81TJQ0W>#)nupoiU<$YE3o5^`O)z#H6XPIUTiCJ%)+m!Cja)HlCpt(_4 z-LK@@_3QTWAt5G4wzhw}4f%}I%#C*ceSUtve&qJNyVfV0mOW5CEzz&eoMv=kZ}IbU zyAB;X#FkQ3-=urm#aN+izfIAT6Y)0x|9n=T^WeFSjry98GDZmo%-mu+Kb*?SzUeDg zna@aKYk9}C?fv748&8E87$5d-wVmh9#*>op{oP%4gWS|yKR-V+mnUKz^Rr|bj^&E$ z#q5x77S>fOtHkOanIBu6fZun`DdtPo)@n#%hEdH>lXcA__o=UkGrp~4(~ouYN4xt^YcIHckBP0I`RDF R7X}6f22WQ%mvv4FO#nljU3&lk literal 0 HcmV?d00001 diff --git a/docs/v0.7.0/index.html b/docs/v0.7.0/index.html new file mode 100644 index 0000000..da2bd20 --- /dev/null +++ b/docs/v0.7.0/index.html @@ -0,0 +1,171 @@ + + + + + + API Document + + + + + + + + +
+ Home + Identifier + Source + + Repository + +
+ + + +

JSON API Store Build Status NPM Version bitHound Score

+

An isomorphic JavaScript library that acts as an in memory data store for +JSON API data. Changes are +broadcast using RxJS. Built to +work with React.

+

Usage

+

Browser

+

At the moment the primary use can for JSON API Store is in the browser:

+

+// Create a new store instance.
+var adapter = new Store.AjaxAdapter({ base: "/api/v1" });
+var store = new Store(adapter);
+
+// Define the "categories" type.
+store.define([ "categories", "category" ], {
+  title: Store.attr(),
+  products: Store.hasMany()
+});
+
+// Define the "products" type.
+store.define([ "products", "product" ], {
+  title: Store.attr(),
+  category: Store.hasOne()
+});
+
+// Subscribe to events using RxJS.
+store.observable.subscribe(function (event) {
+  console.log(event.name, event.type, event.id, event.resource);
+});
+
+// Load all the products.
+store.load("products", { include: "category" }, function (products) {
+
+  products.length; // 1
+  products[0].id; // "1"
+  products[0].title; // "Example Book"
+  products[0].category.id; // "1"
+  products[0].category.title; // "Books"
+
+  products[0] === store.find("products", "1"); // true
+  products[0].category === store.find("categories", "1"); // true
+
+});
+
+

Node

+

You can also use JSON API Store in a Node.js environment (currently, there +aren't any adapters that work in a Node.js):

+

NOTE: Without an adapter the CLUD methods (create, load, update and +destroy) cannot be used.

+

+var Store = require("json-api-store");
+
+var store = new Store();
+
+store.define([ "categories", "category" ], {
+  title: Store.attr(),
+  products: Store.hasMany()
+});
+
+store.define([ "products", "product" ], {
+  title: Store.attr(),
+  category: Store.hasOne()
+});
+
+store.add({
+  type: "products",
+  id: "1",
+  attributes: {
+    title: "Example Product"
+  },
+  relationships: {
+    category: {
+      data: {
+        type: "categories",
+        id: "1"
+      }
+    }
+  }
+});
+
+store.add({
+  type: "categories",
+  id: "1",
+  attributes: {
+    title: "Example Category"
+  }
+});
+
+store.find("products", "1").category.title; // "Example Category"
+
+

Documentation

+

Full documentation is available on the website:

+

http://particlesystem.com/json-api-store/

+

Installing

+

NPM

+
npm i json-api-store
+

Bower

+
bower i json-api-store
+

Download

+

To use directly in the browser you can grab the store.prod.js file.

+
+
+ + + + + + + + + + + + diff --git a/docs/v0.7.0/package.json b/docs/v0.7.0/package.json new file mode 100644 index 0000000..729563d --- /dev/null +++ b/docs/v0.7.0/package.json @@ -0,0 +1,35 @@ +{ + "name": "json-api-store", + "version": "0.6.1", + "description": "An isomorphic JavaScript library that acts as an in memory data store for JSON API data.", + "repository": "haydn/json-api-store", + "main": "dist/store.js", + "scripts": { + "build": "./scripts/build", + "docs": "./node_modules/.bin/esdoc -c esdoc.json", + "release": "./scripts/release", + "test": "./scripts/test" + }, + "author": "Haydn Ewers", + "license": "MIT", + "devDependencies": { + "babel": "^5.8.21", + "babelify": "^6.2.0", + "browser-run": "2.5.0", + "browserify": "^11.0.1", + "chokidar-cli": "^1.0.1", + "esdoc": "^0.2.2", + "eslint": "^1.3.1", + "exorcist": "^0.4.0", + "faucet": "0.0.1", + "sinon": "^1.16.1", + "tape-catch": "^1.0.4", + "tape-run": "^1.1.0", + "tape": "^4.2.0", + "uglifyify": "^3.0.1" + }, + "dependencies": { + "array.prototype.find": "^1.0.0", + "rx": "^4.0.0" + } +} diff --git a/docs/v0.7.0/script/inherited-summary.js b/docs/v0.7.0/script/inherited-summary.js new file mode 100644 index 0000000..0a35b6d --- /dev/null +++ b/docs/v0.7.0/script/inherited-summary.js @@ -0,0 +1,28 @@ +(function(){ + function toggle(ev) { + var button = ev.target; + var parent = ev.target.parentElement; + while(parent) { + if (parent.tagName === 'TABLE' && parent.classList.contains('summary')) break; + parent = parent.parentElement; + } + + if (!parent) return; + + var tbody = parent.querySelector('tbody'); + if (button.classList.contains('opened')) { + button.classList.remove('opened'); + button.classList.add('closed'); + tbody.style.display = 'none'; + } else { + button.classList.remove('closed'); + button.classList.add('opened'); + tbody.style.display = 'block'; + } + } + + var buttons = document.querySelectorAll('.inherited-summary thead .toggle'); + for (var i = 0; i < buttons.length; i++) { + buttons[i].addEventListener('click', toggle); + } +})(); diff --git a/docs/v0.7.0/script/inner-link.js b/docs/v0.7.0/script/inner-link.js new file mode 100644 index 0000000..7b26d93 --- /dev/null +++ b/docs/v0.7.0/script/inner-link.js @@ -0,0 +1,21 @@ +// inner link(#foo) can not correctly scroll, because page has fixed header, +// so, I manually scroll. +(function(){ + var matched = location.hash.match(/errorLines=([\d,]+)/); + if (matched) return; + + function adjust() { + window.scrollBy(0, -55); + var el = document.querySelector('.inner-link-active'); + if (el) el.classList.remove('inner-link-active'); + + var el = document.querySelector(location.hash); + if (el) el.classList.add('inner-link-active'); + } + + window.addEventListener('hashchange', adjust); + + if (location.hash) { + setTimeout(adjust, 0); + } +})(); diff --git a/docs/v0.7.0/script/patch-for-local.js b/docs/v0.7.0/script/patch-for-local.js new file mode 100644 index 0000000..5756d13 --- /dev/null +++ b/docs/v0.7.0/script/patch-for-local.js @@ -0,0 +1,8 @@ +(function(){ + if (location.protocol === 'file:') { + var elms = document.querySelectorAll('a[href="./"]'); + for (var i = 0; i < elms.length; i++) { + elms[i].href = './index.html'; + } + } +})(); diff --git a/docs/v0.7.0/script/prettify/Apache-License-2.0.txt b/docs/v0.7.0/script/prettify/Apache-License-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/docs/v0.7.0/script/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/v0.7.0/script/prettify/prettify.js b/docs/v0.7.0/script/prettify/prettify.js new file mode 100644 index 0000000..eef5ad7 --- /dev/null +++ b/docs/v0.7.0/script/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p' + pair[2] + ''); + } + } + + var innerHTML = ''; + for (kind in html) { + var list = html[kind]; + if (!list.length) continue; + innerHTML += '
  • ' + kind + '
  • \n' + list.join('\n'); + } + result.innerHTML = innerHTML; + if (innerHTML) result.style.display = 'block'; + selectedIndex = -1; + }); + + // down, up and enter key are pressed, select search result. + input.addEventListener('keydown', function(ev){ + if (ev.keyCode === 40) { + // arrow down + var current = result.children[selectedIndex]; + var selected = result.children[selectedIndex + 1]; + if (selected && selected.classList.contains('search-separator')) { + var selected = result.children[selectedIndex + 2]; + selectedIndex++; + } + + if (selected) { + if (current) current.classList.remove('selected'); + selectedIndex++; + selected.classList.add('selected'); + } + } else if (ev.keyCode === 38) { + // arrow up + var current = result.children[selectedIndex]; + var selected = result.children[selectedIndex - 1]; + if (selected && selected.classList.contains('search-separator')) { + var selected = result.children[selectedIndex - 2]; + selectedIndex--; + } + + if (selected) { + if (current) current.classList.remove('selected'); + selectedIndex--; + selected.classList.add('selected'); + } + } else if (ev.keyCode === 13) { + // enter + var current = result.children[selectedIndex]; + if (current) { + var link = current.querySelector('a'); + if (link) location.href = link.href; + } + } else { + return; + } + + ev.preventDefault(); + }); + + // select search result when search result is mouse over. + result.addEventListener('mousemove', function(ev){ + var current = result.children[selectedIndex]; + if (current) current.classList.remove('selected'); + + var li = ev.target; + while (li) { + if (li.nodeName === 'LI') break; + li = li.parentElement; + } + + if (li) { + selectedIndex = Array.prototype.indexOf.call(result.children, li); + li.classList.add('selected'); + } + }); + + // clear search result when body is clicked. + document.body.addEventListener('click', function(ev){ + selectedIndex = -1; + result.style.display = 'none'; + result.innerHTML = ''; + }); + +})(); diff --git a/docs/v0.7.0/script/search_index.js b/docs/v0.7.0/script/search_index.js new file mode 100644 index 0000000..0cdd24a --- /dev/null +++ b/docs/v0.7.0/script/search_index.js @@ -0,0 +1,506 @@ +window.esdocSearchIndex = [ + [ + "json-api-store/src/ajax-adapter.js~ajaxadapter", + "class/src/ajax-adapter.js~AjaxAdapter.html", + "AjaxAdapter json-api-store/src/ajax-adapter.js", + "class" + ], + [ + "json-api-store/src/store.js~store", + "class/src/store.js~Store.html", + "Store json-api-store/src/store.js", + "class" + ], + [ + "json-api-store/src/ajax.js~ajax", + "function/index.html#static-function-ajax", + "ajax json-api-store/src/ajax.js", + "function" + ], + [ + "builtinexternal/ecmascriptexternal.js~array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~arraybuffer", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~ArrayBuffer", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~boolean", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Boolean", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~dataview", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~DataView", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~date", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Date", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~error", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Error", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~evalerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~EvalError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~float32array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Float32Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~float64array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Float64Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~function", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Function", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~generator", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Generator", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~generatorfunction", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~GeneratorFunction", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~infinity", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Infinity", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~int16array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Int16Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~int32array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Int32Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~int8array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Int8Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~internalerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~InternalError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~json", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~JSON", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~map", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Map", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~nan", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~NaN", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~number", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Number", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~object", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Object", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~promise", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Promise", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~proxy", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Proxy", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~rangeerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~RangeError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~referenceerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~ReferenceError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~reflect", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Reflect", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~regexp", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~RegExp", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~set", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Set", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~string", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~String", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~symbol", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Symbol", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~syntaxerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~SyntaxError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~typeerror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~TypeError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~urierror", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~URIError", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~uint16array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Uint16Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~uint32array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Uint32Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~uint8array", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Uint8Array", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~uint8clampedarray", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~Uint8ClampedArray", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~weakmap", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~WeakMap", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~weakset", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~WeakSet", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~boolean", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~boolean", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~function", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~function", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~null", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~null", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~number", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~number", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~object", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~object", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~string", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~string", + "external" + ], + [ + "builtinexternal/ecmascriptexternal.js~undefined", + "external/index.html", + "BuiltinExternal/ECMAScriptExternal.js~undefined", + "external" + ], + [ + "builtinexternal/webapiexternal.js~canvasrenderingcontext2d", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~CanvasRenderingContext2D", + "external" + ], + [ + "builtinexternal/webapiexternal.js~documentfragment", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~DocumentFragment", + "external" + ], + [ + "builtinexternal/webapiexternal.js~element", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~Element", + "external" + ], + [ + "builtinexternal/webapiexternal.js~event", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~Event", + "external" + ], + [ + "builtinexternal/webapiexternal.js~node", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~Node", + "external" + ], + [ + "builtinexternal/webapiexternal.js~nodelist", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~NodeList", + "external" + ], + [ + "builtinexternal/webapiexternal.js~xmlhttprequest", + "external/index.html", + "BuiltinExternal/WebAPIExternal.js~XMLHttpRequest", + "external" + ], + [ + "src/ajax-adapter.js", + "file/src/ajax-adapter.js.html", + "src/ajax-adapter.js", + "file" + ], + [ + "src/ajax-adapter.js~ajaxadapter#constructor", + "class/src/ajax-adapter.js~AjaxAdapter.html#instance-constructor-constructor", + "src/ajax-adapter.js~AjaxAdapter#constructor", + "method" + ], + [ + "src/ajax-adapter.js~ajaxadapter#create", + "class/src/ajax-adapter.js~AjaxAdapter.html#instance-method-create", + "src/ajax-adapter.js~AjaxAdapter#create", + "method" + ], + [ + "src/ajax-adapter.js~ajaxadapter#destroy", + "class/src/ajax-adapter.js~AjaxAdapter.html#instance-method-destroy", + "src/ajax-adapter.js~AjaxAdapter#destroy", + "method" + ], + [ + "src/ajax-adapter.js~ajaxadapter#load", + "class/src/ajax-adapter.js~AjaxAdapter.html#instance-method-load", + "src/ajax-adapter.js~AjaxAdapter#load", + "method" + ], + [ + "src/ajax-adapter.js~ajaxadapter#update", + "class/src/ajax-adapter.js~AjaxAdapter.html#instance-method-update", + "src/ajax-adapter.js~AjaxAdapter#update", + "method" + ], + [ + "src/ajax.js", + "file/src/ajax.js.html", + "src/ajax.js", + "file" + ], + [ + "src/store.js", + "file/src/store.js.html", + "src/store.js", + "file" + ], + [ + "src/store.js~store#add", + "class/src/store.js~Store.html#instance-method-add", + "src/store.js~Store#add", + "method" + ], + [ + "src/store.js~store#constructor", + "class/src/store.js~Store.html#instance-constructor-constructor", + "src/store.js~Store#constructor", + "method" + ], + [ + "src/store.js~store#convert", + "class/src/store.js~Store.html#instance-method-convert", + "src/store.js~Store#convert", + "method" + ], + [ + "src/store.js~store#create", + "class/src/store.js~Store.html#instance-method-create", + "src/store.js~Store#create", + "method" + ], + [ + "src/store.js~store#define", + "class/src/store.js~Store.html#instance-method-define", + "src/store.js~Store#define", + "method" + ], + [ + "src/store.js~store#destroy", + "class/src/store.js~Store.html#instance-method-destroy", + "src/store.js~Store#destroy", + "method" + ], + [ + "src/store.js~store#find", + "class/src/store.js~Store.html#instance-method-find", + "src/store.js~Store#find", + "method" + ], + [ + "src/store.js~store#findall", + "class/src/store.js~Store.html#instance-method-findAll", + "src/store.js~Store#findAll", + "method" + ], + [ + "src/store.js~store#load", + "class/src/store.js~Store.html#instance-method-load", + "src/store.js~Store#load", + "method" + ], + [ + "src/store.js~store#loadall", + "class/src/store.js~Store.html#instance-method-loadAll", + "src/store.js~Store#loadAll", + "method" + ], + [ + "src/store.js~store#observable", + "class/src/store.js~Store.html#instance-member-observable", + "src/store.js~Store#observable", + "member" + ], + [ + "src/store.js~store#off", + "class/src/store.js~Store.html#instance-method-off", + "src/store.js~Store#off", + "method" + ], + [ + "src/store.js~store#on", + "class/src/store.js~Store.html#instance-method-on", + "src/store.js~Store#on", + "method" + ], + [ + "src/store.js~store#push", + "class/src/store.js~Store.html#instance-method-push", + "src/store.js~Store#push", + "method" + ], + [ + "src/store.js~store#remove", + "class/src/store.js~Store.html#instance-method-remove", + "src/store.js~Store#remove", + "method" + ], + [ + "src/store.js~store#update", + "class/src/store.js~Store.html#instance-method-update", + "src/store.js~Store#update", + "method" + ], + [ + "src/store.js~store.attr", + "class/src/store.js~Store.html#static-method-attr", + "src/store.js~Store.attr", + "method" + ], + [ + "src/store.js~store.hasmany", + "class/src/store.js~Store.html#static-method-hasMany", + "src/store.js~Store.hasMany", + "method" + ], + [ + "src/store.js~store.hasone", + "class/src/store.js~Store.html#static-method-hasOne", + "src/store.js~Store.hasOne", + "method" + ] +] \ No newline at end of file diff --git a/docs/v0.7.0/script/test-summary.js b/docs/v0.7.0/script/test-summary.js new file mode 100644 index 0000000..2f32cb0 --- /dev/null +++ b/docs/v0.7.0/script/test-summary.js @@ -0,0 +1,54 @@ +(function(){ + function toggle(ev) { + var button = ev.target; + var parent = ev.target.parentElement; + while(parent) { + if (parent.tagName === 'TR' && parent.classList.contains('test-describe')) break; + parent = parent.parentElement; + } + + if (!parent) return; + + var direction; + if (button.classList.contains('opened')) { + button.classList.remove('opened'); + button.classList.add('closed'); + direction = 'closed'; + } else { + button.classList.remove('closed'); + button.classList.add('opened'); + direction = 'opened'; + } + + var targetDepth = parseInt(parent.dataset.testDepth, 10) + 1; + var nextElement = parent.nextElementSibling; + while (nextElement) { + var depth = parseInt(nextElement.dataset.testDepth, 10); + if (depth >= targetDepth) { + if (direction === 'opened') { + if (depth === targetDepth) nextElement.style.display = ''; + } else if (direction === 'closed') { + nextElement.style.display = 'none'; + var innerButton = nextElement.querySelector('.toggle'); + if (innerButton && innerButton.classList.contains('opened')) { + innerButton.classList.remove('opened'); + innerButton.classList.add('closed'); + } + } + } else { + break; + } + nextElement = nextElement.nextElementSibling; + } + } + + var buttons = document.querySelectorAll('.test-summary tr.test-describe .toggle'); + for (var i = 0; i < buttons.length; i++) { + buttons[i].addEventListener('click', toggle); + } + + var topDescribes = document.querySelectorAll('.test-summary tr[data-test-depth="0"]'); + for (var i = 0; i < topDescribes.length; i++) { + topDescribes[i].style.display = ''; + } +})(); diff --git a/docs/v0.7.0/source.html b/docs/v0.7.0/source.html new file mode 100644 index 0000000..ab71214 --- /dev/null +++ b/docs/v0.7.0/source.html @@ -0,0 +1,111 @@ + + + + + + Source | API Document + + + + + + + + +
    + Home + Identifier + Source + + Repository + +
    + + + +

    Source 19/27

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FileIdentifierDocumentSizeLinesUpdated
    src/ajax-adapter.jsAjaxAdapter0 %0/63003 byte1442015-10-04 23:04:31 (UTC)
    src/ajax.jsajax100 %1/16218 byte2252015-10-04 23:04:31 (UTC)
    src/store.jsStore90 %18/2024674 byte7032015-10-04 23:04:31 (UTC)
    +
    + + + + + + + + + + + + diff --git a/index.html b/index.html index 804e271..e982307 100644 --- a/index.html +++ b/index.html @@ -184,14 +184,14 @@
    npm i json-api-store
    diff --git a/releases/v0.7.0/ajax-adapter.js b/releases/v0.7.0/ajax-adapter.js new file mode 100644 index 0000000..91a6f54 --- /dev/null +++ b/releases/v0.7.0/ajax-adapter.js @@ -0,0 +1,171 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ajax = require("./ajax"); + +var _ajax2 = _interopRequireDefault(_ajax); + +var AjaxAdapter = (function () { + function AjaxAdapter(options) { + _classCallCheck(this, AjaxAdapter); + + this._base = options && options.base || ""; + } + + _createClass(AjaxAdapter, [{ + key: "create", + value: function create(store, type, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: store.convert(type, partial) + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "POST", + responseType: "auto", + url: this._getUrl(type, null, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function (e) { + return store.find(e.response.data.type, e.response.data.id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "destroy", + value: function destroy(store, type, id, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "DELETE", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.remove(type, id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "load", + value: function load(store, type, id, options) { + + if (id && typeof id === "object") { + return this.load(store, type, null, id); + } + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "GET", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function () { + return id ? store.find(type, id) : store.findAll(type); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "update", + value: function update(store, type, id, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var data = store.convert(type, id, partial); + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: data + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "PATCH", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.add(data); + }).map(function () { + return store.find(type, id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "_getUrl", + value: function _getUrl(type, id, options) { + + var params = []; + var url = id ? this._base + "/" + type + "/" + id : this._base + "/" + type; + + if (options) { + + if (options.fields) { + Object.keys(options.fields).forEach(function (field) { + options["fields[" + field + "]"] = options.fields[field]; + }); + delete options.fields; + } + + params = Object.keys(options).map(function (key) { + return key + "=" + encodeURIComponent(options[key]); + }).sort(); + + if (params.length) { + url = url + "?" + params.join("&"); + } + } + + return url; + } + }]); + + return AjaxAdapter; +})(); + +exports["default"] = AjaxAdapter; +module.exports = exports["default"]; diff --git a/releases/v0.7.0/ajax.js b/releases/v0.7.0/ajax.js new file mode 100644 index 0000000..6fee9a4 --- /dev/null +++ b/releases/v0.7.0/ajax.js @@ -0,0 +1,241 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +var _rx = require("rx"); + +var _rx2 = _interopRequireDefault(_rx); + +/** + * + * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc: + * + * https://github.com/Reactive-Extensions/RxJS-DOM + * + * The original source file can be viewed here: + * + * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js + * + * Licensed under the Apache License, Version 2.0: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Modifications from original: + * + * - extracted from "Rx.DOM" namespace + * - minor eslinter cleanup ("var" to "let" etc) + * - addition of "auto" responseType + * + */ + +var root = typeof window !== "undefined" && window || undefined; + +// Gets the proper XMLHttpRequest for support for older IE +function getXMLHttpRequest() { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else { + var progId = undefined; + try { + var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (var i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root.ActiveXObject(progId)) { + break; + } + } catch (e) {} + } + return new root.ActiveXObject(progId); + } catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} + +// Get CORS support even for older IE +function getCORSRequest() { + var xhr = new root.XMLHttpRequest(); + if ('withCredentials' in xhr) { + return xhr; + } else if (!!root.XDomainRequest) { + return new XDomainRequest(); + } else { + throw new Error('CORS is not supported by your browser'); + } +} + +function normalizeAjaxSuccessEvent(e, xhr, settings) { + var response = 'response' in xhr ? xhr.response : xhr.responseText; + if (settings.responseType === 'auto') { + try { + response = JSON.parse(response); + } catch (e) {} + } else { + response = settings.responseType === 'json' ? JSON.parse(response) : response; + } + return { + response: response, + status: xhr.status, + responseType: xhr.responseType, + xhr: xhr, + originalEvent: e + }; +} + +function normalizeAjaxErrorEvent(e, xhr, type) { + return { + type: type, + status: xhr.status, + xhr: xhr, + originalEvent: e + }; +} + +/** + * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL. + * + * @example + * source = ajax('/products'); + * source = ajax({ url: 'products', method: 'GET' }); + * + * @param {Object} settings Can be one of the following: + * + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - responseType: "text" (default), "json" or "auto" + * + * @returns {Observable} An observable sequence containing the XMLHttpRequest. +*/ + +exports["default"] = function (options) { + var settings = { + method: 'GET', + crossDomain: false, + async: true, + headers: {}, + responseType: 'text', + createXHR: function createXHR() { + return this.crossDomain ? getCORSRequest() : getXMLHttpRequest(); + }, + normalizeError: normalizeAjaxErrorEvent, + normalizeSuccess: normalizeAjaxSuccessEvent + }; + + if (typeof options === 'string') { + settings.url = options; + } else { + for (var prop in options) { + if (hasOwnProperty.call(options, prop)) { + settings[prop] = options[prop]; + } + } + } + + var normalizeError = settings.normalizeError; + var normalizeSuccess = settings.normalizeSuccess; + + if (!settings.crossDomain && !settings.headers['X-Requested-With']) { + settings.headers['X-Requested-With'] = 'XMLHttpRequest'; + } + settings.hasContent = settings.body !== undefined; + + return new _rx2["default"].AnonymousObservable(function (observer) { + var isDone = false; + var xhr; + + var processResponse = function processResponse(xhr, e) { + var status = xhr.status === 1223 ? 204 : xhr.status; + if (status >= 200 && status <= 300 || status === 0 || status === '') { + observer.onNext(normalizeSuccess(e, xhr, settings)); + observer.onCompleted(); + } else { + observer.onError(normalizeError(e, xhr, 'error')); + } + isDone = true; + }; + + try { + xhr = settings.createXHR();; + } catch (err) { + observer.onError(err); + } + + try { + if (settings.user) { + xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password); + } else { + xhr.open(settings.method, settings.url, settings.async); + } + + var headers = settings.headers; + for (var header in headers) { + if (hasOwnProperty.call(headers, header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + if (!!xhr.upload || !('withCredentials' in xhr) && !!root.XDomainRequest) { + xhr.onload = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onNext(e); + settings.progressObserver.onCompleted(); + } + processResponse(xhr, e); + }; + + if (settings.progressObserver) { + xhr.onprogress = function (e) { + settings.progressObserver.onNext(e); + }; + } + + xhr.onerror = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'error')); + isDone = true; + }; + + xhr.onabort = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'abort')); + isDone = true; + }; + } else { + + xhr.onreadystatechange = function (e) { + if (xhr.readyState === 4) { + processResponse(xhr, e); + } + }; + } + + xhr.send(settings.hasContent && settings.body || null); + } catch (e) { + observer.onError(e); + } + + return function () { + if (!isDone && xhr.readyState !== 4) { + xhr.abort(); + } + }; + }); +}; + +; +module.exports = exports["default"]; diff --git a/releases/v0.7.0/store.dev.js b/releases/v0.7.0/store.dev.js new file mode 100644 index 0000000..68f773c --- /dev/null +++ b/releases/v0.7.0/store.dev.js @@ -0,0 +1,13381 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Store = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o +// For all details and docs: https://github.com/paulmillr/array.prototype.find +// Fixes and tests supplied by Duncan Hall +(function(globals){ + if (Array.prototype.find) return; + + var find = function(predicate) { + var list = Object(this); + var length = list.length < 0 ? 0 : list.length >>> 0; // ES.ToUint32; + if (length === 0) return undefined; + if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') { + throw new TypeError('Array#find: predicate must be a function'); + } + var thisArg = arguments[1]; + for (var i = 0, value; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) return value; + } + return undefined; + }; + + if (Object.defineProperty) { + try { + Object.defineProperty(Array.prototype, 'find', { + value: find, configurable: true, enumerable: false, writable: true + }); + } catch(e) {} + } + + if (!Array.prototype.find) { + Array.prototype.find = find; + } +})(this); + +},{}],2:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = setTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + clearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + setTimeout(drainQueue, 0); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],3:[function(require,module,exports){ +(function (process,global){ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +;(function (undefined) { + + var objectTypes = { + 'function': true, + 'object': true + }; + + var + freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports, + freeSelf = objectTypes[typeof self] && self.Object && self, + freeWindow = objectTypes[typeof window] && window && window.Object && window, + freeModule = objectTypes[typeof module] && module && !module.nodeType && module, + moduleExports = freeModule && freeModule.exports === freeExports && freeExports, + freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global; + + var root = root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; + + var Rx = { + internals: {}, + config: { + Promise: root.Promise + }, + helpers: { } + }; + + // Defaults + var noop = Rx.helpers.noop = function () { }, + identity = Rx.helpers.identity = function (x) { return x; }, + defaultNow = Rx.helpers.defaultNow = Date.now, + defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); }, + defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); }, + defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); }, + defaultError = Rx.helpers.defaultError = function (err) { throw err; }, + isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; }, + isFunction = Rx.helpers.isFunction = (function () { + + var isFn = function (value) { + return typeof value == 'function' || false; + } + + // fallback for older versions of Chrome and Safari + if (isFn(/x/)) { + isFn = function(value) { + return typeof value == 'function' && toString.call(value) == '[object Function]'; + }; + } + + return isFn; + }()); + + function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;} + + var errorObj = {e: {}}; + + function tryCatcherGen(tryCatchTarget) { + return function tryCatcher() { + try { + return tryCatchTarget.apply(this, arguments); + } catch (e) { + errorObj.e = e; + return errorObj; + } + }; + } + + var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { + if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } + return tryCatcherGen(fn); + }; + + function thrower(e) { + throw e; + } + + Rx.config.longStackSupport = false; + var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })(); + hasStacks = !!stacks.e && !!stacks.e.stack; + + // All code after this point will be filtered from stack traces reported by RxJS + var rStartingLine = captureLine(), rFileName; + + var STACK_JUMP_SEPARATOR = 'From previous event:'; + + function makeStackTraceLong(error, observable) { + // If possible, transform the error stack trace by removing Node and RxJS + // cruft, then concatenating with the stack trace of `observable`. + if (hasStacks && + observable.stack && + typeof error === 'object' && + error !== null && + error.stack && + error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1 + ) { + var stacks = []; + for (var o = observable; !!o; o = o.source) { + if (o.stack) { + stacks.unshift(o.stack); + } + } + stacks.unshift(error.stack); + + var concatedStacks = stacks.join('\n' + STACK_JUMP_SEPARATOR + '\n'); + error.stack = filterStackString(concatedStacks); + } + } + + function filterStackString(stackString) { + var lines = stackString.split('\n'), desiredLines = []; + for (var i = 0, len = lines.length; i < len; i++) { + var line = lines[i]; + + if (!isInternalFrame(line) && !isNodeFrame(line) && line) { + desiredLines.push(line); + } + } + return desiredLines.join('\n'); + } + + function isInternalFrame(stackLine) { + var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine); + if (!fileNameAndLineNumber) { + return false; + } + var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1]; + + return fileName === rFileName && + lineNumber >= rStartingLine && + lineNumber <= rEndingLine; + } + + function isNodeFrame(stackLine) { + return stackLine.indexOf('(module.js:') !== -1 || + stackLine.indexOf('(node.js:') !== -1; + } + + function captureLine() { + if (!hasStacks) { return; } + + try { + throw new Error(); + } catch (e) { + var lines = e.stack.split('\n'); + var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2]; + var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine); + if (!fileNameAndLineNumber) { return; } + + rFileName = fileNameAndLineNumber[0]; + return fileNameAndLineNumber[1]; + } + } + + function getFileNameAndLineNumber(stackLine) { + // Named functions: 'at functionName (filename:lineNumber:columnNumber)' + var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine); + if (attempt1) { return [attempt1[1], Number(attempt1[2])]; } + + // Anonymous functions: 'at filename:lineNumber:columnNumber' + var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine); + if (attempt2) { return [attempt2[1], Number(attempt2[2])]; } + + // Firefox style: 'function@filename:lineNumber or @filename:lineNumber' + var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine); + if (attempt3) { return [attempt3[1], Number(attempt3[2])]; } + } + + var EmptyError = Rx.EmptyError = function() { + this.message = 'Sequence contains no elements.'; + this.name = 'EmptyError'; + Error.call(this); + }; + EmptyError.prototype = Object.create(Error.prototype); + + var ObjectDisposedError = Rx.ObjectDisposedError = function() { + this.message = 'Object has been disposed'; + this.name = 'ObjectDisposedError'; + Error.call(this); + }; + ObjectDisposedError.prototype = Object.create(Error.prototype); + + var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () { + this.message = 'Argument out of range'; + this.name = 'ArgumentOutOfRangeError'; + Error.call(this); + }; + ArgumentOutOfRangeError.prototype = Object.create(Error.prototype); + + var NotSupportedError = Rx.NotSupportedError = function (message) { + this.message = message || 'This operation is not supported'; + this.name = 'NotSupportedError'; + Error.call(this); + }; + NotSupportedError.prototype = Object.create(Error.prototype); + + var NotImplementedError = Rx.NotImplementedError = function (message) { + this.message = message || 'This operation is not implemented'; + this.name = 'NotImplementedError'; + Error.call(this); + }; + NotImplementedError.prototype = Object.create(Error.prototype); + + var notImplemented = Rx.helpers.notImplemented = function () { + throw new NotImplementedError(); + }; + + var notSupported = Rx.helpers.notSupported = function () { + throw new NotSupportedError(); + }; + + // Shim in iterator support + var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || + '_es6shim_iterator_'; + // Bug for mozilla version + if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; + } + + var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined }; + + var isIterable = Rx.helpers.isIterable = function (o) { + return o[$iterator$] !== undefined; + } + + var isArrayLike = Rx.helpers.isArrayLike = function (o) { + return o && o.length !== undefined; + } + + Rx.helpers.iterator = $iterator$; + + var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) { + if (typeof thisArg === 'undefined') { return func; } + switch(argCount) { + case 0: + return function() { + return func.call(thisArg) + }; + case 1: + return function(arg) { + return func.call(thisArg, arg); + } + case 2: + return function(value, index) { + return func.call(thisArg, value, index); + }; + case 3: + return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + } + + return function() { + return func.apply(thisArg, arguments); + }; + }; + + /** Used to determine if values are of the language type Object */ + var dontEnums = ['toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor'], + dontEnumsLength = dontEnums.length; + + /** `Object#toString` result shortcuts */ + var argsClass = '[object Arguments]', + arrayClass = '[object Array]', + boolClass = '[object Boolean]', + dateClass = '[object Date]', + errorClass = '[object Error]', + funcClass = '[object Function]', + numberClass = '[object Number]', + objectClass = '[object Object]', + regexpClass = '[object RegExp]', + stringClass = '[object String]'; + + var toString = Object.prototype.toString, + hasOwnProperty = Object.prototype.hasOwnProperty, + supportsArgsClass = toString.call(arguments) == argsClass, // For less -1); + } + }); + } + } + stackA.pop(); + stackB.pop(); + + return result; + } + + var hasProp = {}.hasOwnProperty, + slice = Array.prototype.slice; + + var inherits = Rx.internals.inherits = function (child, parent) { + function __() { this.constructor = child; } + __.prototype = parent.prototype; + child.prototype = new __(); + }; + + var addProperties = Rx.internals.addProperties = function (obj) { + for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } + for (var idx = 0, ln = sources.length; idx < ln; idx++) { + var source = sources[idx]; + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }; + + // Rx Utils + var addRef = Rx.internals.addRef = function (xs, r) { + return new AnonymousObservable(function (observer) { + return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer)); + }); + }; + + function arrayInitialize(count, factory) { + var a = new Array(count); + for (var i = 0; i < count; i++) { + a[i] = factory(); + } + return a; + } + + function IndexedItem(id, value) { + this.id = id; + this.value = value; + } + + IndexedItem.prototype.compareTo = function (other) { + var c = this.value.compareTo(other.value); + c === 0 && (c = this.id - other.id); + return c; + }; + + var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) { + this.items = new Array(capacity); + this.length = 0; + }; + + var priorityProto = PriorityQueue.prototype; + priorityProto.isHigherPriority = function (left, right) { + return this.items[left].compareTo(this.items[right]) < 0; + }; + + priorityProto.percolate = function (index) { + if (index >= this.length || index < 0) { return; } + var parent = index - 1 >> 1; + if (parent < 0 || parent === index) { return; } + if (this.isHigherPriority(index, parent)) { + var temp = this.items[index]; + this.items[index] = this.items[parent]; + this.items[parent] = temp; + this.percolate(parent); + } + }; + + priorityProto.heapify = function (index) { + +index || (index = 0); + if (index >= this.length || index < 0) { return; } + var left = 2 * index + 1, + right = 2 * index + 2, + first = index; + if (left < this.length && this.isHigherPriority(left, first)) { + first = left; + } + if (right < this.length && this.isHigherPriority(right, first)) { + first = right; + } + if (first !== index) { + var temp = this.items[index]; + this.items[index] = this.items[first]; + this.items[first] = temp; + this.heapify(first); + } + }; + + priorityProto.peek = function () { return this.items[0].value; }; + + priorityProto.removeAt = function (index) { + this.items[index] = this.items[--this.length]; + this.items[this.length] = undefined; + this.heapify(); + }; + + priorityProto.dequeue = function () { + var result = this.peek(); + this.removeAt(0); + return result; + }; + + priorityProto.enqueue = function (item) { + var index = this.length++; + this.items[index] = new IndexedItem(PriorityQueue.count++, item); + this.percolate(index); + }; + + priorityProto.remove = function (item) { + for (var i = 0; i < this.length; i++) { + if (this.items[i].value === item) { + this.removeAt(i); + return true; + } + } + return false; + }; + PriorityQueue.count = 0; + + /** + * Represents a group of disposable resources that are disposed together. + * @constructor + */ + var CompositeDisposable = Rx.CompositeDisposable = function () { + var args = [], i, len; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + len = args.length; + } else { + len = arguments.length; + args = new Array(len); + for(i = 0; i < len; i++) { args[i] = arguments[i]; } + } + this.disposables = args; + this.isDisposed = false; + this.length = args.length; + }; + + var CompositeDisposablePrototype = CompositeDisposable.prototype; + + /** + * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. + * @param {Mixed} item Disposable to add. + */ + CompositeDisposablePrototype.add = function (item) { + if (this.isDisposed) { + item.dispose(); + } else { + this.disposables.push(item); + this.length++; + } + }; + + /** + * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. + * @param {Mixed} item Disposable to remove. + * @returns {Boolean} true if found; false otherwise. + */ + CompositeDisposablePrototype.remove = function (item) { + var shouldDispose = false; + if (!this.isDisposed) { + var idx = this.disposables.indexOf(item); + if (idx !== -1) { + shouldDispose = true; + this.disposables.splice(idx, 1); + this.length--; + item.dispose(); + } + } + return shouldDispose; + }; + + /** + * Disposes all disposables in the group and removes them from the group. + */ + CompositeDisposablePrototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var len = this.disposables.length, currentDisposables = new Array(len); + for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } + this.disposables = []; + this.length = 0; + + for (i = 0; i < len; i++) { + currentDisposables[i].dispose(); + } + } + }; + + /** + * Provides a set of static methods for creating Disposables. + * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. + */ + var Disposable = Rx.Disposable = function (action) { + this.isDisposed = false; + this.action = action || noop; + }; + + /** Performs the task of cleaning up resources. */ + Disposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.action(); + this.isDisposed = true; + } + }; + + /** + * Creates a disposable object that invokes the specified action when disposed. + * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. + * @return {Disposable} The disposable object that runs the given action upon disposal. + */ + var disposableCreate = Disposable.create = function (action) { return new Disposable(action); }; + + /** + * Gets the disposable that does nothing when disposed. + */ + var disposableEmpty = Disposable.empty = { dispose: noop }; + + /** + * Validates whether the given object is a disposable + * @param {Object} Object to test whether it has a dispose method + * @returns {Boolean} true if a disposable object, else false. + */ + var isDisposable = Disposable.isDisposable = function (d) { + return d && isFunction(d.dispose); + }; + + var checkDisposed = Disposable.checkDisposed = function (disposable) { + if (disposable.isDisposed) { throw new ObjectDisposedError(); } + }; + + var disposableFixup = Disposable._fixup = function (result) { + return isDisposable(result) ? result : disposableEmpty; + }; + + // Single assignment + var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () { + this.isDisposed = false; + this.current = null; + }; + SingleAssignmentDisposable.prototype.getDisposable = function () { + return this.current; + }; + SingleAssignmentDisposable.prototype.setDisposable = function (value) { + if (this.current) { throw new Error('Disposable has already been assigned'); } + var shouldDispose = this.isDisposed; + !shouldDispose && (this.current = value); + shouldDispose && value && value.dispose(); + }; + SingleAssignmentDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old = this.current; + this.current = null; + old && old.dispose(); + } + }; + + // Multiple assignment disposable + var SerialDisposable = Rx.SerialDisposable = function () { + this.isDisposed = false; + this.current = null; + }; + SerialDisposable.prototype.getDisposable = function () { + return this.current; + }; + SerialDisposable.prototype.setDisposable = function (value) { + var shouldDispose = this.isDisposed; + if (!shouldDispose) { + var old = this.current; + this.current = value; + } + old && old.dispose(); + shouldDispose && value && value.dispose(); + }; + SerialDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old = this.current; + this.current = null; + } + old && old.dispose(); + }; + + var BinaryDisposable = Rx.BinaryDisposable = function (first, second) { + this._first = first; + this._second = second; + this.isDisposed = false; + }; + + BinaryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old1 = this._first; + this._first = null; + old1 && old1.dispose(); + var old2 = this._second; + this._second = null; + old2 && old2.dispose(); + } + }; + + var NAryDisposable = Rx.NAryDisposable = function (disposables) { + this._disposables = disposables; + this.isDisposed = false; + }; + + NAryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + for (var i = 0, len = this._disposables.length; i < len; i++) { + this._disposables[i].dispose(); + } + this._disposables.length = 0; + } + }; + + /** + * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. + */ + var RefCountDisposable = Rx.RefCountDisposable = (function () { + + function InnerDisposable(disposable) { + this.disposable = disposable; + this.disposable.count++; + this.isInnerDisposed = false; + } + + InnerDisposable.prototype.dispose = function () { + if (!this.disposable.isDisposed && !this.isInnerDisposed) { + this.isInnerDisposed = true; + this.disposable.count--; + if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) { + this.disposable.isDisposed = true; + this.disposable.underlyingDisposable.dispose(); + } + } + }; + + /** + * Initializes a new instance of the RefCountDisposable with the specified disposable. + * @constructor + * @param {Disposable} disposable Underlying disposable. + */ + function RefCountDisposable(disposable) { + this.underlyingDisposable = disposable; + this.isDisposed = false; + this.isPrimaryDisposed = false; + this.count = 0; + } + + /** + * Disposes the underlying disposable only when all dependent disposables have been disposed + */ + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed && !this.isPrimaryDisposed) { + this.isPrimaryDisposed = true; + if (this.count === 0) { + this.isDisposed = true; + this.underlyingDisposable.dispose(); + } + } + }; + + /** + * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable. + * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime. + */ + RefCountDisposable.prototype.getDisposable = function () { + return this.isDisposed ? disposableEmpty : new InnerDisposable(this); + }; + + return RefCountDisposable; + })(); + + function ScheduledDisposable(scheduler, disposable) { + this.scheduler = scheduler; + this.disposable = disposable; + this.isDisposed = false; + } + + function scheduleItem(s, self) { + if (!self.isDisposed) { + self.isDisposed = true; + self.disposable.dispose(); + } + } + + ScheduledDisposable.prototype.dispose = function () { + this.scheduler.schedule(this, scheduleItem); + }; + + var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) { + this.scheduler = scheduler; + this.state = state; + this.action = action; + this.dueTime = dueTime; + this.comparer = comparer || defaultSubComparer; + this.disposable = new SingleAssignmentDisposable(); + } + + ScheduledItem.prototype.invoke = function () { + this.disposable.setDisposable(this.invokeCore()); + }; + + ScheduledItem.prototype.compareTo = function (other) { + return this.comparer(this.dueTime, other.dueTime); + }; + + ScheduledItem.prototype.isCancelled = function () { + return this.disposable.isDisposed; + }; + + ScheduledItem.prototype.invokeCore = function () { + return disposableFixup(this.action(this.scheduler, this.state)); + }; + + /** Provides a set of static properties to access commonly used schedulers. */ + var Scheduler = Rx.Scheduler = (function () { + + function Scheduler() { } + + /** Determines whether the given object is a scheduler */ + Scheduler.isScheduler = function (s) { + return s instanceof Scheduler; + }; + + var schedulerProto = Scheduler.prototype; + + /** + * Schedules an action to be executed. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.schedule = function (state, action) { + throw new NotImplementedError(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime; + dt instanceof Date && (dt = dt - this.now()); + dt = Scheduler.normalize(dt); + + if (dt === 0) { return this.schedule(state, action); } + + return this._scheduleFuture(state, dt, action); + }; + + schedulerProto._scheduleFuture = function (state, dueTime, action) { + throw new NotImplementedError(); + }; + + /** Gets the current time according to the local machine's system clock. */ + Scheduler.now = defaultNow; + + /** Gets the current time according to the local machine's system clock. */ + Scheduler.prototype.now = defaultNow; + + /** + * Normalizes the specified TimeSpan value to a positive value. + * @param {Number} timeSpan The time span value to normalize. + * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0 + */ + Scheduler.normalize = function (timeSpan) { + timeSpan < 0 && (timeSpan = 0); + return timeSpan; + }; + + return Scheduler; + }()); + + var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler; + + (function (schedulerProto) { + + function invokeRecImmediate(scheduler, pair) { + var state = pair[0], action = pair[1], group = new CompositeDisposable(); + action(state, innerAction); + return group; + + function innerAction(state2) { + var isAdded = false, isDone = false; + + var d = scheduler.schedule(state2, scheduleWork); + if (!isDone) { + group.add(d); + isAdded = true; + } + + function scheduleWork(_, state3) { + if (isAdded) { + group.remove(d); + } else { + isDone = true; + } + action(state3, innerAction); + return disposableEmpty; + } + } + } + + function invokeRecDate(scheduler, pair) { + var state = pair[0], action = pair[1], group = new CompositeDisposable(); + action(state, innerAction); + return group; + + function innerAction(state2, dueTime1) { + var isAdded = false, isDone = false; + + var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork); + if (!isDone) { + group.add(d); + isAdded = true; + } + + function scheduleWork(_, state3) { + if (isAdded) { + group.remove(d); + } else { + isDone = true; + } + action(state3, innerAction); + return disposableEmpty; + } + } + } + + /** + * Schedules an action to be executed recursively. + * @param {Mixed} state State passed to the action to be executed. + * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleRecursive = function (state, action) { + return this.schedule([state, action], invokeRecImmediate); + }; + + /** + * Schedules an action to be executed recursively after a specified relative or absolute due time. + * @param {Mixed} state State passed to the action to be executed. + * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. + * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) { + return this.scheduleFuture([state, action], dueTime, invokeRecDate); + }; + + }(Scheduler.prototype)); + + (function (schedulerProto) { + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + Scheduler.prototype.schedulePeriodic = function(state, period, action) { + if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); } + period = normalizeTime(period); + var s = state, id = root.setInterval(function () { s = action(s); }, period); + return disposableCreate(function () { root.clearInterval(id); }); + }; + + }(Scheduler.prototype)); + + (function (schedulerProto) { + /** + * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions. + * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false. + * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling. + */ + schedulerProto.catchError = schedulerProto['catch'] = function (handler) { + return new CatchScheduler(this, handler); + }; + }(Scheduler.prototype)); + + var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () { + function tick(command, recurse) { + recurse(0, this._period); + try { + this._state = this._action(this._state); + } catch (e) { + this._cancel.dispose(); + throw e; + } + } + + function SchedulePeriodicRecursive(scheduler, state, period, action) { + this._scheduler = scheduler; + this._state = state; + this._period = period; + this._action = action; + } + + SchedulePeriodicRecursive.prototype.start = function () { + var d = new SingleAssignmentDisposable(); + this._cancel = d; + d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this))); + + return d; + }; + + return SchedulePeriodicRecursive; + }()); + + /** Gets a scheduler that schedules work immediately on the current thread. */ + var ImmediateScheduler = (function (__super__) { + inherits(ImmediateScheduler, __super__); + function ImmediateScheduler() { + __super__.call(this); + } + + ImmediateScheduler.prototype.schedule = function (state, action) { + return disposableFixup(action(this, state)); + }; + + return ImmediateScheduler; + }(Scheduler)); + + var immediateScheduler = Scheduler.immediate = new ImmediateScheduler(); + + /** + * Gets a scheduler that schedules work as soon as possible on the current thread. + */ + var CurrentThreadScheduler = (function (__super__) { + var queue; + + function runTrampoline () { + while (queue.length > 0) { + var item = queue.dequeue(); + !item.isCancelled() && item.invoke(); + } + } + + inherits(CurrentThreadScheduler, __super__); + function CurrentThreadScheduler() { + __super__.call(this); + } + + CurrentThreadScheduler.prototype.schedule = function (state, action) { + var si = new ScheduledItem(this, state, action, this.now()); + + if (!queue) { + queue = new PriorityQueue(4); + queue.enqueue(si); + + var result = tryCatch(runTrampoline)(); + queue = null; + if (result === errorObj) { thrower(result.e); } + } else { + queue.enqueue(si); + } + return si.disposable; + }; + + CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; }; + + return CurrentThreadScheduler; + }(Scheduler)); + + var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler(); + + var scheduleMethod, clearMethod; + + var localTimer = (function () { + var localSetTimeout, localClearTimeout = noop; + if (!!root.setTimeout) { + localSetTimeout = root.setTimeout; + localClearTimeout = root.clearTimeout; + } else if (!!root.WScript) { + localSetTimeout = function (fn, time) { + root.WScript.Sleep(time); + fn(); + }; + } else { + throw new NotSupportedError(); + } + + return { + setTimeout: localSetTimeout, + clearTimeout: localClearTimeout + }; + }()); + var localSetTimeout = localTimer.setTimeout, + localClearTimeout = localTimer.clearTimeout; + + (function () { + + var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false; + + clearMethod = function (handle) { + delete tasksByHandle[handle]; + }; + + function runTask(handle) { + if (currentlyRunning) { + localSetTimeout(function () { runTask(handle); }, 0); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunning = true; + var result = tryCatch(task)(); + clearMethod(handle); + currentlyRunning = false; + if (result === errorObj) { thrower(result.e); } + } + } + } + + var reNative = new RegExp('^' + + String(toString) + .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + .replace(/toString| for [^\]]+/g, '.*?') + '$' + ); + + var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' && + !reNative.test(setImmediate) && setImmediate; + + function postMessageSupported () { + // Ensure not in a worker + if (!root.postMessage || root.importScripts) { return false; } + var isAsync = false, oldHandler = root.onmessage; + // Test for async + root.onmessage = function () { isAsync = true; }; + root.postMessage('', '*'); + root.onmessage = oldHandler; + + return isAsync; + } + + // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout + if (isFunction(setImmediate)) { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + setImmediate(function () { runTask(id); }); + + return id; + }; + } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + process.nextTick(function () { runTask(id); }); + + return id; + }; + } else if (postMessageSupported()) { + var MSG_PREFIX = 'ms.rx.schedule' + Math.random(); + + function onGlobalPostMessage(event) { + // Only if we're a match to avoid any other global events + if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) { + runTask(event.data.substring(MSG_PREFIX.length)); + } + } + + if (root.addEventListener) { + root.addEventListener('message', onGlobalPostMessage, false); + } else if (root.attachEvent) { + root.attachEvent('onmessage', onGlobalPostMessage); + } else { + root.onmessage = onGlobalPostMessage; + } + + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + root.postMessage(MSG_PREFIX + currentId, '*'); + return id; + }; + } else if (!!root.MessageChannel) { + var channel = new root.MessageChannel(); + + channel.port1.onmessage = function (e) { runTask(e.data); }; + + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + channel.port2.postMessage(id); + return id; + }; + } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) { + + scheduleMethod = function (action) { + var scriptElement = root.document.createElement('script'); + var id = nextHandle++; + tasksByHandle[id] = action; + + scriptElement.onreadystatechange = function () { + runTask(id); + scriptElement.onreadystatechange = null; + scriptElement.parentNode.removeChild(scriptElement); + scriptElement = null; + }; + root.document.documentElement.appendChild(scriptElement); + return id; + }; + + } else { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + localSetTimeout(function () { + runTask(id); + }, 0); + + return id; + }; + } + }()); + + /** + * Gets a scheduler that schedules work via a timed callback based upon platform. + */ + var DefaultScheduler = (function (__super__) { + inherits(DefaultScheduler, __super__); + function DefaultScheduler() { + __super__.call(this); + } + + function DefaultSchedulerDisposable(id) { + this._id = id; + this.isDisposed = false; + } + + DefaultSchedulerDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + localClearTimeout(this._id); + } + }; + + DefaultScheduler.prototype.schedule = function (state, action) { + var scheduler = this, disposable = new SingleAssignmentDisposable(); + var id = scheduleMethod(function () { + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); + }); + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; + + DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable(); + if (dt === 0) { return scheduler.schedule(state, action); } + var id = localSetTimeout(function () { + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); + }, dt); + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; + + return DefaultScheduler; + }(Scheduler)); + + var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler(); + + var CatchScheduler = (function (__super__) { + inherits(CatchScheduler, __super__); + + function CatchScheduler(scheduler, handler) { + this._scheduler = scheduler; + this._handler = handler; + this._recursiveOriginal = null; + this._recursiveWrapper = null; + __super__.call(this); + } + + CatchScheduler.prototype.schedule = function (state, action) { + return this._scheduler.schedule(state, this._wrap(action)); + }; + + CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + return this._scheduler.schedule(state, dueTime, this._wrap(action)); + }; + + CatchScheduler.prototype.now = function () { return this._scheduler.now(); }; + + CatchScheduler.prototype._clone = function (scheduler) { + return new CatchScheduler(scheduler, this._handler); + }; + + CatchScheduler.prototype._wrap = function (action) { + var parent = this; + return function (self, state) { + var res = tryCatch(action)(parent._getRecursiveWrapper(self), state); + if (res === errorObj) { + if (!parent._handler(res.e)) { thrower(res.e); } + return disposableEmpty; + } + return disposableFixup(ret); + }; + }; + + CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { + if (this._recursiveOriginal !== scheduler) { + this._recursiveOriginal = scheduler; + var wrapper = this._clone(scheduler); + wrapper._recursiveOriginal = scheduler; + wrapper._recursiveWrapper = wrapper; + this._recursiveWrapper = wrapper; + } + return this._recursiveWrapper; + }; + + CatchScheduler.prototype.schedulePeriodic = function (state, period, action) { + var self = this, failed = false, d = new SingleAssignmentDisposable(); + + d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) { + if (failed) { return null; } + var res = tryCatch(action)(state1); + if (res === errorObj) { + failed = true; + if (!self._handler(res.e)) { thrower(res.e); } + d.dispose(); + return null; + } + return ret; + })); + + return d; + }; + + return CatchScheduler; + }(Scheduler)); + + /** + * Represents a notification to an observer. + */ + var Notification = Rx.Notification = (function () { + function Notification() { + + } + + Notification.prototype._accept = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + /** + * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. + * + * @memberOf Notification + * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. + * @param {Function} onError Delegate to invoke for an OnError notification. + * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. + * @returns {Any} Result produced by the observation. + */ + Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) { + return observerOrOnNext && typeof observerOrOnNext === 'object' ? + this._acceptObservable(observerOrOnNext) : + this._accept(observerOrOnNext, onError, onCompleted); + }; + + /** + * Returns an observable sequence with a single notification. + * + * @memberOf Notifications + * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on. + * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription. + */ + Notification.prototype.toObservable = function (scheduler) { + var self = this; + isScheduler(scheduler) || (scheduler = immediateScheduler); + return new AnonymousObservable(function (o) { + return scheduler.schedule(self, function (_, notification) { + notification._acceptObservable(o); + notification.kind === 'N' && o.onCompleted(); + }); + }); + }; + + return Notification; + })(); + + var OnNextNotification = (function (__super__) { + inherits(OnNextNotification, __super__); + function OnNextNotification(value) { + this.value = value; + this.kind = 'N'; + } + + OnNextNotification.prototype._accept = function (onNext) { + return onNext(this.value); + }; + + OnNextNotification.prototype._acceptObservable = function (o) { + return o.onNext(this.value); + }; + + OnNextNotification.prototype.toString = function () { + return 'OnNext(' + this.value + ')'; + }; + + return OnNextNotification; + }(Notification)); + + var OnErrorNotification = (function (__super__) { + inherits(OnErrorNotification, __super__); + function OnErrorNotification(error) { + this.error = error; + this.kind = 'E'; + } + + OnErrorNotification.prototype._accept = function (onNext, onError) { + return onError(this.error); + }; + + OnErrorNotification.prototype._acceptObservable = function (o) { + return o.onError(this.error); + }; + + OnErrorNotification.prototype.toString = function () { + return 'OnError(' + this.error + ')'; + }; + + return OnErrorNotification; + }(Notification)); + + var OnCompletedNotification = (function (__super__) { + inherits(OnCompletedNotification, __super__); + function OnCompletedNotification() { + this.kind = 'C'; + } + + OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) { + return onCompleted(); + }; + + OnCompletedNotification.prototype._acceptObservable = function (o) { + return o.onCompleted(); + }; + + OnCompletedNotification.prototype.toString = function () { + return 'OnCompleted()'; + }; + + return OnCompletedNotification; + }(Notification)); + + /** + * Creates an object that represents an OnNext notification to an observer. + * @param {Any} value The value contained in the notification. + * @returns {Notification} The OnNext notification containing the value. + */ + var notificationCreateOnNext = Notification.createOnNext = function (value) { + return new OnNextNotification(value); + }; + + /** + * Creates an object that represents an OnError notification to an observer. + * @param {Any} error The exception contained in the notification. + * @returns {Notification} The OnError notification containing the exception. + */ + var notificationCreateOnError = Notification.createOnError = function (error) { + return new OnErrorNotification(error); + }; + + /** + * Creates an object that represents an OnCompleted notification to an observer. + * @returns {Notification} The OnCompleted notification. + */ + var notificationCreateOnCompleted = Notification.createOnCompleted = function () { + return new OnCompletedNotification(); + }; + + /** + * Supports push-style iteration over an observable sequence. + */ + var Observer = Rx.Observer = function () { }; + + /** + * Creates a notification callback from an observer. + * @returns The action that forwards its input notification to the underlying observer. + */ + Observer.prototype.toNotifier = function () { + var observer = this; + return function (n) { return n.accept(observer); }; + }; + + /** + * Hides the identity of an observer. + * @returns An observer that hides the identity of the specified observer. + */ + Observer.prototype.asObserver = function () { + var self = this; + return new AnonymousObserver( + function (x) { self.onNext(x); }, + function (err) { self.onError(err); }, + function () { self.onCompleted(); }); + }; + + /** + * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods. + * If a violation is detected, an Error is thrown from the offending observer method call. + * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer. + */ + Observer.prototype.checked = function () { return new CheckedObserver(this); }; + + /** + * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions. + * @param {Function} [onNext] Observer's OnNext action implementation. + * @param {Function} [onError] Observer's OnError action implementation. + * @param {Function} [onCompleted] Observer's OnCompleted action implementation. + * @returns {Observer} The observer object implemented using the given actions. + */ + var observerCreate = Observer.create = function (onNext, onError, onCompleted) { + onNext || (onNext = noop); + onError || (onError = defaultError); + onCompleted || (onCompleted = noop); + return new AnonymousObserver(onNext, onError, onCompleted); + }; + + /** + * Creates an observer from a notification callback. + * @param {Function} handler Action that handles a notification. + * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives. + */ + Observer.fromNotifier = function (handler, thisArg) { + var cb = bindCallback(handler, thisArg, 1); + return new AnonymousObserver(function (x) { + return cb(notificationCreateOnNext(x)); + }, function (e) { + return cb(notificationCreateOnError(e)); + }, function () { + return cb(notificationCreateOnCompleted()); + }); + }; + + /** + * Schedules the invocation of observer methods on the given scheduler. + * @param {Scheduler} scheduler Scheduler to schedule observer messages on. + * @returns {Observer} Observer whose messages are scheduled on the given scheduler. + */ + Observer.prototype.notifyOn = function (scheduler) { + return new ObserveOnObserver(scheduler, this); + }; + + Observer.prototype.makeSafe = function(disposable) { + return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable); + }; + + /** + * Abstract base class for implementations of the Observer class. + * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages. + */ + var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) { + inherits(AbstractObserver, __super__); + + /** + * Creates a new observer in a non-stopped state. + */ + function AbstractObserver() { + this.isStopped = false; + } + + // Must be implemented by other observers + AbstractObserver.prototype.next = notImplemented; + AbstractObserver.prototype.error = notImplemented; + AbstractObserver.prototype.completed = notImplemented; + + /** + * Notifies the observer of a new element in the sequence. + * @param {Any} value Next element in the sequence. + */ + AbstractObserver.prototype.onNext = function (value) { + !this.isStopped && this.next(value); + }; + + /** + * Notifies the observer that an exception has occurred. + * @param {Any} error The error that has occurred. + */ + AbstractObserver.prototype.onError = function (error) { + if (!this.isStopped) { + this.isStopped = true; + this.error(error); + } + }; + + /** + * Notifies the observer of the end of the sequence. + */ + AbstractObserver.prototype.onCompleted = function () { + if (!this.isStopped) { + this.isStopped = true; + this.completed(); + } + }; + + /** + * Disposes the observer, causing it to transition to the stopped state. + */ + AbstractObserver.prototype.dispose = function () { this.isStopped = true; }; + + AbstractObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.error(e); + return true; + } + + return false; + }; + + return AbstractObserver; + }(Observer)); + + /** + * Class to create an Observer instance from delegate-based implementations of the on* methods. + */ + var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) { + inherits(AnonymousObserver, __super__); + + /** + * Creates an observer from the specified OnNext, OnError, and OnCompleted actions. + * @param {Any} onNext Observer's OnNext action implementation. + * @param {Any} onError Observer's OnError action implementation. + * @param {Any} onCompleted Observer's OnCompleted action implementation. + */ + function AnonymousObserver(onNext, onError, onCompleted) { + __super__.call(this); + this._onNext = onNext; + this._onError = onError; + this._onCompleted = onCompleted; + } + + /** + * Calls the onNext action. + * @param {Any} value Next element in the sequence. + */ + AnonymousObserver.prototype.next = function (value) { + this._onNext(value); + }; + + /** + * Calls the onError action. + * @param {Any} error The error that has occurred. + */ + AnonymousObserver.prototype.error = function (error) { + this._onError(error); + }; + + /** + * Calls the onCompleted action. + */ + AnonymousObserver.prototype.completed = function () { + this._onCompleted(); + }; + + return AnonymousObserver; + }(AbstractObserver)); + + var CheckedObserver = (function (__super__) { + inherits(CheckedObserver, __super__); + + function CheckedObserver(observer) { + __super__.call(this); + this._observer = observer; + this._state = 0; // 0 - idle, 1 - busy, 2 - done + } + + var CheckedObserverPrototype = CheckedObserver.prototype; + + CheckedObserverPrototype.onNext = function (value) { + this.checkAccess(); + var res = tryCatch(this._observer.onNext).call(this._observer, value); + this._state = 0; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.onError = function (err) { + this.checkAccess(); + var res = tryCatch(this._observer.onError).call(this._observer, err); + this._state = 2; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.onCompleted = function () { + this.checkAccess(); + var res = tryCatch(this._observer.onCompleted).call(this._observer); + this._state = 2; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.checkAccess = function () { + if (this._state === 1) { throw new Error('Re-entrancy detected'); } + if (this._state === 2) { throw new Error('Observer completed'); } + if (this._state === 0) { this._state = 1; } + }; + + return CheckedObserver; + }(Observer)); + + var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) { + inherits(ScheduledObserver, __super__); + + function ScheduledObserver(scheduler, observer) { + __super__.call(this); + this.scheduler = scheduler; + this.observer = observer; + this.isAcquired = false; + this.hasFaulted = false; + this.queue = []; + this.disposable = new SerialDisposable(); + } + + ScheduledObserver.prototype.next = function (value) { + var self = this; + this.queue.push(function () { self.observer.onNext(value); }); + }; + + ScheduledObserver.prototype.error = function (e) { + var self = this; + this.queue.push(function () { self.observer.onError(e); }); + }; + + ScheduledObserver.prototype.completed = function () { + var self = this; + this.queue.push(function () { self.observer.onCompleted(); }); + }; + + ScheduledObserver.prototype.ensureActive = function () { + var isOwner = false; + if (!this.hasFaulted && this.queue.length > 0) { + isOwner = !this.isAcquired; + this.isAcquired = true; + } + if (isOwner) { + this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) { + var work; + if (parent.queue.length > 0) { + work = parent.queue.shift(); + } else { + parent.isAcquired = false; + return; + } + var res = tryCatch(work)(); + if (res === errorObj) { + parent.queue = []; + parent.hasFaulted = true; + return thrower(res.e); + } + self(parent); + })); + } + }; + + ScheduledObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this.disposable.dispose(); + }; + + return ScheduledObserver; + }(AbstractObserver)); + + var ObserveOnObserver = (function (__super__) { + inherits(ObserveOnObserver, __super__); + + function ObserveOnObserver(scheduler, observer, cancel) { + __super__.call(this, scheduler, observer); + this._cancel = cancel; + } + + ObserveOnObserver.prototype.next = function (value) { + __super__.prototype.next.call(this, value); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.error = function (e) { + __super__.prototype.error.call(this, e); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.completed = function () { + __super__.prototype.completed.call(this); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this._cancel && this._cancel.dispose(); + this._cancel = null; + }; + + return ObserveOnObserver; + })(ScheduledObserver); + + var observableProto; + + /** + * Represents a push-style collection. + */ + var Observable = Rx.Observable = (function () { + + function makeSubscribe(self, subscribe) { + return function (o) { + var oldOnError = o.onError; + o.onError = function (e) { + makeStackTraceLong(e, self); + oldOnError.call(o, e); + }; + + return subscribe.call(self, o); + }; + } + + function Observable() { + if (Rx.config.longStackSupport && hasStacks) { + var oldSubscribe = this._subscribe; + var e = tryCatch(thrower)(new Error()).e; + this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); + this._subscribe = makeSubscribe(this, oldSubscribe); + } + } + + observableProto = Observable.prototype; + + /** + * Determines whether the given object is an Observable + * @param {Any} An object to determine whether it is an Observable + * @returns {Boolean} true if an Observable, else false. + */ + Observable.isObservable = function (o) { + return o && isFunction(o.subscribe); + }; + + /** + * Subscribes an o to the observable sequence. + * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. + * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { + return this._subscribe(typeof oOrOnNext === 'object' ? + oOrOnNext : + observerCreate(oOrOnNext, onError, onCompleted)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onNext The function to invoke on each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnNext = function (onNext, thisArg) { + return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + }; + + /** + * Subscribes to an exceptional condition in the sequence with an optional "this" argument. + * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnError = function (onError, thisArg) { + return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { + return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + }; + + return Observable; + })(); + + var ObservableBase = Rx.ObservableBase = (function (__super__) { + inherits(ObservableBase, __super__); + + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.subscribeCore).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function ObservableBase() { + __super__.call(this); + } + + ObservableBase.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + ObservableBase.prototype.subscribeCore = notImplemented; + + return ObservableBase; + }(Observable)); + +var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) { + + inherits(FlatMapObservable, __super__); + + function FlatMapObservable(source, selector, resultSelector, thisArg) { + this.resultSelector = isFunction(resultSelector) ? resultSelector : null; + this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); + this.source = source; + __super__.call(this); + } + + FlatMapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(observer, selector, resultSelector, source) { + this.i = 0; + this.selector = selector; + this.resultSelector = resultSelector; + this.source = source; + this.o = observer; + AbstractObserver.call(this); + } + + InnerObserver.prototype._wrapResult = function(result, x, i) { + return this.resultSelector ? + result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : + result; + }; + + InnerObserver.prototype.next = function(x) { + var i = this.i++; + var result = tryCatch(this.selector)(x, i, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result)); + this.o.onNext(this._wrapResult(result, x, i)); + }; + + InnerObserver.prototype.error = function(e) { this.o.onError(e); }; + + InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); }; + + return FlatMapObservable; + +}(ObservableBase)); + + var Enumerable = Rx.internals.Enumerable = function () { }; + + function IsDisposedDisposable(state) { + this._s = state; + this.isDisposed = false; + } + + IsDisposedDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.isDisposed = true; + } + }; + + var ConcatEnumerableObservable = (function(__super__) { + inherits(ConcatEnumerableObservable, __super__); + function ConcatEnumerableObservable(sources) { + this.sources = sources; + __super__.call(this); + } + + ConcatEnumerableObservable.prototype.subscribeCore = function (o) { + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + return o.onCompleted(); + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e))); + }); + + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, s, e) { + this._o = o; + this._s = s; + this._e = e; + AbstractObserver.call(this); + } + InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.onError = function (e) { this._o.onError(e); }; + InnerObserver.prototype.onCompleted = function () { this._s(this._e); }; + + return ConcatEnumerableObservable; + }(ObservableBase)); + + Enumerable.prototype.concat = function () { + return new ConcatEnumerableObservable(this); + }; + + var CatchErrorObservable = (function(__super__) { + inherits(CatchErrorObservable, __super__); + function CatchErrorObservable(sources) { + this.sources = sources; + __super__.call(this); + } + + CatchErrorObservable.prototype.subscribeCore = function (o) { + var e = this.sources[$iterator$](); + + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + return lastException !== null ? o.onError(lastException) : o.onCompleted(); + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self))); + }); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, recurse) { + this._o = o; + this._recurse = recurse; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.error = function (e) { this._recurse(e); }; + InnerObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return CatchErrorObservable; + }(ObservableBase)); + + Enumerable.prototype.catchError = function () { + return new CatchErrorObservable(this); + }; + + Enumerable.prototype.catchErrorWhen = function (notificationHandler) { + var sources = this; + return new AnonymousObservable(function (o) { + var exceptions = new Subject(), + notifier = new Subject(), + handled = notificationHandler(exceptions), + notificationDisposable = handled.subscribe(notifier); + + var e = sources[$iterator$](); + + var state = { isDisposed: false }, + lastException, + subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + if (lastException) { + o.onError(lastException); + } else { + o.onCompleted(); + } + return; + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var outer = new SingleAssignmentDisposable(); + var inner = new SingleAssignmentDisposable(); + subscription.setDisposable(new BinaryDisposable(inner, outer)); + outer.setDisposable(currentValue.subscribe( + function(x) { o.onNext(x); }, + function (exn) { + inner.setDisposable(notifier.subscribe(self, function(ex) { + o.onError(ex); + }, function() { + o.onCompleted(); + })); + + exceptions.onNext(exn); + }, + function() { o.onCompleted(); })); + }); + + return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]); + }); + }; + + var RepeatEnumerable = (function (__super__) { + inherits(RepeatEnumerable, __super__); + + function RepeatEnumerable(v, c) { + this.v = v; + this.c = c == null ? -1 : c; + } + RepeatEnumerable.prototype[$iterator$] = function () { + return new RepeatEnumerator(this); + }; + + function RepeatEnumerator(p) { + this.v = p.v; + this.l = p.c; + } + RepeatEnumerator.prototype.next = function () { + if (this.l === 0) { return doneEnumerator; } + if (this.l > 0) { this.l--; } + return { done: false, value: this.v }; + }; + + return RepeatEnumerable; + }(Enumerable)); + + var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) { + return new RepeatEnumerable(value, repeatCount); + }; + + var OfEnumerable = (function(__super__) { + inherits(OfEnumerable, __super__); + function OfEnumerable(s, fn, thisArg) { + this.s = s; + this.fn = fn ? bindCallback(fn, thisArg, 3) : null; + } + OfEnumerable.prototype[$iterator$] = function () { + return new OfEnumerator(this); + }; + + function OfEnumerator(p) { + this.i = -1; + this.s = p.s; + this.l = this.s.length; + this.fn = p.fn; + } + OfEnumerator.prototype.next = function () { + return ++this.i < this.l ? + { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } : + doneEnumerator; + }; + + return OfEnumerable; + }(Enumerable)); + + var enumerableOf = Enumerable.of = function (source, selector, thisArg) { + return new OfEnumerable(source, selector, thisArg); + }; + +var ObserveOnObservable = (function (__super__) { + inherits(ObserveOnObservable, __super__); + function ObserveOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + ObserveOnObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ObserveOnObserver(this._s, o)); + }; + + return ObserveOnObservable; +}(ObservableBase)); + + /** + * Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + * + * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects + * that require to be run on a scheduler, use subscribeOn. + * + * @param {Scheduler} scheduler Scheduler to notify observers on. + * @returns {Observable} The source sequence whose observations happen on the specified scheduler. + */ + observableProto.observeOn = function (scheduler) { + return new ObserveOnObservable(this, scheduler); + }; + + var SubscribeOnObservable = (function (__super__) { + inherits(SubscribeOnObservable, __super__); + function SubscribeOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + function scheduleMethod(scheduler, state) { + var source = state[0], d = state[1], o = state[2]; + d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o))); + } + + SubscribeOnObservable.prototype.subscribeCore = function (o) { + var m = new SingleAssignmentDisposable(), d = new SerialDisposable(); + d.setDisposable(m); + m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod)); + return d; + }; + + return SubscribeOnObservable; + }(ObservableBase)); + + /** + * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used; + * see the remarks section for more information on the distinction between subscribeOn and observeOn. + + * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer + * callbacks on a scheduler, use observeOn. + + * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on. + * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + observableProto.subscribeOn = function (scheduler) { + return new SubscribeOnObservable(this, scheduler); + }; + + var FromPromiseObservable = (function(__super__) { + inherits(FromPromiseObservable, __super__); + function FromPromiseObservable(p) { + this.p = p; + __super__.call(this); + } + + FromPromiseObservable.prototype.subscribeCore = function(o) { + this.p + .then(function (data) { + o.onNext(data); + o.onCompleted(); + }, function (err) { + o.onError(err); + }); + return disposableEmpty; + }; + + return FromPromiseObservable; + }(ObservableBase)); + + /** + * Converts a Promise to an Observable sequence + * @param {Promise} An ES6 Compliant promise. + * @returns {Observable} An Observable sequence which wraps the existing promise success and failure. + */ + var observableFromPromise = Observable.fromPromise = function (promise) { + return new FromPromiseObservable(promise); + }; + + /* + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence. + */ + observableProto.toPromise = function (promiseCtor) { + promiseCtor || (promiseCtor = Rx.config.Promise); + if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); } + var source = this; + return new promiseCtor(function (resolve, reject) { + // No cancellation can be done + var value; + source.subscribe(function (v) { + value = v; + }, reject, function () { + resolve(value); + }); + }); + }; + + var ToArrayObservable = (function(__super__) { + inherits(ToArrayObservable, __super__); + function ToArrayObservable(source) { + this.source = source; + __super__.call(this); + } + + ToArrayObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o) { + this.o = o; + this.a = []; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this.a.push(x); }; + InnerObserver.prototype.error = function (e) { this.o.onError(e); }; + InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); }; + + return ToArrayObservable; + }(ObservableBase)); + + /** + * Creates an array from an observable sequence. + * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + */ + observableProto.toArray = function () { + return new ToArrayObservable(this); + }; + + /** + * Creates an observable sequence from a specified subscribe method implementation. + * @example + * var res = Rx.Observable.create(function (observer) { return function () { } ); + * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } ); + * var res = Rx.Observable.create(function (observer) { } ); + * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable. + * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method. + */ + Observable.create = function (subscribe, parent) { + return new AnonymousObservable(subscribe, parent); + }; + + var Defer = (function(__super__) { + inherits(Defer, __super__); + function Defer(factory) { + this._f = factory; + __super__.call(this); + } + + Defer.prototype.subscribeCore = function (o) { + var result = tryCatch(this._f)(); + if (result === errorObj) { return observableThrow(result.e).subscribe(o);} + isPromise(result) && (result = observableFromPromise(result)); + return result.subscribe(o); + }; + + return Defer; + }(ObservableBase)); + + /** + * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. + * + * @example + * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); }); + * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise. + * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function. + */ + var observableDefer = Observable.defer = function (observableFactory) { + return new Defer(observableFactory); + }; + + var EmptyObservable = (function(__super__) { + inherits(EmptyObservable, __super__); + function EmptyObservable(scheduler) { + this.scheduler = scheduler; + __super__.call(this); + } + + EmptyObservable.prototype.subscribeCore = function (observer) { + var sink = new EmptySink(observer, this.scheduler); + return sink.run(); + }; + + function EmptySink(observer, scheduler) { + this.observer = observer; + this.scheduler = scheduler; + } + + function scheduleItem(s, state) { + state.onCompleted(); + return disposableEmpty; + } + + EmptySink.prototype.run = function () { + var state = this.observer; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); + }; + + return EmptyObservable; + }(ObservableBase)); + + var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler); + + /** + * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message. + * + * @example + * var res = Rx.Observable.empty(); + * var res = Rx.Observable.empty(Rx.Scheduler.timeout); + * @param {Scheduler} [scheduler] Scheduler to send the termination call on. + * @returns {Observable} An observable sequence with no elements. + */ + var observableEmpty = Observable.empty = function (scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler); + }; + + var FromObservable = (function(__super__) { + inherits(FromObservable, __super__); + function FromObservable(iterable, mapper, scheduler) { + this.iterable = iterable; + this.mapper = mapper; + this.scheduler = scheduler; + __super__.call(this); + } + + FromObservable.prototype.subscribeCore = function (o) { + var sink = new FromSink(o, this); + return sink.run(); + }; + + return FromObservable; + }(ObservableBase)); + + var FromSink = (function () { + function FromSink(o, parent) { + this.o = o; + this.parent = parent; + } + + FromSink.prototype.run = function () { + var list = Object(this.parent.iterable), + it = getIterable(list), + o = this.o, + mapper = this.parent.mapper; + + function loopRecursive(i, recurse) { + var next = tryCatch(it.next).call(it); + if (next === errorObj) { return o.onError(next.e); } + if (next.done) { return o.onCompleted(); } + + var result = next.value; + + if (isFunction(mapper)) { + result = tryCatch(mapper)(result, i); + if (result === errorObj) { return o.onError(result.e); } + } + + o.onNext(result); + recurse(i + 1); + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + return FromSink; + }()); + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function StringIterable(s) { + this._s = s; + } + + StringIterable.prototype[$iterator$] = function () { + return new StringIterator(this._s); + }; + + function StringIterator(s) { + this._s = s; + this._l = s.length; + this._i = 0; + } + + StringIterator.prototype[$iterator$] = function () { + return this; + }; + + StringIterator.prototype.next = function () { + return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator; + }; + + function ArrayIterable(a) { + this._a = a; + } + + ArrayIterable.prototype[$iterator$] = function () { + return new ArrayIterator(this._a); + }; + + function ArrayIterator(a) { + this._a = a; + this._l = toLength(a); + this._i = 0; + } + + ArrayIterator.prototype[$iterator$] = function () { + return this; + }; + + ArrayIterator.prototype.next = function () { + return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator; + }; + + function numberIsFinite(value) { + return typeof value === 'number' && root.isFinite(value); + } + + function isNan(n) { + return n !== n; + } + + function getIterable(o) { + var i = o[$iterator$], it; + if (!i && typeof o === 'string') { + it = new StringIterable(o); + return it[$iterator$](); + } + if (!i && o.length !== undefined) { + it = new ArrayIterable(o); + return it[$iterator$](); + } + if (!i) { throw new TypeError('Object is not iterable'); } + return o[$iterator$](); + } + + function sign(value) { + var number = +value; + if (number === 0) { return number; } + if (isNaN(number)) { return number; } + return number < 0 ? -1 : 1; + } + + function toLength(o) { + var len = +o.length; + if (isNaN(len)) { return 0; } + if (len === 0 || !numberIsFinite(len)) { return len; } + len = sign(len) * Math.floor(Math.abs(len)); + if (len <= 0) { return 0; } + if (len > maxSafeInteger) { return maxSafeInteger; } + return len; + } + + /** + * This method creates a new Observable sequence from an array-like or iterable object. + * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence. + * @param {Function} [mapFn] Map function to call on every element of the array. + * @param {Any} [thisArg] The context to use calling the mapFn if provided. + * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) { + if (iterable == null) { + throw new Error('iterable cannot be null.') + } + if (mapFn && !isFunction(mapFn)) { + throw new Error('mapFn when provided must be a function'); + } + if (mapFn) { + var mapper = bindCallback(mapFn, thisArg, 2); + } + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromObservable(iterable, mapper, scheduler); + } + + var FromArrayObservable = (function(__super__) { + inherits(FromArrayObservable, __super__); + function FromArrayObservable(args, scheduler) { + this.args = args; + this.scheduler = scheduler; + __super__.call(this); + } + + FromArrayObservable.prototype.subscribeCore = function (observer) { + var sink = new FromArraySink(observer, this); + return sink.run(); + }; + + return FromArrayObservable; + }(ObservableBase)); + + function FromArraySink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + FromArraySink.prototype.run = function () { + var observer = this.observer, args = this.parent.args, len = args.length; + function loopRecursive(i, recurse) { + if (i < len) { + observer.onNext(args[i]); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + /** + * Converts an array to an observable sequence, using an optional scheduler to enumerate the array. + * @deprecated use Observable.from or Observable.of + * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. + * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence. + */ + var observableFromArray = Observable.fromArray = function (array, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromArrayObservable(array, scheduler) + }; + + var GenerateObservable = (function (__super__) { + inherits(GenerateObservable, __super__); + function GenerateObservable(state, cndFn, itrFn, resFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._s = s; + this._first = true; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + var hasResult = tryCatch(self._cndFn)(self._state); + if (hasResult === errorObj) { return self._o.onError(hasResult.e); } + if (hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + self._o.onNext(result); + recurse(self); + } else { + self._o.onCompleted(); + } + } + + GenerateObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursive(this, scheduleRecursive); + }; + + return GenerateObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. + * + * @example + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }); + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout); + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread. + * @returns {Observable} The generated sequence. + */ + Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler); + }; + + function observableOf (scheduler, array) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromArrayObservable(array, scheduler); + } + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. + */ + Observable.of = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return new FromArrayObservable(args, currentThreadScheduler); + }; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments. + * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. + */ + Observable.ofWithScheduler = function (scheduler) { + var len = arguments.length, args = new Array(len - 1); + for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; } + return new FromArrayObservable(args, scheduler); + }; + + /** + * Creates an Observable sequence from changes to an array using Array.observe. + * @param {Array} array An array to observe changes. + * @returns {Observable} An observable sequence containing changes to an array from Array.observe. + */ + Observable.ofArrayChanges = function(array) { + if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); } + if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Array.observe(array, observerFn); + + return function () { + Array.unobserve(array, observerFn); + }; + }); + }; + + /** + * Creates an Observable sequence from changes to an object using Object.observe. + * @param {Object} obj An object to observe changes. + * @returns {Observable} An observable sequence containing changes to an object from Object.observe. + */ + Observable.ofObjectChanges = function(obj) { + if (obj == null) { throw new TypeError('object must not be null or undefined.'); } + if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Object.observe(obj, observerFn); + + return function () { + Object.unobserve(obj, observerFn); + }; + }); + }; + + var NeverObservable = (function(__super__) { + inherits(NeverObservable, __super__); + function NeverObservable() { + __super__.call(this); + } + + NeverObservable.prototype.subscribeCore = function (observer) { + return disposableEmpty; + }; + + return NeverObservable; + }(ObservableBase)); + + var NEVER_OBSERVABLE = new NeverObservable(); + + /** + * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). + * @returns {Observable} An observable sequence whose observers will never get called. + */ + var observableNever = Observable.never = function () { + return NEVER_OBSERVABLE; + }; + + var PairsObservable = (function(__super__) { + inherits(PairsObservable, __super__); + function PairsObservable(obj, scheduler) { + this.obj = obj; + this.keys = Object.keys(obj); + this.scheduler = scheduler; + __super__.call(this); + } + + PairsObservable.prototype.subscribeCore = function (observer) { + var sink = new PairsSink(observer, this); + return sink.run(); + }; + + return PairsObservable; + }(ObservableBase)); + + function PairsSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + PairsSink.prototype.run = function () { + var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length; + function loopRecursive(i, recurse) { + if (i < len) { + var key = keys[i]; + observer.onNext([key, obj[key]]); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + /** + * Convert an object into an observable sequence of [key, value] pairs. + * @param {Object} obj The object to inspect. + * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. + * @returns {Observable} An observable sequence of [key, value] pairs from the object. + */ + Observable.pairs = function (obj, scheduler) { + scheduler || (scheduler = currentThreadScheduler); + return new PairsObservable(obj, scheduler); + }; + + var RangeObservable = (function(__super__) { + inherits(RangeObservable, __super__); + function RangeObservable(start, count, scheduler) { + this.start = start; + this.rangeCount = count; + this.scheduler = scheduler; + __super__.call(this); + } + + RangeObservable.prototype.subscribeCore = function (observer) { + var sink = new RangeSink(observer, this); + return sink.run(); + }; + + return RangeObservable; + }(ObservableBase)); + + var RangeSink = (function () { + function RangeSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + RangeSink.prototype.run = function () { + var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer; + function loopRecursive(i, recurse) { + if (i < count) { + observer.onNext(start + i); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + return RangeSink; + }()); + + /** + * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages. + * @param {Number} start The value of the first integer in the sequence. + * @param {Number} count The number of sequential integers to generate. + * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread. + * @returns {Observable} An observable sequence that contains a range of sequential integral numbers. + */ + Observable.range = function (start, count, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new RangeObservable(start, count, scheduler); + }; + + var RepeatObservable = (function(__super__) { + inherits(RepeatObservable, __super__); + function RepeatObservable(value, repeatCount, scheduler) { + this.value = value; + this.repeatCount = repeatCount == null ? -1 : repeatCount; + this.scheduler = scheduler; + __super__.call(this); + } + + RepeatObservable.prototype.subscribeCore = function (observer) { + var sink = new RepeatSink(observer, this); + return sink.run(); + }; + + return RepeatObservable; + }(ObservableBase)); + + function RepeatSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + RepeatSink.prototype.run = function () { + var observer = this.observer, value = this.parent.value; + function loopRecursive(i, recurse) { + if (i === -1 || i > 0) { + observer.onNext(value); + i > 0 && i--; + } + if (i === 0) { return observer.onCompleted(); } + recurse(i); + } + + return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive); + }; + + /** + * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages. + * @param {Mixed} value Element to repeat. + * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely. + * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate. + * @returns {Observable} An observable sequence that repeats the given element the specified number of times. + */ + Observable.repeat = function (value, repeatCount, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new RepeatObservable(value, repeatCount, scheduler); + }; + + var JustObservable = (function(__super__) { + inherits(JustObservable, __super__); + function JustObservable(value, scheduler) { + this.value = value; + this.scheduler = scheduler; + __super__.call(this); + } + + JustObservable.prototype.subscribeCore = function (observer) { + var sink = new JustSink(observer, this.value, this.scheduler); + return sink.run(); + }; + + function JustSink(observer, value, scheduler) { + this.observer = observer; + this.value = value; + this.scheduler = scheduler; + } + + function scheduleItem(s, state) { + var value = state[0], observer = state[1]; + observer.onNext(value); + observer.onCompleted(); + return disposableEmpty; + } + + JustSink.prototype.run = function () { + var state = [this.value, this.observer]; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); + }; + + return JustObservable; + }(ObservableBase)); + + /** + * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages. + * There is an alias called 'just' or browsers 0) { + parent.handleSubscribe(parent.q.shift()); + } else { + parent.activeCount--; + parent.done && parent.activeCount === 0 && parent.o.onCompleted(); + } + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeObserver; + }()); + + + + + + /** + * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences. + * Or merges two observable sequences into a single observable sequence. + * + * @example + * 1 - merged = sources.merge(1); + * 2 - merged = source.merge(otherSource); + * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.merge = function (maxConcurrentOrOther) { + return typeof maxConcurrentOrOther !== 'number' ? + observableMerge(this, maxConcurrentOrOther) : + new MergeObservable(this, maxConcurrentOrOther); + }; + + /** + * Merges all the observable sequences into a single observable sequence. + * The scheduler is optional and if not specified, the immediate scheduler is used. + * @returns {Observable} The observable sequence that merges the elements of the observable sequences. + */ + var observableMerge = Observable.merge = function () { + var scheduler, sources = [], i, len = arguments.length; + if (!arguments[0]) { + scheduler = immediateScheduler; + for(i = 1; i < len; i++) { sources.push(arguments[i]); } + } else if (isScheduler(arguments[0])) { + scheduler = arguments[0]; + for(i = 1; i < len; i++) { sources.push(arguments[i]); } + } else { + scheduler = immediateScheduler; + for(i = 0; i < len; i++) { sources.push(arguments[i]); } + } + if (Array.isArray(sources[0])) { + sources = sources[0]; + } + return observableOf(scheduler, sources).mergeAll(); + }; + + var MergeAllObservable = (function (__super__) { + inherits(MergeAllObservable, __super__); + + function MergeAllObservable(source) { + this.source = source; + __super__.call(this); + } + + MergeAllObservable.prototype.subscribeCore = function (observer) { + var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); + g.add(m); + m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); + return g; + }; + + function MergeAllObserver(o, g) { + this.o = o; + this.g = g; + this.isStopped = false; + this.done = false; + } + MergeAllObserver.prototype.onNext = function(innerSource) { + if(this.isStopped) { return; } + var sad = new SingleAssignmentDisposable(); + this.g.add(sad); + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + }; + MergeAllObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + } + }; + MergeAllObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.done = true; + this.g.length === 1 && this.o.onCompleted(); + } + }; + MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; + MergeAllObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + + return false; + }; + + function InnerObserver(parent, sad) { + this.parent = parent; + this.sad = sad; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; + InnerObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + var parent = this.parent; + this.isStopped = true; + parent.g.remove(this.sad); + parent.done && parent.g.length === 1 && parent.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeAllObservable; + }(ObservableBase)); + + /** + * Merges an observable sequence of observable sequences into an observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.mergeAll = function () { + return new MergeAllObservable(this); + }; + + var CompositeError = Rx.CompositeError = function(errors) { + this.name = "NotImplementedError"; + this.innerErrors = errors; + this.message = 'This contains multiple errors. Check the innerErrors'; + Error.call(this); + } + CompositeError.prototype = Error.prototype; + + /** + * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to + * receive all successfully emitted items from all of the source Observables without being interrupted by + * an error notification from one of them. + * + * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an + * error via the Observer's onError, mergeDelayError will refrain from propagating that + * error notification until all of the merged Observables have finished emitting items. + * @param {Array | Arguments} args Arguments or an array to merge. + * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable + */ + Observable.mergeDelayError = function() { + var args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + var len = arguments.length; + args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + var source = observableOf(null, args); + + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(), + m = new SingleAssignmentDisposable(), + isStopped = false, + errors = []; + + function setCompletion() { + if (errors.length === 0) { + o.onCompleted(); + } else if (errors.length === 1) { + o.onError(errors[0]); + } else { + o.onError(new CompositeError(errors)); + } + } + + group.add(m); + + m.setDisposable(source.subscribe( + function (innerSource) { + var innerSubscription = new SingleAssignmentDisposable(); + group.add(innerSubscription); + + // Check for promises support + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { + errors.push(e); + group.remove(innerSubscription); + isStopped && group.length === 1 && setCompletion(); + }, + function () { + group.remove(innerSubscription); + isStopped && group.length === 1 && setCompletion(); + })); + }, + function (e) { + errors.push(e); + isStopped = true; + group.length === 1 && setCompletion(); + }, + function () { + isStopped = true; + group.length === 1 && setCompletion(); + })); + return group; + }); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates. + * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally. + */ + observableProto.onErrorResumeNext = function (second) { + if (!second) { throw new Error('Second observable is required'); } + return onErrorResumeNext([this, second]); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * + * @example + * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs); + * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]); + * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. + */ + var onErrorResumeNext = Observable.onErrorResumeNext = function () { + var sources = []; + if (Array.isArray(arguments[0])) { + sources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } + } + return new AnonymousObservable(function (observer) { + var pos = 0, subscription = new SerialDisposable(), + cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) { + var current, d; + if (pos < sources.length) { + current = sources[pos++]; + isPromise(current) && (current = observableFromPromise(current)); + d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self)); + } else { + observer.onCompleted(); + } + }); + return new BinaryDisposable(subscription, cancelable); + }); + }; + + var SkipUntilObservable = (function(__super__) { + inherits(SkipUntilObservable, __super__); + + function SkipUntilObservable(source, other) { + this._s = source; + this._o = isPromise(other) ? observableFromPromise(other) : other; + this._open = false; + __super__.call(this); + } + + SkipUntilObservable.prototype.subscribeCore = function(o) { + var leftSubscription = new SingleAssignmentDisposable(); + leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this))); + + isPromise(this._o) && (this._o = observableFromPromise(this._o)); + + var rightSubscription = new SingleAssignmentDisposable(); + rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription))); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }; + + return SkipUntilObservable; + }(ObservableBase)); + + var SkipUntilSourceObserver = (function(__super__) { + inherits(SkipUntilSourceObserver, __super__); + function SkipUntilSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilSourceObserver.prototype.next = function (x) { + this._p._open && this._o.onNext(x); + }; + + SkipUntilSourceObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + SkipUntilSourceObserver.prototype.onCompleted = function () { + this._p._open && this._o.onCompleted(); + }; + + return SkipUntilSourceObserver; + }(AbstractObserver)); + + var SkipUntilOtherObserver = (function(__super__) { + inherits(SkipUntilOtherObserver, __super__); + function SkipUntilOtherObserver(o, p, r) { + this._o = o; + this._p = p; + this._r = r; + __super__.call(this); + } + + SkipUntilOtherObserver.prototype.next = function () { + this._p._open = true; + this._r.dispose(); + }; + + SkipUntilOtherObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + SkipUntilOtherObserver.prototype.onCompleted = function () { + this._r.dispose(); + }; + + return SkipUntilOtherObserver; + }(AbstractObserver)); + + /** + * Returns the values from the source observable sequence only after the other observable sequence produces a value. + * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence. + * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation. + */ + observableProto.skipUntil = function (other) { + return new SkipUntilObservable(this, other); + }; + + var SwitchObservable = (function(__super__) { + inherits(SwitchObservable, __super__); + function SwitchObservable(source) { + this.source = source; + __super__.call(this); + } + + SwitchObservable.prototype.subscribeCore = function (o) { + var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner)); + return new BinaryDisposable(s, inner); + }; + + inherits(SwitchObserver, AbstractObserver); + function SwitchObserver(o, inner) { + this.o = o; + this.inner = inner; + this.stopped = false; + this.latest = 0; + this.hasLatest = false; + AbstractObserver.call(this); + } + + SwitchObserver.prototype.next = function (innerSource) { + var d = new SingleAssignmentDisposable(), id = ++this.latest; + this.hasLatest = true; + this.inner.setDisposable(d); + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + d.setDisposable(innerSource.subscribe(new InnerObserver(this, id))); + }; + + SwitchObserver.prototype.error = function (e) { + this.o.onError(e); + }; + + SwitchObserver.prototype.completed = function () { + this.stopped = true; + !this.hasLatest && this.o.onCompleted(); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(parent, id) { + this.parent = parent; + this.id = id; + AbstractObserver.call(this); + } + InnerObserver.prototype.next = function (x) { + this.parent.latest === this.id && this.parent.o.onNext(x); + }; + + InnerObserver.prototype.error = function (e) { + this.parent.latest === this.id && this.parent.o.onError(e); + }; + + InnerObserver.prototype.completed = function () { + if (this.parent.latest === this.id) { + this.parent.hasLatest = false; + this.parent.isStopped && this.parent.o.onCompleted(); + } + }; + + return SwitchObservable; + }(ObservableBase)); + + /** + * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + observableProto['switch'] = observableProto.switchLatest = function () { + return new SwitchObservable(this); + }; + + var TakeUntilObservable = (function(__super__) { + inherits(TakeUntilObservable, __super__); + + function TakeUntilObservable(source, other) { + this.source = source; + this.other = isPromise(other) ? observableFromPromise(other) : other; + __super__.call(this); + } + + TakeUntilObservable.prototype.subscribeCore = function(o) { + return new BinaryDisposable( + this.source.subscribe(o), + this.other.subscribe(new TakeUntilObserver(o)) + ); + }; + + return TakeUntilObservable; + }(ObservableBase)); + + var TakeUntilObserver = (function(__super__) { + inherits(TakeUntilObserver, __super__); + function TakeUntilObserver(o) { + this._o = o; + __super__.call(this); + } + + TakeUntilObserver.prototype.next = function () { + this._o.onCompleted(); + }; + + TakeUntilObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + TakeUntilObserver.prototype.onCompleted = noop; + + return TakeUntilObserver; + }(AbstractObserver)); + + /** + * Returns the values from the source observable sequence until the other observable sequence produces a value. + * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence. + * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + */ + observableProto.takeUntil = function (other) { + return new TakeUntilObservable(this, other); + }; + + function falseFactory() { return false; } + function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; + } + + var WithLatestFromObservable = (function(__super__) { + inherits(WithLatestFromObservable, __super__); + function WithLatestFromObservable(source, sources, resultSelector) { + var len = sources.length; + this._s = source; + this._ss = sources; + this._cb = resultSelector; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._v = new Array(len); + __super__.call(this); + } + + WithLatestFromObservable.prototype.subscribeCore = function (o) { + var n = this._ss.length, subscriptions = new Array(n + 1); + for (var i = 0; i < n; i++) { + var other = this._ss[i], sad = new SingleAssignmentDisposable(); + isPromise(other) && (other = observableFromPromise(other)); + sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this))); + subscriptions[i] = sad; + } + + var sad = new SingleAssignmentDisposable(); + sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this))); + subscriptions[n] = sad; + + return new NAryDisposable(subscriptions); + }; + + return WithLatestFromObservable; + }(ObservableBase)); + + var WithLatestFromOtherObserver = (function (__super__) { + inherits(WithLatestFromOtherObserver, __super__); + function WithLatestFromOtherObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + WithLatestFromOtherObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + this._p._hvAll = this._p._hv.every(identity); + }; + + WithLatestFromOtherObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromOtherObserver.prototype.completed = noop; + + return WithLatestFromOtherObserver; + }(AbstractObserver)); + + var WithLatestFromSourceObserver = (function (__super__) { + inherits(WithLatestFromSourceObserver, __super__); + function WithLatestFromSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + WithLatestFromSourceObserver.prototype.next = function (x) { + var allValues = [x].concat(this._p._v); + if (!this._p._hvAll) { return; } + var res = tryCatch(this._p._cb).apply(null, allValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + }; + + WithLatestFromSourceObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromSourceObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return WithLatestFromSourceObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element. + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + observableProto.withLatestFrom = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + + return new WithLatestFromObservable(this, args, resultSelector); + }; + + function falseFactory() { return false; } + function emptyArrayFactory() { return []; } + + var ZipObservable = (function(__super__) { + inherits(ZipObservable, __super__); + function ZipObservable(sources, resultSelector) { + var len = sources.length; + this._s = sources; + this._cb = resultSelector; + this._done = arrayInitialize(len, falseFactory); + this._q = arrayInitialize(len, emptyArrayFactory); + __super__.call(this); + } + + ZipObservable.prototype.subscribeCore = function(observer) { + var n = this._s.length, subscriptions = new Array(n); + + for (var i = 0; i < n; i++) { + var source = this._s[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this))); + } + + return new NAryDisposable(subscriptions); + }; + + return ZipObservable; + }(ObservableBase)); + + var ZipObserver = (function (__super__) { + inherits(ZipObserver, __super__); + function ZipObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + ZipObserver.prototype.next = function (x) { + this._p._q[this._i].push(x); + if (this._p._q.every(function (x) { return x.length > 0; })) { + var queuedValues = this._p._q.map(function (x) { return x.shift(); }); + var res = tryCatch(this._p._cb).apply(null, queuedValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); + } + }; + + ZipObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ZipObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return ZipObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. + * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. + * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. + */ + observableProto.zip = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + + var parent = this; + args.unshift(parent); + + return new ZipObservable(args, resultSelector); + }; + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + * @param arguments Observable sources. + * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources. + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + Observable.zip = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + if (Array.isArray(args[0])) { + args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0]; + } + var first = args.shift(); + return first.zip.apply(first, args); + }; + +function falseFactory() { return false; } +function emptyArrayFactory() { return []; } +function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; +} + +/** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. + * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. + * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. + */ +observableProto.zipIterable = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + + var parent = this; + args.unshift(parent); + return new AnonymousObservable(function (o) { + var n = args.length, + queues = arrayInitialize(n, emptyArrayFactory), + isDone = arrayInitialize(n, falseFactory); + + var subscriptions = new Array(n); + for (var idx = 0; idx < n; idx++) { + (function (i) { + var source = args[i], sad = new SingleAssignmentDisposable(); + + (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source)); + + sad.setDisposable(source.subscribe(function (x) { + queues[i].push(x); + if (queues.every(function (x) { return x.length > 0; })) { + var queuedValues = queues.map(function (x) { return x.shift(); }), + res = tryCatch(resultSelector).apply(parent, queuedValues); + if (res === errorObj) { return o.onError(res.e); } + o.onNext(res); + } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { + o.onCompleted(); + } + }, function (e) { o.onError(e); }, function () { + isDone[i] = true; + isDone.every(identity) && o.onCompleted(); + })); + subscriptions[i] = sad; + })(idx); + } + + return new CompositeDisposable(subscriptions); + }, parent); +}; + + function asObservable(source) { + return function subscribe(o) { return source.subscribe(o); }; + } + + /** + * Hides the identity of an observable sequence. + * @returns {Observable} An observable sequence that hides the identity of the source sequence. + */ + observableProto.asObservable = function () { + return new AnonymousObservable(asObservable(this), this); + }; + + function toArray(x) { return x.toArray(); } + function notEmpty(x) { return x.length > 0; } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information. + * @param {Number} count Length of each buffer. + * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithCount = function (count, skip) { + typeof skip !== 'number' && (skip = count); + return this.windowWithCount(count, skip) + .flatMap(toArray) + .filter(notEmpty); + }; + + var DematerializeObservable = (function (__super__) { + inherits(DematerializeObservable, __super__); + function DematerializeObservable(source) { + this.source = source; + __super__.call(this); + } + + DematerializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DematerializeObserver(o)); + }; + + return DematerializeObservable; + }(ObservableBase)); + + var DematerializeObserver = (function (__super__) { + inherits(DematerializeObserver, __super__); + + function DematerializeObserver(o) { + this._o = o; + __super__.call(this); + } + + DematerializeObserver.prototype.next = function (x) { x.accept(this._o); }; + DematerializeObserver.prototype.error = function (e) { this._o.onError(e); }; + DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DematerializeObserver; + }(AbstractObserver)); + + /** + * Dematerializes the explicit notification values of an observable sequence as implicit notifications. + * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. + */ + observableProto.dematerialize = function () { + return new DematerializeObservable(this); + }; + + var DistinctUntilChangedObservable = (function(__super__) { + inherits(DistinctUntilChangedObservable, __super__); + function DistinctUntilChangedObservable(source, keyFn, comparer) { + this.source = source; + this.keyFn = keyFn; + this.comparer = comparer; + __super__.call(this); + } + + DistinctUntilChangedObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer)); + }; + + return DistinctUntilChangedObservable; + }(ObservableBase)); + + var DistinctUntilChangedObserver = (function(__super__) { + inherits(DistinctUntilChangedObserver, __super__); + function DistinctUntilChangedObserver(o, keyFn, comparer) { + this.o = o; + this.keyFn = keyFn; + this.comparer = comparer; + this.hasCurrentKey = false; + this.currentKey = null; + __super__.call(this); + } + + DistinctUntilChangedObserver.prototype.next = function (x) { + var key = x, comparerEquals; + if (isFunction(this.keyFn)) { + key = tryCatch(this.keyFn)(x); + if (key === errorObj) { return this.o.onError(key.e); } + } + if (this.hasCurrentKey) { + comparerEquals = tryCatch(this.comparer)(this.currentKey, key); + if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); } + } + if (!this.hasCurrentKey || !comparerEquals) { + this.hasCurrentKey = true; + this.currentKey = key; + this.o.onNext(x); + } + }; + DistinctUntilChangedObserver.prototype.error = function(e) { + this.o.onError(e); + }; + DistinctUntilChangedObserver.prototype.completed = function () { + this.o.onCompleted(); + }; + + return DistinctUntilChangedObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer. + * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value. + * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function. + * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. + */ + observableProto.distinctUntilChanged = function (keyFn, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctUntilChangedObservable(this, keyFn, comparer); + }; + + var TapObservable = (function(__super__) { + inherits(TapObservable,__super__); + function TapObservable(source, observerOrOnNext, onError, onCompleted) { + this.source = source; + this._oN = observerOrOnNext; + this._oE = onError; + this._oC = onCompleted; + __super__.call(this); + } + + TapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, p) { + this.o = o; + this.t = !p._oN || isFunction(p._oN) ? + observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) : + p._oN; + this.isStopped = false; + AbstractObserver.call(this); + } + InnerObserver.prototype.next = function(x) { + var res = tryCatch(this.t.onNext).call(this.t, x); + if (res === errorObj) { this.o.onError(res.e); } + this.o.onNext(x); + }; + InnerObserver.prototype.error = function(err) { + var res = tryCatch(this.t.onError).call(this.t, err); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onError(err); + }; + InnerObserver.prototype.completed = function() { + var res = tryCatch(this.t.onCompleted).call(this.t); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onCompleted(); + }; + + return TapObservable; + }(ObservableBase)); + + /** + * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) { + return new TapObservable(this, observerOrOnNext, onError, onCompleted); + }; + + /** + * Invokes an action for each element in the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onNext Action to invoke for each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) { + return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext); + }; + + /** + * Invokes an action upon exceptional termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) { + return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError); + }; + + /** + * Invokes an action upon graceful termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) { + return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted); + }; + + /** + * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. + * @param {Function} finallyAction Action to invoke after the source observable sequence terminates. + * @returns {Observable} Source sequence with the action-invoking termination behavior applied. + */ + observableProto['finally'] = function (action) { + var source = this; + return new AnonymousObservable(function (observer) { + var subscription = tryCatch(source.subscribe).call(source, observer); + if (subscription === errorObj) { + action(); + return thrower(subscription.e); + } + return disposableCreate(function () { + var r = tryCatch(subscription.dispose).call(subscription); + action(); + r === errorObj && thrower(r.e); + }); + }, this); + }; + + var IgnoreElementsObservable = (function(__super__) { + inherits(IgnoreElementsObservable, __super__); + + function IgnoreElementsObservable(source) { + this.source = source; + __super__.call(this); + } + + IgnoreElementsObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + function InnerObserver(o) { + this.o = o; + this.isStopped = false; + } + InnerObserver.prototype.onNext = noop; + InnerObserver.prototype.onError = function (err) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.observer.onError(e); + return true; + } + + return false; + }; + + return IgnoreElementsObservable; + }(ObservableBase)); + + /** + * Ignores all elements in an observable sequence leaving only the termination messages. + * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence. + */ + observableProto.ignoreElements = function () { + return new IgnoreElementsObservable(this); + }; + + var MaterializeObservable = (function (__super__) { + inherits(MaterializeObservable, __super__); + function MaterializeObservable(source, fn) { + this.source = source; + __super__.call(this); + } + + MaterializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new MaterializeObserver(o)); + }; + + return MaterializeObservable; + }(ObservableBase)); + + var MaterializeObserver = (function (__super__) { + inherits(MaterializeObserver, __super__); + + function MaterializeObserver(o) { + this._o = o; + __super__.call(this); + } + + MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) }; + MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); }; + MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); }; + + return MaterializeObserver; + }(AbstractObserver)); + + /** + * Materializes the implicit notifications of an observable sequence as explicit notification values. + * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence. + */ + observableProto.materialize = function () { + return new MaterializeObservable(this); + }; + + /** + * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely. + * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely. + * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly. + */ + observableProto.repeat = function (repeatCount) { + return enumerableRepeat(this, repeatCount).concat(); + }; + + /** + * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely. + * Note if you encounter an error and want it to retry once, then you must use .retry(2); + * + * @example + * var res = retried = retry.repeat(); + * var res = retried = retry.repeat(2); + * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely. + * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + observableProto.retry = function (retryCount) { + return enumerableRepeat(this, retryCount).catchError(); + }; + + /** + * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. + * if the notifier completes, the observable sequence completes. + * + * @example + * var timer = Observable.timer(500); + * var source = observable.retryWhen(timer); + * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively. + * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + observableProto.retryWhen = function (notifier) { + return enumerableRepeat(this).catchErrorWhen(notifier); + }; + var ScanObservable = (function(__super__) { + inherits(ScanObservable, __super__); + function ScanObservable(source, accumulator, hasSeed, seed) { + this.source = source; + this.accumulator = accumulator; + this.hasSeed = hasSeed; + this.seed = seed; + __super__.call(this); + } + + ScanObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new ScanObserver(o,this)); + }; + + return ScanObservable; + }(ObservableBase)); + + var ScanObserver = (function (__super__) { + inherits(ScanObserver, __super__); + function ScanObserver(o, parent) { + this._o = o; + this._p = parent; + this._fn = parent.accumulator; + this._hs = parent.hasSeed; + this._s = parent.seed; + this._ha = false; + this._a = null; + this._hv = false; + this._i = 0; + __super__.call(this); + } + + ScanObserver.prototype.next = function (x) { + !this._hv && (this._hv = true); + if (this._ha) { + this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); + } else { + this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; + this._ha = true; + } + if (this._a === errorObj) { return this._o.onError(this._a.e); } + this._o.onNext(this._a); + this._i++; + }; + + ScanObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ScanObserver.prototype.completed = function () { + !this._hv && this._hs && this._o.onNext(this._s); + this._o.onCompleted(); + }; + + return ScanObserver; + }(AbstractObserver)); + + /** + * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. + * For aggregation behavior with no intermediate results, see Observable.aggregate. + * @param {Mixed} [seed] The initial accumulator value. + * @param {Function} accumulator An accumulator function to be invoked on each element. + * @returns {Observable} An observable sequence containing the accumulated values. + */ + observableProto.scan = function () { + var hasSeed = false, seed, accumulator = arguments[0]; + if (arguments.length === 2) { + hasSeed = true; + seed = arguments[1]; + } + return new ScanObservable(this, accumulator, hasSeed, seed); + }; + + var SkipLastObservable = (function (__super__) { + inherits(SkipLastObservable, __super__); + function SkipLastObservable(source, c) { + this.source = source; + this._c = c; + __super__.call(this); + } + + SkipLastObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastObserver(o, this._c)); + }; + + return SkipLastObservable; + }(ObservableBase)); + + var SkipLastObserver = (function (__super__) { + inherits(SkipLastObserver, __super__); + function SkipLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + SkipLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._o.onNext(this._q.shift()); + }; + + SkipLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + SkipLastObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return SkipLastObserver; + }(AbstractObserver)); + + /** + * Bypasses a specified number of elements at the end of an observable sequence. + * @description + * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are + * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed. + * @param count Number of elements to bypass at the end of the source sequence. + * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end. + */ + observableProto.skipLast = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + return new SkipLastObservable(this, count); + }; + + /** + * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend. + * @example + * var res = source.startWith(1, 2, 3); + * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3); + * @param {Arguments} args The specified values to prepend to the observable sequence + * @returns {Observable} The source sequence prepended with the specified values. + */ + observableProto.startWith = function () { + var values, scheduler, start = 0; + if (!!arguments.length && isScheduler(arguments[0])) { + scheduler = arguments[0]; + start = 1; + } else { + scheduler = immediateScheduler; + } + for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); } + return enumerableOf([observableFromArray(args, scheduler), this]).concat(); + }; + + var TakeLastObserver = (function (__super__) { + inherits(TakeLastObserver, __super__); + function TakeLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastObserver.prototype.completed = function () { + while (this._q.length > 0) { this._o.onNext(this._q.shift()); } + this._o.onCompleted(); + }; + + return TakeLastObserver; + }(AbstractObserver)); + + /** + * Returns a specified number of contiguous elements from the end of an observable sequence. + * @description + * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of + * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence. + */ + observableProto.takeLast = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastObserver(o, count)); + }, source); + }; + + var TakeLastBufferObserver = (function (__super__) { + inherits(TakeLastBufferObserver, __super__); + function TakeLastBufferObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastBufferObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastBufferObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastBufferObserver.prototype.completed = function () { + this._o.onNext(this._q); + this._o.onCompleted(); + }; + + return TakeLastBufferObserver; + }(AbstractObserver)); + + /** + * Returns an array with the specified number of contiguous elements from the end of an observable sequence. + * + * @description + * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the + * source sequence, this buffer is produced on the result sequence. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence. + */ + observableProto.takeLastBuffer = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastBufferObserver(o, count)); + }, source); + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on element count information. + * @param {Number} count Length of each window. + * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithCount = function (count, skip) { + var source = this; + +count || (count = 0); + Math.abs(count) === Infinity && (count = 0); + if (count <= 0) { throw new ArgumentOutOfRangeError(); } + skip == null && (skip = count); + +skip || (skip = 0); + Math.abs(skip) === Infinity && (skip = 0); + + if (skip <= 0) { throw new ArgumentOutOfRangeError(); } + return new AnonymousObservable(function (observer) { + var m = new SingleAssignmentDisposable(), + refCountDisposable = new RefCountDisposable(m), + n = 0, + q = []; + + function createWindow () { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + + createWindow(); + + m.setDisposable(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + var c = n - count + 1; + c >= 0 && c % skip === 0 && q.shift().onCompleted(); + ++n % skip === 0 && createWindow(); + }, + function (e) { + while (q.length > 0) { q.shift().onError(e); } + observer.onError(e); + }, + function () { + while (q.length > 0) { q.shift().onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function concatMap(source, selector, thisArg) { + var selectorFunc = bindCallback(selector, thisArg, 3); + return source.map(function (x, i) { + var result = selectorFunc(x, i, source); + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result)); + return result; + }).concatAll(); + } + + /** + * One of the Following: + * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * + * @example + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }); + * Or: + * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence. + * + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; }); + * Or: + * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence. + * + * var res = source.concatMap(Rx.Observable.fromArray([1,2,3])); + * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the + * source sequence onto which could be either an observable or Promise. + * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element. + */ + observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) { + if (isFunction(selector) && isFunction(resultSelector)) { + return this.concatMap(function (x, i) { + var selectorResult = selector(x, i); + isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult)); + (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult)); + + return selectorResult.map(function (y, i2) { + return resultSelector(x, y, i, i2); + }); + }); + } + return isFunction(selector) ? + concatMap(this, selector, thisArg) : + concatMap(this, function () { return selector; }); + }; + + /** + * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) { + var source = this, + onNextFunc = bindCallback(onNext, thisArg, 2), + onErrorFunc = bindCallback(onError, thisArg, 1), + onCompletedFunc = bindCallback(onCompleted, thisArg, 0); + return new AnonymousObservable(function (observer) { + var index = 0; + return source.subscribe( + function (x) { + var result; + try { + result = onNextFunc(x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onErrorFunc(err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompletedFunc(); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, this).concatAll(); + }; + + var DefaultIfEmptyObserver = (function (__super__) { + inherits(DefaultIfEmptyObserver, __super__); + function DefaultIfEmptyObserver(o, d) { + this._o = o; + this._d = d; + this._f = false; + __super__.call(this); + } + + DefaultIfEmptyObserver.prototype.next = function (x) { + this._f = true; + this._o.onNext(x); + }; + + DefaultIfEmptyObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + DefaultIfEmptyObserver.prototype.completed = function () { + !this._f && this._o.onNext(defaultValue); + this._o.onCompleted(); + }; + + return DefaultIfEmptyObserver; + }(AbstractObserver)); + + /** + * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty. + * + * var res = obs = xs.defaultIfEmpty(); + * 2 - obs = xs.defaultIfEmpty(false); + * + * @memberOf Observable# + * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null. + * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. + */ + observableProto.defaultIfEmpty = function (defaultValue) { + var source = this; + defaultValue === undefined && (defaultValue = null); + return new AnonymousObservable(function (o) { + return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue)); + }, source); + }; + + // Swap out for Array.findIndex + function arrayIndexOfComparer(array, item, comparer) { + for (var i = 0, len = array.length; i < len; i++) { + if (comparer(array[i], item)) { return i; } + } + return -1; + } + + function HashSet(comparer) { + this.comparer = comparer; + this.set = []; + } + HashSet.prototype.push = function(value) { + var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1; + retValue && this.set.push(value); + return retValue; + }; + + var DistinctObservable = (function (__super__) { + inherits(DistinctObservable, __super__); + function DistinctObservable(source, keyFn, cmpFn) { + this.source = source; + this._keyFn = keyFn; + this._cmpFn = cmpFn; + __super__.call(this); + } + + DistinctObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn)); + }; + + return DistinctObservable; + }(ObservableBase)); + + var DistinctObserver = (function (__super__) { + inherits(DistinctObserver, __super__); + function DistinctObserver(o, keyFn, cmpFn) { + this._o = o; + this._keyFn = keyFn; + this._h = new HashSet(cmpFn); + __super__.call(this); + } + + DistinctObserver.prototype.next = function (x) { + var key = x; + if (isFunction(this._keyFn)) { + key = tryCatch(this._keyFn)(x); + if (key === errorObj) { return this._o.onError(key.e); } + } + this._h.push(key) && this._o.onNext(x); + }; + + DistinctObserver.prototype.error = function (e) { this._o.onError(e); }; + DistinctObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DistinctObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. + * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. + * + * @example + * var res = obs = xs.distinct(); + * 2 - obs = xs.distinct(function (x) { return x.id; }); + * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; }); + * @param {Function} [keySelector] A function to compute the comparison key for each element. + * @param {Function} [comparer] Used to compare items in the collection. + * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. + */ + observableProto.distinct = function (keySelector, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctObservable(this, keySelector, comparer); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. + * + * @example + * var res = observable.groupBy(function (x) { return x.id; }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} [elementSelector] A function to map each source element to an element in an observable group. + * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + */ + observableProto.groupBy = function (keySelector, elementSelector) { + return this.groupByUntil(keySelector, elementSelector, observableNever); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function. + * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same + * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request. + * + * @example + * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} durationSelector A function to signal the expiration of a group. + * @returns {Observable} + * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered. + * + */ + observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) { + var source = this; + return new AnonymousObservable(function (o) { + var map = new Map(), + groupDisposable = new CompositeDisposable(), + refCountDisposable = new RefCountDisposable(groupDisposable), + handleError = function (e) { return function (item) { item.onError(e); }; }; + + groupDisposable.add( + source.subscribe(function (x) { + var key = tryCatch(keySelector)(x); + if (key === errorObj) { + map.forEach(handleError(key.e)); + return o.onError(key.e); + } + + var fireNewMapEntry = false, writer = map.get(key); + if (writer === undefined) { + writer = new Subject(); + map.set(key, writer); + fireNewMapEntry = true; + } + + if (fireNewMapEntry) { + var group = new GroupedObservable(key, writer, refCountDisposable), + durationGroup = new GroupedObservable(key, writer); + var duration = tryCatch(durationSelector)(durationGroup); + if (duration === errorObj) { + map.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + o.onNext(group); + + var md = new SingleAssignmentDisposable(); + groupDisposable.add(md); + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, + function () { + if (map['delete'](key)) { writer.onCompleted(); } + groupDisposable.remove(md); + })); + } + + var element = x; + if (isFunction(elementSelector)) { + element = tryCatch(elementSelector)(x); + if (element === errorObj) { + map.forEach(handleError(element.e)); + return o.onError(element.e); + } + } + + writer.onNext(element); + }, function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, function () { + map.forEach(function (item) { item.onCompleted(); }); + o.onCompleted(); + })); + + return refCountDisposable; + }, source); + }; + + var MapObservable = (function (__super__) { + inherits(MapObservable, __super__); + + function MapObservable(source, selector, thisArg) { + this.source = source; + this.selector = bindCallback(selector, thisArg, 3); + __super__.call(this); + } + + function innerMap(selector, self) { + return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); } + } + + MapObservable.prototype.internalMap = function (selector, thisArg) { + return new MapObservable(this.source, innerMap(selector, this), thisArg); + }; + + MapObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, selector, source) { + this.o = o; + this.selector = selector; + this.source = source; + this.i = 0; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function(x) { + var result = tryCatch(this.selector)(x, this.i++, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + this.o.onNext(result); + }; + + InnerObserver.prototype.error = function (e) { + this.o.onError(e); + }; + + InnerObserver.prototype.completed = function () { + this.o.onCompleted(); + }; + + return MapObservable; + + }(ObservableBase)); + + /** + * Projects each element of an observable sequence into a new form by incorporating the element's index. + * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source. + */ + observableProto.map = observableProto.select = function (selector, thisArg) { + var selectorFn = typeof selector === 'function' ? selector : function () { return selector; }; + return this instanceof MapObservable ? + this.internalMap(selectorFn, thisArg) : + new MapObservable(this, selectorFn, thisArg); + }; + + function plucker(args, len) { + return function mapper(x) { + var currentProp = x; + for (var i = 0; i < len; i++) { + var p = currentProp[args[i]]; + if (typeof p !== 'undefined') { + currentProp = p; + } else { + return undefined; + } + } + return currentProp; + } + } + + /** + * Retrieves the value of a specified nested property from all elements in + * the Observable sequence. + * @param {Arguments} arguments The nested properties to pluck. + * @returns {Observable} Returns a new Observable sequence of property values. + */ + observableProto.pluck = function () { + var len = arguments.length, args = new Array(len); + if (len === 0) { throw new Error('List of properties cannot be empty.'); } + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return this.map(plucker(args, len)); + }; + +observableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll(); +}; + + +// +//Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { +// return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +//}; +// + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) { + var source = this; + return new AnonymousObservable(function (observer) { + var index = 0; + + return source.subscribe( + function (x) { + var result; + try { + result = onNext.call(thisArg, x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onError.call(thisArg, err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompleted.call(thisArg); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, source).mergeAll(); + }; + +Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); +}; + var SkipObservable = (function(__super__) { + inherits(SkipObservable, __super__); + function SkipObservable(source, count) { + this.source = source; + this.skipCount = count; + __super__.call(this); + } + + SkipObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.skipCount)); + }; + + function InnerObserver(o, c) { + this.c = c; + this.r = c; + this.o = o; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { + if (this.isStopped) { return; } + if (this.r <= 0) { + this.o.onNext(x); + } else { + this.r--; + } + }; + InnerObserver.prototype.onError = function(e) { + if (!this.isStopped) { this.isStopped = true; this.o.onError(e); } + }; + InnerObserver.prototype.onCompleted = function() { + if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function(e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + }; + + return SkipObservable; + }(ObservableBase)); + + /** + * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. + * @param {Number} count The number of elements to skip before returning the remaining elements. + * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence. + */ + observableProto.skip = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + return new SkipObservable(this, count); + }; + var SkipWhileObservable = (function (__super__) { + inherits(SkipWhileObservable, __super__); + function SkipWhileObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + SkipWhileObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipWhileObserver(o, this)); + }; + + return SkipWhileObservable; + }(ObservableBase)); + + var SkipWhileObserver = (function (__super__) { + inherits(SkipWhileObserver, __super__); + + function SkipWhileObserver(o, p) { + this._o = o; + this._p = p; + this._i = 0; + this._r = false; + __super__.call(this); + } + + SkipWhileObserver.prototype.next = function (x) { + if (!this._r) { + var res = tryCatch(this._p._fn)(x, this._i++, this._p); + if (res === errorObj) { return this._o.onError(res.e); } + this._r = !res; + } + this._r && this._o.onNext(x); + }; + SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWhileObserver; + }(AbstractObserver)); + + /** + * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + * The element's index is used in the logic of the predicate function. + * + * var res = source.skipWhile(function (value) { return value < 10; }); + * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; }); + * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. + */ + observableProto.skipWhile = function (predicate, thisArg) { + var fn = bindCallback(predicate, thisArg, 3); + return new SkipWhileObservable(this, fn); + }; + + var TakeObservable = (function(__super__) { + inherits(TakeObservable, __super__); + + function TakeObservable(source, count) { + this.source = source; + this.takeCount = count; + __super__.call(this); + } + + TakeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.takeCount)); + }; + + function InnerObserver(o, c) { + this.o = o; + this.c = c; + this.r = c; + this.isStopped = false; + } + InnerObserver.prototype = { + onNext: function (x) { + if (this.isStopped) { return; } + if (this.r-- > 0) { + this.o.onNext(x); + this.r <= 0 && this.o.onCompleted(); + } + }, + onError: function (err) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }, + onCompleted: function () { + if (!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }, + dispose: function () { this.isStopped = true; }, + fail: function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + } + }; + + return TakeObservable; + }(ObservableBase)); + + /** + * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0). + * @param {Number} count The number of elements to return. + * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.value = null; + this.error = null; + } + }); + + return BehaviorSubject; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. + */ + var ReplaySubject = Rx.ReplaySubject = (function (__super__) { + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function createRemovableDisposable(subject, observer) { + return disposableCreate(function () { + observer.dispose(); + !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); + }); + } + + inherits(ReplaySubject, __super__); + + /** + * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. + * @param {Number} [bufferSize] Maximum element count of the replay buffer. + * @param {Number} [windowSize] Maximum time length of the replay buffer. + * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. + */ + function ReplaySubject(bufferSize, windowSize, scheduler) { + this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; + this.windowSize = windowSize == null ? maxSafeInteger : windowSize; + this.scheduler = scheduler || currentThreadScheduler; + this.q = []; + this.observers = []; + this.isStopped = false; + this.isDisposed = false; + this.hasError = false; + this.error = null; + __super__.call(this); + } + + addProperties(ReplaySubject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so); + + this._trim(this.scheduler.now()); + this.observers.push(so); + + for (var i = 0, len = this.q.length; i < len; i++) { + so.onNext(this.q[i].value); + } + + if (this.hasError) { + so.onError(this.error); + } else if (this.isStopped) { + so.onCompleted(); + } + + so.ensureActive(); + return subscription; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + return this.observers.length > 0; + }, + _trim: function (now) { + while (this.q.length > this.bufferSize) { + this.q.shift(); + } + while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { + this.q.shift(); + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + var now = this.scheduler.now(); + this.q.push({ interval: now, value: value }); + this._trim(now); + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onNext(value); + observer.ensureActive(); + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.error = error; + this.hasError = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onError(error); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onCompleted(); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + return ReplaySubject; + }(Observable)); + + var RefCountObservable = (function (__super__) { + inherits(RefCountObservable, __super__); + function RefCountObservable(source) { + this.source = source; + this._count = 0; + this._connectableSubscription = null; + __super__.call(this); + } + + RefCountObservable.prototype.subscribeCore = function (o) { + var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o); + shouldConnect && (this._connectableSubscription = this.source.connect()); + return new RefCountDisposable(this, subscription); + }; + + function RefCountDisposable(p, s) { + this._p = p; + this._s = s; + this.isDisposed = false; + } + + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.dispose(); + --this._p._count === 0 && this._p._connectableSubscription.dispose(); + } + }; + + return RefCountObservable; + }(ObservableBase)); + + var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { + inherits(ConnectableObservable, __super__); + function ConnectableObservable(source, subject) { + this.source = source; + this._hasSubscription = false; + this._subscription = null; + this._sourceObservable = source.asObservable(); + this._subject = subject; + __super__.call(this); + } + + function ConnectDisposable(parent) { + this._p = parent; + this.isDisposed = false; + } + + ConnectDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._p._hasSubscription = false; + } + }; + + ConnectableObservable.prototype.connect = function () { + if (!this._hasSubscription) { + this._hasSubscription = true; + this._subscription = new BinaryDisposable( + this._sourceObservable.subscribe(this._subject), + new ConnectDisposable(this) + ); + } + return this._subscription; + }; + + ConnectableObservable.prototype._subscribe = function (o) { + return this._subject.subscribe(o); + }; + + ConnectableObservable.prototype.refCount = function () { + return new RefCountObservable(this); + }; + + return ConnectableObservable; + }(Observable)); + + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence + * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`) + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source. + */ + observableProto.singleInstance = function() { + var source = this, hasObservable = false, observable; + + function getObservable() { + if (!hasObservable) { + hasObservable = true; + observable = source.finally(function() { hasObservable = false; }).publish().refCount(); + } + return observable; + } + + return new AnonymousObservable(function(o) { + return getObservable().subscribe(o); + }); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var leftDone = false, rightDone = false; + var leftId = 0, rightId = 0; + var leftMap = new Map(), rightMap = new Map(); + var handleError = function (e) { o.onError(e); }; + + group.add(left.subscribe( + function (value) { + var id = leftId++, md = new SingleAssignmentDisposable(); + + leftMap.set(id, value); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted(); + group.remove(md); + })); + + rightMap.forEach(function (v) { + var result = tryCatch(resultSelector)(value, v); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + leftDone = true; + (rightDone || leftMap.size === 0) && o.onCompleted(); + }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++, md = new SingleAssignmentDisposable(); + + rightMap.set(id, value); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted(); + group.remove(md); + })); + + leftMap.forEach(function (v) { + var result = tryCatch(resultSelector)(v, value); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + rightDone = true; + (leftDone || rightMap.size === 0) && o.onCompleted(); + }) + ); + return group; + }, left); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations, and groups the results. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var r = new RefCountDisposable(group); + var leftMap = new Map(), rightMap = new Map(); + var leftId = 0, rightId = 0; + var handleError = function (e) { return function (v) { v.onError(e); }; }; + + function handleError(e) { }; + + group.add(left.subscribe( + function (value) { + var s = new Subject(); + var id = leftId++; + leftMap.set(id, s); + + var result = tryCatch(resultSelector)(value, addRef(s, r)); + if (result === errorObj) { + leftMap.forEach(handleError(result.e)); + return o.onError(result.e); + } + o.onNext(result); + + rightMap.forEach(function (v) { s.onNext(v); }); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + leftMap['delete'](id) && s.onCompleted(); + group.remove(md); + })); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { o.onCompleted(); }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++; + rightMap.set(id, value); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + rightMap['delete'](id); + group.remove(md); + })); + + leftMap.forEach(function (v) { v.onNext(value); }); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }) + ); + + return r; + }, left); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers. + * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.buffer = function () { + return this.window.apply(this, arguments) + .flatMap(toArray); + }; + + /** + * Projects each element of an observable sequence into zero or more windows. + * + * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { + if (arguments.length === 1 && typeof arguments[0] !== 'function') { + return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector); + } + return typeof windowOpeningsOrClosingSelector === 'function' ? + observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) : + observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector); + }; + + function observableWindowWithOpenings(windowOpenings, windowClosingSelector) { + return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) { + return win; + }); + } + + function observableWindowWithBoundaries(windowBoundaries) { + var source = this; + return new AnonymousObservable(function (observer) { + var win = new Subject(), + d = new CompositeDisposable(), + r = new RefCountDisposable(d); + + observer.onNext(addRef(win, r)); + + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries)); + + d.add(windowBoundaries.subscribe(function (w) { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + return r; + }, source); + } + + function observableWindowWithClosingSelector(windowClosingSelector) { + var source = this; + return new AnonymousObservable(function (observer) { + var m = new SerialDisposable(), + d = new CompositeDisposable(m), + r = new RefCountDisposable(d), + win = new Subject(); + observer.onNext(addRef(win, r)); + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + function createWindowClose () { + var windowClose; + try { + windowClose = windowClosingSelector(); + } catch (e) { + observer.onError(e); + return; + } + + isPromise(windowClose) && (windowClose = observableFromPromise(windowClose)); + + var m1 = new SingleAssignmentDisposable(); + m.setDisposable(m1); + m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + createWindowClose(); + })); + } + + createWindowClose(); + return r; + }, source); + } + + /** + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. + * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array. + */ + observableProto.pairwise = function () { + var source = this; + return new AnonymousObservable(function (observer) { + var previous, hasPrevious = false; + return source.subscribe( + function (x) { + if (hasPrevious) { + observer.onNext([previous, x]); + } else { + hasPrevious = true; + } + previous = x; + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer)); + }, source); + }; + + /** + * Returns two observables which partition the observations of the source by the given function. + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes + * when the source completes. + * @param {Function} predicate + * The function to determine which output Observable will trigger a particular observation. + * @returns {Array} + * An array of observables. The first triggers when the predicate returns true, + * and the second triggers when the predicate returns false. + */ + observableProto.partition = function(predicate, thisArg) { + return [ + this.filter(predicate, thisArg), + this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); }) + ]; + }; + + var WhileEnumerable = (function(__super__) { + inherits(WhileEnumerable, __super__); + function WhileEnumerable(c, s) { + this.c = c; + this.s = s; + } + WhileEnumerable.prototype[$iterator$] = function () { + var self = this; + return { + next: function () { + return self.c() ? + { done: false, value: self.s } : + { done: true, value: void 0 }; + } + }; + }; + return WhileEnumerable; + }(Enumerable)); + + function enumerableWhile(condition, source) { + return new WhileEnumerable(condition, source); + } + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + observableProto.letBind = observableProto['let'] = function (func) { + return func(this); + }; + + /** + * Determines whether an observable collection contains values. + * + * @example + * 1 - res = Rx.Observable.if(condition, obs1); + * 2 - res = Rx.Observable.if(condition, obs1, obs2); + * 3 - res = Rx.Observable.if(condition, obs1, scheduler); + * @param {Function} condition The condition which determines if the thenSource or elseSource will be run. + * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true. + * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. + * @returns {Observable} An observable sequence which is either the thenSource or elseSource. + */ + Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) { + return observableDefer(function () { + elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty()); + + isPromise(thenSource) && (thenSource = observableFromPromise(thenSource)); + isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler)); + + // Assume a scheduler for empty only + typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler)); + return condition() ? thenSource : elseSourceOrScheduler; + }); + }; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers 0) { + isOwner = !isAcquired; + isAcquired = true; + } + if (isOwner) { + m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) { + var work; + if (q.length > 0) { + work = q.shift(); + } else { + isAcquired = false; + return; + } + var m1 = new SingleAssignmentDisposable(); + d.add(m1); + m1.setDisposable(work.subscribe(function (x) { + o.onNext(x); + var result = null; + try { + result = selector(x); + } catch (e) { + o.onError(e); + } + q.push(result); + activeCount++; + ensureActive(); + }, function (e) { o.onError(e); }, function () { + d.remove(m1); + activeCount--; + if (activeCount === 0) { + o.onCompleted(); + } + })); + self(); + })); + } + }; + + q.push(source); + activeCount++; + ensureActive(); + return d; + }, this); + }; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * 1 - res = Rx.Observable.forkJoin([obs1, obs2]); + * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences. + */ + Observable.forkJoin = function () { + var allSources = []; + if (Array.isArray(arguments[0])) { + allSources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); } + } + return new AnonymousObservable(function (subscriber) { + var count = allSources.length; + if (count === 0) { + subscriber.onCompleted(); + return disposableEmpty; + } + var group = new CompositeDisposable(), + finished = false, + hasResults = new Array(count), + hasCompleted = new Array(count), + results = new Array(count); + + for (var idx = 0; idx < count; idx++) { + (function (i) { + var source = allSources[i]; + isPromise(source) && (source = observableFromPromise(source)); + group.add( + source.subscribe( + function (value) { + if (!finished) { + hasResults[i] = true; + results[i] = value; + } + }, + function (e) { + finished = true; + subscriber.onError(e); + group.dispose(); + }, + function () { + if (!finished) { + if (!hasResults[i]) { + subscriber.onCompleted(); + return; + } + hasCompleted[i] = true; + for (var ix = 0; ix < count; ix++) { + if (!hasCompleted[ix]) { return; } + } + finished = true; + subscriber.onNext(results); + subscriber.onCompleted(); + } + })); + })(idx); + } + + return group; + }); + }; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * @param {Observable} second Second observable sequence. + * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + observableProto.forkJoin = function (second, resultSelector) { + var first = this; + return new AnonymousObservable(function (observer) { + var leftStopped = false, rightStopped = false, + hasLeft = false, hasRight = false, + lastLeft, lastRight, + leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable(); + + isPromise(second) && (second = observableFromPromise(second)); + + leftSubscription.setDisposable( + first.subscribe(function (left) { + hasLeft = true; + lastLeft = left; + }, function (err) { + rightSubscription.dispose(); + observer.onError(err); + }, function () { + leftStopped = true; + if (rightStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + rightSubscription.setDisposable( + second.subscribe(function (right) { + hasRight = true; + lastRight = right; + }, function (err) { + leftSubscription.dispose(); + observer.onError(err); + }, function () { + rightStopped = true; + if (leftStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(result.e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }, first); + }; + + /** + * Comonadic bind operator. + * @param {Function} selector A transform function to apply to each element. + * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns {Observable} An observable sequence which results from the comonadic bind operation. + */ + observableProto.manySelect = observableProto.extend = function (selector, scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + var source = this; + return observableDefer(function () { + var chain; + + return source + .map(function (x) { + var curr = new ChainObservable(x); + + chain && chain.onNext(x); + chain = curr; + + return curr; + }) + .tap( + noop, + function (e) { chain && chain.onError(e); }, + function () { chain && chain.onCompleted(); } + ) + .observeOn(scheduler) + .map(selector); + }, source); + }; + + var ChainObservable = (function (__super__) { + inherits(ChainObservable, __super__); + function ChainObservable(head) { + __super__.call(this); + this.head = head; + this.tail = new AsyncSubject(); + } + + addProperties(ChainObservable.prototype, Observer, { + _subscribe: function (o) { + var g = new CompositeDisposable(); + g.add(currentThreadScheduler.schedule(this, function (_, self) { + o.onNext(self.head); + g.add(self.tail.mergeAll().subscribe(o)); + })); + + return g; + }, + onCompleted: function () { + this.onNext(Observable.empty()); + }, + onError: function (e) { + this.onNext(Observable['throw'](e)); + }, + onNext: function (v) { + this.tail.onNext(v); + this.tail.onCompleted(); + } + }); + + return ChainObservable; + + }(Observable)); + + var Map = root.Map || (function () { + function Map() { + this.size = 0; + this._values = []; + this._keys = []; + } + + Map.prototype['delete'] = function (key) { + var i = this._keys.indexOf(key); + if (i === -1) { return false; } + this._values.splice(i, 1); + this._keys.splice(i, 1); + this.size--; + return true; + }; + + Map.prototype.get = function (key) { + var i = this._keys.indexOf(key); + return i === -1 ? undefined : this._values[i]; + }; + + Map.prototype.set = function (key, value) { + var i = this._keys.indexOf(key); + if (i === -1) { + this._keys.push(key); + this._values.push(value); + this.size++; + } else { + this._values[i] = value; + } + return this; + }; + + Map.prototype.forEach = function (cb, thisArg) { + for (var i = 0; i < this.size; i++) { + cb.call(thisArg, this._values[i], this._keys[i]); + } + }; + + return Map; + }()); + + /** + * @constructor + * Represents a join pattern over observable sequences. + */ + function Pattern(patterns) { + this.patterns = patterns; + } + + /** + * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. + * @param other Observable sequence to match in addition to the current pattern. + * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value. + */ + Pattern.prototype.and = function (other) { + return new Pattern(this.patterns.concat(other)); + }; + + /** + * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. + * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. + * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + Pattern.prototype.thenDo = function (selector) { + return new Plan(this, selector); + }; + + function Plan(expression, selector) { + this.expression = expression; + this.selector = selector; + } + + Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) { + var self = this; + var joinObservers = []; + for (var i = 0, len = this.expression.patterns.length; i < len; i++) { + joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer))); + } + var activePlan = new ActivePlan(joinObservers, function () { + var result; + try { + result = self.selector.apply(self, arguments); + } catch (e) { + observer.onError(e); + return; + } + observer.onNext(result); + }, function () { + for (var j = 0, jlen = joinObservers.length; j < jlen; j++) { + joinObservers[j].removeActivePlan(activePlan); + } + deactivate(activePlan); + }); + for (i = 0, len = joinObservers.length; i < len; i++) { + joinObservers[i].addActivePlan(activePlan); + } + return activePlan; + }; + + function planCreateObserver(externalSubscriptions, observable, onError) { + var entry = externalSubscriptions.get(observable); + if (!entry) { + var observer = new JoinObserver(observable, onError); + externalSubscriptions.set(observable, observer); + return observer; + } + return entry; + } + + function ActivePlan(joinObserverArray, onNext, onCompleted) { + this.joinObserverArray = joinObserverArray; + this.onNext = onNext; + this.onCompleted = onCompleted; + this.joinObservers = new Map(); + for (var i = 0, len = this.joinObserverArray.length; i < len; i++) { + var joinObserver = this.joinObserverArray[i]; + this.joinObservers.set(joinObserver, joinObserver); + } + } + + ActivePlan.prototype.dequeue = function () { + this.joinObservers.forEach(function (v) { v.queue.shift(); }); + }; + + ActivePlan.prototype.match = function () { + var i, len, hasValues = true; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + if (this.joinObserverArray[i].queue.length === 0) { + hasValues = false; + break; + } + } + if (hasValues) { + var firstValues = [], + isCompleted = false; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + firstValues.push(this.joinObserverArray[i].queue[0]); + this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true); + } + if (isCompleted) { + this.onCompleted(); + } else { + this.dequeue(); + var values = []; + for (i = 0, len = firstValues.length; i < firstValues.length; i++) { + values.push(firstValues[i].value); + } + this.onNext.apply(this, values); + } + } + }; + + var JoinObserver = (function (__super__) { + inherits(JoinObserver, __super__); + + function JoinObserver(source, onError) { + __super__.call(this); + this.source = source; + this.onError = onError; + this.queue = []; + this.activePlans = []; + this.subscription = new SingleAssignmentDisposable(); + this.isDisposed = false; + } + + var JoinObserverPrototype = JoinObserver.prototype; + + JoinObserverPrototype.next = function (notification) { + if (!this.isDisposed) { + if (notification.kind === 'E') { + return this.onError(notification.error); + } + this.queue.push(notification); + var activePlans = this.activePlans.slice(0); + for (var i = 0, len = activePlans.length; i < len; i++) { + activePlans[i].match(); + } + } + }; + + JoinObserverPrototype.error = noop; + JoinObserverPrototype.completed = noop; + + JoinObserverPrototype.addActivePlan = function (activePlan) { + this.activePlans.push(activePlan); + }; + + JoinObserverPrototype.subscribe = function () { + this.subscription.setDisposable(this.source.materialize().subscribe(this)); + }; + + JoinObserverPrototype.removeActivePlan = function (activePlan) { + this.activePlans.splice(this.activePlans.indexOf(activePlan), 1); + this.activePlans.length === 0 && this.dispose(); + }; + + JoinObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + if (!this.isDisposed) { + this.isDisposed = true; + this.subscription.dispose(); + } + }; + + return JoinObserver; + } (AbstractObserver)); + + /** + * Creates a pattern that matches when both observable sequences have an available value. + * + * @param right Observable sequence to match with the current sequence. + * @return {Pattern} Pattern object that matches when both observable sequences have an available value. + */ + observableProto.and = function (right) { + return new Pattern([this, right]); + }; + + /** + * Matches when the observable sequence has an available value and projects the value. + * + * @param {Function} selector Selector that will be invoked for values in the source sequence. + * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + observableProto.thenDo = function (selector) { + return new Pattern([this]).thenDo(selector); + }; + + /** + * Joins together the results from several patterns. + * + * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns. + * @returns {Observable} Observable sequence with the results form matching several patterns. + */ + Observable.when = function () { + var len = arguments.length, plans; + if (Array.isArray(arguments[0])) { + plans = arguments[0]; + } else { + plans = new Array(len); + for(var i = 0; i < len; i++) { plans[i] = arguments[i]; } + } + return new AnonymousObservable(function (o) { + var activePlans = [], + externalSubscriptions = new Map(); + var outObserver = observerCreate( + function (x) { o.onNext(x); }, + function (err) { + externalSubscriptions.forEach(function (v) { v.onError(err); }); + o.onError(err); + }, + function (x) { o.onCompleted(); } + ); + try { + for (var i = 0, len = plans.length; i < len; i++) { + activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) { + var idx = activePlans.indexOf(activePlan); + activePlans.splice(idx, 1); + activePlans.length === 0 && o.onCompleted(); + })); + } + } catch (e) { + observableThrow(e).subscribe(o); + } + var group = new CompositeDisposable(); + externalSubscriptions.forEach(function (joinObserver) { + joinObserver.subscribe(); + group.add(joinObserver); + }); + + return group; + }); + }; + + var TimerObservable = (function(__super__) { + inherits(TimerObservable, __super__); + function TimerObservable(dt, s) { + this._dt = dt; + this._s = s; + __super__.call(this); + } + + TimerObservable.prototype.subscribeCore = function (o) { + return this._s.scheduleFuture(o, this._dt, scheduleMethod); + }; + + function scheduleMethod(s, o) { + o.onNext(0); + o.onCompleted(); + } + + return TimerObservable; + }(ObservableBase)); + + function _observableTimer(dueTime, scheduler) { + return new TimerObservable(dueTime, scheduler); + } + + function observableTimerDateAndPeriod(dueTime, period, scheduler) { + return new AnonymousObservable(function (observer) { + var d = dueTime, p = normalizeTime(period); + return scheduler.scheduleRecursiveFuture(0, d, function (count, self) { + if (p > 0) { + var now = scheduler.now(); + d = d + p; + d <= now && (d = now + p); + } + observer.onNext(count); + self(count + 1, new Date(d)); + }); + }); + } + + function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { + return dueTime === period ? + new AnonymousObservable(function (observer) { + return scheduler.schedulePeriodic(0, period, function (count) { + observer.onNext(count); + return count + 1; + }); + }) : + observableDefer(function () { + return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler); + }); + } + + /** + * Returns an observable sequence that produces a value after each period. + * + * @example + * 1 - res = Rx.Observable.interval(1000); + * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); + * + * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. + * @returns {Observable} An observable sequence that produces a value after each period. + */ + var observableinterval = Observable.interval = function (period, scheduler) { + return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler); + }; + + /** + * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. + * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period. + */ + var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { + var period; + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { + period = periodOrScheduler; + } else if (isScheduler(periodOrScheduler)) { + scheduler = periodOrScheduler; + } + if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) { + return _observableTimer(dueTime, scheduler); + } + if (dueTime instanceof Date && period !== undefined) { + return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler); + } + return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); + }; + + function observableDelayRelative(source, dueTime, scheduler) { + return new AnonymousObservable(function (o) { + var active = false, + cancelable = new SerialDisposable(), + exception = null, + q = [], + running = false, + subscription; + subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) { + var d, shouldRun; + if (notification.value.kind === 'E') { + q = []; + q.push(notification); + exception = notification.value.error; + shouldRun = !running; + } else { + q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); + shouldRun = !active; + active = true; + } + if (shouldRun) { + if (exception !== null) { + o.onError(exception); + } else { + d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) { + var e, recurseDueTime, result, shouldRecurse; + if (exception !== null) { + return; + } + running = true; + do { + result = null; + if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) { + result = q.shift().value; + } + if (result !== null) { + result.accept(o); + } + } while (result !== null); + shouldRecurse = false; + recurseDueTime = 0; + if (q.length > 0) { + shouldRecurse = true; + recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now()); + } else { + active = false; + } + e = exception; + running = false; + if (e !== null) { + o.onError(e); + } else if (shouldRecurse) { + self(null, recurseDueTime); + } + })); + } + } + }); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + function observableDelayAbsolute(source, dueTime, scheduler) { + return observableDefer(function () { + return observableDelayRelative(source, dueTime - scheduler.now(), scheduler); + }); + } + + function delayWithSelector(source, subscriptionDelay, delayDurationSelector) { + var subDelay, selector; + if (isFunction(subscriptionDelay)) { + selector = subscriptionDelay; + } else { + subDelay = subscriptionDelay; + selector = delayDurationSelector; + } + return new AnonymousObservable(function (o) { + var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable(); + + function start() { + subscription.setDisposable(source.subscribe( + function (x) { + var delay = tryCatch(selector)(x); + if (delay === errorObj) { return o.onError(delay.e); } + var d = new SingleAssignmentDisposable(); + delays.add(d); + d.setDisposable(delay.subscribe( + function () { + o.onNext(x); + delays.remove(d); + done(); + }, + function (e) { o.onError(e); }, + function () { + o.onNext(x); + delays.remove(d); + done(); + } + )); + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + subscription.dispose(); + done(); + } + )); + } + + function done () { + atEnd && delays.length === 0 && o.onCompleted(); + } + + if (!subDelay) { + start(); + } else { + subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); + } + + return new BinaryDisposable(subscription, delays); + }, this); + } + + /** + * Time shifts the observable sequence by dueTime. + * The relative time intervals between the values are preserved. + * + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. + * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delay = function () { + var firstArg = arguments[0]; + if (typeof firstArg === 'number' || firstArg instanceof Date) { + var dueTime = firstArg, scheduler = arguments[1]; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return dueTime instanceof Date ? + observableDelayAbsolute(this, dueTime, scheduler) : + observableDelayRelative(this, dueTime, scheduler); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return delayWithSelector(this, firstArg, arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var DebounceObservable = (function (__super__) { + inherits(DebounceObservable, __super__); + function DebounceObservable(source, dt, s) { + isScheduler(s) || (s = defaultScheduler); + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DebounceObservable.prototype.subscribeCore = function (o) { + var cancelable = new SerialDisposable(); + return new BinaryDisposable( + this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)), + cancelable); + }; + + return DebounceObservable; + }(ObservableBase)); + + var DebounceObserver = (function (__super__) { + inherits(DebounceObserver, __super__); + function DebounceObserver(observer, source, dueTime, scheduler, cancelable) { + this._o = observer; + this._s = source; + this._d = dueTime; + this._scheduler = scheduler; + this._c = cancelable; + this._v = null; + this._hv = false; + this._id = 0; + __super__.call(this); + } + + DebounceObserver.prototype.next = function (x) { + this._hv = true; + this._v = x; + var currentId = ++this._id, d = new SingleAssignmentDisposable(); + this._c.setDisposable(d); + d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) { + self._hv && self._id === currentId && self._o.onNext(x); + self._hv = false; + })); + }; + + DebounceObserver.prototype.error = function (e) { + this._c.dispose(); + this._o.onError(e); + this._hv = false; + this._id++; + }; + + DebounceObserver.prototype.completed = function () { + this._c.dispose(); + this._hv && this._o.onNext(this._v); + this._o.onCompleted(); + this._hv = false; + this._id++; + }; + + return DebounceObserver; + }(AbstractObserver)); + + function debounceWithSelector(source, durationSelector) { + return new AnonymousObservable(function (o) { + var value, hasValue = false, cancelable = new SerialDisposable(), id = 0; + var subscription = source.subscribe( + function (x) { + var throttle = tryCatch(durationSelector)(x); + if (throttle === errorObj) { return o.onError(throttle.e); } + + isPromise(throttle) && (throttle = observableFromPromise(throttle)); + + hasValue = true; + value = x; + id++; + var currentid = id, d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(throttle.subscribe( + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + }, + function (e) { o.onError(e); }, + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + } + )); + }, + function (e) { + cancelable.dispose(); + o.onError(e); + hasValue = false; + id++; + }, + function () { + cancelable.dispose(); + hasValue && o.onNext(value); + o.onCompleted(); + hasValue = false; + id++; + } + ); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + observableProto.debounce = function () { + if (isFunction (arguments[0])) { + return debounceWithSelector(this, arguments[0]); + } else if (typeof arguments[0] === 'number') { + return new DebounceObservable(this, arguments[0], arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on timing information. + * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + var source = this, timeShift; + timeShiftOrScheduler == null && (timeShift = timeSpan); + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (typeof timeShiftOrScheduler === 'number') { + timeShift = timeShiftOrScheduler; + } else if (isScheduler(timeShiftOrScheduler)) { + timeShift = timeSpan; + scheduler = timeShiftOrScheduler; + } + return new AnonymousObservable(function (observer) { + var groupDisposable, + nextShift = timeShift, + nextSpan = timeSpan, + q = [], + refCountDisposable, + timerD = new SerialDisposable(), + totalTime = 0; + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable); + + function createTimer () { + var m = new SingleAssignmentDisposable(), + isSpan = false, + isShift = false; + timerD.setDisposable(m); + if (nextSpan === nextShift) { + isSpan = true; + isShift = true; + } else if (nextSpan < nextShift) { + isSpan = true; + } else { + isShift = true; + } + var newTotalTime = isSpan ? nextSpan : nextShift, + ts = newTotalTime - totalTime; + totalTime = newTotalTime; + if (isSpan) { + nextSpan += timeShift; + } + if (isShift) { + nextShift += timeShift; + } + m.setDisposable(scheduler.scheduleFuture(null, ts, function () { + if (isShift) { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + isSpan && q.shift().onCompleted(); + createTimer(); + })); + }; + q.push(new Subject()); + observer.onNext(addRef(q[0], refCountDisposable)); + createTimer(); + groupDisposable.add(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + }, + function (e) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); } + observer.onError(e); + }, + function () { + for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + /** + * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a window. + * @param {Number} count Maximum element count of a window. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (observer) { + var timerD = new SerialDisposable(), + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable), + n = 0, + windowId = 0, + s = new Subject(); + + function createTimer(id) { + var m = new SingleAssignmentDisposable(); + timerD.setDisposable(m); + m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () { + if (id !== windowId) { return; } + n = 0; + var newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + createTimer(newId); + })); + } + + observer.onNext(addRef(s, refCountDisposable)); + createTimer(0); + + groupDisposable.add(source.subscribe( + function (x) { + var newId = 0, newWindow = false; + s.onNext(x); + if (++n === count) { + newWindow = true; + n = 0; + newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + } + newWindow && createTimer(newId); + }, + function (e) { + s.onError(e); + observer.onError(e); + }, function () { + s.onCompleted(); + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. + * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. + * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a buffer. + * @param {Number} count Maximum element count of a buffer. + * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) { + return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray); + }; + + var TimeIntervalObservable = (function (__super__) { + inherits(TimeIntervalObservable, __super__); + function TimeIntervalObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimeIntervalObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimeIntervalObserver(o, this._s)); + }; + + return TimeIntervalObservable; + }(ObservableBase)); + + var TimeIntervalObserver = (function (__super__) { + inherits(TimeIntervalObserver, __super__); + + function TimeIntervalObserver(o, s) { + this._o = o; + this._s = s; + this._l = s.now(); + __super__.call(this); + } + + TimeIntervalObserver.prototype.next = function (x) { + var now = this._s.now(), span = now - this._l; + this._l = now; + this._o.onNext({ value: x, interval: span }); + }; + TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); }; + TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return TimeIntervalObserver; + }(AbstractObserver)); + + /** + * Records the time interval between consecutive values in an observable sequence. + * + * @example + * 1 - res = source.timeInterval(); + * 2 - res = source.timeInterval(Rx.Scheduler.timeout); + * + * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence with time interval information on values. + */ + observableProto.timeInterval = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimeIntervalObservable(this, scheduler); + }; + + var TimestampObservable = (function (__super__) { + inherits(TimestampObservable, __super__); + function TimestampObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimestampObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimestampObserver(o, this._s)); + }; + + return TimestampObservable; + }(ObservableBase)); + + var TimestampObserver = (function (__super__) { + inherits(TimestampObserver, __super__); + function TimestampObserver(o, s) { + this._o = o; + this._s = s; + __super__.call(this); + } + + TimestampObserver.prototype.next = function (x) { + this._o.onNext({ value: x, timestamp: this._s.now() }); + }; + + TimestampObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TimestampObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return TimestampObserver; + }(AbstractObserver)); + + /** + * Records the timestamp for each value in an observable sequence. + * + * @example + * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } + * 2 - res = source.timestamp(Rx.Scheduler.default); + * + * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used. + * @returns {Observable} An observable sequence with timestamp information on values. + */ + observableProto.timestamp = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimestampObservable(this, scheduler); + }; + + function sampleObservable(source, sampler) { + return new AnonymousObservable(function (o) { + var atEnd = false, value, hasValue = false; + + function sampleSubscribe() { + if (hasValue) { + hasValue = false; + o.onNext(value); + } + atEnd && o.onCompleted(); + } + + var sourceSubscription = new SingleAssignmentDisposable(); + sourceSubscription.setDisposable(source.subscribe( + function (newValue) { + hasValue = true; + value = newValue; + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + sourceSubscription.dispose(); + } + )); + + return new BinaryDisposable( + sourceSubscription, + sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe) + ); + }, source); + } + + /** + * Samples the observable sequence at each interval. + * + * @example + * 1 - res = source.sample(sampleObservable); // Sampler tick sequence + * 2 - res = source.sample(5000); // 5 seconds + * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds + * + * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable. + * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Sampled observable sequence. + */ + observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return typeof intervalOrSampler === 'number' ? + sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : + sampleObservable(this, intervalOrSampler); + }; + + var TimeoutError = Rx.TimeoutError = function(message) { + this.message = message || 'Timeout has occurred'; + this.name = 'TimeoutError'; + Error.call(this); + }; + TimeoutError.prototype = Object.create(Error.prototype); + + function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) { + if (isFunction(firstTimeout)) { + other = timeoutDurationSelector; + timeoutDurationSelector = firstTimeout; + firstTimeout = observableNever(); + } + other || (other = observableThrow(new TimeoutError())); + return new AnonymousObservable(function (o) { + var subscription = new SerialDisposable(), + timer = new SerialDisposable(), + original = new SingleAssignmentDisposable(); + + subscription.setDisposable(original); + + var id = 0, switched = false; + + function setTimer(timeout) { + var myId = id, d = new SingleAssignmentDisposable(); + + function timerWins() { + switched = (myId === id); + return switched; + } + + timer.setDisposable(d); + d.setDisposable(timeout.subscribe(function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + d.dispose(); + }, function (e) { + timerWins() && o.onError(e); + }, function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + })); + }; + + setTimer(firstTimeout); + + function oWins() { + var res = !switched; + if (res) { id++; } + return res; + } + + original.setDisposable(source.subscribe(function (x) { + if (oWins()) { + o.onNext(x); + var timeout = tryCatch(timeoutDurationSelector)(x); + if (timeout === errorObj) { return o.onError(timeout.e); } + setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout); + } + }, function (e) { + oWins() && o.onError(e); + }, function () { + oWins() && o.onCompleted(); + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + function timeout(source, dueTime, other, scheduler) { + if (isScheduler(other)) { + scheduler = other; + other = observableThrow(new TimeoutError()); + } + if (other instanceof Error) { other = observableThrow(other); } + isScheduler(scheduler) || (scheduler = defaultScheduler); + + return new AnonymousObservable(function (o) { + var id = 0, + original = new SingleAssignmentDisposable(), + subscription = new SerialDisposable(), + switched = false, + timer = new SerialDisposable(); + + subscription.setDisposable(original); + + function createTimer() { + var myId = id; + timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () { + switched = id === myId; + if (switched) { + isPromise(other) && (other = observableFromPromise(other)); + subscription.setDisposable(other.subscribe(o)); + } + })); + } + + createTimer(); + + original.setDisposable(source.subscribe(function (x) { + if (!switched) { + id++; + o.onNext(x); + createTimer(); + } + }, function (e) { + if (!switched) { + id++; + o.onError(e); + } + }, function () { + if (!switched) { + id++; + o.onCompleted(); + } + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + observableProto.timeout = function () { + var firstArg = arguments[0]; + if (firstArg instanceof Date || typeof firstArg === 'number') { + return timeout(this, firstArg, arguments[1], arguments[2]); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var GenerateAbsoluteObservable = (function (__super__) { + inherits(GenerateAbsoluteObservable, __super__); + function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateAbsoluteObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive); + }; + + return GenerateAbsoluteObservable; + }(ObservableBase)); + + /** + * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithAbsoluteTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return new Date(); } + * }); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var GenerateRelativeObservable = (function (__super__) { + inherits(GenerateRelativeObservable, __super__); + function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateRelativeObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive); + }; + + return GenerateRelativeObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithRelativeTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return 500; } + * ); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var DelaySubscription = (function(__super__) { + inherits(DelaySubscription, __super__); + function DelaySubscription(source, dt, s) { + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DelaySubscription.prototype.subscribeCore = function (o) { + var d = new SerialDisposable(); + + d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod)); + + return d; + }; + + function scheduleMethod(s, state) { + var source = state[0], o = state[1], d = state[2]; + d.setDisposable(source.subscribe(o)); + } + + return DelaySubscription; + }(ObservableBase)); + + /** + * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.delaySubscription(5000); // 5s + * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds + * + * @param {Number} dueTime Relative or absolute time shift of the subscription. + * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delaySubscription = function (dueTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new DelaySubscription(this, dueTime, scheduler); + }; + + var SkipLastWithTimeObservable = (function (__super__) { + inherits(SkipLastWithTimeObservable, __super__); + function SkipLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + SkipLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastWithTimeObserver(o, this)); + }; + + return SkipLastWithTimeObservable; + }(ObservableBase)); + + var SkipLastWithTimeObserver = (function (__super__) { + inherits(SkipLastWithTimeObserver, __super__); + + function SkipLastWithTimeObserver(o, p) { + this._o = o; + this._s = p._s; + this._d = p._d; + this._q = []; + __super__.call(this); + } + + SkipLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + }; + SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + this._o.onCompleted(); + }; + + return SkipLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for skipping elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence. + */ + observableProto.skipLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipLastWithTimeObservable(this, duration, scheduler); + }; + + var TakeLastWithTimeObservable = (function (__super__) { + inherits(TakeLastWithTimeObservable, __super__); + function TakeLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + TakeLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s)); + }; + + return TakeLastWithTimeObservable; + }(ObservableBase)); + + var TakeLastWithTimeObserver = (function (__super__) { + inherits(TakeLastWithTimeObserver, __super__); + + function TakeLastWithTimeObserver(o, d, s) { + this._o = o; + this._d = d; + this._s = s; + this._q = []; + __super__.call(this); + } + + TakeLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._q.shift(); + } + }; + TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + TakeLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0) { + var next = this._q.shift(); + if (now - next.interval <= this._d) { this._o.onNext(next.value); } + } + this._o.onCompleted(); + }; + + return TakeLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeLastWithTimeObservable(this, duration, scheduler); + }; + + /** + * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastBufferWithTime = function (duration, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (o) { + var q = []; + return source.subscribe(function (x) { + var now = scheduler.now(); + q.push({ interval: now, value: x }); + while (q.length > 0 && now - q[0].interval >= duration) { + q.shift(); + } + }, function (e) { o.onError(e); }, function () { + var now = scheduler.now(), res = []; + while (q.length > 0) { + var next = q.shift(); + now - next.interval <= duration && res.push(next.value); + } + o.onNext(res); + o.onCompleted(); + }); + }, source); + }; + + var TakeWithTimeObservable = (function (__super__) { + inherits(TakeWithTimeObservable, __super__); + function TakeWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + function scheduleMethod(s, o) { + o.onCompleted(); + } + + TakeWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(o, this._d, scheduleMethod), + this.source.subscribe(o) + ); + }; + + return TakeWithTimeObservable; + }(ObservableBase)); + + /** + * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.takeWithTime(5000, [optional scheduler]); + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence. + */ + observableProto.takeWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeWithTimeObservable(this, duration, scheduler); + }; + + var SkipWithTimeObservable = (function (__super__) { + inherits(SkipWithTimeObservable, __super__); + function SkipWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + this._open = false; + __super__.call(this); + } + + function scheduleMethod(s, self) { + self._open = true; + } + + SkipWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(this, this._d, scheduleMethod), + this.source.subscribe(new SkipWithTimeObserver(o, this)) + ); + }; + + return SkipWithTimeObservable; + }(ObservableBase)); + + var SkipWithTimeObserver = (function (__super__) { + inherits(SkipWithTimeObserver, __super__); + + function SkipWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * @description + * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. + * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded + * may not execute immediately, despite the zero due time. + * + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. + * @param {Number} duration Duration for skipping elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence. + */ + observableProto.skipWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipWithTimeObservable(this, duration, scheduler); + }; + + var SkipUntilWithTimeObservable = (function (__super__) { + inherits(SkipUntilWithTimeObservable, __super__); + function SkipUntilWithTimeObservable(source, startTime, scheduler) { + this.source = source; + this._st = startTime; + this._s = scheduler; + __super__.call(this); + } + + function scheduleMethod(s, state) { + state._open = true; + } + + SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) { + this._open = false; + return new BinaryDisposable( + this._s.scheduleFuture(this, this._st, scheduleMethod), + this.source.subscribe(new SkipUntilWithTimeObserver(o, this)) + ); + }; + + return SkipUntilWithTimeObservable; + }(ObservableBase)); + + var SkipUntilWithTimeObserver = (function (__super__) { + inherits(SkipUntilWithTimeObserver, __super__); + + function SkipUntilWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipUntilWithTimeObserver; + }(AbstractObserver)); + + + /** + * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time. + * + * @examples + * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]); + * 2 - res = source.skipUntilWithTime(5000, [scheduler]); + * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped until the specified start time. + */ + observableProto.skipUntilWithTime = function (startTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipUntilWithTimeObservable(this, startTime, scheduler); + }; + + /** + * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. + * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. + * @returns {Observable} An observable sequence with the elements taken until the specified end time. + */ + observableProto.takeUntilWithTime = function (endTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var source = this; + return new AnonymousObservable(function (o) { + return new BinaryDisposable( + scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }), + source.subscribe(o)); + }, source); + }; + + /** + * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. + * @param {Number} windowDuration time to wait before emitting another item after emitting the last item + * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout. + * @returns {Observable} An Observable that performs the throttle operation. + */ + observableProto.throttle = function (windowDuration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var duration = +windowDuration || 0; + if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } + var source = this; + return new AnonymousObservable(function (o) { + var lastOnNext = 0; + return source.subscribe( + function (x) { + var now = scheduler.now(); + if (lastOnNext === 0 || now - lastOnNext >= duration) { + lastOnNext = now; + o.onNext(x); + } + },function (e) { o.onError(e); }, function () { o.onCompleted(); } + ); + }, source); + }; + + var TransduceObserver = (function (__super__) { + inherits(TransduceObserver, __super__); + function TransduceObserver(o, xform) { + this._o = o; + this._xform = xform; + __super__.call(this); + } + + TransduceObserver.prototype.next = function (x) { + var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x); + if (res === errorObj) { this._o.onError(res.e); } + }; + + TransduceObserver.prototype.error = function (e) { this._o.onError(e); }; + + TransduceObserver.prototype.completed = function () { + this._xform['@@transducer/result'](this._o); + }; + + return TransduceObserver; + }(AbstractObserver)); + + function transformForObserver(o) { + return { + '@@transducer/init': function() { + return o; + }, + '@@transducer/step': function(obs, input) { + return obs.onNext(input); + }, + '@@transducer/result': function(obs) { + return obs.onCompleted(); + } + }; + } + + /** + * Executes a transducer to transform the observable sequence + * @param {Transducer} transducer A transducer to execute + * @returns {Observable} An Observable sequence containing the results from the transducer. + */ + observableProto.transduce = function(transducer) { + var source = this; + return new AnonymousObservable(function(o) { + var xform = transducer(transformForObserver(o)); + return source.subscribe(new TransduceObserver(o, xform)); + }, source); + }; + + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * @returns {Observable} A exclusive observable with only the results that happen when subscribed. + */ + observableProto.switchFirst = function () { + var sources = this; + return new AnonymousObservable(function (o) { + var hasCurrent = false, + isStopped = false, + m = new SingleAssignmentDisposable(), + g = new CompositeDisposable(); + + g.add(m); + + m.setDisposable(sources.subscribe( + function (innerSource) { + if (!hasCurrent) { + hasCurrent = true; + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + var innerSubscription = new SingleAssignmentDisposable(); + g.add(innerSubscription); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { o.onError(e); }, + function () { + g.remove(innerSubscription); + hasCurrent = false; + isStopped && g.length === 1 && o.onCompleted(); + })); + } + }, + function (e) { o.onError(e); }, + function () { + isStopped = true; + !hasCurrent && g.length === 1 && o.onCompleted(); + })); + + return g; + }, this); + }; + +observableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst(); +}; + +Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +}; + /** Provides a set of extension methods for virtual time scheduling. */ + var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) { + inherits(VirtualTimeScheduler, __super__); + + /** + * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer. + * + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function VirtualTimeScheduler(initialClock, comparer) { + this.clock = initialClock; + this.comparer = comparer; + this.isEnabled = false; + this.queue = new PriorityQueue(1024); + __super__.call(this); + } + + var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype; + + VirtualTimeSchedulerPrototype.now = function () { + return this.toAbsoluteTime(this.clock); + }; + + VirtualTimeSchedulerPrototype.schedule = function (state, action) { + return this.scheduleAbsolute(state, this.clock, action); + }; + + VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime instanceof Date ? + this.toRelativeTime(dueTime - this.now()) : + this.toRelativeTime(dueTime); + + return this.scheduleRelative(state, dt, action); + }; + + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + VirtualTimeSchedulerPrototype.add = notImplemented; + + /** + * Converts an absolute time to a number + * @param {Any} The absolute time. + * @returns {Number} The absolute time in ms + */ + VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented; + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) { + var s = new SchedulePeriodicRecursive(this, state, period, action); + return s.start(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) { + var runAt = this.add(this.clock, dueTime); + return this.scheduleAbsolute(state, runAt, action); + }; + + /** + * Starts the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.start = function () { + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + } + }; + + /** + * Stops the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.stop = function () { + this.isEnabled = false; + }; + + /** + * Advances the scheduler's clock to the specified time, running all work till that point. + * @param {Number} time Absolute time to advance the scheduler's clock to. + */ + VirtualTimeSchedulerPrototype.advanceTo = function (time) { + var dueToClock = this.comparer(this.clock, time); + if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null && this.comparer(next.dueTime, time) <= 0) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + this.clock = time; + } + }; + + /** + * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.advanceBy = function (time) { + var dt = this.add(this.clock, time), + dueToClock = this.comparer(this.clock, dt); + if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + + this.advanceTo(dt); + }; + + /** + * Advances the scheduler's clock by the specified relative time. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.sleep = function (time) { + var dt = this.add(this.clock, time); + if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); } + + this.clock = dt; + }; + + /** + * Gets the next scheduled item to be executed. + * @returns {ScheduledItem} The next scheduled item. + */ + VirtualTimeSchedulerPrototype.getNext = function () { + while (this.queue.length > 0) { + var next = this.queue.peek(); + if (next.isCancelled()) { + this.queue.dequeue(); + } else { + return next; + } + } + return null; + }; + + /** + * Schedules an action to be executed at dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Absolute time at which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) { + var self = this; + + function run(scheduler, state1) { + self.queue.remove(si); + return action(scheduler, state1); + } + + var si = new ScheduledItem(this, state, run, dueTime, this.comparer); + this.queue.enqueue(si); + + return si.disposable; + }; + + return VirtualTimeScheduler; + }(Scheduler)); + + /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */ + Rx.HistoricalScheduler = (function (__super__) { + inherits(HistoricalScheduler, __super__); + + /** + * Creates a new historical scheduler with the specified initial clock value. + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function HistoricalScheduler(initialClock, comparer) { + var clock = initialClock == null ? 0 : initialClock; + var cmp = comparer || defaultSubComparer; + __super__.call(this, clock, cmp); + } + + var HistoricalSchedulerProto = HistoricalScheduler.prototype; + + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + HistoricalSchedulerProto.add = function (absolute, relative) { + return absolute + relative; + }; + + HistoricalSchedulerProto.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @memberOf HistoricalScheduler + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + HistoricalSchedulerProto.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + + return HistoricalScheduler; + }(Rx.VirtualTimeScheduler)); + +function OnNextPredicate(predicate) { + this.predicate = predicate; +} + +OnNextPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'N') { return false; } + return this.predicate(other.value); +}; + +function OnErrorPredicate(predicate) { + this.predicate = predicate; +} + +OnErrorPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'E') { return false; } + return this.predicate(other.error); +}; + +var ReactiveTest = Rx.ReactiveTest = { + /** Default virtual time used for creation of observable sequences in unit tests. */ + created: 100, + /** Default virtual time used to subscribe to observable sequences in unit tests. */ + subscribed: 200, + /** Default virtual time used to dispose subscriptions in unit tests. */ + disposed: 1000, + + /** + * Factory method for an OnNext notification record at a given time with a given value or a predicate function. + * + * 1 - ReactiveTest.onNext(200, 42); + * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); + * + * @param ticks Recorded virtual time the OnNext notification occurs. + * @param value Recorded value stored in the OnNext notification or a predicate. + * @return Recorded OnNext notification. + */ + onNext: function (ticks, value) { + return typeof value === 'function' ? + new Recorded(ticks, new OnNextPredicate(value)) : + new Recorded(ticks, Notification.createOnNext(value)); + }, + /** + * Factory method for an OnError notification record at a given time with a given error. + * + * 1 - ReactiveTest.onNext(200, new Error('error')); + * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); + * + * @param ticks Recorded virtual time the OnError notification occurs. + * @param exception Recorded exception stored in the OnError notification. + * @return Recorded OnError notification. + */ + onError: function (ticks, error) { + return typeof error === 'function' ? + new Recorded(ticks, new OnErrorPredicate(error)) : + new Recorded(ticks, Notification.createOnError(error)); + }, + /** + * Factory method for an OnCompleted notification record at a given time. + * + * @param ticks Recorded virtual time the OnCompleted notification occurs. + * @return Recorded OnCompleted notification. + */ + onCompleted: function (ticks) { + return new Recorded(ticks, Notification.createOnCompleted()); + }, + /** + * Factory method for a subscription record based on a given subscription and disposal time. + * + * @param start Virtual time indicating when the subscription was created. + * @param end Virtual time indicating when the subscription was disposed. + * @return Subscription object. + */ + subscribe: function (start, end) { + return new Subscription(start, end); + } +}; + + /** + * Creates a new object recording the production of the specified value at the given virtual time. + * + * @constructor + * @param {Number} time Virtual time the value was produced on. + * @param {Mixed} value Value that was produced. + * @param {Function} comparer An optional comparer. + */ + var Recorded = Rx.Recorded = function (time, value, comparer) { + this.time = time; + this.value = value; + this.comparer = comparer || defaultComparer; + }; + + /** + * Checks whether the given recorded object is equal to the current instance. + * + * @param {Recorded} other Recorded object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Recorded.prototype.equals = function (other) { + return this.time === other.time && this.comparer(this.value, other.value); + }; + + /** + * Returns a string representation of the current Recorded value. + * + * @returns {String} String representation of the current Recorded value. + */ + Recorded.prototype.toString = function () { + return this.value.toString() + '@' + this.time; + }; + + /** + * Creates a new subscription object with the given virtual subscription and unsubscription time. + * + * @constructor + * @param {Number} subscribe Virtual time at which the subscription occurred. + * @param {Number} unsubscribe Virtual time at which the unsubscription occurred. + */ + var Subscription = Rx.Subscription = function (start, end) { + this.subscribe = start; + this.unsubscribe = end || Number.MAX_VALUE; + }; + + /** + * Checks whether the given subscription is equal to the current instance. + * @param other Subscription object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Subscription.prototype.equals = function (other) { + return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; + }; + + /** + * Returns a string representation of the current Subscription value. + * @returns {String} String representation of the current Subscription value. + */ + Subscription.prototype.toString = function () { + return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')'; + }; + + var MockDisposable = Rx.MockDisposable = function (scheduler) { + this.scheduler = scheduler; + this.disposes = []; + this.disposes.push(this.scheduler.clock); + }; + + MockDisposable.prototype.dispose = function () { + this.disposes.push(this.scheduler.clock); + }; + + var MockObserver = (function (__super__) { + inherits(MockObserver, __super__); + + function MockObserver(scheduler) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = []; + } + + var MockObserverPrototype = MockObserver.prototype; + + MockObserverPrototype.onNext = function (value) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value))); + }; + + MockObserverPrototype.onError = function (e) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e))); + }; + + MockObserverPrototype.onCompleted = function () { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted())); + }; + + return MockObserver; + })(Observer); + + function MockPromise(scheduler, messages) { + var self = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + var message = this.messages[i], + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = self.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; + }); + })(notification); + } + } + + MockPromise.prototype.then = function (onResolved, onRejected) { + var self = this; + + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + + var newPromise; + + var observer = Rx.Observer.create( + function (x) { + var retValue = onResolved(x); + if (retValue && typeof retValue.then === 'function') { + newPromise = retValue; + } else { + var ticks = self.scheduler.clock; + newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]); + } + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + }, + function (err) { + onRejected(err); + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + } + ); + this.observers.push(observer); + + return newPromise || new MockPromise(this.scheduler, this.messages); + }; + + var HotObservable = (function (__super__) { + inherits(HotObservable, __super__); + + function HotObservable(scheduler, messages) { + __super__.call(this); + var message, notification, observable = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = observable.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; + }); + })(notification); + } + } + + HotObservable.prototype._subscribe = function (o) { + var observable = this; + this.observers.push(o); + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + return disposableCreate(function () { + var idx = observable.observers.indexOf(o); + observable.observers.splice(idx, 1); + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + }); + }; + + return HotObservable; + })(Observable); + + var ColdObservable = (function (__super__) { + inherits(ColdObservable, __super__); + + function ColdObservable(scheduler, messages) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + } + + ColdObservable.prototype._subscribe = function (o) { + var message, notification, observable = this; + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + var d = new CompositeDisposable(); + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + d.add(observable.scheduler.scheduleRelative(null, message.time, function () { + innerNotification.accept(o); + return disposableEmpty; + })); + })(notification); + } + return disposableCreate(function () { + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + d.dispose(); + }); + }; + + return ColdObservable; + })(Observable); + + /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ + Rx.TestScheduler = (function (__super__) { + inherits(TestScheduler, __super__); + + function baseComparer(x, y) { + return x > y ? 1 : (x < y ? -1 : 0); + } + + function TestScheduler() { + __super__.call(this, 0, baseComparer); + } + + /** + * Schedules an action to be executed at the specified virtual time. + * + * @param state State passed to the action to be executed. + * @param dueTime Absolute virtual time at which to execute the action. + * @param action Action to be executed. + * @return Disposable object used to cancel the scheduled action (best effort). + */ + TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) { + dueTime <= this.clock && (dueTime = this.clock + 1); + return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action); + }; + /** + * Adds a relative virtual time to an absolute virtual time value. + * + * @param absolute Absolute virtual time value. + * @param relative Relative virtual time value to add. + * @return Resulting absolute virtual time sum value. + */ + TestScheduler.prototype.add = function (absolute, relative) { + return absolute + relative; + }; + /** + * Converts the absolute virtual time value to a DateTimeOffset value. + * + * @param absolute Absolute virtual time value to convert. + * @return Corresponding DateTimeOffset value. + */ + TestScheduler.prototype.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + /** + * Converts the TimeSpan value to a relative virtual time value. + * + * @param timeSpan TimeSpan value to convert. + * @return Corresponding relative virtual time value. + */ + TestScheduler.prototype.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + /** + * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. + * + * @param create Factory method to create an observable sequence. + * @param created Virtual time at which to invoke the factory to create an observable sequence. + * @param subscribed Virtual time at which to subscribe to the created observable sequence. + * @param disposed Virtual time at which to dispose the subscription. + * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. + */ + TestScheduler.prototype.startScheduler = function (createFn, settings) { + settings || (settings = {}); + settings.created == null && (settings.created = ReactiveTest.created); + settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed); + settings.disposed == null && (settings.disposed = ReactiveTest.disposed); + + var observer = this.createObserver(), source, subscription; + + this.scheduleAbsolute(null, settings.created, function () { + source = createFn(); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.subscribed, function () { + subscription = source.subscribe(observer); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.disposed, function () { + subscription.dispose(); + return disposableEmpty; + }); + + this.start(); + + return observer; + }; + + /** + * Creates a hot observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified absolute virtual times. + * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createHotObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new HotObservable(this, args); + }; + + /** + * Creates a cold observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. + * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createColdObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new ColdObservable(this, args); + }; + + /** + * Creates a resolved promise with the given value and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} value The value to yield at the given tick. + * @returns {MockPromise} A mock Promise which fulfills with the given value. + */ + TestScheduler.prototype.createResolvedPromise = function (ticks, value) { + return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]); + }; + + /** + * Creates a rejected promise with the given reason and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} reason The reason for rejection to yield at the given tick. + * @returns {MockPromise} A mock Promise which rejects with the given reason. + */ + TestScheduler.prototype.createRejectedPromise = function (ticks, reason) { + return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]); + }; + + /** + * Creates an observer that records received notification messages and timestamps those. + * @return Observer that can be used to assert the timing of received notifications. + */ + TestScheduler.prototype.createObserver = function () { + return new MockObserver(this); + }; + + return TestScheduler; + })(VirtualTimeScheduler); + + var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) { + inherits(AnonymousObservable, __super__); + + // Fix subscriber to check for undefined or function returned to decorate as Disposable + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.__subscribe).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function AnonymousObservable(subscribe, parent) { + this.source = parent; + this.__subscribe = subscribe; + __super__.call(this); + } + + AnonymousObservable.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + return AnonymousObservable; + + }(Observable)); + + var AutoDetachObserver = (function (__super__) { + inherits(AutoDetachObserver, __super__); + + function AutoDetachObserver(observer) { + __super__.call(this); + this.observer = observer; + this.m = new SingleAssignmentDisposable(); + } + + var AutoDetachObserverPrototype = AutoDetachObserver.prototype; + + AutoDetachObserverPrototype.next = function (value) { + var result = tryCatch(this.observer.onNext).call(this.observer, value); + if (result === errorObj) { + this.dispose(); + thrower(result.e); + } + }; + + AutoDetachObserverPrototype.error = function (err) { + var result = tryCatch(this.observer.onError).call(this.observer, err); + this.dispose(); + result === errorObj && thrower(result.e); + }; + + AutoDetachObserverPrototype.completed = function () { + var result = tryCatch(this.observer.onCompleted).call(this.observer); + this.dispose(); + result === errorObj && thrower(result.e); + }; + + AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); }; + AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); }; + + AutoDetachObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + this.m.dispose(); + }; + + return AutoDetachObserver; + }(AbstractObserver)); + + var UnderlyingObservable = (function (__super__) { + inherits(UnderlyingObservable, __super__); + function UnderlyingObservable(m, u) { + this._m = m; + this._u = u; + __super__.call(this); + } + + UnderlyingObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o)); + }; + + return UnderlyingObservable; + }(ObservableBase)); + + var GroupedObservable = (function (__super__) { + inherits(GroupedObservable, __super__); + function GroupedObservable(key, underlyingObservable, mergedDisposable) { + __super__.call(this); + this.key = key; + this.underlyingObservable = !mergedDisposable ? + underlyingObservable : + new UnderlyingObservable(mergedDisposable, underlyingObservable); + } + + GroupedObservable.prototype._subscribe = function (o) { + return this.underlyingObservable.subscribe(o); + }; + + return GroupedObservable; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed observers. + */ + var Subject = Rx.Subject = (function (__super__) { + inherits(Subject, __super__); + function Subject() { + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; + this.observers = []; + this.hasError = false; + } + + addProperties(Subject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + if (this.hasError) { + o.onError(this.error); + return disposableEmpty; + } + o.onCompleted(); + return disposableEmpty; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { return this.observers.length > 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + this.error = error; + this.hasError = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (!this.isStopped) { + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + /** + * Creates a subject from the specified observer and observable. + * @param {Observer} observer The observer used to send messages to the subject. + * @param {Observable} observable The observable used to subscribe to messages sent from the subject. + * @returns {Subject} Subject implemented using the given observer and observable. + */ + Subject.create = function (observer, observable) { + return new AnonymousSubject(observer, observable); + }; + + return Subject; + }(Observable)); + + /** + * Represents the result of an asynchronous operation. + * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers. + */ + var AsyncSubject = Rx.AsyncSubject = (function (__super__) { + inherits(AsyncSubject, __super__); + + /** + * Creates a subject that can only receive one value and that value is cached for all future observations. + * @constructor + */ + function AsyncSubject() { + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; + this.hasValue = false; + this.observers = []; + this.hasError = false; + } + + addProperties(AsyncSubject.prototype, Observer, { + _subscribe: function (o) { + checkDisposed(this); + + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + + if (this.hasError) { + o.onError(this.error); + } else if (this.hasValue) { + o.onNext(this.value); + o.onCompleted(); + } else { + o.onCompleted(); + } + + return disposableEmpty; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + checkDisposed(this); + return this.observers.length > 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any). + */ + onCompleted: function () { + var i, len; + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + var os = cloneArray(this.observers), len = os.length; + + if (this.hasValue) { + for (i = 0; i < len; i++) { + var o = os[i]; + o.onNext(this.value); + o.onCompleted(); + } + } else { + for (i = 0; i < len; i++) { + os[i].onCompleted(); + } + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the error. + * @param {Mixed} error The Error to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + } + }, + /** + * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers. + * @param {Mixed} value The value to store in the subject. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + this.hasValue = true; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.error = null; + this.value = null; + } + }); + + return AsyncSubject; + }(Observable)); + + var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) { + inherits(AnonymousSubject, __super__); + function AnonymousSubject(observer, observable) { + this.observer = observer; + this.observable = observable; + __super__.call(this); + } + + addProperties(AnonymousSubject.prototype, Observer.prototype, { + _subscribe: function (o) { + return this.observable.subscribe(o); + }, + onCompleted: function () { + this.observer.onCompleted(); + }, + onError: function (error) { + this.observer.onError(error); + }, + onNext: function (value) { + this.observer.onNext(value); + } + }); + + return AnonymousSubject; + }(Observable)); + + /** + * Used to pause and resume streams. + */ + Rx.Pauser = (function (__super__) { + inherits(Pauser, __super__); + function Pauser() { + __super__.call(this); + } + + /** + * Pauses the underlying sequence. + */ + Pauser.prototype.pause = function () { this.onNext(false); }; + + /** + * Resumes the underlying sequence. + */ + Pauser.prototype.resume = function () { this.onNext(true); }; + + return Pauser; + }(Subject)); + + if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { + root.Rx = Rx; + + define(function() { + return Rx; + }); + } else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { + (freeModule.exports = Rx).Rx = Rx; + } else { + freeExports.Rx = Rx; + } + } else { + // in a browser or Rhino + root.Rx = Rx; + } + + // All code before this point will be filtered from stack traces. + var rEndingLine = captureLine(); + +}.call(this)); + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"_process":2}],4:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ajax = require("./ajax"); + +var _ajax2 = _interopRequireDefault(_ajax); + +var AjaxAdapter = (function () { + function AjaxAdapter(options) { + _classCallCheck(this, AjaxAdapter); + + this._base = options && options.base || ""; + } + + _createClass(AjaxAdapter, [{ + key: "create", + value: function create(store, type, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: store.convert(type, partial) + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "POST", + responseType: "auto", + url: this._getUrl(type, null, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function (e) { + return store.find(e.response.data.type, e.response.data.id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "destroy", + value: function destroy(store, type, id, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "DELETE", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.remove(type, id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "load", + value: function load(store, type, id, options) { + + if (id && typeof id === "object") { + return this.load(store, type, null, id); + } + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var source = (0, _ajax2["default"])({ + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "GET", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function (e) { + return store.push(e.response); + }).map(function () { + return id ? store.find(type, id) : store.findAll(type); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "update", + value: function update(store, type, id, partial, options) { + + if (!store._types[type]) { + throw new Error("Unknown type '" + type + "'"); + } + + var data = store.convert(type, id, partial); + + var source = (0, _ajax2["default"])({ + body: JSON.stringify({ + data: data + }), + crossDomain: true, + headers: { + "Content-Type": "application/vnd.api+json" + }, + method: "PATCH", + responseType: "auto", + url: this._getUrl(type, id, options) + })["do"](function () { + return store.add(data); + }).map(function () { + return store.find(type, id); + }).publish(); + + source.connect(); + + return source; + } + }, { + key: "_getUrl", + value: function _getUrl(type, id, options) { + + var params = []; + var url = id ? this._base + "/" + type + "/" + id : this._base + "/" + type; + + if (options) { + + if (options.fields) { + Object.keys(options.fields).forEach(function (field) { + options["fields[" + field + "]"] = options.fields[field]; + }); + delete options.fields; + } + + params = Object.keys(options).map(function (key) { + return key + "=" + encodeURIComponent(options[key]); + }).sort(); + + if (params.length) { + url = url + "?" + params.join("&"); + } + } + + return url; + } + }]); + + return AjaxAdapter; +})(); + +exports["default"] = AjaxAdapter; +module.exports = exports["default"]; + +},{"./ajax":5}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +var _rx = require("rx"); + +var _rx2 = _interopRequireDefault(_rx); + +/** + * + * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc: + * + * https://github.com/Reactive-Extensions/RxJS-DOM + * + * The original source file can be viewed here: + * + * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js + * + * Licensed under the Apache License, Version 2.0: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Modifications from original: + * + * - extracted from "Rx.DOM" namespace + * - minor eslinter cleanup ("var" to "let" etc) + * - addition of "auto" responseType + * + */ + +var root = typeof window !== "undefined" && window || undefined; + +// Gets the proper XMLHttpRequest for support for older IE +function getXMLHttpRequest() { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else { + var progId = undefined; + try { + var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (var i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root.ActiveXObject(progId)) { + break; + } + } catch (e) {} + } + return new root.ActiveXObject(progId); + } catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} + +// Get CORS support even for older IE +function getCORSRequest() { + var xhr = new root.XMLHttpRequest(); + if ('withCredentials' in xhr) { + return xhr; + } else if (!!root.XDomainRequest) { + return new XDomainRequest(); + } else { + throw new Error('CORS is not supported by your browser'); + } +} + +function normalizeAjaxSuccessEvent(e, xhr, settings) { + var response = 'response' in xhr ? xhr.response : xhr.responseText; + if (settings.responseType === 'auto') { + try { + response = JSON.parse(response); + } catch (e) {} + } else { + response = settings.responseType === 'json' ? JSON.parse(response) : response; + } + return { + response: response, + status: xhr.status, + responseType: xhr.responseType, + xhr: xhr, + originalEvent: e + }; +} + +function normalizeAjaxErrorEvent(e, xhr, type) { + return { + type: type, + status: xhr.status, + xhr: xhr, + originalEvent: e + }; +} + +/** + * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL. + * + * @example + * source = ajax('/products'); + * source = ajax({ url: 'products', method: 'GET' }); + * + * @param {Object} settings Can be one of the following: + * + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - responseType: "text" (default), "json" or "auto" + * + * @returns {Observable} An observable sequence containing the XMLHttpRequest. +*/ + +exports["default"] = function (options) { + var settings = { + method: 'GET', + crossDomain: false, + async: true, + headers: {}, + responseType: 'text', + createXHR: function createXHR() { + return this.crossDomain ? getCORSRequest() : getXMLHttpRequest(); + }, + normalizeError: normalizeAjaxErrorEvent, + normalizeSuccess: normalizeAjaxSuccessEvent + }; + + if (typeof options === 'string') { + settings.url = options; + } else { + for (var prop in options) { + if (hasOwnProperty.call(options, prop)) { + settings[prop] = options[prop]; + } + } + } + + var normalizeError = settings.normalizeError; + var normalizeSuccess = settings.normalizeSuccess; + + if (!settings.crossDomain && !settings.headers['X-Requested-With']) { + settings.headers['X-Requested-With'] = 'XMLHttpRequest'; + } + settings.hasContent = settings.body !== undefined; + + return new _rx2["default"].AnonymousObservable(function (observer) { + var isDone = false; + var xhr; + + var processResponse = function processResponse(xhr, e) { + var status = xhr.status === 1223 ? 204 : xhr.status; + if (status >= 200 && status <= 300 || status === 0 || status === '') { + observer.onNext(normalizeSuccess(e, xhr, settings)); + observer.onCompleted(); + } else { + observer.onError(normalizeError(e, xhr, 'error')); + } + isDone = true; + }; + + try { + xhr = settings.createXHR();; + } catch (err) { + observer.onError(err); + } + + try { + if (settings.user) { + xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password); + } else { + xhr.open(settings.method, settings.url, settings.async); + } + + var headers = settings.headers; + for (var header in headers) { + if (hasOwnProperty.call(headers, header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + if (!!xhr.upload || !('withCredentials' in xhr) && !!root.XDomainRequest) { + xhr.onload = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onNext(e); + settings.progressObserver.onCompleted(); + } + processResponse(xhr, e); + }; + + if (settings.progressObserver) { + xhr.onprogress = function (e) { + settings.progressObserver.onNext(e); + }; + } + + xhr.onerror = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'error')); + isDone = true; + }; + + xhr.onabort = function (e) { + if (settings.progressObserver) { + settings.progressObserver.onError(e); + } + observer.onError(normalizeError(e, xhr, 'abort')); + isDone = true; + }; + } else { + + xhr.onreadystatechange = function (e) { + if (xhr.readyState === 4) { + processResponse(xhr, e); + } + }; + } + + xhr.send(settings.hasContent && settings.body || null); + } catch (e) { + observer.onError(e); + } + + return function () { + if (!isDone && xhr.readyState !== 4) { + xhr.abort(); + } + }; + }); +}; + +; +module.exports = exports["default"]; + +},{"rx":3}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +require("array.prototype.find"); + +var _rx = require("rx"); + +var _rx2 = _interopRequireDefault(_rx); + +var _ajaxAdapter = require("./ajax-adapter"); + +var _ajaxAdapter2 = _interopRequireDefault(_ajaxAdapter); + +var Store = (function () { + _createClass(Store, null, [{ + key: "attr", + + /** + * Creates a field definition for an attribute. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.default] - Default value for this field. + * @return {Object} - Field definition. + */ + value: function attr(name, options) { + if (name && typeof name === 'object') { + return Store.attr(null, name); + } else { + return { + type: "attr", + "default": options && options["default"], + deserialize: function deserialize(data, key) { + return data.attributes && data.attributes[name || key]; + }, + serialize: function serialize(resource, data, key) { + data.attributes[name || key] = resource[key]; + } + }; + } + } + + /** + * Creates a field definition for an has-one relationship. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.inverse] - Name of the inverse relationship. + * @return {Object} - Field definition. + */ + }, { + key: "hasOne", + value: function hasOne(name, options) { + if (name && typeof name === 'object') { + return Store.hasOne(null, name); + } else { + return { + type: "has-one", + inverse: options && options.inverse, + deserialize: function deserialize(data, key) { + name = name || key; + if (data.relationships && data.relationships[name]) { + if (data.relationships[name].data === null) { + return null; + } else if (data.relationships[name].data) { + return this.find(data.relationships[name].data.type, data.relationships[name].data.id); + } + } + }, + serialize: function serialize(resource, data, key) { + if (resource[key] === null) { + data.relationships[name || key] = null; + } else if (resource[key]) { + data.relationships[name || key] = { + data: { + type: resource[key].type, + id: resource[key].id + } + }; + } + } + }; + } + } + + /** + * Creates a field definition for an has-many relationship. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.inverse] - Name of the inverse relationship. + * @return {Object} - Field definition. + */ + }, { + key: "hasMany", + value: function hasMany(name, options) { + if (name && typeof name === 'object') { + return Store.hasMany(null, name); + } else { + return { + type: "has-many", + "default": [], + inverse: options && options.inverse, + deserialize: function deserialize(data, key) { + var _this = this; + + name = name || key; + if (data.relationships && data.relationships[name]) { + if (data.relationships[name].data === null) { + return []; + } else if (data.relationships[name].data) { + return data.relationships[name].data.map(function (c) { + return _this.find(c.type, c.id); + }); + } + } + }, + serialize: function serialize(resource, data, key) { + if (resource[key]) { + data.relationships[name || key] = { + data: resource[key].map(function (x) { + return { type: x.type, id: x.id }; + }) + }; + } + } + }; + } + } + }]); + + function Store(adapter) { + _classCallCheck(this, Store); + + this._adapter = adapter; + this._data = {}; + this._subject = new _rx2["default"].Subject(); + this._subscriptions = {}; + this._types = {}; + + /** + * An observable that will emit events when any resource in added, updated + * or removed. The object passed to listeners will be in this format: + * + *

    +     * { name: string, type: string, id: string, resource: object }
    +     * 

    + * + * You can learn more about RxJS observables at the GitHub repo: + * https://github.com/Reactive-Extensions/RxJS + * + * @type {Rx.Observable} + * @since 0.6.0 + * + * @example + * let store = new Store(); + * + * store.observable.filter(e => e.name === "added").subscribe(event => { + * console.log(event.name); // "added" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // Map {...} + * }); + * + * store.observable.filter(e => e.name === "updated").subscribe(event => { + * console.log(event.name); // "updated" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // Map {...} + * }); + * + * store.observable.filter(e => e.name === "removed").subscribe(event => { + * console.log(event.name); // "removed" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // null + * }); + */ + this.observable = this._subject.asObservable(); + } + + /** + * Add an individual resource to the store. This is used internally by the + * `push()` method. + * + * @since 0.1.0 + * @param {!Object} object - A JSON API Resource Object to be added. See: + http://jsonapi.org/format/#document-resource-objects + */ + + _createClass(Store, [{ + key: "add", + value: function add(object) { + var _this2 = this; + + if (object) { + if (object.type && object.id) { + (function () { + var name = _this2._data[object.type] && _this2._data[object.type][object.id] ? "updated" : "added"; + var resource = _this2.find(object.type, object.id); + var definition = _this2._types[object.type]; + Object.keys(definition).forEach(function (fieldName) { + if (fieldName[0] !== "_") { + _this2._addField(object, resource, definition, fieldName); + } + }); + _this2._subject.onNext({ + name: name, + type: object.type, + id: object.id, + resource: resource + }); + })(); + } else { + throw new TypeError("The data must have a type and id"); + } + } else { + throw new TypeError("You must provide data to add"); + } + } + + /** + * Converts the given partial into a JSON API compliant representation. + * + * @since 0.5.0 + * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property. + * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property. + * @param {!object} partial - The data to convert. + * @return {object} - JSON API version of the object. + */ + }, { + key: "convert", + value: function convert(type, id, partial) { + var _this3 = this; + + if (type && typeof type === "object") { + return this.convert(type.type, type.id, type); + } else if (id && typeof id === "object") { + return this.convert(type, id.id, id); + } else { + var _ret2 = (function () { + var data = { + type: type, + attributes: {}, + relationships: {} + }; + if (id) { + data.id = id; + } + var definition = _this3._types[data.type]; + Object.keys(definition).forEach(function (fieldName) { + if (fieldName[0] !== "_") { + definition[fieldName].serialize(partial, data, fieldName); + } + }); + return { + v: data + }; + })(); + + if (typeof _ret2 === "object") return _ret2.v; + } + } + + /** + * Attempts to create the resource through the adapter and adds it to the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!Object} partial - Data to create the resource with. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.create("product", { title: "A Book" }).subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "create", + value: function create(type, partial, options) { + if (this._adapter) { + return this._adapter.create(this, type, partial, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Defines a type of resource. + * + * @since 0.2.0 + * @param {!string|string[]} names - Name(s) of the resource. + * @param {!Object} definition - The resource's definition. + */ + }, { + key: "define", + value: function define(names, definition) { + var _this4 = this; + + names = names.constructor === Array ? names : [names]; + if (definition) { + definition._names = names; + names.forEach(function (name) { + if (!_this4._types[name]) { + _this4._types[name] = definition; + } else { + throw new Error("The type '" + name + "' has already been defined."); + } + }); + } else { + throw new Error("You must provide a definition for the type '" + names[0] + "'."); + } + } + + /** + * Attempts to delete the resource through the adapter and removes it from + * the store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.destroy("product", "1").subscribe(() => { + * console.log("Destroyed!"); + * }); + */ + }, { + key: "destroy", + value: function destroy(type, id, options) { + if (this._adapter) { + return this._adapter.destroy(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Finds a resource by type and id. + * + * NOTE: If the resource hasn't been loaded via an add() or push() call it + * will be automatically created when find is called. + * + * @since 0.1.0 + * @param {!string} type - Type of the resource to find. + * @param {!string} id - The id of the resource to find. + * @return {Object} - The resource. + */ + }, { + key: "find", + value: function find(type, id) { + var _this5 = this; + + if (type) { + var _ret3 = (function () { + var definition = _this5._types[type]; + if (definition) { + if (!_this5._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this5._data[t] = collection; + }); + })(); + } + if (id) { + if (!_this5._data[type][id]) { + _this5._data[type][id] = { + _dependents: [], + type: type, + id: id + }; + Object.keys(definition).forEach(function (key) { + if (key[0] !== "_") { + _this5._data[type][id][key] = definition[key]["default"]; + } + }); + } + return { + v: _this5._data[type][id] + }; + } else { + // throw new TypeError(`You must provide an id`); + /*eslint-disable*/ + console.warn(["Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + return { + v: _this5.findAll(type) + }; + } + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + })(); + + if (typeof _ret3 === "object") return _ret3.v; + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Finds all the resources of a given type. + * + * @since 0.7.0 + * @param {!string} type - Type of the resource to find. + * @return {Object[]} - An array of resources. + */ + }, { + key: "findAll", + value: function findAll(type) { + var _this6 = this; + + if (type) { + var definition = this._types[type]; + if (definition) { + if (!this._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this6._data[t] = collection; + }); + })(); + } + return Object.keys(this._data[type]).map(function (x) { + return _this6._data[type][x]; + }); + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Attempts to load the given resource through the adapter and adds it to the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.load("products", "1").subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "load", + value: function load(type, id, options) { + if (!id || typeof id === "object") { + /*eslint-disable*/ + console.warn(["Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + } + if (this._adapter) { + return this._adapter.load(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Attempts to load all the resources of the given type through the adapter + * and adds them to the store if successful. + * + * @since 0.7.0 + * @param {!string} type - Type of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.loadAll("products").subscribe((products) => { + * console.log(products); + * }); + */ + }, { + key: "loadAll", + value: function loadAll(type, options) { + if (this._adapter) { + return this._adapter.load(this, type, null, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Unregister an event listener that was registered with on(). + * + * @deprecated Use the store.observable property instead of this. + * @since 0.4.0 + * @param {string} event - Name of the event. + * @param {string} type - Name of resource to originally passed to on(). + * @param {string} [id] - ID of the resource to originally passed to on(). + * @param {function} callback - Function originally passed to on(). + */ + }, { + key: "off", + value: function off(event, type, id, callback) { + /*eslint-disable*/ + console.warn(["The `store.off()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ + if (event === "added" || event === "updated" || event === "removed") { + if (this._types[type]) { + if (id && ({}).toString.call(id) === '[object Function]') { + this.off.call(this, event, type, null, id, callback); + } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || "*"]) { + this._subscriptions[event][type][id || "*"].dispose(); + delete this._subscriptions[event][type][id || "*"]; + } + } else { + throw new Error("Unknown type '" + type + "'"); + } + } else { + throw new Error("Unknown event '" + event + "'"); + } + } + + /** + * Register an event listener: "added", "updated" or "removed". + * + * @deprecated Use the store.observable property instead of this. + * @since 0.4.0 + * @param {string} event - Name of the event. + * @param {string} type - Name of resource to watch. + * @param {string} [id] - ID of the resource to watch. + * @param {function} callback - Function to call when the event occurs. + * @param {Object} [context] - Context in which to call the callback. + */ + }, { + key: "on", + value: function on(event, type, id, callback, context) { + var _this7 = this; + + /*eslint-disable*/ + console.warn(["The `store.on()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ + if (event === "added" || event === "updated" || event === "removed") { + if (this._types[type]) { + if (id && ({}).toString.call(id) === '[object Function]') { + this.on.call(this, event, type, null, id, callback); + } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || "*"]) { + var subscription = this._subject.filter(function (e) { + return e.name === event; + }); + subscription = subscription.filter(function (e) { + return _this7._types[type]._names.indexOf(e.type) !== -1; + }); + if (id) { + subscription = subscription.filter(function (e) { + return e.id === id; + }); + } + subscription = subscription.map(function (e) { + return _this7.find(e.type, e.id); + }); + this._subscriptions[event] = this._subscriptions[event] || {}; + if (!this._subscriptions[event][type]) { + (function () { + var obj = {}; + _this7._types[type]._names.forEach(function (type) { + _this7._subscriptions[event][type] = obj; + }); + })(); + } + this._subscriptions[event][type][id || "*"] = subscription.subscribe(callback.bind(context)); + } + } else { + throw new Error("Unknown type '" + type + "'"); + } + } else { + throw new Error("Unknown event '" + event + "'"); + } + } + + /** + * Add a JSON API response to the store. This method can be used to handle a + * successful GET or POST response from the server. + * + * @since 0.1.0 + * @param {Object} root - Top Level Object to push. See: + http://jsonapi.org/format/#document-top-level + */ + }, { + key: "push", + value: function push(root) { + var _this8 = this; + + if (root.data.constructor === Array) { + root.data.forEach(function (x) { + return _this8.add(x); + }); + } else { + this.add(root.data); + } + if (root.included) { + root.included.forEach(function (x) { + return _this8.add(x); + }); + } + } + + /** + * Remove a resource or collection of resources from the store. + * + * @since 0.1.0 + * @param {!string} type - Type of the resource(s) to remove. + * @param {string} [id] - The id of the resource to remove. If omitted all + * resources of the type will be removed. + */ + }, { + key: "remove", + value: function remove(type, id) { + var _this9 = this; + + if (type) { + if (this._types[type]) { + if (id) { + var resource = this._data[type] && this._data[type][id]; + if (resource) { + this._remove(resource); + this._subject.onNext({ + name: "removed", + type: type, + id: id, + resource: null + }); + } + } else { + Object.keys(this._data[type]).forEach(function (id) { + return _this9.remove(type, id); + }); + } + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type to remove"); + } + } + + /** + * Attempts to update the resource through the adapter and updates it in the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {!Object} partial - Data to update the resource with. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.update("product", "1", { title: "foo" }).subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "update", + value: function update(type, id, partial, options) { + if (this._adapter) { + return this._adapter.update(this, type, id, partial, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + }, { + key: "_addField", + value: function _addField(object, resource, definition, fieldName) { + var _this10 = this; + + var field = definition[fieldName]; + var newValue = field.deserialize.call(this, object, fieldName); + if (typeof newValue !== "undefined") { + if (field.type === "has-one") { + if (resource[fieldName]) { + this._removeInverseRelationship(resource, fieldName, resource[fieldName], field); + } + if (newValue) { + this._addInverseRelationship(resource, fieldName, newValue, field); + } + } else if (field.type === "has-many") { + resource[fieldName].forEach(function (r) { + if (resource[fieldName].indexOf(r) !== -1) { + _this10._removeInverseRelationship(resource, fieldName, r, field); + } + }); + newValue.forEach(function (r) { + _this10._addInverseRelationship(resource, fieldName, r, field); + }); + } + resource[fieldName] = newValue; + } + } + }, { + key: "_addInverseRelationship", + value: function _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) { + var targetDefinition = this._types[targetResource.type]; + var sourceDefinition = this._types[sourceResource.type]; + if (targetDefinition) { + var targetFieldName = [sourceField.inverse].concat(sourceDefinition._names).find(function (x) { + return targetDefinition[x]; + }); + var targetField = targetDefinition && targetDefinition[targetFieldName]; + targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName }); + if (targetField) { + if (targetField.type === "has-one") { + sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName }); + targetResource[targetFieldName] = sourceResource; + } else if (targetField.type === "has-many") { + sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName }); + if (targetResource[targetFieldName].indexOf(sourceResource) === -1) { + targetResource[targetFieldName].push(sourceResource); + } + } else if (targetField.type === "attr") { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is an attribute ('" + targetFieldName + "')"); + } + } else if (sourceField.inverse) { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is missing ('" + sourceField.inverse + "')"); + } + } + } + }, { + key: "_remove", + value: function _remove(resource) { + var _this11 = this; + + resource._dependents.forEach(function (dependent) { + var dependentResource = _this11._data[dependent.type][dependent.id]; + switch (_this11._types[dependent.type][dependent.fieldName].type) { + case "has-one": + { + dependentResource[dependent.fieldName] = null; + break; + } + case "has-many": + { + var index = dependentResource[dependent.fieldName].indexOf(resource); + if (index !== -1) { + dependentResource[dependent.fieldName].splice(index, 1); + } + break; + } + default: + { + break; + } + } + // TODO: This only needs to be run once for each dependent. + dependentResource._dependents = dependentResource._dependents.filter(function (d) { + return !(d.type === resource.type && d.id === resource.id); + }); + }); + delete this._data[resource.type][resource.id]; + } + }, { + key: "_removeInverseRelationship", + value: function _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) { + var targetDefinition = this._types[targetResource.type]; + var targetFieldName = sourceField.inverse || sourceResource.type; + var targetField = targetDefinition && targetDefinition[targetFieldName]; + targetResource._dependents = targetResource._dependents.filter(function (r) { + return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName); + }); + if (targetField) { + if (targetField.type === "has-one") { + sourceResource._dependents = sourceResource._dependents.filter(function (r) { + return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName); + }); + targetResource[targetFieldName] = null; + } else if (targetField.type === "has-many") { + sourceResource._dependents = sourceResource._dependents.filter(function (r) { + return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName); + }); + targetResource[targetFieldName] = targetResource[targetFieldName].filter(function (r) { + return r !== sourceResource; + }); + } else if (targetField.type === "attr") { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is an attribute ('" + targetFieldName + "')"); + } + } else if (sourceField.inverse) { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is missing ('" + sourceField.inverse + "')"); + } + } + }]); + + return Store; +})(); + +exports["default"] = Store; + +Store.Rx = _rx2["default"]; +Store.AjaxAdapter = _ajaxAdapter2["default"]; +module.exports = exports["default"]; + +},{"./ajax-adapter":4,"array.prototype.find":1,"rx":3}]},{},[6])(6) +}); +//# sourceMappingURL=store.dev.js.map diff --git a/releases/v0.7.0/store.dev.js.map b/releases/v0.7.0/store.dev.js.map new file mode 100644 index 0000000..eb4e609 --- /dev/null +++ b/releases/v0.7.0/store.dev.js.map @@ -0,0 +1,25 @@ +{ + "version": 3, + "sources": [ + "../node_modules/browserify/node_modules/browser-pack/_prelude.js", + "../node_modules/array.prototype.find/index.js", + "../node_modules/browserify/node_modules/process/browser.js", + "../node_modules/rx/dist/rx.all.js", + "../src/ajax-adapter.js", + "../src/ajax.js", + "../src/store.js" + ], + "names": [], + "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;oBCpuXiB,QAAQ;;;;IAEJ,WAAW;AAEnB,WAFQ,WAAW,CAElB,OAAO,EAAE;0BAFF,WAAW;;AAG5B,QAAI,CAAC,KAAK,GAAG,AAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAK,EAAE,CAAC;GAC9C;;eAJkB,WAAW;;WAMxB,gBAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;;AAEpC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,YAAI,EAAE,IAAI,CAAC,SAAS,CAAC;AACnB,cAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACnC,CAAC;AACF,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,MAAM;AACd,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;OACvC,CAAC,MAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;OAAA,CAAC,CAC/B,GAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;OAAA,CAAC,CAC9D,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEM,iBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAEhC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,QAAQ;AAChB,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC;eAAM,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;OAAA,CAAC,CAChC,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEG,cAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAE7B,UAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AAChC,eAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;OACzC;;AAED,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,MAAM,GAAG,uBAAK;AAChB,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,KAAK;AACb,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC,UAAA,CAAC;eAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;OAAA,CAAC,CAC/B,GAAG,CAAC;eAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;OAAA,CAAC,CAC1D,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEK,gBAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;;AAExC,UAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvB,cAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;OAC3C;;AAED,UAAI,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;;AAE5C,UAAI,MAAM,GAAG,uBAAK;AAChB,YAAI,EAAE,IAAI,CAAC,SAAS,CAAC;AACnB,cAAI,EAAE,IAAI;SACX,CAAC;AACF,mBAAW,EAAE,IAAI;AACjB,eAAO,EAAE;AACP,wBAAc,EAAE,0BAA0B;SAC3C;AACD,cAAM,EAAE,OAAO;AACf,oBAAY,EAAE,MAAM;AACpB,WAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC;OACrC,CAAC,MAAG,CAAC;eAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;OAAA,CAAC,CACzB,GAAG,CAAC;eAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;OAAA,CAAC,CAC/B,OAAO,EAAE,CAAC;;AAEb,YAAM,CAAC,OAAO,EAAE,CAAC;;AAEjB,aAAO,MAAM,CAAC;KAEf;;;WAEM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;AAEzB,UAAI,MAAM,GAAG,EAAE,CAAC;AAChB,UAAI,GAAG,GAAG,EAAE,GAAM,IAAI,CAAC,KAAK,SAAI,IAAI,SAAI,EAAE,GAAQ,IAAI,CAAC,KAAK,SAAI,IAAI,AAAE,CAAC;;AAEvE,UAAI,OAAO,EAAE;;AAEX,YAAI,OAAO,CAAC,MAAM,EAAE;AAClB,gBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK,EAAI;AAC3C,mBAAO,aAAW,KAAK,OAAI,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;WACrD,CAAC,CAAC;AACH,iBAAO,OAAO,CAAC,MAAM,CAAC;SACvB;;AAED,cAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAA,GAAG,EAAI;AACvC,iBAAO,GAAG,GAAG,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;SACrD,CAAC,CAAC,IAAI,EAAE,CAAC;;AAEV,YAAI,MAAM,CAAC,MAAM,EAAE;AACjB,aAAG,GAAM,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,AAAE,CAAC;SACpC;OAEF;;AAED,aAAO,GAAG,CAAC;KAEZ;;;SA3IkB,WAAW;;;qBAAX,WAAW;;;;;;;;;;;;kBCFjB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBnB,IAAI,IAAI,GAAG,AAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,aAAS,CAAC;;;AAG7D,SAAS,iBAAiB,GAAG;AAC3B,MAAI,IAAI,CAAC,cAAc,EAAE;AACvB,WAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;GAClC,MAAM;AACL,QAAI,MAAM,YAAA,CAAC;AACX,QAAI;AACF,UAAI,OAAO,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;AAC5E,WAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AACzB,YAAI;AACF,gBAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,cAAI,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;AAClC,kBAAM;WACP;SACF,CAAC,OAAM,CAAC,EAAE,EAAG;OACf;AACD,aAAO,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;KACvC,CAAC,OAAO,CAAC,EAAE;AACV,YAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;GACF;CACF;;;AAGD,SAAS,cAAc,GAAG;AACxB,MAAI,GAAG,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;AACpC,MAAI,iBAAiB,IAAI,GAAG,EAAE;AAC5B,WAAO,GAAG,CAAC;GACZ,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE;AAChC,WAAO,IAAI,cAAc,EAAE,CAAC;GAC7B,MAAM;AACL,UAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;GAC1D;CACF;;AAED,SAAS,yBAAyB,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE;AACnD,MAAI,QAAQ,GAAG,AAAC,UAAU,IAAI,GAAG,GAAI,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC;AACrE,MAAI,QAAQ,CAAC,YAAY,KAAK,MAAM,EAAE;AACpC,QAAI;AACF,cAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KACjC,CAAC,OAAO,CAAC,EAAE,EAAE;GACf,MAAM;AACL,YAAQ,GAAG,QAAQ,CAAC,YAAY,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;GAC/E;AACD,SAAO;AACL,YAAQ,EAAE,QAAQ;AAClB,UAAM,EAAE,GAAG,CAAC,MAAM;AAClB,gBAAY,EAAE,GAAG,CAAC,YAAY;AAC9B,OAAG,EAAE,GAAG;AACR,iBAAa,EAAE,CAAC;GACjB,CAAC;CACH;;AAED,SAAS,uBAAuB,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE;AAC7C,SAAO;AACL,QAAI,EAAE,IAAI;AACV,UAAM,EAAE,GAAG,CAAC,MAAM;AAClB,OAAG,EAAE,GAAG;AACR,iBAAa,EAAE,CAAC;GACjB,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;qBAuBc,UAAU,OAAO,EAAE;AAChC,MAAI,QAAQ,GAAG;AACb,UAAM,EAAE,KAAK;AACb,eAAW,EAAE,KAAK;AAClB,SAAK,EAAE,IAAI;AACX,WAAO,EAAE,EAAE;AACX,gBAAY,EAAE,MAAM;AACpB,aAAS,EAAE,qBAAU;AACnB,aAAO,IAAI,CAAC,WAAW,GAAG,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;KAClE;AACD,kBAAc,EAAE,uBAAuB;AACvC,oBAAgB,EAAE,yBAAyB;GAC5C,CAAC;;AAEF,MAAG,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC9B,YAAQ,CAAC,GAAG,GAAG,OAAO,CAAC;GACxB,MAAM;AACL,SAAI,IAAI,IAAI,IAAI,OAAO,EAAE;AACvB,UAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;AACrC,gBAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;OAChC;KACF;GACF;;AAED,MAAI,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;AAC7C,MAAI,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;;AAEjD,MAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AAClE,YAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,gBAAgB,CAAC;GACzD;AACD,UAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;;AAElD,SAAO,IAAI,gBAAG,mBAAmB,CAAC,UAAU,QAAQ,EAAE;AACpD,QAAI,MAAM,GAAG,KAAK,CAAC;AACnB,QAAI,GAAG,CAAC;;AAER,QAAI,eAAe,GAAG,SAAlB,eAAe,CAAY,GAAG,EAAE,CAAC,EAAC;AACpC,UAAI,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;AACpD,UAAI,AAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAK,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,EAAE,EAAE;AACrE,gBAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpD,gBAAQ,CAAC,WAAW,EAAE,CAAC;OACxB,MAAM;AACL,gBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;OACnD;AACD,YAAM,GAAG,IAAI,CAAC;KACf,CAAC;;AAEF,QAAI;AACF,SAAG,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;KAC7B,CAAC,OAAO,GAAG,EAAE;AACZ,cAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KACvB;;AAED,QAAI;AACF,UAAI,QAAQ,CAAC,IAAI,EAAE;AACjB,WAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;OAC3F,MAAM;AACL,WAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;OACzD;;AAED,UAAI,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAC/B,WAAK,IAAI,MAAM,IAAI,OAAO,EAAE;AAC1B,YAAI,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;AACxC,aAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;SAC/C;OACF;;AAED,UAAG,CAAC,CAAC,GAAG,CAAC,MAAM,IAAK,EAAE,iBAAiB,IAAI,GAAG,CAAA,AAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,AAAC,EAAE;AACzE,WAAG,CAAC,MAAM,GAAG,UAAS,CAAC,EAAE;AACvB,cAAG,QAAQ,CAAC,gBAAgB,EAAE;AAC5B,oBAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpC,oBAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC;WACzC;AACD,yBAAe,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;SACzB,CAAC;;AAEF,YAAG,QAAQ,CAAC,gBAAgB,EAAE;AAC5B,aAAG,CAAC,UAAU,GAAG,UAAS,CAAC,EAAE;AAC3B,oBAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;WACrC,CAAC;SACH;;AAED,WAAG,CAAC,OAAO,GAAG,UAAS,CAAC,EAAE;AACxB,cAAI,QAAQ,CAAC,gBAAgB,EAAE;AAC7B,oBAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;WACtC;AACD,kBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,gBAAM,GAAG,IAAI,CAAC;SACf,CAAC;;AAEF,WAAG,CAAC,OAAO,GAAG,UAAS,CAAC,EAAE;AACxB,cAAI,QAAQ,CAAC,gBAAgB,EAAE;AAC7B,oBAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;WACtC;AACD,kBAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,gBAAM,GAAG,IAAI,CAAC;SACf,CAAC;OACH,MAAM;;AAEL,WAAG,CAAC,kBAAkB,GAAG,UAAU,CAAC,EAAE;AACpC,cAAI,GAAG,CAAC,UAAU,KAAK,CAAC,EAAE;AACxB,2BAAe,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;WACzB;SACF,CAAC;OACH;;AAED,SAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;KACxD,CAAC,OAAO,CAAC,EAAE;AACV,cAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACrB;;AAED,WAAO,YAAY;AACjB,UAAI,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,EAAE;AAAE,WAAG,CAAC,KAAK,EAAE,CAAC;OAAE;KACtD,CAAC;GACH,CAAC,CAAC;CACJ;;AAAA,CAAC;;;;;;;;;;;;;;;;QChOK,sBAAsB;;kBACd,IAAI;;;;2BACK,gBAAgB;;;;IAEnB,KAAK;eAAL,KAAK;;;;;;;;;;;;WAWb,cAAC,IAAI,EAAE,OAAO,EAAE;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAC/B,MAAM;AACL,eAAO;AACL,cAAI,EAAE,MAAM;AACZ,qBAAS,OAAO,IAAI,OAAO,WAAQ;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,mBAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;WACxD;AACD,mBAAS,EAAE,mBAAU,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACxC,gBAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;WAC9C;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWY,gBAAC,IAAI,EAAE,OAAO,EAAE;AAC3B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OACjC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,SAAS;AACf,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,IAAI,CAAC;eACb,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;eACxF;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;AAC1B,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;aACxC,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACxB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE;AACJ,sBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI;AACxB,oBAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;iBACrB;eACF,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;;;;;;;;;;;WAWa,iBAAC,IAAI,EAAE,OAAO,EAAE;AAC5B,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;OAClC,MAAM;AACL,eAAO;AACL,cAAI,EAAE,UAAU;AAChB,qBAAS,EAAE;AACX,iBAAO,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;AACnC,qBAAW,EAAE,qBAAU,IAAI,EAAE,GAAG,EAAE;;;AAChC,gBAAI,GAAG,IAAI,IAAI,GAAG,CAAC;AACnB,gBAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;AAClD,kBAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;AAC1C,uBAAO,EAAE,CAAC;eACX,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACxC,uBAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,EAAK;AAC9C,yBAAO,MAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBAChC,CAAC,CAAC;eACJ;aACF;WACF;AACD,mBAAS,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;AACjD,gBAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACjB,kBAAI,CAAC,aAAa,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG;AAChC,oBAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,EAAI;AAC3B,yBAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;iBACnC,CAAC;eACH,CAAC;aACH;WACF;SACF,CAAC;OACH;KACF;;;AAEU,WAhHQ,KAAK,CAgHZ,OAAO,EAAE;0BAhHF,KAAK;;AAkHtB,QAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,QAAI,CAAC,KAAK,GAAG,EAAE,CAAC;AAChB,QAAI,CAAC,QAAQ,GAAG,IAAI,gBAAG,OAAO,EAAE,CAAC;AACjC,QAAI,CAAC,cAAc,GAAG,EAAE,CAAC;AACzB,QAAI,CAAC,MAAM,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,QAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;GAEhD;;;;;;;;;;;eAhKkB,KAAK;;WA0KrB,aAAC,MAAM,EAAE;;;AACV,UAAI,MAAM,EAAE;AACV,YAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,EAAE;;AAC5B,gBAAI,IAAI,GAAG,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,OAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC;AAC/F,gBAAI,QAAQ,GAAG,OAAK,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AACjD,gBAAI,UAAU,GAAG,OAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1C,kBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,kBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,uBAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;eACzD;aACF,CAAC,CAAC;AACH,mBAAK,QAAQ,CAAC,MAAM,CAAC;AACnB,kBAAI,EAAE,IAAI;AACV,kBAAI,EAAE,MAAM,CAAC,IAAI;AACjB,gBAAE,EAAE,MAAM,CAAC,EAAE;AACb,sBAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;;SACJ,MAAM;AACL,gBAAM,IAAI,SAAS,oCAAoC,CAAC;SACzD;OACF,MAAM;AACL,cAAM,IAAI,SAAS,gCAAgC,CAAC;OACrD;KACF;;;;;;;;;;;;;WAWM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;;;AACzB,UAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AACpC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;OAC/C,MAAM,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;AACvC,eAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;OACtC,MAAM;;AACL,cAAI,IAAI,GAAG;AACT,gBAAI,EAAE,IAAI;AACV,sBAAU,EAAE,EAAE;AACd,yBAAa,EAAE,EAAE;WAClB,CAAC;AACF,cAAI,EAAE,EAAE;AACN,gBAAI,CAAC,EAAE,GAAG,EAAE,CAAC;WACd;AACD,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AAC3C,gBAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AACxB,wBAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;aAC3D;WACF,CAAC,CAAC;AACH;eAAO,IAAI;YAAC;;;;OACb;KACF;;;;;;;;;;;;;;;;;;;;;WAmBK,gBAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;AAC7B,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;OAC3D,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;WASK,gBAAC,KAAK,EAAE,UAAU,EAAE;;;AACxB,WAAK,GAAG,AAAC,KAAK,CAAC,WAAW,KAAK,KAAK,GAAI,KAAK,GAAG,CAAE,KAAK,CAAE,CAAC;AAC1D,UAAI,UAAU,EAAE;AACd,kBAAU,CAAC,MAAM,GAAG,KAAK,CAAC;AAC1B,aAAK,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACpB,cAAI,CAAC,OAAK,MAAM,CAAC,IAAI,CAAC,EAAE;AACtB,mBAAK,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;WAChC,MAAM;AACL,kBAAM,IAAI,KAAK,gBAAc,IAAI,iCAA8B,CAAC;WACjE;SACF,CAAC,CAAC;OACJ,MAAM;AACL,cAAM,IAAI,KAAK,kDAAgD,KAAK,CAAC,CAAC,CAAC,QAAK,CAAC;OAC9E;KACF;;;;;;;;;;;;;;;;;;;;;WAmBM,iBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;AACzB,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;OACvD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;;WAaG,cAAC,IAAI,EAAE,EAAE,EAAE;;;AACb,UAAI,IAAI,EAAE;;AACR,cAAI,UAAU,GAAG,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,cAAI,UAAU,EAAE;AACd,gBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,EAAE;;AACrB,oBAAI,UAAU,GAAG,EAAE,CAAC;AACpB,0BAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;yBAAI,OAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU;iBAAA,CAAC,CAAC;;aAC5D;AACD,gBAAI,EAAE,EAAE;AACN,kBAAI,CAAC,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE;AACzB,uBAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG;AACrB,6BAAW,EAAE,EAAE;AACf,sBAAI,EAAE,IAAI;AACV,oBAAE,EAAE,EAAE;iBACP,CAAC;AACF,sBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG,EAAI;AACrC,sBAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAClB,2BAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,WAAQ,CAAC;mBACrD;iBACF,CAAC,CAAC;eACJ;AACD;mBAAO,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAAC;aAC7B,MAAM;;;AAGL,qBAAO,CAAC,IAAI,CAAC,CACX,kHAAkH,EAClH,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd;mBAAO,OAAK,OAAO,CAAC,IAAI,CAAC;gBAAC;aAC3B;WACF,MAAM;AACL,kBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;WAC/C;;;;OACF,MAAM;AACL,cAAM,IAAI,SAAS,2BAA2B,CAAC;OAChD;KACF;;;;;;;;;;;WASM,iBAAC,IAAI,EAAE;;;AACZ,UAAI,IAAI,EAAE;AACR,YAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,YAAI,UAAU,EAAE;AACd,cAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;;AACrB,kBAAI,UAAU,GAAG,EAAE,CAAC;AACpB,wBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,CAAC;uBAAI,OAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU;eAAA,CAAC,CAAC;;WAC5D;AACD,iBAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC;mBAAI,OAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;WAAA,CAAC,CAAC;SACpE,MAAM;AACL,gBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;SAC/C;OACF,MAAM;AACL,cAAM,IAAI,SAAS,2BAA2B,CAAC;OAChD;KACF;;;;;;;;;;;;;;;;;;;;;WAmBG,cAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE;AACtB,UAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;;AAEjC,eAAO,CAAC,IAAI,CAAC,CACX,kHAAkH,EAClH,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;OAEf;AACD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;OACpD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;;;;;;;WAkBM,iBAAC,IAAI,EAAE,OAAO,EAAE;AACrB,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;OACtD,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;;;;;;;;;;;;WAYE,aAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE;;AAE7B,aAAO,CAAC,IAAI,CAAC,CACX,+EAA+E,EAC/E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACtD,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AACxH,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AACtD,mBAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;WACpD;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;;;;WAaC,YAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE;;;;AAErC,aAAO,CAAC,IAAI,CAAC,CACX,8EAA8E,EAC9E,uFAAuF,CACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEd,UAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;AACnE,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,IAAI,CAAC,GAAE,CAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,mBAAmB,EAAE;AACxD,gBAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;WACrD,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE;AAC3H,gBAAI,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,CAAC,CAAC,IAAI,KAAK,KAAK;aAAA,CAAC,CAAC;AAC/D,wBAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;qBAAI,OAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAAA,CAAC,CAAC;AACzF,gBAAI,EAAE,EAAE;AACN,0BAAY,GAAG,YAAY,CAAC,MAAM,CAAC,UAAA,CAAC;uBAAI,CAAC,CAAC,EAAE,KAAK,EAAE;eAAA,CAAC,CAAC;aACtD;AACD,wBAAY,GAAG,YAAY,CAAC,GAAG,CAAC,UAAA,CAAC;qBAAI,OAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAAA,CAAC,CAAC;AAC9D,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAC9D,gBAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE;;AACrC,oBAAI,GAAG,GAAG,EAAE,CAAC;AACb,uBAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,IAAI,EAAI;AACvC,yBAAK,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;iBACxC,CAAC,CAAC;;aACJ;AACD,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;WAC9F;SACF,MAAM;AACL,gBAAM,IAAI,KAAK,oBAAkB,IAAI,OAAI,CAAC;SAC3C;OACF,MAAM;AACL,cAAM,IAAI,KAAK,qBAAmB,KAAK,OAAI,CAAC;OAC7C;KACF;;;;;;;;;;;;WAUG,cAAC,IAAI,EAAE;;;AACT,UAAI,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;AACnC,YAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACrC,MAAM;AACL,YAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;OACrB;AACD,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,YAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,CAAC;iBAAI,OAAK,GAAG,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;OACzC;KACF;;;;;;;;;;;;WAUK,gBAAC,IAAI,EAAE,EAAE,EAAE;;;AACf,UAAI,IAAI,EAAE;AACR,YAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACrB,cAAI,EAAE,EAAE;AACN,gBAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AACxD,gBAAI,QAAQ,EAAE;AACZ,kBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvB,kBAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACnB,oBAAI,EAAE,SAAS;AACf,oBAAI,EAAE,IAAI;AACV,kBAAE,EAAE,EAAE;AACN,wBAAQ,EAAE,IAAI;eACf,CAAC,CAAC;aACJ;WACF,MAAM;AACL,kBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAA,EAAE;qBAAI,OAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;aAAA,CAAC,CAAC;WACpE;SACF,MAAM;AACL,gBAAM,IAAI,SAAS,oBAAkB,IAAI,OAAI,CAAC;SAC/C;OACF,MAAM;AACL,cAAM,IAAI,SAAS,qCAAqC,CAAC;OAC1D;KACF;;;;;;;;;;;;;;;;;;;;;;WAoBK,gBAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;AACjC,UAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,eAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;OAC/D,MAAM;AACL,cAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;OACnH;KACF;;;WAEQ,mBAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE;;;AACjD,UAAI,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAClC,UAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/D,UAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,YAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;AAC5B,cAAI,QAAQ,CAAC,SAAS,CAAC,EAAE;AACvB,gBAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;WAClF;AACD,cAAI,QAAQ,EAAE;AACZ,gBAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;WACpE;SACF,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;AACpC,kBAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AAC/B,gBAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;AACzC,sBAAK,0BAA0B,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aAChE;WACF,CAAC,CAAC;AACH,kBAAQ,CAAC,OAAO,CAAC,UAAA,CAAC,EAAI;AACpB,oBAAK,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;WAC7D,CAAC,CAAC;SACJ;AACD,gBAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;OAChC;KACF;;;WAEsB,iCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACpF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,gBAAgB,EAAE;AACpB,YAAI,eAAe,GAAG,CAAE,WAAW,CAAC,OAAO,CAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC;iBAAI,gBAAgB,CAAC,CAAC,CAAC;SAAA,CAAC,CAAC;AAC7G,YAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,sBAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,YAAI,WAAW,EAAE;AACf,cAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,0BAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC;WAClD,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,0BAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;AAClH,gBAAI,cAAc,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;AAClE,4BAAc,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aACtD;WACF,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,kBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;WACjH;SACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,gBAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;SAChH;OACF;KACF;;;WAEM,iBAAC,QAAQ,EAAE;;;AAChB,cAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,UAAA,SAAS,EAAI;AACxC,YAAI,iBAAiB,GAAG,QAAK,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACjE,gBAAQ,QAAK,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI;AAC3D,eAAK,SAAS;AAAE;AACd,+BAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;AAC9C,oBAAM;aACP;AAAA,AACD,eAAK,UAAU;AAAE;AACf,kBAAI,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrE,kBAAI,KAAK,KAAK,CAAC,CAAC,EAAE;AAChB,iCAAiB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;eACzD;AACD,oBAAM;aACP;AAAA,AACD;AAAS;AACP,oBAAM;aACP;AAAA,SACF;;AAED,yBAAiB,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AACxE,iBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAA,AAAC,CAAC;SAC5D,CAAC,CAAC;OACJ,CAAC,CAAC;AACH,aAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;KAC/C;;;WAEyB,oCAAC,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE;AACvF,UAAI,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACxD,UAAI,eAAe,GAAG,WAAW,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC;AACjE,UAAI,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;AACxE,oBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,eAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;OAC3G,CAAC,CAAC;AACH,UAAI,WAAW,EAAE;AACf,YAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;AAClC,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;SACxC,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,EAAE;AAC1C,wBAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAClE,mBAAO,EAAE,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,eAAe,CAAA,AAAC,CAAC;WAC3G,CAAC,CAAC;AACH,wBAAc,CAAC,eAAe,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI;AAC5E,mBAAO,CAAC,KAAK,cAAc,CAAC;WAC7B,CAAC,CAAC;SACJ,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,EAAE;AACtC,gBAAM,IAAI,KAAK,wCAAsC,eAAe,4BAAuB,eAAe,QAAK,CAAC;SACjH;OACF,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;AAC9B,cAAM,IAAI,KAAK,wCAAsC,eAAe,uBAAkB,WAAW,CAAC,OAAO,QAAK,CAAC;OAChH;KACF;;;SArrBkB,KAAK;;;qBAAL,KAAK;;AAyrB1B,KAAK,CAAC,EAAE,kBAAK,CAAC;AACd,KAAK,CAAC,WAAW,2BAAc,CAAC", + "file": "generated.js", + "sourceRoot": "", + "sourcesContent": [ + "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o\n// For all details and docs: https://github.com/paulmillr/array.prototype.find\n// Fixes and tests supplied by Duncan Hall \n(function(globals){\n if (Array.prototype.find) return;\n\n var find = function(predicate) {\n var list = Object(this);\n var length = list.length < 0 ? 0 : list.length >>> 0; // ES.ToUint32;\n if (length === 0) return undefined;\n if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') {\n throw new TypeError('Array#find: predicate must be a function');\n }\n var thisArg = arguments[1];\n for (var i = 0, value; i < length; i++) {\n value = list[i];\n if (predicate.call(thisArg, value, i, list)) return value;\n }\n return undefined;\n };\n\n if (Object.defineProperty) {\n try {\n Object.defineProperty(Array.prototype, 'find', {\n value: find, configurable: true, enumerable: false, writable: true\n });\n } catch(e) {}\n }\n\n if (!Array.prototype.find) {\n Array.prototype.find = find;\n }\n})(this);\n", + "// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", + "// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\n;(function (undefined) {\n\n var objectTypes = {\n 'function': true,\n 'object': true\n };\n\n var\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeSelf = objectTypes[typeof self] && self.Object && self,\n freeWindow = objectTypes[typeof window] && window && window.Object && window,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;\n\n var root = root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;\n\n var Rx = {\n internals: {},\n config: {\n Promise: root.Promise\n },\n helpers: { }\n };\n\n // Defaults\n var noop = Rx.helpers.noop = function () { },\n identity = Rx.helpers.identity = function (x) { return x; },\n defaultNow = Rx.helpers.defaultNow = Date.now,\n defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },\n defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },\n defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },\n defaultError = Rx.helpers.defaultError = function (err) { throw err; },\n isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; },\n isFunction = Rx.helpers.isFunction = (function () {\n\n var isFn = function (value) {\n return typeof value == 'function' || false;\n }\n\n // fallback for older versions of Chrome and Safari\n if (isFn(/x/)) {\n isFn = function(value) {\n return typeof value == 'function' && toString.call(value) == '[object Function]';\n };\n }\n\n return isFn;\n }());\n\n function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}\n\n var errorObj = {e: {}};\n \n function tryCatcherGen(tryCatchTarget) {\n return function tryCatcher() {\n try {\n return tryCatchTarget.apply(this, arguments);\n } catch (e) {\n errorObj.e = e;\n return errorObj;\n }\n };\n }\n\n var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) {\n if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }\n return tryCatcherGen(fn);\n };\n\n function thrower(e) {\n throw e;\n }\n\n Rx.config.longStackSupport = false;\n var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })();\n hasStacks = !!stacks.e && !!stacks.e.stack;\n\n // All code after this point will be filtered from stack traces reported by RxJS\n var rStartingLine = captureLine(), rFileName;\n\n var STACK_JUMP_SEPARATOR = 'From previous event:';\n\n function makeStackTraceLong(error, observable) {\n // If possible, transform the error stack trace by removing Node and RxJS\n // cruft, then concatenating with the stack trace of `observable`.\n if (hasStacks &&\n observable.stack &&\n typeof error === 'object' &&\n error !== null &&\n error.stack &&\n error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1\n ) {\n var stacks = [];\n for (var o = observable; !!o; o = o.source) {\n if (o.stack) {\n stacks.unshift(o.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join('\\n' + STACK_JUMP_SEPARATOR + '\\n');\n error.stack = filterStackString(concatedStacks);\n }\n }\n\n function filterStackString(stackString) {\n var lines = stackString.split('\\n'), desiredLines = [];\n for (var i = 0, len = lines.length; i < len; i++) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join('\\n');\n }\n\n function isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n if (!fileNameAndLineNumber) {\n return false;\n }\n var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];\n\n return fileName === rFileName &&\n lineNumber >= rStartingLine &&\n lineNumber <= rEndingLine;\n }\n\n function isNodeFrame(stackLine) {\n return stackLine.indexOf('(module.js:') !== -1 ||\n stackLine.indexOf('(node.js:') !== -1;\n }\n\n function captureLine() {\n if (!hasStacks) { return; }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split('\\n');\n var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) { return; }\n\n rFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n }\n\n function getFileNameAndLineNumber(stackLine) {\n // Named functions: 'at functionName (filename:lineNumber:columnNumber)'\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }\n\n // Anonymous functions: 'at filename:lineNumber:columnNumber'\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }\n\n // Firefox style: 'function@filename:lineNumber or @filename:lineNumber'\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }\n }\n\n var EmptyError = Rx.EmptyError = function() {\n this.message = 'Sequence contains no elements.';\n this.name = 'EmptyError';\n Error.call(this);\n };\n EmptyError.prototype = Object.create(Error.prototype);\n\n var ObjectDisposedError = Rx.ObjectDisposedError = function() {\n this.message = 'Object has been disposed';\n this.name = 'ObjectDisposedError';\n Error.call(this);\n };\n ObjectDisposedError.prototype = Object.create(Error.prototype);\n\n var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {\n this.message = 'Argument out of range';\n this.name = 'ArgumentOutOfRangeError';\n Error.call(this);\n };\n ArgumentOutOfRangeError.prototype = Object.create(Error.prototype);\n\n var NotSupportedError = Rx.NotSupportedError = function (message) {\n this.message = message || 'This operation is not supported';\n this.name = 'NotSupportedError';\n Error.call(this);\n };\n NotSupportedError.prototype = Object.create(Error.prototype);\n\n var NotImplementedError = Rx.NotImplementedError = function (message) {\n this.message = message || 'This operation is not implemented';\n this.name = 'NotImplementedError';\n Error.call(this);\n };\n NotImplementedError.prototype = Object.create(Error.prototype);\n\n var notImplemented = Rx.helpers.notImplemented = function () {\n throw new NotImplementedError();\n };\n\n var notSupported = Rx.helpers.notSupported = function () {\n throw new NotSupportedError();\n };\n\n // Shim in iterator support\n var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||\n '_es6shim_iterator_';\n // Bug for mozilla version\n if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {\n $iterator$ = '@@iterator';\n }\n\n var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };\n\n var isIterable = Rx.helpers.isIterable = function (o) {\n return o[$iterator$] !== undefined;\n }\n\n var isArrayLike = Rx.helpers.isArrayLike = function (o) {\n return o && o.length !== undefined;\n }\n\n Rx.helpers.iterator = $iterator$;\n\n var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {\n if (typeof thisArg === 'undefined') { return func; }\n switch(argCount) {\n case 0:\n return function() {\n return func.call(thisArg)\n };\n case 1:\n return function(arg) {\n return func.call(thisArg, arg);\n }\n case 2:\n return function(value, index) {\n return func.call(thisArg, value, index);\n };\n case 3:\n return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n }\n\n return function() {\n return func.apply(thisArg, arguments);\n };\n };\n\n /** Used to determine if values are of the language type Object */\n var dontEnums = ['toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'],\n dontEnumsLength = dontEnums.length;\n\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n errorClass = '[object Error]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n var toString = Object.prototype.toString,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n supportsArgsClass = toString.call(arguments) == argsClass, // For less -1);\n }\n });\n }\n }\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\n var hasProp = {}.hasOwnProperty,\n slice = Array.prototype.slice;\n\n var inherits = Rx.internals.inherits = function (child, parent) {\n function __() { this.constructor = child; }\n __.prototype = parent.prototype;\n child.prototype = new __();\n };\n\n var addProperties = Rx.internals.addProperties = function (obj) {\n for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n for (var idx = 0, ln = sources.length; idx < ln; idx++) {\n var source = sources[idx];\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n };\n\n // Rx Utils\n var addRef = Rx.internals.addRef = function (xs, r) {\n return new AnonymousObservable(function (observer) {\n return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer));\n });\n };\n\n function arrayInitialize(count, factory) {\n var a = new Array(count);\n for (var i = 0; i < count; i++) {\n a[i] = factory();\n }\n return a;\n }\n\n function IndexedItem(id, value) {\n this.id = id;\n this.value = value;\n }\n\n IndexedItem.prototype.compareTo = function (other) {\n var c = this.value.compareTo(other.value);\n c === 0 && (c = this.id - other.id);\n return c;\n };\n\n var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {\n this.items = new Array(capacity);\n this.length = 0;\n };\n\n var priorityProto = PriorityQueue.prototype;\n priorityProto.isHigherPriority = function (left, right) {\n return this.items[left].compareTo(this.items[right]) < 0;\n };\n\n priorityProto.percolate = function (index) {\n if (index >= this.length || index < 0) { return; }\n var parent = index - 1 >> 1;\n if (parent < 0 || parent === index) { return; }\n if (this.isHigherPriority(index, parent)) {\n var temp = this.items[index];\n this.items[index] = this.items[parent];\n this.items[parent] = temp;\n this.percolate(parent);\n }\n };\n\n priorityProto.heapify = function (index) {\n +index || (index = 0);\n if (index >= this.length || index < 0) { return; }\n var left = 2 * index + 1,\n right = 2 * index + 2,\n first = index;\n if (left < this.length && this.isHigherPriority(left, first)) {\n first = left;\n }\n if (right < this.length && this.isHigherPriority(right, first)) {\n first = right;\n }\n if (first !== index) {\n var temp = this.items[index];\n this.items[index] = this.items[first];\n this.items[first] = temp;\n this.heapify(first);\n }\n };\n\n priorityProto.peek = function () { return this.items[0].value; };\n\n priorityProto.removeAt = function (index) {\n this.items[index] = this.items[--this.length];\n this.items[this.length] = undefined;\n this.heapify();\n };\n\n priorityProto.dequeue = function () {\n var result = this.peek();\n this.removeAt(0);\n return result;\n };\n\n priorityProto.enqueue = function (item) {\n var index = this.length++;\n this.items[index] = new IndexedItem(PriorityQueue.count++, item);\n this.percolate(index);\n };\n\n priorityProto.remove = function (item) {\n for (var i = 0; i < this.length; i++) {\n if (this.items[i].value === item) {\n this.removeAt(i);\n return true;\n }\n }\n return false;\n };\n PriorityQueue.count = 0;\n\n /**\n * Represents a group of disposable resources that are disposed together.\n * @constructor\n */\n var CompositeDisposable = Rx.CompositeDisposable = function () {\n var args = [], i, len;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n len = args.length;\n } else {\n len = arguments.length;\n args = new Array(len);\n for(i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n this.disposables = args;\n this.isDisposed = false;\n this.length = args.length;\n };\n\n var CompositeDisposablePrototype = CompositeDisposable.prototype;\n\n /**\n * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.\n * @param {Mixed} item Disposable to add.\n */\n CompositeDisposablePrototype.add = function (item) {\n if (this.isDisposed) {\n item.dispose();\n } else {\n this.disposables.push(item);\n this.length++;\n }\n };\n\n /**\n * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.\n * @param {Mixed} item Disposable to remove.\n * @returns {Boolean} true if found; false otherwise.\n */\n CompositeDisposablePrototype.remove = function (item) {\n var shouldDispose = false;\n if (!this.isDisposed) {\n var idx = this.disposables.indexOf(item);\n if (idx !== -1) {\n shouldDispose = true;\n this.disposables.splice(idx, 1);\n this.length--;\n item.dispose();\n }\n }\n return shouldDispose;\n };\n\n /**\n * Disposes all disposables in the group and removes them from the group.\n */\n CompositeDisposablePrototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var len = this.disposables.length, currentDisposables = new Array(len);\n for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }\n this.disposables = [];\n this.length = 0;\n\n for (i = 0; i < len; i++) {\n currentDisposables[i].dispose();\n }\n }\n };\n\n /**\n * Provides a set of static methods for creating Disposables.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n */\n var Disposable = Rx.Disposable = function (action) {\n this.isDisposed = false;\n this.action = action || noop;\n };\n\n /** Performs the task of cleaning up resources. */\n Disposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.action();\n this.isDisposed = true;\n }\n };\n\n /**\n * Creates a disposable object that invokes the specified action when disposed.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n * @return {Disposable} The disposable object that runs the given action upon disposal.\n */\n var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };\n\n /**\n * Gets the disposable that does nothing when disposed.\n */\n var disposableEmpty = Disposable.empty = { dispose: noop };\n\n /**\n * Validates whether the given object is a disposable\n * @param {Object} Object to test whether it has a dispose method\n * @returns {Boolean} true if a disposable object, else false.\n */\n var isDisposable = Disposable.isDisposable = function (d) {\n return d && isFunction(d.dispose);\n };\n\n var checkDisposed = Disposable.checkDisposed = function (disposable) {\n if (disposable.isDisposed) { throw new ObjectDisposedError(); }\n };\n\n var disposableFixup = Disposable._fixup = function (result) {\n return isDisposable(result) ? result : disposableEmpty;\n };\n\n // Single assignment\n var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SingleAssignmentDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SingleAssignmentDisposable.prototype.setDisposable = function (value) {\n if (this.current) { throw new Error('Disposable has already been assigned'); }\n var shouldDispose = this.isDisposed;\n !shouldDispose && (this.current = value);\n shouldDispose && value && value.dispose();\n };\n SingleAssignmentDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n old && old.dispose();\n }\n };\n\n // Multiple assignment disposable\n var SerialDisposable = Rx.SerialDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SerialDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SerialDisposable.prototype.setDisposable = function (value) {\n var shouldDispose = this.isDisposed;\n if (!shouldDispose) {\n var old = this.current;\n this.current = value;\n }\n old && old.dispose();\n shouldDispose && value && value.dispose();\n };\n SerialDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\n var BinaryDisposable = Rx.BinaryDisposable = function (first, second) {\n this._first = first;\n this._second = second;\n this.isDisposed = false;\n };\n\n BinaryDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old1 = this._first;\n this._first = null;\n old1 && old1.dispose();\n var old2 = this._second;\n this._second = null;\n old2 && old2.dispose();\n }\n };\n\n var NAryDisposable = Rx.NAryDisposable = function (disposables) {\n this._disposables = disposables;\n this.isDisposed = false;\n };\n\n NAryDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n for (var i = 0, len = this._disposables.length; i < len; i++) {\n this._disposables[i].dispose();\n }\n this._disposables.length = 0;\n }\n };\n\n /**\n * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.\n */\n var RefCountDisposable = Rx.RefCountDisposable = (function () {\n\n function InnerDisposable(disposable) {\n this.disposable = disposable;\n this.disposable.count++;\n this.isInnerDisposed = false;\n }\n\n InnerDisposable.prototype.dispose = function () {\n if (!this.disposable.isDisposed && !this.isInnerDisposed) {\n this.isInnerDisposed = true;\n this.disposable.count--;\n if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {\n this.disposable.isDisposed = true;\n this.disposable.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Initializes a new instance of the RefCountDisposable with the specified disposable.\n * @constructor\n * @param {Disposable} disposable Underlying disposable.\n */\n function RefCountDisposable(disposable) {\n this.underlyingDisposable = disposable;\n this.isDisposed = false;\n this.isPrimaryDisposed = false;\n this.count = 0;\n }\n\n /**\n * Disposes the underlying disposable only when all dependent disposables have been disposed\n */\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed && !this.isPrimaryDisposed) {\n this.isPrimaryDisposed = true;\n if (this.count === 0) {\n this.isDisposed = true;\n this.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.\n * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.\n */\n RefCountDisposable.prototype.getDisposable = function () {\n return this.isDisposed ? disposableEmpty : new InnerDisposable(this);\n };\n\n return RefCountDisposable;\n })();\n\n function ScheduledDisposable(scheduler, disposable) {\n this.scheduler = scheduler;\n this.disposable = disposable;\n this.isDisposed = false;\n }\n\n function scheduleItem(s, self) {\n if (!self.isDisposed) {\n self.isDisposed = true;\n self.disposable.dispose();\n }\n }\n\n ScheduledDisposable.prototype.dispose = function () {\n this.scheduler.schedule(this, scheduleItem);\n };\n\n var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {\n this.scheduler = scheduler;\n this.state = state;\n this.action = action;\n this.dueTime = dueTime;\n this.comparer = comparer || defaultSubComparer;\n this.disposable = new SingleAssignmentDisposable();\n }\n\n ScheduledItem.prototype.invoke = function () {\n this.disposable.setDisposable(this.invokeCore());\n };\n\n ScheduledItem.prototype.compareTo = function (other) {\n return this.comparer(this.dueTime, other.dueTime);\n };\n\n ScheduledItem.prototype.isCancelled = function () {\n return this.disposable.isDisposed;\n };\n\n ScheduledItem.prototype.invokeCore = function () {\n return disposableFixup(this.action(this.scheduler, this.state));\n };\n\n /** Provides a set of static properties to access commonly used schedulers. */\n var Scheduler = Rx.Scheduler = (function () {\n\n function Scheduler() { }\n\n /** Determines whether the given object is a scheduler */\n Scheduler.isScheduler = function (s) {\n return s instanceof Scheduler;\n };\n\n var schedulerProto = Scheduler.prototype;\n\n /**\n * Schedules an action to be executed.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.schedule = function (state, action) {\n throw new NotImplementedError();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleFuture = function (state, dueTime, action) {\n var dt = dueTime;\n dt instanceof Date && (dt = dt - this.now());\n dt = Scheduler.normalize(dt);\n\n if (dt === 0) { return this.schedule(state, action); }\n\n return this._scheduleFuture(state, dt, action);\n };\n\n schedulerProto._scheduleFuture = function (state, dueTime, action) {\n throw new NotImplementedError();\n };\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.now = defaultNow;\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.prototype.now = defaultNow;\n\n /**\n * Normalizes the specified TimeSpan value to a positive value.\n * @param {Number} timeSpan The time span value to normalize.\n * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0\n */\n Scheduler.normalize = function (timeSpan) {\n timeSpan < 0 && (timeSpan = 0);\n return timeSpan;\n };\n\n return Scheduler;\n }());\n\n var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;\n\n (function (schedulerProto) {\n\n function invokeRecImmediate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2) {\n var isAdded = false, isDone = false;\n\n var d = scheduler.schedule(state2, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n function invokeRecDate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n action(state, innerAction);\n return group;\n\n function innerAction(state2, dueTime1) {\n var isAdded = false, isDone = false;\n\n var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork);\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n\n function scheduleWork(_, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n action(state3, innerAction);\n return disposableEmpty;\n }\n }\n }\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursive = function (state, action) {\n return this.schedule([state, action], invokeRecImmediate);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative or absolute due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) {\n return this.scheduleFuture([state, action], dueTime, invokeRecDate);\n };\n\n }(Scheduler.prototype));\n\n (function (schedulerProto) {\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodic = function(state, period, action) {\n if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }\n period = normalizeTime(period);\n var s = state, id = root.setInterval(function () { s = action(s); }, period);\n return disposableCreate(function () { root.clearInterval(id); });\n };\n\n }(Scheduler.prototype));\n\n (function (schedulerProto) {\n /**\n * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.\n * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.\n * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.\n */\n schedulerProto.catchError = schedulerProto['catch'] = function (handler) {\n return new CatchScheduler(this, handler);\n };\n }(Scheduler.prototype));\n\n var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {\n function tick(command, recurse) {\n recurse(0, this._period);\n try {\n this._state = this._action(this._state);\n } catch (e) {\n this._cancel.dispose();\n throw e;\n }\n }\n\n function SchedulePeriodicRecursive(scheduler, state, period, action) {\n this._scheduler = scheduler;\n this._state = state;\n this._period = period;\n this._action = action;\n }\n\n SchedulePeriodicRecursive.prototype.start = function () {\n var d = new SingleAssignmentDisposable();\n this._cancel = d;\n d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this)));\n\n return d;\n };\n\n return SchedulePeriodicRecursive;\n }());\n\n /** Gets a scheduler that schedules work immediately on the current thread. */\n var ImmediateScheduler = (function (__super__) {\n inherits(ImmediateScheduler, __super__);\n function ImmediateScheduler() {\n __super__.call(this);\n }\n\n ImmediateScheduler.prototype.schedule = function (state, action) {\n return disposableFixup(action(this, state));\n };\n\n return ImmediateScheduler;\n }(Scheduler));\n\n var immediateScheduler = Scheduler.immediate = new ImmediateScheduler();\n\n /**\n * Gets a scheduler that schedules work as soon as possible on the current thread.\n */\n var CurrentThreadScheduler = (function (__super__) {\n var queue;\n\n function runTrampoline () {\n while (queue.length > 0) {\n var item = queue.dequeue();\n !item.isCancelled() && item.invoke();\n }\n }\n\n inherits(CurrentThreadScheduler, __super__);\n function CurrentThreadScheduler() {\n __super__.call(this);\n }\n\n CurrentThreadScheduler.prototype.schedule = function (state, action) {\n var si = new ScheduledItem(this, state, action, this.now());\n\n if (!queue) {\n queue = new PriorityQueue(4);\n queue.enqueue(si);\n\n var result = tryCatch(runTrampoline)();\n queue = null;\n if (result === errorObj) { thrower(result.e); }\n } else {\n queue.enqueue(si);\n }\n return si.disposable;\n };\n\n CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; };\n\n return CurrentThreadScheduler;\n }(Scheduler));\n\n var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler();\n\n var scheduleMethod, clearMethod;\n\n var localTimer = (function () {\n var localSetTimeout, localClearTimeout = noop;\n if (!!root.setTimeout) {\n localSetTimeout = root.setTimeout;\n localClearTimeout = root.clearTimeout;\n } else if (!!root.WScript) {\n localSetTimeout = function (fn, time) {\n root.WScript.Sleep(time);\n fn();\n };\n } else {\n throw new NotSupportedError();\n }\n\n return {\n setTimeout: localSetTimeout,\n clearTimeout: localClearTimeout\n };\n }());\n var localSetTimeout = localTimer.setTimeout,\n localClearTimeout = localTimer.clearTimeout;\n\n (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;\n\n clearMethod = function (handle) {\n delete tasksByHandle[handle];\n };\n\n function runTask(handle) {\n if (currentlyRunning) {\n localSetTimeout(function () { runTask(handle); }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n var result = tryCatch(task)();\n clearMethod(handle);\n currentlyRunning = false;\n if (result === errorObj) { thrower(result.e); }\n }\n }\n }\n\n var reNative = new RegExp('^' +\n String(toString)\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/toString| for [^\\]]+/g, '.*?') + '$'\n );\n\n var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&\n !reNative.test(setImmediate) && setImmediate;\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n if (isFunction(setImmediate)) {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n setImmediate(function () { runTask(id); });\n\n return id;\n };\n } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n process.nextTick(function () { runTask(id); });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent) {\n root.attachEvent('onmessage', onGlobalPostMessage);\n } else {\n root.onmessage = onGlobalPostMessage;\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (e) { runTask(e.data); };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n localSetTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n }());\n\n /**\n * Gets a scheduler that schedules work via a timed callback based upon platform.\n */\n var DefaultScheduler = (function (__super__) {\n inherits(DefaultScheduler, __super__);\n function DefaultScheduler() {\n __super__.call(this);\n }\n\n function DefaultSchedulerDisposable(id) {\n this._id = id;\n this.isDisposed = false;\n }\n\n DefaultSchedulerDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n localClearTimeout(this._id);\n }\n };\n\n DefaultScheduler.prototype.schedule = function (state, action) {\n var scheduler = this, disposable = new SingleAssignmentDisposable();\n var id = scheduleMethod(function () {\n !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state)));\n });\n return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id));\n };\n\n DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();\n if (dt === 0) { return scheduler.schedule(state, action); }\n var id = localSetTimeout(function () {\n !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state)));\n }, dt);\n return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id));\n };\n\n return DefaultScheduler;\n }(Scheduler));\n\n var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler();\n\n var CatchScheduler = (function (__super__) {\n inherits(CatchScheduler, __super__);\n\n function CatchScheduler(scheduler, handler) {\n this._scheduler = scheduler;\n this._handler = handler;\n this._recursiveOriginal = null;\n this._recursiveWrapper = null;\n __super__.call(this);\n }\n\n CatchScheduler.prototype.schedule = function (state, action) {\n return this._scheduler.schedule(state, this._wrap(action));\n };\n\n CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) {\n return this._scheduler.schedule(state, dueTime, this._wrap(action));\n };\n\n CatchScheduler.prototype.now = function () { return this._scheduler.now(); };\n\n CatchScheduler.prototype._clone = function (scheduler) {\n return new CatchScheduler(scheduler, this._handler);\n };\n\n CatchScheduler.prototype._wrap = function (action) {\n var parent = this;\n return function (self, state) {\n var res = tryCatch(action)(parent._getRecursiveWrapper(self), state);\n if (res === errorObj) {\n if (!parent._handler(res.e)) { thrower(res.e); }\n return disposableEmpty;\n }\n return disposableFixup(ret);\n };\n };\n\n CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {\n if (this._recursiveOriginal !== scheduler) {\n this._recursiveOriginal = scheduler;\n var wrapper = this._clone(scheduler);\n wrapper._recursiveOriginal = scheduler;\n wrapper._recursiveWrapper = wrapper;\n this._recursiveWrapper = wrapper;\n }\n return this._recursiveWrapper;\n };\n\n CatchScheduler.prototype.schedulePeriodic = function (state, period, action) {\n var self = this, failed = false, d = new SingleAssignmentDisposable();\n\n d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) {\n if (failed) { return null; }\n var res = tryCatch(action)(state1);\n if (res === errorObj) {\n failed = true;\n if (!self._handler(res.e)) { thrower(res.e); }\n d.dispose();\n return null;\n }\n return ret;\n }));\n\n return d;\n };\n\n return CatchScheduler;\n }(Scheduler));\n\n /**\n * Represents a notification to an observer.\n */\n var Notification = Rx.Notification = (function () {\n function Notification() {\n\n }\n\n Notification.prototype._accept = function (onNext, onError, onCompleted) {\n throw new NotImplementedError();\n };\n\n Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) {\n throw new NotImplementedError();\n };\n\n /**\n * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.\n *\n * @memberOf Notification\n * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..\n * @param {Function} onError Delegate to invoke for an OnError notification.\n * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.\n * @returns {Any} Result produced by the observation.\n */\n Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {\n return observerOrOnNext && typeof observerOrOnNext === 'object' ?\n this._acceptObservable(observerOrOnNext) :\n this._accept(observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Returns an observable sequence with a single notification.\n *\n * @memberOf Notifications\n * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.\n * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.\n */\n Notification.prototype.toObservable = function (scheduler) {\n var self = this;\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (o) {\n return scheduler.schedule(self, function (_, notification) {\n notification._acceptObservable(o);\n notification.kind === 'N' && o.onCompleted();\n });\n });\n };\n\n return Notification;\n })();\n\n var OnNextNotification = (function (__super__) {\n inherits(OnNextNotification, __super__);\n function OnNextNotification(value) {\n this.value = value;\n this.kind = 'N';\n }\n\n OnNextNotification.prototype._accept = function (onNext) {\n return onNext(this.value);\n };\n\n OnNextNotification.prototype._acceptObservable = function (o) {\n return o.onNext(this.value);\n };\n\n OnNextNotification.prototype.toString = function () {\n return 'OnNext(' + this.value + ')';\n };\n\n return OnNextNotification;\n }(Notification));\n\n var OnErrorNotification = (function (__super__) {\n inherits(OnErrorNotification, __super__);\n function OnErrorNotification(error) {\n this.error = error;\n this.kind = 'E';\n }\n\n OnErrorNotification.prototype._accept = function (onNext, onError) {\n return onError(this.error);\n };\n\n OnErrorNotification.prototype._acceptObservable = function (o) {\n return o.onError(this.error);\n };\n\n OnErrorNotification.prototype.toString = function () {\n return 'OnError(' + this.error + ')';\n };\n\n return OnErrorNotification;\n }(Notification));\n\n var OnCompletedNotification = (function (__super__) {\n inherits(OnCompletedNotification, __super__);\n function OnCompletedNotification() {\n this.kind = 'C';\n }\n\n OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) {\n return onCompleted();\n };\n\n OnCompletedNotification.prototype._acceptObservable = function (o) {\n return o.onCompleted();\n };\n\n OnCompletedNotification.prototype.toString = function () {\n return 'OnCompleted()';\n };\n\n return OnCompletedNotification;\n }(Notification));\n\n /**\n * Creates an object that represents an OnNext notification to an observer.\n * @param {Any} value The value contained in the notification.\n * @returns {Notification} The OnNext notification containing the value.\n */\n var notificationCreateOnNext = Notification.createOnNext = function (value) {\n return new OnNextNotification(value);\n };\n\n /**\n * Creates an object that represents an OnError notification to an observer.\n * @param {Any} error The exception contained in the notification.\n * @returns {Notification} The OnError notification containing the exception.\n */\n var notificationCreateOnError = Notification.createOnError = function (error) {\n return new OnErrorNotification(error);\n };\n\n /**\n * Creates an object that represents an OnCompleted notification to an observer.\n * @returns {Notification} The OnCompleted notification.\n */\n var notificationCreateOnCompleted = Notification.createOnCompleted = function () {\n return new OnCompletedNotification();\n };\n\n /**\n * Supports push-style iteration over an observable sequence.\n */\n var Observer = Rx.Observer = function () { };\n\n /**\n * Creates a notification callback from an observer.\n * @returns The action that forwards its input notification to the underlying observer.\n */\n Observer.prototype.toNotifier = function () {\n var observer = this;\n return function (n) { return n.accept(observer); };\n };\n\n /**\n * Hides the identity of an observer.\n * @returns An observer that hides the identity of the specified observer.\n */\n Observer.prototype.asObserver = function () {\n var self = this;\n return new AnonymousObserver(\n function (x) { self.onNext(x); },\n function (err) { self.onError(err); },\n function () { self.onCompleted(); });\n };\n\n /**\n * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.\n * If a violation is detected, an Error is thrown from the offending observer method call.\n * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.\n */\n Observer.prototype.checked = function () { return new CheckedObserver(this); };\n\n /**\n * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.\n * @param {Function} [onNext] Observer's OnNext action implementation.\n * @param {Function} [onError] Observer's OnError action implementation.\n * @param {Function} [onCompleted] Observer's OnCompleted action implementation.\n * @returns {Observer} The observer object implemented using the given actions.\n */\n var observerCreate = Observer.create = function (onNext, onError, onCompleted) {\n onNext || (onNext = noop);\n onError || (onError = defaultError);\n onCompleted || (onCompleted = noop);\n return new AnonymousObserver(onNext, onError, onCompleted);\n };\n\n /**\n * Creates an observer from a notification callback.\n * @param {Function} handler Action that handles a notification.\n * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.\n */\n Observer.fromNotifier = function (handler, thisArg) {\n var cb = bindCallback(handler, thisArg, 1);\n return new AnonymousObserver(function (x) {\n return cb(notificationCreateOnNext(x));\n }, function (e) {\n return cb(notificationCreateOnError(e));\n }, function () {\n return cb(notificationCreateOnCompleted());\n });\n };\n\n /**\n * Schedules the invocation of observer methods on the given scheduler.\n * @param {Scheduler} scheduler Scheduler to schedule observer messages on.\n * @returns {Observer} Observer whose messages are scheduled on the given scheduler.\n */\n Observer.prototype.notifyOn = function (scheduler) {\n return new ObserveOnObserver(scheduler, this);\n };\n\n Observer.prototype.makeSafe = function(disposable) {\n return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable);\n };\n\n /**\n * Abstract base class for implementations of the Observer class.\n * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.\n */\n var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {\n inherits(AbstractObserver, __super__);\n\n /**\n * Creates a new observer in a non-stopped state.\n */\n function AbstractObserver() {\n this.isStopped = false;\n }\n\n // Must be implemented by other observers\n AbstractObserver.prototype.next = notImplemented;\n AbstractObserver.prototype.error = notImplemented;\n AbstractObserver.prototype.completed = notImplemented;\n\n /**\n * Notifies the observer of a new element in the sequence.\n * @param {Any} value Next element in the sequence.\n */\n AbstractObserver.prototype.onNext = function (value) {\n !this.isStopped && this.next(value);\n };\n\n /**\n * Notifies the observer that an exception has occurred.\n * @param {Any} error The error that has occurred.\n */\n AbstractObserver.prototype.onError = function (error) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(error);\n }\n };\n\n /**\n * Notifies the observer of the end of the sequence.\n */\n AbstractObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.completed();\n }\n };\n\n /**\n * Disposes the observer, causing it to transition to the stopped state.\n */\n AbstractObserver.prototype.dispose = function () { this.isStopped = true; };\n\n AbstractObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(e);\n return true;\n }\n\n return false;\n };\n\n return AbstractObserver;\n }(Observer));\n\n /**\n * Class to create an Observer instance from delegate-based implementations of the on* methods.\n */\n var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {\n inherits(AnonymousObserver, __super__);\n\n /**\n * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.\n * @param {Any} onNext Observer's OnNext action implementation.\n * @param {Any} onError Observer's OnError action implementation.\n * @param {Any} onCompleted Observer's OnCompleted action implementation.\n */\n function AnonymousObserver(onNext, onError, onCompleted) {\n __super__.call(this);\n this._onNext = onNext;\n this._onError = onError;\n this._onCompleted = onCompleted;\n }\n\n /**\n * Calls the onNext action.\n * @param {Any} value Next element in the sequence.\n */\n AnonymousObserver.prototype.next = function (value) {\n this._onNext(value);\n };\n\n /**\n * Calls the onError action.\n * @param {Any} error The error that has occurred.\n */\n AnonymousObserver.prototype.error = function (error) {\n this._onError(error);\n };\n\n /**\n * Calls the onCompleted action.\n */\n AnonymousObserver.prototype.completed = function () {\n this._onCompleted();\n };\n\n return AnonymousObserver;\n }(AbstractObserver));\n\n var CheckedObserver = (function (__super__) {\n inherits(CheckedObserver, __super__);\n\n function CheckedObserver(observer) {\n __super__.call(this);\n this._observer = observer;\n this._state = 0; // 0 - idle, 1 - busy, 2 - done\n }\n\n var CheckedObserverPrototype = CheckedObserver.prototype;\n\n CheckedObserverPrototype.onNext = function (value) {\n this.checkAccess();\n var res = tryCatch(this._observer.onNext).call(this._observer, value);\n this._state = 0;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onError = function (err) {\n this.checkAccess();\n var res = tryCatch(this._observer.onError).call(this._observer, err);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onCompleted = function () {\n this.checkAccess();\n var res = tryCatch(this._observer.onCompleted).call(this._observer);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.checkAccess = function () {\n if (this._state === 1) { throw new Error('Re-entrancy detected'); }\n if (this._state === 2) { throw new Error('Observer completed'); }\n if (this._state === 0) { this._state = 1; }\n };\n\n return CheckedObserver;\n }(Observer));\n\n var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {\n inherits(ScheduledObserver, __super__);\n\n function ScheduledObserver(scheduler, observer) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.observer = observer;\n this.isAcquired = false;\n this.hasFaulted = false;\n this.queue = [];\n this.disposable = new SerialDisposable();\n }\n\n ScheduledObserver.prototype.next = function (value) {\n var self = this;\n this.queue.push(function () { self.observer.onNext(value); });\n };\n\n ScheduledObserver.prototype.error = function (e) {\n var self = this;\n this.queue.push(function () { self.observer.onError(e); });\n };\n\n ScheduledObserver.prototype.completed = function () {\n var self = this;\n this.queue.push(function () { self.observer.onCompleted(); });\n };\n\n ScheduledObserver.prototype.ensureActive = function () {\n var isOwner = false;\n if (!this.hasFaulted && this.queue.length > 0) {\n isOwner = !this.isAcquired;\n this.isAcquired = true;\n }\n if (isOwner) {\n this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) {\n var work;\n if (parent.queue.length > 0) {\n work = parent.queue.shift();\n } else {\n parent.isAcquired = false;\n return;\n }\n var res = tryCatch(work)();\n if (res === errorObj) {\n parent.queue = [];\n parent.hasFaulted = true;\n return thrower(res.e);\n }\n self(parent);\n }));\n }\n };\n\n ScheduledObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.disposable.dispose();\n };\n\n return ScheduledObserver;\n }(AbstractObserver));\n\n var ObserveOnObserver = (function (__super__) {\n inherits(ObserveOnObserver, __super__);\n\n function ObserveOnObserver(scheduler, observer, cancel) {\n __super__.call(this, scheduler, observer);\n this._cancel = cancel;\n }\n\n ObserveOnObserver.prototype.next = function (value) {\n __super__.prototype.next.call(this, value);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.error = function (e) {\n __super__.prototype.error.call(this, e);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.completed = function () {\n __super__.prototype.completed.call(this);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this._cancel && this._cancel.dispose();\n this._cancel = null;\n };\n\n return ObserveOnObserver;\n })(ScheduledObserver);\n\n var observableProto;\n\n /**\n * Represents a push-style collection.\n */\n var Observable = Rx.Observable = (function () {\n\n function makeSubscribe(self, subscribe) {\n return function (o) {\n var oldOnError = o.onError;\n o.onError = function (e) {\n makeStackTraceLong(e, self);\n oldOnError.call(o, e);\n };\n\n return subscribe.call(self, o);\n };\n }\n\n function Observable() {\n if (Rx.config.longStackSupport && hasStacks) {\n var oldSubscribe = this._subscribe;\n var e = tryCatch(thrower)(new Error()).e;\n this.stack = e.stack.substring(e.stack.indexOf('\\n') + 1);\n this._subscribe = makeSubscribe(this, oldSubscribe);\n }\n }\n\n observableProto = Observable.prototype;\n\n /**\n * Determines whether the given object is an Observable\n * @param {Any} An object to determine whether it is an Observable\n * @returns {Boolean} true if an Observable, else false.\n */\n Observable.isObservable = function (o) {\n return o && isFunction(o.subscribe);\n };\n\n /**\n * Subscribes an o to the observable sequence.\n * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.\n * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) {\n return this._subscribe(typeof oOrOnNext === 'object' ?\n oOrOnNext :\n observerCreate(oOrOnNext, onError, onCompleted));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onNext The function to invoke on each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnNext = function (onNext, thisArg) {\n return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));\n };\n\n /**\n * Subscribes to an exceptional condition in the sequence with an optional \"this\" argument.\n * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnError = function (onError, thisArg) {\n return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {\n return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));\n };\n\n return Observable;\n })();\n\n var ObservableBase = Rx.ObservableBase = (function (__super__) {\n inherits(ObservableBase, __super__);\n\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.subscribeCore).call(self, ado);\n if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function ObservableBase() {\n __super__.call(this);\n }\n\n ObservableBase.prototype._subscribe = function (o) {\n var ado = new AutoDetachObserver(o), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.schedule(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n };\n\n ObservableBase.prototype.subscribeCore = notImplemented;\n\n return ObservableBase;\n }(Observable));\n\nvar FlatMapObservable = Rx.FlatMapObservable = (function(__super__) {\n\n inherits(FlatMapObservable, __super__);\n\n function FlatMapObservable(source, selector, resultSelector, thisArg) {\n this.resultSelector = isFunction(resultSelector) ? resultSelector : null;\n this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3);\n this.source = source;\n __super__.call(this);\n }\n\n FlatMapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(observer, selector, resultSelector, source) {\n this.i = 0;\n this.selector = selector;\n this.resultSelector = resultSelector;\n this.source = source;\n this.o = observer;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype._wrapResult = function(result, x, i) {\n return this.resultSelector ?\n result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) :\n result;\n };\n\n InnerObserver.prototype.next = function(x) {\n var i = this.i++;\n var result = tryCatch(this.selector)(x, i, this.source);\n if (result === errorObj) { return this.o.onError(result.e); }\n\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result));\n this.o.onNext(this._wrapResult(result, x, i));\n };\n\n InnerObserver.prototype.error = function(e) { this.o.onError(e); };\n\n InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); };\n\n return FlatMapObservable;\n\n}(ObservableBase));\n\n var Enumerable = Rx.internals.Enumerable = function () { };\n\n function IsDisposedDisposable(state) {\n this._s = state;\n this.isDisposed = false;\n }\n\n IsDisposedDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._s.isDisposed = true;\n }\n };\n\n var ConcatEnumerableObservable = (function(__super__) {\n inherits(ConcatEnumerableObservable, __super__);\n function ConcatEnumerableObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n\n ConcatEnumerableObservable.prototype.subscribeCore = function (o) {\n var state = { isDisposed: false }, subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e)));\n });\n\n return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, s, e) {\n this._o = o;\n this._s = s;\n this._e = e;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); };\n InnerObserver.prototype.onError = function (e) { this._o.onError(e); };\n InnerObserver.prototype.onCompleted = function () { this._s(this._e); };\n\n return ConcatEnumerableObservable;\n }(ObservableBase));\n\n Enumerable.prototype.concat = function () {\n return new ConcatEnumerableObservable(this);\n };\n\n var CatchErrorObservable = (function(__super__) {\n inherits(CatchErrorObservable, __super__);\n function CatchErrorObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n\n CatchErrorObservable.prototype.subscribeCore = function (o) {\n var e = this.sources[$iterator$]();\n\n var state = { isDisposed: false }, subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return lastException !== null ? o.onError(lastException) : o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self)));\n });\n return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, recurse) {\n this._o = o;\n this._recurse = recurse;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function (x) { this._o.onNext(x); };\n InnerObserver.prototype.error = function (e) { this._recurse(e); };\n InnerObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return CatchErrorObservable;\n }(ObservableBase));\n\n Enumerable.prototype.catchError = function () {\n return new CatchErrorObservable(this);\n };\n\n Enumerable.prototype.catchErrorWhen = function (notificationHandler) {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var exceptions = new Subject(),\n notifier = new Subject(),\n handled = notificationHandler(exceptions),\n notificationDisposable = handled.subscribe(notifier);\n\n var e = sources[$iterator$]();\n\n var state = { isDisposed: false },\n lastException,\n subscription = new SerialDisposable();\n var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) {\n if (state.isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n if (lastException) {\n o.onError(lastException);\n } else {\n o.onCompleted();\n }\n return;\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var outer = new SingleAssignmentDisposable();\n var inner = new SingleAssignmentDisposable();\n subscription.setDisposable(new BinaryDisposable(inner, outer));\n outer.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n function (exn) {\n inner.setDisposable(notifier.subscribe(self, function(ex) {\n o.onError(ex);\n }, function() {\n o.onCompleted();\n }));\n\n exceptions.onNext(exn);\n },\n function() { o.onCompleted(); }));\n });\n\n return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]);\n });\n };\n\n var RepeatEnumerable = (function (__super__) {\n inherits(RepeatEnumerable, __super__);\n\n function RepeatEnumerable(v, c) {\n this.v = v;\n this.c = c == null ? -1 : c;\n }\n RepeatEnumerable.prototype[$iterator$] = function () {\n return new RepeatEnumerator(this);\n };\n\n function RepeatEnumerator(p) {\n this.v = p.v;\n this.l = p.c;\n }\n RepeatEnumerator.prototype.next = function () {\n if (this.l === 0) { return doneEnumerator; }\n if (this.l > 0) { this.l--; }\n return { done: false, value: this.v };\n };\n\n return RepeatEnumerable;\n }(Enumerable));\n\n var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {\n return new RepeatEnumerable(value, repeatCount);\n };\n\n var OfEnumerable = (function(__super__) {\n inherits(OfEnumerable, __super__);\n function OfEnumerable(s, fn, thisArg) {\n this.s = s;\n this.fn = fn ? bindCallback(fn, thisArg, 3) : null;\n }\n OfEnumerable.prototype[$iterator$] = function () {\n return new OfEnumerator(this);\n };\n\n function OfEnumerator(p) {\n this.i = -1;\n this.s = p.s;\n this.l = this.s.length;\n this.fn = p.fn;\n }\n OfEnumerator.prototype.next = function () {\n return ++this.i < this.l ?\n { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } :\n doneEnumerator;\n };\n\n return OfEnumerable;\n }(Enumerable));\n\n var enumerableOf = Enumerable.of = function (source, selector, thisArg) {\n return new OfEnumerable(source, selector, thisArg);\n };\n\nvar ObserveOnObservable = (function (__super__) {\n inherits(ObserveOnObservable, __super__);\n function ObserveOnObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n ObserveOnObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ObserveOnObserver(this._s, o));\n };\n\n return ObserveOnObservable;\n}(ObservableBase));\n\n /**\n * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.\n *\n * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects\n * that require to be run on a scheduler, use subscribeOn.\n *\n * @param {Scheduler} scheduler Scheduler to notify observers on.\n * @returns {Observable} The source sequence whose observations happen on the specified scheduler.\n */\n observableProto.observeOn = function (scheduler) {\n return new ObserveOnObservable(this, scheduler);\n };\n\n var SubscribeOnObservable = (function (__super__) {\n inherits(SubscribeOnObservable, __super__);\n function SubscribeOnObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n function scheduleMethod(scheduler, state) {\n var source = state[0], d = state[1], o = state[2];\n d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o)));\n }\n\n SubscribeOnObservable.prototype.subscribeCore = function (o) {\n var m = new SingleAssignmentDisposable(), d = new SerialDisposable();\n d.setDisposable(m);\n m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod));\n return d;\n };\n\n return SubscribeOnObservable;\n }(ObservableBase));\n\n /**\n * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;\n * see the remarks section for more information on the distinction between subscribeOn and observeOn.\n\n * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer\n * callbacks on a scheduler, use observeOn.\n\n * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.\n * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.\n */\n observableProto.subscribeOn = function (scheduler) {\n return new SubscribeOnObservable(this, scheduler);\n };\n\n var FromPromiseObservable = (function(__super__) {\n inherits(FromPromiseObservable, __super__);\n function FromPromiseObservable(p) {\n this.p = p;\n __super__.call(this);\n }\n\n FromPromiseObservable.prototype.subscribeCore = function(o) {\n this.p\n .then(function (data) {\n o.onNext(data);\n o.onCompleted();\n }, function (err) {\n o.onError(err);\n });\n return disposableEmpty;\n };\n\n return FromPromiseObservable;\n }(ObservableBase));\n\n /**\n * Converts a Promise to an Observable sequence\n * @param {Promise} An ES6 Compliant promise.\n * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.\n */\n var observableFromPromise = Observable.fromPromise = function (promise) {\n return new FromPromiseObservable(promise);\n };\n\n /*\n * Converts an existing observable sequence to an ES6 Compatible Promise\n * @example\n * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);\n *\n * // With config\n * Rx.config.Promise = RSVP.Promise;\n * var promise = Rx.Observable.return(42).toPromise();\n * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.\n * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.\n */\n observableProto.toPromise = function (promiseCtor) {\n promiseCtor || (promiseCtor = Rx.config.Promise);\n if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }\n var source = this;\n return new promiseCtor(function (resolve, reject) {\n // No cancellation can be done\n var value;\n source.subscribe(function (v) {\n value = v;\n }, reject, function () {\n resolve(value);\n });\n });\n };\n\n var ToArrayObservable = (function(__super__) {\n inherits(ToArrayObservable, __super__);\n function ToArrayObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToArrayObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o) {\n this.o = o;\n this.a = [];\n AbstractObserver.call(this);\n }\n \n InnerObserver.prototype.next = function (x) { this.a.push(x); };\n InnerObserver.prototype.error = function (e) { this.o.onError(e); };\n InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); };\n\n return ToArrayObservable;\n }(ObservableBase));\n\n /**\n * Creates an array from an observable sequence.\n * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.\n */\n observableProto.toArray = function () {\n return new ToArrayObservable(this);\n };\n\n /**\n * Creates an observable sequence from a specified subscribe method implementation.\n * @example\n * var res = Rx.Observable.create(function (observer) { return function () { } );\n * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );\n * var res = Rx.Observable.create(function (observer) { } );\n * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.\n * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.\n */\n Observable.create = function (subscribe, parent) {\n return new AnonymousObservable(subscribe, parent);\n };\n\n var Defer = (function(__super__) {\n inherits(Defer, __super__);\n function Defer(factory) {\n this._f = factory;\n __super__.call(this);\n }\n\n Defer.prototype.subscribeCore = function (o) {\n var result = tryCatch(this._f)();\n if (result === errorObj) { return observableThrow(result.e).subscribe(o);}\n isPromise(result) && (result = observableFromPromise(result));\n return result.subscribe(o);\n };\n\n return Defer;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.\n *\n * @example\n * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });\n * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.\n * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.\n */\n var observableDefer = Observable.defer = function (observableFactory) {\n return new Defer(observableFactory);\n };\n\n var EmptyObservable = (function(__super__) {\n inherits(EmptyObservable, __super__);\n function EmptyObservable(scheduler) {\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n EmptyObservable.prototype.subscribeCore = function (observer) {\n var sink = new EmptySink(observer, this.scheduler);\n return sink.run();\n };\n\n function EmptySink(observer, scheduler) {\n this.observer = observer;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n state.onCompleted();\n return disposableEmpty;\n }\n\n EmptySink.prototype.run = function () {\n var state = this.observer;\n return this.scheduler === immediateScheduler ?\n scheduleItem(null, state) :\n this.scheduler.schedule(state, scheduleItem);\n };\n\n return EmptyObservable;\n }(ObservableBase));\n\n var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler);\n\n /**\n * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.\n *\n * @example\n * var res = Rx.Observable.empty();\n * var res = Rx.Observable.empty(Rx.Scheduler.timeout);\n * @param {Scheduler} [scheduler] Scheduler to send the termination call on.\n * @returns {Observable} An observable sequence with no elements.\n */\n var observableEmpty = Observable.empty = function (scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler);\n };\n\n var FromObservable = (function(__super__) {\n inherits(FromObservable, __super__);\n function FromObservable(iterable, mapper, scheduler) {\n this.iterable = iterable;\n this.mapper = mapper;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromObservable.prototype.subscribeCore = function (o) {\n var sink = new FromSink(o, this);\n return sink.run();\n };\n\n return FromObservable;\n }(ObservableBase));\n\n var FromSink = (function () {\n function FromSink(o, parent) {\n this.o = o;\n this.parent = parent;\n }\n\n FromSink.prototype.run = function () {\n var list = Object(this.parent.iterable),\n it = getIterable(list),\n o = this.o,\n mapper = this.parent.mapper;\n\n function loopRecursive(i, recurse) {\n var next = tryCatch(it.next).call(it);\n if (next === errorObj) { return o.onError(next.e); }\n if (next.done) { return o.onCompleted(); }\n\n var result = next.value;\n\n if (isFunction(mapper)) {\n result = tryCatch(mapper)(result, i);\n if (result === errorObj) { return o.onError(result.e); }\n }\n\n o.onNext(result);\n recurse(i + 1);\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n return FromSink;\n }());\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function StringIterable(s) {\n this._s = s;\n }\n\n StringIterable.prototype[$iterator$] = function () {\n return new StringIterator(this._s);\n };\n\n function StringIterator(s) {\n this._s = s;\n this._l = s.length;\n this._i = 0;\n }\n\n StringIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n StringIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;\n };\n\n function ArrayIterable(a) {\n this._a = a;\n }\n\n ArrayIterable.prototype[$iterator$] = function () {\n return new ArrayIterator(this._a);\n };\n\n function ArrayIterator(a) {\n this._a = a;\n this._l = toLength(a);\n this._i = 0;\n }\n\n ArrayIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n ArrayIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;\n };\n\n function numberIsFinite(value) {\n return typeof value === 'number' && root.isFinite(value);\n }\n\n function isNan(n) {\n return n !== n;\n }\n\n function getIterable(o) {\n var i = o[$iterator$], it;\n if (!i && typeof o === 'string') {\n it = new StringIterable(o);\n return it[$iterator$]();\n }\n if (!i && o.length !== undefined) {\n it = new ArrayIterable(o);\n return it[$iterator$]();\n }\n if (!i) { throw new TypeError('Object is not iterable'); }\n return o[$iterator$]();\n }\n\n function sign(value) {\n var number = +value;\n if (number === 0) { return number; }\n if (isNaN(number)) { return number; }\n return number < 0 ? -1 : 1;\n }\n\n function toLength(o) {\n var len = +o.length;\n if (isNaN(len)) { return 0; }\n if (len === 0 || !numberIsFinite(len)) { return len; }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) { return 0; }\n if (len > maxSafeInteger) { return maxSafeInteger; }\n return len;\n }\n\n /**\n * This method creates a new Observable sequence from an array-like or iterable object.\n * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.\n * @param {Function} [mapFn] Map function to call on every element of the array.\n * @param {Any} [thisArg] The context to use calling the mapFn if provided.\n * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.\n */\n var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {\n if (iterable == null) {\n throw new Error('iterable cannot be null.')\n }\n if (mapFn && !isFunction(mapFn)) {\n throw new Error('mapFn when provided must be a function');\n }\n if (mapFn) {\n var mapper = bindCallback(mapFn, thisArg, 2);\n }\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromObservable(iterable, mapper, scheduler);\n }\n\n var FromArrayObservable = (function(__super__) {\n inherits(FromArrayObservable, __super__);\n function FromArrayObservable(args, scheduler) {\n this.args = args;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromArrayObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromArraySink(observer, this);\n return sink.run();\n };\n\n return FromArrayObservable;\n }(ObservableBase));\n\n function FromArraySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromArraySink.prototype.run = function () {\n var observer = this.observer, args = this.parent.args, len = args.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n observer.onNext(args[i]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n /**\n * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.\n * @deprecated use Observable.from or Observable.of\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.\n */\n var observableFromArray = Observable.fromArray = function (array, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler)\n };\n\n var GenerateObservable = (function (__super__) {\n inherits(GenerateObservable, __super__);\n function GenerateObservable(state, cndFn, itrFn, resFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._s = s;\n this._first = true;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n var hasResult = tryCatch(self._cndFn)(self._state);\n if (hasResult === errorObj) { return self._o.onError(hasResult.e); }\n if (hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n self._o.onNext(result);\n recurse(self);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursive(this, scheduleRecursive);\n };\n\n return GenerateObservable;\n }(ObservableBase));\n\n /**\n * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.\n *\n * @example\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.\n * @returns {Observable} The generated sequence.\n */\n Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler);\n };\n\n function observableOf (scheduler, array) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler);\n }\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.of = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return new FromArrayObservable(args, currentThreadScheduler);\n };\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.ofWithScheduler = function (scheduler) {\n var len = arguments.length, args = new Array(len - 1);\n for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }\n return new FromArrayObservable(args, scheduler);\n };\n\n /**\n * Creates an Observable sequence from changes to an array using Array.observe.\n * @param {Array} array An array to observe changes.\n * @returns {Observable} An observable sequence containing changes to an array from Array.observe.\n */\n Observable.ofArrayChanges = function(array) {\n if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); }\n if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n \n Array.observe(array, observerFn);\n\n return function () {\n Array.unobserve(array, observerFn);\n };\n });\n };\n\n /**\n * Creates an Observable sequence from changes to an object using Object.observe.\n * @param {Object} obj An object to observe changes.\n * @returns {Observable} An observable sequence containing changes to an object from Object.observe.\n */\n Observable.ofObjectChanges = function(obj) {\n if (obj == null) { throw new TypeError('object must not be null or undefined.'); }\n if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n\n Object.observe(obj, observerFn);\n\n return function () {\n Object.unobserve(obj, observerFn);\n };\n });\n };\n\n var NeverObservable = (function(__super__) {\n inherits(NeverObservable, __super__);\n function NeverObservable() {\n __super__.call(this);\n }\n\n NeverObservable.prototype.subscribeCore = function (observer) {\n return disposableEmpty;\n };\n\n return NeverObservable;\n }(ObservableBase));\n\n var NEVER_OBSERVABLE = new NeverObservable();\n\n /**\n * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).\n * @returns {Observable} An observable sequence whose observers will never get called.\n */\n var observableNever = Observable.never = function () {\n return NEVER_OBSERVABLE;\n };\n\n var PairsObservable = (function(__super__) {\n inherits(PairsObservable, __super__);\n function PairsObservable(obj, scheduler) {\n this.obj = obj;\n this.keys = Object.keys(obj);\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n PairsObservable.prototype.subscribeCore = function (observer) {\n var sink = new PairsSink(observer, this);\n return sink.run();\n };\n\n return PairsObservable;\n }(ObservableBase));\n\n function PairsSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n PairsSink.prototype.run = function () {\n var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n var key = keys[i];\n observer.onNext([key, obj[key]]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n /**\n * Convert an object into an observable sequence of [key, value] pairs.\n * @param {Object} obj The object to inspect.\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} An observable sequence of [key, value] pairs from the object.\n */\n Observable.pairs = function (obj, scheduler) {\n scheduler || (scheduler = currentThreadScheduler);\n return new PairsObservable(obj, scheduler);\n };\n\n var RangeObservable = (function(__super__) {\n inherits(RangeObservable, __super__);\n function RangeObservable(start, count, scheduler) {\n this.start = start;\n this.rangeCount = count;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RangeObservable.prototype.subscribeCore = function (observer) {\n var sink = new RangeSink(observer, this);\n return sink.run();\n };\n\n return RangeObservable;\n }(ObservableBase));\n\n var RangeSink = (function () {\n function RangeSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RangeSink.prototype.run = function () {\n var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;\n function loopRecursive(i, recurse) {\n if (i < count) {\n observer.onNext(start + i);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursive(0, loopRecursive);\n };\n\n return RangeSink;\n }());\n\n /**\n * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.\n * @param {Number} start The value of the first integer in the sequence.\n * @param {Number} count The number of sequential integers to generate.\n * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.\n * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.\n */\n Observable.range = function (start, count, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RangeObservable(start, count, scheduler);\n };\n\n var RepeatObservable = (function(__super__) {\n inherits(RepeatObservable, __super__);\n function RepeatObservable(value, repeatCount, scheduler) {\n this.value = value;\n this.repeatCount = repeatCount == null ? -1 : repeatCount;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RepeatObservable.prototype.subscribeCore = function (observer) {\n var sink = new RepeatSink(observer, this);\n return sink.run();\n };\n\n return RepeatObservable;\n }(ObservableBase));\n\n function RepeatSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RepeatSink.prototype.run = function () {\n var observer = this.observer, value = this.parent.value;\n function loopRecursive(i, recurse) {\n if (i === -1 || i > 0) {\n observer.onNext(value);\n i > 0 && i--;\n }\n if (i === 0) { return observer.onCompleted(); }\n recurse(i);\n }\n\n return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive);\n };\n\n /**\n * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.\n * @param {Mixed} value Element to repeat.\n * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.\n * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence that repeats the given element the specified number of times.\n */\n Observable.repeat = function (value, repeatCount, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RepeatObservable(value, repeatCount, scheduler);\n };\n\n var JustObservable = (function(__super__) {\n inherits(JustObservable, __super__);\n function JustObservable(value, scheduler) {\n this.value = value;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n JustObservable.prototype.subscribeCore = function (observer) {\n var sink = new JustSink(observer, this.value, this.scheduler);\n return sink.run();\n };\n\n function JustSink(observer, value, scheduler) {\n this.observer = observer;\n this.value = value;\n this.scheduler = scheduler;\n }\n\n function scheduleItem(s, state) {\n var value = state[0], observer = state[1];\n observer.onNext(value);\n observer.onCompleted();\n return disposableEmpty;\n }\n\n JustSink.prototype.run = function () {\n var state = [this.value, this.observer];\n return this.scheduler === immediateScheduler ?\n scheduleItem(null, state) :\n this.scheduler.schedule(state, scheduleItem);\n };\n\n return JustObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.\n * There is an alias called 'just' or browsers 0) {\n parent.handleSubscribe(parent.q.shift());\n } else {\n parent.activeCount--;\n parent.done && parent.activeCount === 0 && parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeObserver;\n }());\n\n\n\n\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.\n * Or merges two observable sequences into a single observable sequence.\n *\n * @example\n * 1 - merged = sources.merge(1);\n * 2 - merged = source.merge(otherSource);\n * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.merge = function (maxConcurrentOrOther) {\n return typeof maxConcurrentOrOther !== 'number' ?\n observableMerge(this, maxConcurrentOrOther) :\n new MergeObservable(this, maxConcurrentOrOther);\n };\n\n /**\n * Merges all the observable sequences into a single observable sequence.\n * The scheduler is optional and if not specified, the immediate scheduler is used.\n * @returns {Observable} The observable sequence that merges the elements of the observable sequences.\n */\n var observableMerge = Observable.merge = function () {\n var scheduler, sources = [], i, len = arguments.length;\n if (!arguments[0]) {\n scheduler = immediateScheduler;\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else if (isScheduler(arguments[0])) {\n scheduler = arguments[0];\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else {\n scheduler = immediateScheduler;\n for(i = 0; i < len; i++) { sources.push(arguments[i]); }\n }\n if (Array.isArray(sources[0])) {\n sources = sources[0];\n }\n return observableOf(scheduler, sources).mergeAll();\n };\n\n var MergeAllObservable = (function (__super__) {\n inherits(MergeAllObservable, __super__);\n\n function MergeAllObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n MergeAllObservable.prototype.subscribeCore = function (observer) {\n var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();\n g.add(m);\n m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));\n return g;\n };\n\n function MergeAllObserver(o, g) {\n this.o = o;\n this.g = g;\n this.isStopped = false;\n this.done = false;\n }\n MergeAllObserver.prototype.onNext = function(innerSource) {\n if(this.isStopped) { return; }\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad)));\n };\n MergeAllObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeAllObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.g.length === 1 && this.o.onCompleted();\n }\n };\n MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeAllObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, sad) {\n this.parent = parent;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n var parent = this.parent;\n this.isStopped = true;\n parent.g.remove(this.sad);\n parent.done && parent.g.length === 1 && parent.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeAllObservable;\n }(ObservableBase));\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.mergeAll = function () {\n return new MergeAllObservable(this);\n };\n\n var CompositeError = Rx.CompositeError = function(errors) {\n this.name = \"NotImplementedError\";\n this.innerErrors = errors;\n this.message = 'This contains multiple errors. Check the innerErrors';\n Error.call(this);\n }\n CompositeError.prototype = Error.prototype;\n\n /**\n * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to\n * receive all successfully emitted items from all of the source Observables without being interrupted by\n * an error notification from one of them.\n *\n * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an\n * error via the Observer's onError, mergeDelayError will refrain from propagating that\n * error notification until all of the merged Observables have finished emitting items.\n * @param {Array | Arguments} args Arguments or an array to merge.\n * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable\n */\n Observable.mergeDelayError = function() {\n var args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n var len = arguments.length;\n args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n var source = observableOf(null, args);\n\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable(),\n m = new SingleAssignmentDisposable(),\n isStopped = false,\n errors = [];\n\n function setCompletion() {\n if (errors.length === 0) {\n o.onCompleted();\n } else if (errors.length === 1) {\n o.onError(errors[0]);\n } else {\n o.onError(new CompositeError(errors));\n }\n }\n\n group.add(m);\n\n m.setDisposable(source.subscribe(\n function (innerSource) {\n var innerSubscription = new SingleAssignmentDisposable();\n group.add(innerSubscription);\n\n // Check for promises support\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) {\n errors.push(e);\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n },\n function () {\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n }));\n },\n function (e) {\n errors.push(e);\n isStopped = true;\n group.length === 1 && setCompletion();\n },\n function () {\n isStopped = true;\n group.length === 1 && setCompletion();\n }));\n return group;\n });\n };\n\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.\n * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.\n */\n observableProto.onErrorResumeNext = function (second) {\n if (!second) { throw new Error('Second observable is required'); }\n return onErrorResumeNext([this, second]);\n };\n\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n *\n * @example\n * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);\n * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);\n * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.\n */\n var onErrorResumeNext = Observable.onErrorResumeNext = function () {\n var sources = [];\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (observer) {\n var pos = 0, subscription = new SerialDisposable(),\n cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) {\n var current, d;\n if (pos < sources.length) {\n current = sources[pos++];\n isPromise(current) && (current = observableFromPromise(current));\n d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));\n } else {\n observer.onCompleted();\n }\n });\n return new BinaryDisposable(subscription, cancelable);\n });\n };\n\n var SkipUntilObservable = (function(__super__) {\n inherits(SkipUntilObservable, __super__);\n\n function SkipUntilObservable(source, other) {\n this._s = source;\n this._o = isPromise(other) ? observableFromPromise(other) : other;\n this._open = false;\n __super__.call(this);\n }\n\n SkipUntilObservable.prototype.subscribeCore = function(o) {\n var leftSubscription = new SingleAssignmentDisposable();\n leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this)));\n\n isPromise(this._o) && (this._o = observableFromPromise(this._o));\n\n var rightSubscription = new SingleAssignmentDisposable();\n rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription)));\n\n return new BinaryDisposable(leftSubscription, rightSubscription);\n };\n\n return SkipUntilObservable;\n }(ObservableBase));\n\n var SkipUntilSourceObserver = (function(__super__) {\n inherits(SkipUntilSourceObserver, __super__);\n function SkipUntilSourceObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipUntilSourceObserver.prototype.next = function (x) {\n this._p._open && this._o.onNext(x);\n };\n\n SkipUntilSourceObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n SkipUntilSourceObserver.prototype.onCompleted = function () {\n this._p._open && this._o.onCompleted();\n };\n\n return SkipUntilSourceObserver;\n }(AbstractObserver));\n\n var SkipUntilOtherObserver = (function(__super__) {\n inherits(SkipUntilOtherObserver, __super__);\n function SkipUntilOtherObserver(o, p, r) {\n this._o = o;\n this._p = p;\n this._r = r;\n __super__.call(this);\n }\n\n SkipUntilOtherObserver.prototype.next = function () {\n this._p._open = true;\n this._r.dispose();\n };\n\n SkipUntilOtherObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n SkipUntilOtherObserver.prototype.onCompleted = function () {\n this._r.dispose();\n };\n\n return SkipUntilOtherObserver;\n }(AbstractObserver));\n\n /**\n * Returns the values from the source observable sequence only after the other observable sequence produces a value.\n * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.\n */\n observableProto.skipUntil = function (other) {\n return new SkipUntilObservable(this, other);\n };\n\n var SwitchObservable = (function(__super__) {\n inherits(SwitchObservable, __super__);\n function SwitchObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n SwitchObservable.prototype.subscribeCore = function (o) {\n var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner));\n return new BinaryDisposable(s, inner);\n };\n\n inherits(SwitchObserver, AbstractObserver);\n function SwitchObserver(o, inner) {\n this.o = o;\n this.inner = inner;\n this.stopped = false;\n this.latest = 0;\n this.hasLatest = false;\n AbstractObserver.call(this);\n }\n\n SwitchObserver.prototype.next = function (innerSource) {\n var d = new SingleAssignmentDisposable(), id = ++this.latest;\n this.hasLatest = true;\n this.inner.setDisposable(d);\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n d.setDisposable(innerSource.subscribe(new InnerObserver(this, id)));\n };\n\n SwitchObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n SwitchObserver.prototype.completed = function () {\n this.stopped = true;\n !this.hasLatest && this.o.onCompleted();\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(parent, id) {\n this.parent = parent;\n this.id = id;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.next = function (x) {\n this.parent.latest === this.id && this.parent.o.onNext(x);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.parent.latest === this.id && this.parent.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n if (this.parent.latest === this.id) {\n this.parent.hasLatest = false;\n this.parent.isStopped && this.parent.o.onCompleted();\n }\n };\n\n return SwitchObservable;\n }(ObservableBase));\n\n /**\n * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto['switch'] = observableProto.switchLatest = function () {\n return new SwitchObservable(this);\n };\n\n var TakeUntilObservable = (function(__super__) {\n inherits(TakeUntilObservable, __super__);\n\n function TakeUntilObservable(source, other) {\n this.source = source;\n this.other = isPromise(other) ? observableFromPromise(other) : other;\n __super__.call(this);\n }\n\n TakeUntilObservable.prototype.subscribeCore = function(o) {\n return new BinaryDisposable(\n this.source.subscribe(o),\n this.other.subscribe(new TakeUntilObserver(o))\n );\n };\n\n return TakeUntilObservable;\n }(ObservableBase));\n\n var TakeUntilObserver = (function(__super__) {\n inherits(TakeUntilObserver, __super__);\n function TakeUntilObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n TakeUntilObserver.prototype.next = function () {\n this._o.onCompleted();\n };\n\n TakeUntilObserver.prototype.error = function (err) {\n this._o.onError(err);\n };\n\n TakeUntilObserver.prototype.onCompleted = noop;\n\n return TakeUntilObserver;\n }(AbstractObserver));\n\n /**\n * Returns the values from the source observable sequence until the other observable sequence produces a value.\n * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.\n */\n observableProto.takeUntil = function (other) {\n return new TakeUntilObservable(this, other);\n };\n\n function falseFactory() { return false; }\n function argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n }\n\n var WithLatestFromObservable = (function(__super__) {\n inherits(WithLatestFromObservable, __super__);\n function WithLatestFromObservable(source, sources, resultSelector) {\n var len = sources.length;\n this._s = source;\n this._ss = sources;\n this._cb = resultSelector;\n this._hv = arrayInitialize(len, falseFactory);\n this._hvAll = false;\n this._v = new Array(len);\n __super__.call(this);\n }\n\n WithLatestFromObservable.prototype.subscribeCore = function (o) {\n var n = this._ss.length, subscriptions = new Array(n + 1);\n for (var i = 0; i < n; i++) {\n var other = this._ss[i], sad = new SingleAssignmentDisposable();\n isPromise(other) && (other = observableFromPromise(other));\n sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this)));\n subscriptions[i] = sad;\n }\n\n var sad = new SingleAssignmentDisposable();\n sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this)));\n subscriptions[n] = sad;\n\n return new NAryDisposable(subscriptions);\n };\n\n return WithLatestFromObservable;\n }(ObservableBase));\n\n var WithLatestFromOtherObserver = (function (__super__) {\n inherits(WithLatestFromOtherObserver, __super__);\n function WithLatestFromOtherObserver(o, i, p) {\n this._o = o;\n this._i = i;\n this._p = p;\n __super__.call(this);\n }\n\n WithLatestFromOtherObserver.prototype.next = function (x) {\n this._p._v[this._i] = x;\n this._p._hv[this._i] = true;\n this._p._hvAll = this._p._hv.every(identity);\n };\n\n WithLatestFromOtherObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n WithLatestFromOtherObserver.prototype.completed = noop;\n\n return WithLatestFromOtherObserver;\n }(AbstractObserver));\n\n var WithLatestFromSourceObserver = (function (__super__) {\n inherits(WithLatestFromSourceObserver, __super__);\n function WithLatestFromSourceObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n WithLatestFromSourceObserver.prototype.next = function (x) {\n var allValues = [x].concat(this._p._v);\n if (!this._p._hvAll) { return; }\n var res = tryCatch(this._p._cb).apply(null, allValues);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._o.onNext(res);\n };\n\n WithLatestFromSourceObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n WithLatestFromSourceObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return WithLatestFromSourceObserver;\n }(AbstractObserver));\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.withLatestFrom = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n Array.isArray(args[0]) && (args = args[0]);\n\n return new WithLatestFromObservable(this, args, resultSelector);\n };\n\n function falseFactory() { return false; }\n function emptyArrayFactory() { return []; }\n\n var ZipObservable = (function(__super__) {\n inherits(ZipObservable, __super__);\n function ZipObservable(sources, resultSelector) {\n var len = sources.length;\n this._s = sources;\n this._cb = resultSelector;\n this._done = arrayInitialize(len, falseFactory);\n this._q = arrayInitialize(len, emptyArrayFactory);\n __super__.call(this);\n }\n\n ZipObservable.prototype.subscribeCore = function(observer) {\n var n = this._s.length, subscriptions = new Array(n);\n\n for (var i = 0; i < n; i++) {\n var source = this._s[i], sad = new SingleAssignmentDisposable();\n subscriptions[i] = sad;\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this)));\n }\n\n return new NAryDisposable(subscriptions);\n };\n\n return ZipObservable;\n }(ObservableBase));\n\n var ZipObserver = (function (__super__) {\n inherits(ZipObserver, __super__);\n function ZipObserver(o, i, p) {\n this._o = o;\n this._i = i;\n this._p = p;\n __super__.call(this);\n }\n\n ZipObserver.prototype.next = function (x) {\n this._p._q[this._i].push(x);\n if (this._p._q.every(function (x) { return x.length > 0; })) {\n var queuedValues = this._p._q.map(function (x) { return x.shift(); });\n var res = tryCatch(this._p._cb).apply(null, queuedValues);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._o.onNext(res);\n } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) {\n this._o.onCompleted();\n }\n };\n\n ZipObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ZipObserver.prototype.completed = function () {\n this._p._done[this._i] = true;\n this._p._done.every(identity) && this._o.onCompleted();\n };\n\n return ZipObserver;\n }(AbstractObserver));\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\n observableProto.zip = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n Array.isArray(args[0]) && (args = args[0]);\n\n var parent = this;\n args.unshift(parent);\n\n return new ZipObservable(args, resultSelector);\n };\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n * @param arguments Observable sources.\n * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n Observable.zip = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n if (Array.isArray(args[0])) {\n args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];\n }\n var first = args.shift();\n return first.zip.apply(first, args);\n };\n\nfunction falseFactory() { return false; }\nfunction emptyArrayFactory() { return []; }\nfunction argumentsToArray() {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return args;\n}\n\n/**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\nobservableProto.zipIterable = function () {\n if (arguments.length === 0) { throw new Error('invalid arguments'); }\n\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray;\n\n var parent = this;\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n\n (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source));\n\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n};\n\n function asObservable(source) {\n return function subscribe(o) { return source.subscribe(o); };\n }\n\n /**\n * Hides the identity of an observable sequence.\n * @returns {Observable} An observable sequence that hides the identity of the source sequence.\n */\n observableProto.asObservable = function () {\n return new AnonymousObservable(asObservable(this), this);\n };\n\n function toArray(x) { return x.toArray(); }\n function notEmpty(x) { return x.length > 0; }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.\n * @param {Number} count Length of each buffer.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithCount = function (count, skip) {\n typeof skip !== 'number' && (skip = count);\n return this.windowWithCount(count, skip)\n .flatMap(toArray)\n .filter(notEmpty);\n };\n\n var DematerializeObservable = (function (__super__) {\n inherits(DematerializeObservable, __super__);\n function DematerializeObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n DematerializeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DematerializeObserver(o));\n };\n\n return DematerializeObservable;\n }(ObservableBase));\n\n var DematerializeObserver = (function (__super__) {\n inherits(DematerializeObserver, __super__);\n\n function DematerializeObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n DematerializeObserver.prototype.next = function (x) { x.accept(this._o); };\n DematerializeObserver.prototype.error = function (e) { this._o.onError(e); };\n DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return DematerializeObserver;\n }(AbstractObserver));\n\n /**\n * Dematerializes the explicit notification values of an observable sequence as implicit notifications.\n * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.\n */\n observableProto.dematerialize = function () {\n return new DematerializeObservable(this);\n };\n\n var DistinctUntilChangedObservable = (function(__super__) {\n inherits(DistinctUntilChangedObservable, __super__);\n function DistinctUntilChangedObservable(source, keyFn, comparer) {\n this.source = source;\n this.keyFn = keyFn;\n this.comparer = comparer;\n __super__.call(this);\n }\n\n DistinctUntilChangedObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer));\n };\n\n return DistinctUntilChangedObservable;\n }(ObservableBase));\n\n var DistinctUntilChangedObserver = (function(__super__) {\n inherits(DistinctUntilChangedObserver, __super__);\n function DistinctUntilChangedObserver(o, keyFn, comparer) {\n this.o = o;\n this.keyFn = keyFn;\n this.comparer = comparer;\n this.hasCurrentKey = false;\n this.currentKey = null;\n __super__.call(this);\n }\n\n DistinctUntilChangedObserver.prototype.next = function (x) {\n var key = x, comparerEquals;\n if (isFunction(this.keyFn)) {\n key = tryCatch(this.keyFn)(x);\n if (key === errorObj) { return this.o.onError(key.e); }\n }\n if (this.hasCurrentKey) {\n comparerEquals = tryCatch(this.comparer)(this.currentKey, key);\n if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); }\n }\n if (!this.hasCurrentKey || !comparerEquals) {\n this.hasCurrentKey = true;\n this.currentKey = key;\n this.o.onNext(x);\n }\n };\n DistinctUntilChangedObserver.prototype.error = function(e) {\n this.o.onError(e);\n };\n DistinctUntilChangedObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return DistinctUntilChangedObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer.\n * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value.\n * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.\n * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinctUntilChanged = function (keyFn, comparer) {\n comparer || (comparer = defaultComparer);\n return new DistinctUntilChangedObservable(this, keyFn, comparer);\n };\n\n var TapObservable = (function(__super__) {\n inherits(TapObservable,__super__);\n function TapObservable(source, observerOrOnNext, onError, onCompleted) {\n this.source = source;\n this._oN = observerOrOnNext;\n this._oE = onError;\n this._oC = onCompleted;\n __super__.call(this);\n }\n\n TapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, p) {\n this.o = o;\n this.t = !p._oN || isFunction(p._oN) ?\n observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) :\n p._oN;\n this.isStopped = false;\n AbstractObserver.call(this);\n }\n InnerObserver.prototype.next = function(x) {\n var res = tryCatch(this.t.onNext).call(this.t, x);\n if (res === errorObj) { this.o.onError(res.e); }\n this.o.onNext(x);\n };\n InnerObserver.prototype.error = function(err) {\n var res = tryCatch(this.t.onError).call(this.t, err);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onError(err);\n };\n InnerObserver.prototype.completed = function() {\n var res = tryCatch(this.t.onCompleted).call(this.t);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onCompleted();\n };\n\n return TapObservable;\n }(ObservableBase));\n\n /**\n * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {\n return new TapObservable(this, observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Invokes an action for each element in the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onNext Action to invoke for each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {\n return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);\n };\n\n /**\n * Invokes an action upon exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {\n return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);\n };\n\n /**\n * Invokes an action upon graceful termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {\n return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);\n };\n\n /**\n * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.\n * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.\n * @returns {Observable} Source sequence with the action-invoking termination behavior applied.\n */\n observableProto['finally'] = function (action) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription = tryCatch(source.subscribe).call(source, observer);\n if (subscription === errorObj) {\n action();\n return thrower(subscription.e);\n }\n return disposableCreate(function () {\n var r = tryCatch(subscription.dispose).call(subscription);\n action();\n r === errorObj && thrower(r.e);\n });\n }, this);\n };\n\n var IgnoreElementsObservable = (function(__super__) {\n inherits(IgnoreElementsObservable, __super__);\n\n function IgnoreElementsObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IgnoreElementsObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = noop;\n InnerObserver.prototype.onError = function (err) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n\n return false;\n };\n\n return IgnoreElementsObservable;\n }(ObservableBase));\n\n /**\n * Ignores all elements in an observable sequence leaving only the termination messages.\n * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.\n */\n observableProto.ignoreElements = function () {\n return new IgnoreElementsObservable(this);\n };\n\n var MaterializeObservable = (function (__super__) {\n inherits(MaterializeObservable, __super__);\n function MaterializeObservable(source, fn) {\n this.source = source;\n __super__.call(this);\n }\n\n MaterializeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new MaterializeObserver(o));\n };\n\n return MaterializeObservable;\n }(ObservableBase));\n\n var MaterializeObserver = (function (__super__) {\n inherits(MaterializeObserver, __super__);\n\n function MaterializeObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) };\n MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); };\n MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); };\n\n return MaterializeObserver;\n }(AbstractObserver));\n\n /**\n * Materializes the implicit notifications of an observable sequence as explicit notification values.\n * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.\n */\n observableProto.materialize = function () {\n return new MaterializeObservable(this);\n };\n\n /**\n * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.\n * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.\n * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.\n */\n observableProto.repeat = function (repeatCount) {\n return enumerableRepeat(this, repeatCount).concat();\n };\n\n /**\n * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.\n * Note if you encounter an error and want it to retry once, then you must use .retry(2);\n *\n * @example\n * var res = retried = retry.repeat();\n * var res = retried = retry.repeat(2);\n * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retry = function (retryCount) {\n return enumerableRepeat(this, retryCount).catchError();\n };\n\n /**\n * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. \n * if the notifier completes, the observable sequence completes.\n *\n * @example\n * var timer = Observable.timer(500);\n * var source = observable.retryWhen(timer);\n * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retryWhen = function (notifier) {\n return enumerableRepeat(this).catchErrorWhen(notifier);\n };\n var ScanObservable = (function(__super__) {\n inherits(ScanObservable, __super__);\n function ScanObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ScanObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new ScanObserver(o,this));\n };\n\n return ScanObservable;\n }(ObservableBase));\n\n var ScanObserver = (function (__super__) {\n inherits(ScanObserver, __super__);\n function ScanObserver(o, parent) {\n this._o = o;\n this._p = parent;\n this._fn = parent.accumulator;\n this._hs = parent.hasSeed;\n this._s = parent.seed;\n this._ha = false;\n this._a = null;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n ScanObserver.prototype.next = function (x) {\n !this._hv && (this._hv = true);\n if (this._ha) {\n this._a = tryCatch(this._fn)(this._a, x, this._i, this._p);\n } else {\n this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x;\n this._ha = true;\n }\n if (this._a === errorObj) { return this._o.onError(this._a.e); }\n this._o.onNext(this._a);\n this._i++;\n };\n\n ScanObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ScanObserver.prototype.completed = function () {\n !this._hv && this._hs && this._o.onNext(this._s);\n this._o.onCompleted();\n };\n\n return ScanObserver;\n }(AbstractObserver));\n\n /**\n * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.\n * For aggregation behavior with no intermediate results, see Observable.aggregate.\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing the accumulated values.\n */\n observableProto.scan = function () {\n var hasSeed = false, seed, accumulator = arguments[0];\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[1];\n }\n return new ScanObservable(this, accumulator, hasSeed, seed);\n };\n\n var SkipLastObservable = (function (__super__) {\n inherits(SkipLastObservable, __super__);\n function SkipLastObservable(source, c) {\n this.source = source;\n this._c = c;\n __super__.call(this);\n }\n\n SkipLastObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipLastObserver(o, this._c));\n };\n\n return SkipLastObservable;\n }(ObservableBase));\n\n var SkipLastObserver = (function (__super__) {\n inherits(SkipLastObserver, __super__);\n function SkipLastObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n SkipLastObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._o.onNext(this._q.shift());\n };\n\n SkipLastObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n SkipLastObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return SkipLastObserver;\n }(AbstractObserver));\n\n /**\n * Bypasses a specified number of elements at the end of an observable sequence.\n * @description\n * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are\n * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.\n * @param count Number of elements to bypass at the end of the source sequence.\n * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.\n */\n observableProto.skipLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipLastObservable(this, count);\n };\n\n /**\n * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.\n * @example\n * var res = source.startWith(1, 2, 3);\n * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);\n * @param {Arguments} args The specified values to prepend to the observable sequence\n * @returns {Observable} The source sequence prepended with the specified values.\n */\n observableProto.startWith = function () {\n var values, scheduler, start = 0;\n if (!!arguments.length && isScheduler(arguments[0])) {\n scheduler = arguments[0];\n start = 1;\n } else {\n scheduler = immediateScheduler;\n }\n for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n return enumerableOf([observableFromArray(args, scheduler), this]).concat();\n };\n\n var TakeLastObserver = (function (__super__) {\n inherits(TakeLastObserver, __super__);\n function TakeLastObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._q.shift();\n };\n\n TakeLastObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TakeLastObserver.prototype.completed = function () {\n while (this._q.length > 0) { this._o.onNext(this._q.shift()); }\n this._o.onCompleted();\n };\n\n return TakeLastObserver;\n }(AbstractObserver));\n\n /**\n * Returns a specified number of contiguous elements from the end of an observable sequence.\n * @description\n * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of\n * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(new TakeLastObserver(o, count));\n }, source);\n };\n\n var TakeLastBufferObserver = (function (__super__) {\n inherits(TakeLastBufferObserver, __super__);\n function TakeLastBufferObserver(o, c) {\n this._o = o;\n this._c = c;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastBufferObserver.prototype.next = function (x) {\n this._q.push(x);\n this._q.length > this._c && this._q.shift();\n };\n\n TakeLastBufferObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TakeLastBufferObserver.prototype.completed = function () {\n this._o.onNext(this._q);\n this._o.onCompleted();\n };\n\n return TakeLastBufferObserver;\n }(AbstractObserver));\n\n /**\n * Returns an array with the specified number of contiguous elements from the end of an observable sequence.\n *\n * @description\n * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the\n * source sequence, this buffer is produced on the result sequence.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLastBuffer = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(new TakeLastBufferObserver(o, count));\n }, source);\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.\n * @param {Number} count Length of each window.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithCount = function (count, skip) {\n var source = this;\n +count || (count = 0);\n Math.abs(count) === Infinity && (count = 0);\n if (count <= 0) { throw new ArgumentOutOfRangeError(); }\n skip == null && (skip = count);\n +skip || (skip = 0);\n Math.abs(skip) === Infinity && (skip = 0);\n\n if (skip <= 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(),\n refCountDisposable = new RefCountDisposable(m),\n n = 0,\n q = [];\n\n function createWindow () {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n\n createWindow();\n\n m.setDisposable(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n var c = n - count + 1;\n c >= 0 && c % skip === 0 && q.shift().onCompleted();\n ++n % skip === 0 && createWindow();\n },\n function (e) {\n while (q.length > 0) { q.shift().onError(e); }\n observer.onError(e);\n },\n function () {\n while (q.length > 0) { q.shift().onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n function concatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).concatAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the\n * source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.concatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n });\n }\n return isFunction(selector) ?\n concatMap(this, selector, thisArg) :\n concatMap(this, function () { return selector; });\n };\n\n /**\n * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {\n var source = this,\n onNextFunc = bindCallback(onNext, thisArg, 2),\n onErrorFunc = bindCallback(onError, thisArg, 1),\n onCompletedFunc = bindCallback(onCompleted, thisArg, 0);\n return new AnonymousObservable(function (observer) {\n var index = 0;\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNextFunc(x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onErrorFunc(err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompletedFunc();\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, this).concatAll();\n };\n\n var DefaultIfEmptyObserver = (function (__super__) {\n inherits(DefaultIfEmptyObserver, __super__);\n function DefaultIfEmptyObserver(o, d) {\n this._o = o;\n this._d = d;\n this._f = false;\n __super__.call(this);\n }\n\n DefaultIfEmptyObserver.prototype.next = function (x) {\n this._f = true;\n this._o.onNext(x);\n };\n\n DefaultIfEmptyObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n DefaultIfEmptyObserver.prototype.completed = function () {\n !this._f && this._o.onNext(defaultValue);\n this._o.onCompleted();\n };\n\n return DefaultIfEmptyObserver;\n }(AbstractObserver));\n\n /**\n * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.\n *\n * var res = obs = xs.defaultIfEmpty();\n * 2 - obs = xs.defaultIfEmpty(false);\n *\n * @memberOf Observable#\n * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.\n * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.\n */\n observableProto.defaultIfEmpty = function (defaultValue) {\n var source = this;\n defaultValue === undefined && (defaultValue = null);\n return new AnonymousObservable(function (o) {\n return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue));\n }, source);\n };\n\n // Swap out for Array.findIndex\n function arrayIndexOfComparer(array, item, comparer) {\n for (var i = 0, len = array.length; i < len; i++) {\n if (comparer(array[i], item)) { return i; }\n }\n return -1;\n }\n\n function HashSet(comparer) {\n this.comparer = comparer;\n this.set = [];\n }\n HashSet.prototype.push = function(value) {\n var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1;\n retValue && this.set.push(value);\n return retValue;\n };\n\n var DistinctObservable = (function (__super__) {\n inherits(DistinctObservable, __super__);\n function DistinctObservable(source, keyFn, cmpFn) {\n this.source = source;\n this._keyFn = keyFn;\n this._cmpFn = cmpFn;\n __super__.call(this);\n }\n\n DistinctObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn));\n };\n\n return DistinctObservable;\n }(ObservableBase));\n\n var DistinctObserver = (function (__super__) {\n inherits(DistinctObserver, __super__);\n function DistinctObserver(o, keyFn, cmpFn) {\n this._o = o;\n this._keyFn = keyFn;\n this._h = new HashSet(cmpFn);\n __super__.call(this);\n }\n\n DistinctObserver.prototype.next = function (x) {\n var key = x;\n if (isFunction(this._keyFn)) {\n key = tryCatch(this._keyFn)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n }\n this._h.push(key) && this._o.onNext(x);\n };\n\n DistinctObserver.prototype.error = function (e) { this._o.onError(e); };\n DistinctObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return DistinctObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.\n * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.\n *\n * @example\n * var res = obs = xs.distinct();\n * 2 - obs = xs.distinct(function (x) { return x.id; });\n * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });\n * @param {Function} [keySelector] A function to compute the comparison key for each element.\n * @param {Function} [comparer] Used to compare items in the collection.\n * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinct = function (keySelector, comparer) {\n comparer || (comparer = defaultComparer);\n return new DistinctObservable(this, keySelector, comparer);\n };\n\n /**\n * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.\n *\n * @example\n * var res = observable.groupBy(function (x) { return x.id; });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.\n * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n */\n observableProto.groupBy = function (keySelector, elementSelector) {\n return this.groupByUntil(keySelector, elementSelector, observableNever);\n };\n\n /**\n * Groups the elements of an observable sequence according to a specified key selector function.\n * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same\n * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.\n *\n * @example\n * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} durationSelector A function to signal the expiration of a group.\n * @returns {Observable}\n * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.\n *\n */\n observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var map = new Map(),\n groupDisposable = new CompositeDisposable(),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n handleError = function (e) { return function (item) { item.onError(e); }; };\n\n groupDisposable.add(\n source.subscribe(function (x) {\n var key = tryCatch(keySelector)(x);\n if (key === errorObj) {\n map.forEach(handleError(key.e));\n return o.onError(key.e);\n }\n\n var fireNewMapEntry = false, writer = map.get(key);\n if (writer === undefined) {\n writer = new Subject();\n map.set(key, writer);\n fireNewMapEntry = true;\n }\n\n if (fireNewMapEntry) {\n var group = new GroupedObservable(key, writer, refCountDisposable),\n durationGroup = new GroupedObservable(key, writer);\n var duration = tryCatch(durationSelector)(durationGroup);\n if (duration === errorObj) {\n map.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n o.onNext(group);\n\n var md = new SingleAssignmentDisposable();\n groupDisposable.add(md);\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n map.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n if (map['delete'](key)) { writer.onCompleted(); }\n groupDisposable.remove(md);\n }));\n }\n\n var element = x;\n if (isFunction(elementSelector)) {\n element = tryCatch(elementSelector)(x);\n if (element === errorObj) {\n map.forEach(handleError(element.e));\n return o.onError(element.e);\n }\n }\n\n writer.onNext(element);\n }, function (e) {\n map.forEach(handleError(e));\n o.onError(e);\n }, function () {\n map.forEach(function (item) { item.onCompleted(); });\n o.onCompleted();\n }));\n\n return refCountDisposable;\n }, source);\n };\n\n var MapObservable = (function (__super__) {\n inherits(MapObservable, __super__);\n\n function MapObservable(source, selector, thisArg) {\n this.source = source;\n this.selector = bindCallback(selector, thisArg, 3);\n __super__.call(this);\n }\n\n function innerMap(selector, self) {\n return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }\n }\n\n MapObservable.prototype.internalMap = function (selector, thisArg) {\n return new MapObservable(this.source, innerMap(selector, this), thisArg);\n };\n\n MapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this));\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, selector, source) {\n this.o = o;\n this.selector = selector;\n this.source = source;\n this.i = 0;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function(x) {\n var result = tryCatch(this.selector)(x, this.i++, this.source);\n if (result === errorObj) { return this.o.onError(result.e); }\n this.o.onNext(result);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return MapObservable;\n\n }(ObservableBase));\n\n /**\n * Projects each element of an observable sequence into a new form by incorporating the element's index.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.\n */\n observableProto.map = observableProto.select = function (selector, thisArg) {\n var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };\n return this instanceof MapObservable ?\n this.internalMap(selectorFn, thisArg) :\n new MapObservable(this, selectorFn, thisArg);\n };\n\n function plucker(args, len) {\n return function mapper(x) {\n var currentProp = x;\n for (var i = 0; i < len; i++) {\n var p = currentProp[args[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n }\n }\n\n /**\n * Retrieves the value of a specified nested property from all elements in\n * the Observable sequence.\n * @param {Arguments} arguments The nested properties to pluck.\n * @returns {Observable} Returns a new Observable sequence of property values.\n */\n observableProto.pluck = function () {\n var len = arguments.length, args = new Array(len);\n if (len === 0) { throw new Error('List of properties cannot be empty.'); }\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return this.map(plucker(args, len));\n };\n\nobservableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll();\n};\n\n\n//\n//Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) {\n// return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit);\n//};\n//\n\n /**\n * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var index = 0;\n\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNext.call(thisArg, x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onError.call(thisArg, err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompleted.call(thisArg);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, source).mergeAll();\n };\n\nRx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest();\n};\n var SkipObservable = (function(__super__) {\n inherits(SkipObservable, __super__);\n function SkipObservable(source, count) {\n this.source = source;\n this.skipCount = count;\n __super__.call(this);\n }\n \n SkipObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.skipCount));\n };\n \n function InnerObserver(o, c) {\n this.c = c;\n this.r = c;\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n if (this.r <= 0) { \n this.o.onNext(x);\n } else {\n this.r--;\n }\n };\n InnerObserver.prototype.onError = function(e) {\n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n \n return SkipObservable;\n }(ObservableBase)); \n \n /**\n * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.\n * @param {Number} count The number of elements to skip before returning the remaining elements.\n * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.\n */\n observableProto.skip = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipObservable(this, count);\n };\n var SkipWhileObservable = (function (__super__) {\n inherits(SkipWhileObservable, __super__);\n function SkipWhileObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SkipWhileObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipWhileObserver(o, this));\n };\n\n return SkipWhileObservable;\n }(ObservableBase));\n\n var SkipWhileObserver = (function (__super__) {\n inherits(SkipWhileObserver, __super__);\n\n function SkipWhileObserver(o, p) {\n this._o = o;\n this._p = p;\n this._i = 0;\n this._r = false;\n __super__.call(this);\n }\n\n SkipWhileObserver.prototype.next = function (x) {\n if (!this._r) {\n var res = tryCatch(this._p._fn)(x, this._i++, this._p);\n if (res === errorObj) { return this._o.onError(res.e); }\n this._r = !res;\n }\n this._r && this._o.onNext(x);\n };\n SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipWhileObserver;\n }(AbstractObserver));\n\n /**\n * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.\n * The element's index is used in the logic of the predicate function.\n *\n * var res = source.skipWhile(function (value) { return value < 10; });\n * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\n observableProto.skipWhile = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new SkipWhileObservable(this, fn);\n };\n\n var TakeObservable = (function(__super__) {\n inherits(TakeObservable, __super__);\n \n function TakeObservable(source, count) {\n this.source = source;\n this.takeCount = count;\n __super__.call(this);\n }\n \n TakeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.takeCount));\n };\n \n function InnerObserver(o, c) {\n this.o = o;\n this.c = c;\n this.r = c;\n this.isStopped = false;\n }\n InnerObserver.prototype = {\n onNext: function (x) {\n if (this.isStopped) { return; }\n if (this.r-- > 0) {\n this.o.onNext(x);\n this.r <= 0 && this.o.onCompleted();\n }\n },\n onError: function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n },\n onCompleted: function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n },\n dispose: function () { this.isStopped = true; },\n fail: function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n }\n };\n \n return TakeObservable;\n }(ObservableBase)); \n \n /**\n * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).\n * @param {Number} count The number of elements to return.\n * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case is set to 0.\n * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.\n */\n observableProto.take = function (count, scheduler) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n if (count === 0) { return observableEmpty(scheduler); }\n return new TakeObservable(this, count);\n };\n\n var TakeWhileObservable = (function (__super__) {\n inherits(TakeWhileObservable, __super__);\n function TakeWhileObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n TakeWhileObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TakeWhileObserver(o, this));\n };\n\n return TakeWhileObservable;\n }(ObservableBase));\n\n var TakeWhileObserver = (function (__super__) {\n inherits(TakeWhileObserver, __super__);\n\n function TakeWhileObserver(o, p) {\n this._o = o;\n this._p = p;\n this._i = 0;\n this._r = true;\n __super__.call(this);\n }\n\n TakeWhileObserver.prototype.next = function (x) {\n if (this._r) {\n this._r = tryCatch(this._p._fn)(x, this._i++, this._p);\n if (this._r === errorObj) { return this._o.onError(this._r.e); }\n }\n if (this._r) {\n this._o.onNext(x);\n } else {\n this._o.onCompleted();\n }\n };\n TakeWhileObserver.prototype.error = function (e) { this._o.onError(e); };\n TakeWhileObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return TakeWhileObserver;\n }(AbstractObserver));\n\n /**\n * Returns elements from an observable sequence as long as a specified condition is true.\n * The element's index is used in the logic of the predicate function.\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.\n */\n observableProto.takeWhile = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new TakeWhileObservable(this, fn);\n };\n\n var FilterObservable = (function (__super__) {\n inherits(FilterObservable, __super__);\n\n function FilterObservable(source, predicate, thisArg) {\n this.source = source;\n this.predicate = bindCallback(predicate, thisArg, 3);\n __super__.call(this);\n }\n\n FilterObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.predicate, this));\n };\n\n function innerPredicate(predicate, self) {\n return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }\n }\n\n FilterObservable.prototype.internalFilter = function(predicate, thisArg) {\n return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);\n };\n\n inherits(InnerObserver, AbstractObserver);\n function InnerObserver(o, predicate, source) {\n this.o = o;\n this.predicate = predicate;\n this.source = source;\n this.i = 0;\n AbstractObserver.call(this);\n }\n\n InnerObserver.prototype.next = function(x) {\n var shouldYield = tryCatch(this.predicate)(x, this.i++, this.source);\n if (shouldYield === errorObj) {\n return this.o.onError(shouldYield.e);\n }\n shouldYield && this.o.onNext(x);\n };\n\n InnerObserver.prototype.error = function (e) {\n this.o.onError(e);\n };\n\n InnerObserver.prototype.completed = function () {\n this.o.onCompleted();\n };\n\n return FilterObservable;\n\n }(ObservableBase));\n\n /**\n * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.\n * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.\n */\n observableProto.filter = observableProto.where = function (predicate, thisArg) {\n return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :\n new FilterObservable(this, predicate, thisArg);\n };\n\n var ExtremaByObservable = (function (__super__) {\n inherits(ExtremaByObservable, __super__);\n function ExtremaByObservable(source, k, c) {\n this.source = source;\n this._k = k;\n this._c = c;\n __super__.call(this);\n }\n\n ExtremaByObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ExtremaByObserver(o, this._k, this._c));\n };\n\n return ExtremaByObservable;\n }(ObservableBase));\n\n var ExtremaByObserver = (function (__super__) {\n inherits(ExtremaByObserver, __super__);\n function ExtremaByObserver(o, k, c) {\n this._o = o;\n this._k = k;\n this._c = c;\n this._v = null;\n this._hv = false;\n this._l = [];\n __super__.call(this);\n }\n\n ExtremaByObserver.prototype.next = function (x) {\n var key = tryCatch(this._k)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n var comparison = 0;\n if (!this._hv) {\n this._hv = true;\n this._v = key;\n } else {\n comparison = tryCatch(this._c)(key, this._v);\n if (comparison === errorObj) { return this._o.onError(comparison.e); }\n }\n if (comparison > 0) {\n this._v = key;\n this._l = [];\n }\n if (comparison >= 0) { this._l.push(x); }\n };\n\n ExtremaByObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ExtremaByObserver.prototype.completed = function () {\n this._o.onNext(this._l);\n this._o.onCompleted();\n };\n\n return ExtremaByObserver;\n }(AbstractObserver));\n\n function firstOnly(x) {\n if (x.length === 0) { throw new EmptyError(); }\n return x[0];\n }\n\n var ReduceObservable = (function(__super__) {\n inherits(ReduceObservable, __super__);\n function ReduceObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ReduceObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new ReduceObserver(observer,this));\n };\n\n return ReduceObservable;\n }(ObservableBase));\n\n var ReduceObserver = (function (__super__) {\n inherits(ReduceObserver, __super__);\n function ReduceObserver(o, parent) {\n this._o = o;\n this._p = parent;\n this._fn = parent.accumulator;\n this._hs = parent.hasSeed;\n this._s = parent.seed;\n this._ha = false;\n this._a = null;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n ReduceObserver.prototype.next = function (x) {\n !this._hv && (this._hv = true);\n if (this._ha) {\n this._a = tryCatch(this._fn)(this._a, x, this._i, this._p);\n } else {\n this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x;\n this._ha = true;\n }\n if (this._a === errorObj) { return this._o.onError(this._a.e); }\n this._i++;\n };\n\n ReduceObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ReduceObserver.prototype.completed = function () {\n this._hv && this._o.onNext(this._a);\n !this._hv && this._hs && this._o.onNext(this._s);\n !this._hv && !this._hs && this._o.onError(new EmptyError());\n this._o.onCompleted();\n };\n\n return ReduceObserver;\n }(AbstractObserver));\n\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @param {Any} [seed] The initial accumulator value.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.reduce = function () {\n var hasSeed = false, seed, accumulator = arguments[0];\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[1];\n }\n return new ReduceObservable(this, accumulator, hasSeed, seed);\n };\n\n var SomeObservable = (function (__super__) {\n inherits(SomeObservable, __super__);\n function SomeObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SomeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SomeObserver(o, this._fn, this.source));\n };\n\n return SomeObservable;\n }(ObservableBase));\n\n var SomeObserver = (function (__super__) {\n inherits(SomeObserver, __super__);\n\n function SomeObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n SomeObserver.prototype.next = function (x) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n if (Boolean(result)) {\n this._o.onNext(true);\n this._o.onCompleted();\n }\n };\n SomeObserver.prototype.error = function (e) { this._o.onError(e); };\n SomeObserver.prototype.completed = function () {\n this._o.onNext(false);\n this._o.onCompleted();\n };\n\n return SomeObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.\n */\n observableProto.some = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new SomeObservable(this, fn);\n };\n\n var IsEmptyObservable = (function (__super__) {\n inherits(IsEmptyObservable, __super__);\n function IsEmptyObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IsEmptyObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new IsEmptyObserver(o));\n };\n\n return IsEmptyObservable;\n }(ObservableBase));\n\n var IsEmptyObserver = (function(__super__) {\n inherits(IsEmptyObserver, __super__);\n function IsEmptyObserver(o) {\n this._o = o;\n __super__.call(this);\n }\n\n IsEmptyObserver.prototype.next = function () {\n this._o.onNext(false);\n this._o.onCompleted();\n };\n IsEmptyObserver.prototype.error = function (e) { this._o.onError(e); };\n IsEmptyObserver.prototype.completed = function () {\n this._o.onNext(true);\n this._o.onCompleted();\n };\n\n return IsEmptyObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether an observable sequence is empty.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.\n */\n observableProto.isEmpty = function () {\n return new IsEmptyObservable(this);\n };\n\n var EveryObservable = (function (__super__) {\n inherits(EveryObservable, __super__);\n function EveryObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n EveryObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new EveryObserver(o, this._fn, this.source));\n };\n\n return EveryObservable;\n }(ObservableBase));\n\n var EveryObserver = (function (__super__) {\n inherits(EveryObserver, __super__);\n\n function EveryObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n EveryObserver.prototype.next = function (x) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n if (!Boolean(result)) {\n this._o.onNext(false);\n this._o.onCompleted();\n }\n };\n EveryObserver.prototype.error = function (e) { this._o.onError(e); };\n EveryObserver.prototype.completed = function () {\n this._o.onNext(true);\n this._o.onCompleted();\n };\n\n return EveryObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether all elements of an observable sequence satisfy a condition.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.\n */\n observableProto.every = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new EveryObservable(this, fn);\n };\n\n var IncludesObservable = (function (__super__) {\n inherits(IncludesObservable, __super__);\n function IncludesObservable(source, elem, idx) {\n var n = +idx || 0;\n Math.abs(n) === Infinity && (n = 0);\n\n this.source = source;\n this._elem = elem;\n this._n = n;\n __super__.call(this);\n }\n\n IncludesObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(false);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new IncludesObserver(o, this._elem, this._n));\n };\n\n return IncludesObservable;\n }(ObservableBase));\n\n var IncludesObserver = (function (__super__) {\n inherits(IncludesObserver, __super__);\n function IncludesObserver(o, elem, n) {\n this._o = o;\n this._elem = elem;\n this._n = n;\n this._i = 0;\n __super__.call(this);\n }\n\n function comparer(a, b) {\n return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));\n }\n\n IncludesObserver.prototype.next = function (x) {\n if (this._i++ >= this._n && comparer(x, this._elem)) {\n this._o.onNext(true);\n this._o.onCompleted();\n }\n };\n IncludesObserver.prototype.error = function (e) { this._o.onError(e); };\n IncludesObserver.prototype.completed = function () { this._o.onNext(false); this._o.onCompleted(); };\n\n return IncludesObserver;\n }(AbstractObserver));\n\n /**\n * Determines whether an observable sequence includes a specified element with an optional equality comparer.\n * @param searchElement The value to locate in the source sequence.\n * @param {Number} [fromIndex] An equality comparer to compare elements.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.\n */\n observableProto.includes = function (searchElement, fromIndex) {\n return new IncludesObservable(this, searchElement, fromIndex);\n };\n\n var CountObservable = (function (__super__) {\n inherits(CountObservable, __super__);\n function CountObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n CountObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new CountObserver(o, this._fn, this.source));\n };\n\n return CountObservable;\n }(ObservableBase));\n\n var CountObserver = (function (__super__) {\n inherits(CountObserver, __super__);\n\n function CountObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n this._c = 0;\n __super__.call(this);\n }\n\n CountObserver.prototype.next = function (x) {\n if (this._fn) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n Boolean(result) && (this._c++);\n } else {\n this._c++;\n }\n };\n CountObserver.prototype.error = function (e) { this._o.onError(e); };\n CountObserver.prototype.completed = function () {\n this._o.onNext(this._c);\n this._o.onCompleted();\n };\n\n return CountObserver;\n }(AbstractObserver));\n\n /**\n * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.\n * @example\n * res = source.count();\n * res = source.count(function (x) { return x > 3; });\n * @param {Function} [predicate]A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.\n */\n observableProto.count = function (predicate, thisArg) {\n var fn = bindCallback(predicate, thisArg, 3);\n return new CountObservable(this, fn);\n };\n\n var IndexOfObservable = (function (__super__) {\n inherits(IndexOfObservable, __super__);\n function IndexOfObservable(source, e, n) {\n this.source = source;\n this._e = e;\n this._n = n;\n __super__.call(this);\n }\n\n IndexOfObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new IndexOfObserver(o, this._e, this._n));\n };\n\n return IndexOfObservable;\n }(ObservableBase));\n\n var IndexOfObserver = (function (__super__) {\n inherits(IndexOfObserver, __super__);\n function IndexOfObserver(o, e, n) {\n this._o = o;\n this._e = e;\n this._n = n;\n this._i = 0;\n __super__.call(this);\n }\n\n IndexOfObserver.prototype.next = function (x) {\n if (this._i >= this._n && x === this._e) {\n this._o.onNext(this._i);\n this._o.onCompleted();\n }\n this._i++;\n };\n IndexOfObserver.prototype.error = function (e) { this._o.onError(e); };\n IndexOfObserver.prototype.completed = function () { this._o.onNext(-1); this._o.onCompleted(); };\n\n return IndexOfObserver;\n }(AbstractObserver));\n\n /**\n * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.indexOf = function(searchElement, fromIndex) {\n var n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n return new IndexOfObservable(this, searchElement, n);\n };\n\n var SumObservable = (function (__super__) {\n inherits(SumObservable, __super__);\n function SumObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n SumObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SumObserver(o, this._fn, this.source));\n };\n\n return SumObservable;\n }(ObservableBase));\n\n var SumObserver = (function (__super__) {\n inherits(SumObserver, __super__);\n\n function SumObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._i = 0;\n this._c = 0;\n __super__.call(this);\n }\n\n SumObserver.prototype.next = function (x) {\n if (this._fn) {\n var result = tryCatch(this._fn)(x, this._i++, this._s);\n if (result === errorObj) { return this._o.onError(result.e); }\n this._c += result;\n } else {\n this._c += x;\n }\n };\n SumObserver.prototype.error = function (e) { this._o.onError(e); };\n SumObserver.prototype.completed = function () {\n this._o.onNext(this._c);\n this._o.onCompleted();\n };\n\n return SumObserver;\n }(AbstractObserver));\n\n /**\n * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.\n */\n observableProto.sum = function (keySelector, thisArg) {\n var fn = bindCallback(keySelector, thisArg, 3);\n return new SumObservable(this, fn);\n };\n\n /**\n * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.\n * @example\n * var res = source.minBy(function (x) { return x.value; });\n * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.\n */\n observableProto.minBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return new ExtremaByObservable(this, keySelector, function (x, y) { return comparer(x, y) * -1; });\n };\n\n /**\n * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.\n * @example\n * var res = source.min();\n * var res = source.min(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.\n */\n observableProto.min = function (comparer) {\n return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\n /**\n * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.\n * @example\n * var res = source.maxBy(function (x) { return x.value; });\n * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.\n */\n observableProto.maxBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return new ExtremaByObservable(this, keySelector, comparer);\n };\n\n /**\n * Returns the maximum value in an observable sequence according to the specified comparer.\n * @example\n * var res = source.max();\n * var res = source.max(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.\n */\n observableProto.max = function (comparer) {\n return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\n var AverageObservable = (function (__super__) {\n inherits(AverageObservable, __super__);\n function AverageObservable(source, fn) {\n this.source = source;\n this._fn = fn;\n __super__.call(this);\n }\n\n AverageObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new AverageObserver(o, this._fn, this.source));\n };\n\n return AverageObservable;\n }(ObservableBase));\n\n var AverageObserver = (function(__super__) {\n inherits(AverageObserver, __super__);\n function AverageObserver(o, fn, s) {\n this._o = o;\n this._fn = fn;\n this._s = s;\n this._c = 0;\n this._t = 0;\n __super__.call(this);\n }\n\n AverageObserver.prototype.next = function (x) {\n if(this._fn) {\n var r = tryCatch(this._fn)(x, this._c++, this._s);\n if (r === errorObj) { return this._o.onError(r.e); }\n this._t += r;\n } else {\n this._c++;\n this._t += x;\n }\n };\n AverageObserver.prototype.error = function (e) { this._o.onError(e); };\n AverageObserver.prototype.completed = function () {\n if (this._c === 0) { return this._o.onError(new EmptyError()); }\n this._o.onNext(this._t / this._c);\n this._o.onCompleted();\n };\n\n return AverageObserver;\n }(AbstractObserver));\n\n /**\n * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.\n */\n observableProto.average = function (keySelector, thisArg) {\n var source = this, fn;\n if (isFunction(keySelector)) {\n fn = bindCallback(keySelector, thisArg, 3);\n }\n return new AverageObservable(source, fn);\n };\n\n /**\n * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.\n *\n * @example\n * var res = res = source.sequenceEqual([1,2,3]);\n * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });\n * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));\n * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });\n * @param {Observable} second Second observable sequence or array to compare.\n * @param {Function} [comparer] Comparer used to compare elements of both sequences.\n * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.\n */\n observableProto.sequenceEqual = function (second, comparer) {\n var first = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var donel = false, doner = false, ql = [], qr = [];\n var subscription1 = first.subscribe(function (x) {\n if (qr.length > 0) {\n var v = qr.shift();\n var equal = tryCatch(comparer)(v, x);\n if (equal === errorObj) { return o.onError(equal.e); }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (doner) {\n o.onNext(false);\n o.onCompleted();\n } else {\n ql.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n donel = true;\n if (ql.length === 0) {\n if (qr.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (doner) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n\n (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));\n isPromise(second) && (second = observableFromPromise(second));\n var subscription2 = second.subscribe(function (x) {\n if (ql.length > 0) {\n var v = ql.shift();\n var equal = tryCatch(comparer)(v, x);\n if (equal === errorObj) { return o.onError(equal.e); }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (donel) {\n o.onNext(false);\n o.onCompleted();\n } else {\n qr.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n doner = true;\n if (qr.length === 0) {\n if (ql.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (donel) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n return new BinaryDisposable(subscription1, subscription2);\n }, first);\n };\n\n var ElementAtObservable = (function (__super__) {\n inherits(ElementAtObservable, __super__);\n function ElementAtObservable(source, i, d) {\n this.source = source;\n this._i = i;\n this._d = d;\n __super__.call(this);\n }\n\n ElementAtObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ElementAtObserver(o, this._i, this._d));\n };\n\n return ElementAtObservable;\n }(ObservableBase));\n\n var ElementAtObserver = (function (__super__) {\n inherits(ElementAtObserver, __super__);\n\n function ElementAtObserver(o, i, d) {\n this._o = o;\n this._i = i;\n this._d = d;\n __super__.call(this);\n }\n\n ElementAtObserver.prototype.next = function (x) {\n if (this._i-- === 0) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n };\n ElementAtObserver.prototype.error = function (e) { this._o.onError(e); };\n ElementAtObserver.prototype.completed = function () {\n if (this._d === undefined) {\n this._o.onError(new ArgumentOutOfRangeError());\n } else {\n this._o.onNext(this._d);\n this._o.onCompleted();\n }\n };\n\n return ElementAtObserver;\n }(AbstractObserver));\n\n /**\n * Returns the element at a specified index in a sequence or default value if not found.\n * @param {Number} index The zero-based index of the element to retrieve.\n * @param {Any} [defaultValue] The default value to use if elementAt does not find a value.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.\n */\n observableProto.elementAt = function (index, defaultValue) {\n if (index < 0) { throw new ArgumentOutOfRangeError(); }\n return new ElementAtObservable(this, index, defaultValue);\n };\n\n var SingleObserver = (function(__super__) {\n inherits(SingleObserver, __super__);\n function SingleObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n this._hv = false;\n this._v = null;\n __super__.call(this);\n }\n\n SingleObserver.prototype.next = function (x) {\n var shouldYield = false;\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n Boolean(res) && (shouldYield = true);\n } else if (!this._obj.predicate) {\n shouldYield = true;\n }\n if (shouldYield) {\n if (this._hv) {\n return this._o.onError(new Error('Sequence contains more than one matching element'));\n }\n this._hv = true;\n this._v = x;\n }\n };\n SingleObserver.prototype.error = function (e) { this._o.onError(e); };\n SingleObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n this._o.onCompleted();\n }\n else if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return SingleObserver;\n }(AbstractObserver));\n\n\n /**\n * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.single = function (predicate, thisArg) {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new AnonymousObservable(function (o) {\n return source.subscribe(new SingleObserver(o, obj, source));\n }, source);\n };\n\n var FirstObservable = (function (__super__) {\n inherits(FirstObservable, __super__);\n function FirstObservable(source, obj) {\n this.source = source;\n this._obj = obj;\n __super__.call(this);\n }\n\n FirstObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new FirstObserver(o, this._obj, this.source));\n };\n\n return FirstObservable;\n }(ObservableBase));\n\n var FirstObserver = (function(__super__) {\n inherits(FirstObserver, __super__);\n function FirstObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n __super__.call(this);\n }\n\n FirstObserver.prototype.next = function (x) {\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n if (Boolean(res)) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n } else if (!this._obj.predicate) {\n this._o.onNext(x);\n this._o.onCompleted();\n }\n };\n FirstObserver.prototype.error = function (e) { this._o.onError(e); };\n FirstObserver.prototype.completed = function () {\n if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return FirstObserver;\n }(AbstractObserver));\n\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.\n */\n observableProto.first = function () {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new FirstObservable(this, obj);\n };\n\n var LastObservable = (function (__super__) {\n inherits(LastObservable, __super__);\n function LastObservable(source, obj) {\n this.source = source;\n this._obj = obj;\n __super__.call(this);\n }\n\n LastObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new LastObserver(o, this._obj, this.source));\n };\n\n return LastObservable;\n }(ObservableBase));\n\n var LastObserver = (function(__super__) {\n inherits(LastObserver, __super__);\n function LastObserver(o, obj, s) {\n this._o = o;\n this._obj = obj;\n this._s = s;\n this._i = 0;\n this._hv = false;\n this._v = null;\n __super__.call(this);\n }\n\n LastObserver.prototype.next = function (x) {\n var shouldYield = false;\n if (this._obj.predicate) {\n var res = tryCatch(this._obj.predicate)(x, this._i++, this._s);\n if (res === errorObj) { return this._o.onError(res.e); }\n Boolean(res) && (shouldYield = true);\n } else if (!this._obj.predicate) {\n shouldYield = true;\n }\n if (shouldYield) {\n this._hv = true;\n this._v = x;\n }\n };\n LastObserver.prototype.error = function (e) { this._o.onError(e); };\n LastObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n this._o.onCompleted();\n }\n else if (this._obj.defaultValue === undefined) {\n this._o.onError(new EmptyError());\n } else {\n this._o.onNext(this._obj.defaultValue);\n this._o.onCompleted();\n }\n };\n\n return LastObserver;\n }(AbstractObserver));\n\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.last = function () {\n var obj = {}, source = this;\n if (typeof arguments[0] === 'object') {\n obj = arguments[0];\n } else {\n obj = {\n predicate: arguments[0],\n thisArg: arguments[1],\n defaultValue: arguments[2]\n };\n }\n if (isFunction (obj.predicate)) {\n var fn = obj.predicate;\n obj.predicate = bindCallback(fn, obj.thisArg, 3);\n }\n return new LastObservable(this, obj);\n };\n\n var FindValueObserver = (function(__super__) {\n inherits(FindValueObserver, __super__);\n function FindValueObserver(observer, source, callback, yieldIndex) {\n this._o = observer;\n this._s = source;\n this._cb = callback;\n this._y = yieldIndex;\n this._i = 0;\n __super__.call(this);\n }\n\n FindValueObserver.prototype.next = function (x) {\n var shouldRun = tryCatch(this._cb)(x, this._i, this._s);\n if (shouldRun === errorObj) { return this._o.onError(shouldRun.e); }\n if (shouldRun) {\n this._o.onNext(this._y ? this._i : x);\n this._o.onCompleted();\n } else {\n this._i++;\n }\n };\n\n FindValueObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n FindValueObserver.prototype.completed = function () {\n this._y && this._o.onNext(-1);\n this._o.onCompleted();\n };\n\n return FindValueObserver;\n }(AbstractObserver));\n\n function findValue (source, predicate, thisArg, yieldIndex) {\n var callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n return source.subscribe(new FindValueObserver(o, source, callback, yieldIndex));\n }, source);\n }\n\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.\n */\n observableProto.find = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, false);\n };\n\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns\n * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.\n */\n observableProto.findIndex = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, true);\n };\n\n var ToSetObservable = (function (__super__) {\n inherits(ToSetObservable, __super__);\n function ToSetObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToSetObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ToSetObserver(o));\n };\n\n return ToSetObservable;\n }(ObservableBase));\n\n var ToSetObserver = (function (__super__) {\n inherits(ToSetObserver, __super__);\n function ToSetObserver(o) {\n this._o = o;\n this._s = new root.Set();\n __super__.call(this);\n }\n\n ToSetObserver.prototype.next = function (x) {\n this._s.add(x);\n };\n\n ToSetObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ToSetObserver.prototype.completed = function () {\n this._o.onNext(this._s);\n this._o.onCompleted();\n };\n\n return ToSetObserver;\n }(AbstractObserver));\n\n /**\n * Converts the observable sequence to a Set if it exists.\n * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.\n */\n observableProto.toSet = function () {\n if (typeof root.Set === 'undefined') { throw new TypeError(); }\n return new ToSetObservable(this);\n };\n\n var ToMapObservable = (function (__super__) {\n inherits(ToMapObservable, __super__);\n function ToMapObservable(source, k, e) {\n this.source = source;\n this._k = k;\n this._e = e;\n __super__.call(this);\n }\n\n ToMapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new ToMapObserver(o, this._k, this._e));\n };\n\n return ToMapObservable;\n }(ObservableBase));\n\n var ToMapObserver = (function (__super__) {\n inherits(ToMapObserver, __super__);\n function ToMapObserver(o, k, e) {\n this._o = o;\n this._k = k;\n this._e = e;\n this._m = new root.Map();\n __super__.call(this);\n }\n\n ToMapObserver.prototype.next = function (x) {\n var key = tryCatch(this._k)(x);\n if (key === errorObj) { return this._o.onError(key.e); }\n var elem = x;\n if (this._e) {\n elem = tryCatch(this._e)(x);\n if (elem === errorObj) { return this._o.onError(elem.e); }\n }\n\n this._m.set(key, elem);\n };\n\n ToMapObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n ToMapObserver.prototype.completed = function () {\n this._o.onNext(this._m);\n this._o.onCompleted();\n };\n\n return ToMapObserver;\n }(AbstractObserver));\n\n /**\n * Converts the observable sequence to a Map if it exists.\n * @param {Function} keySelector A function which produces the key for the Map.\n * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.\n * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.\n */\n observableProto.toMap = function (keySelector, elementSelector) {\n if (typeof root.Map === 'undefined') { throw new TypeError(); }\n return new ToMapObservable(this, keySelector, elementSelector);\n };\n\n var SliceObservable = (function (__super__) {\n inherits(SliceObservable, __super__);\n function SliceObservable(source, b, e) {\n this.source = source;\n this._b = b;\n this._e = e;\n __super__.call(this);\n }\n\n SliceObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SliceObserver(o, this._b, this._e));\n };\n\n return SliceObservable;\n }(ObservableBase));\n\n var SliceObserver = (function (__super__) {\n inherits(SliceObserver, __super__);\n\n function SliceObserver(o, b, e) {\n this._o = o;\n this._b = b;\n this._e = e;\n this._i = 0;\n __super__.call(this);\n }\n\n SliceObserver.prototype.next = function (x) {\n if (this._i >= this._b) {\n if (this._e === this._i) {\n this._o.onCompleted();\n } else {\n this._o.onNext(x);\n }\n }\n this._i++;\n };\n SliceObserver.prototype.error = function (e) { this._o.onError(e); };\n SliceObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SliceObserver;\n }(AbstractObserver));\n\n /*\n * The slice() method returns a shallow copy of a portion of an Observable into a new Observable object.\n * Unlike the array version, this does not support negative numbers for being or end.\n * @param {Number} [begin] Zero-based index at which to begin extraction. If omitted, this will default to zero.\n * @param {Number} [end] Zero-based index at which to end extraction. slice extracts up to but not including end.\n * If omitted, this will emit the rest of the Observable object.\n * @returns {Observable} A shallow copy of a portion of an Observable into a new Observable object.\n */\n observableProto.slice = function (begin, end) {\n var start = begin || 0;\n if (start < 0) { throw new Rx.ArgumentOutOfRangeError(); }\n if (typeof end === 'number' && end < start) {\n throw new Rx.ArgumentOutOfRangeError();\n }\n return new SliceObservable(this, start, end);\n };\n\n var LastIndexOfObservable = (function (__super__) {\n inherits(LastIndexOfObservable, __super__);\n function LastIndexOfObservable(source, e, n) {\n this.source = source;\n this._e = e;\n this._n = n;\n __super__.call(this);\n }\n\n LastIndexOfObservable.prototype.subscribeCore = function (o) {\n if (this._n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n\n return this.source.subscribe(new LastIndexOfObserver(o, this._e, this._n));\n };\n\n return LastIndexOfObservable;\n }(ObservableBase));\n\n var LastIndexOfObserver = (function (__super__) {\n inherits(LastIndexOfObserver, __super__);\n function LastIndexOfObserver(o, e, n) {\n this._o = o;\n this._e = e;\n this._n = n;\n this._v = 0;\n this._hv = false;\n this._i = 0;\n __super__.call(this);\n }\n\n LastIndexOfObserver.prototype.next = function (x) {\n if (this._i >= this._n && x === this._e) {\n this._hv = true;\n this._v = this._i;\n }\n this._i++;\n };\n LastIndexOfObserver.prototype.error = function (e) { this._o.onError(e); };\n LastIndexOfObserver.prototype.completed = function () {\n if (this._hv) {\n this._o.onNext(this._v);\n } else {\n this._o.onNext(-1);\n }\n this._o.onCompleted();\n };\n\n return LastIndexOfObserver;\n }(AbstractObserver));\n\n /**\n * Returns the last index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the last index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.lastIndexOf = function(searchElement, fromIndex) {\n var n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n return new LastIndexOfObservable(this, searchElement, n);\n };\n\n Observable.wrap = function (fn) {\n createObservable.__generatorFunction__ = fn;\n return createObservable;\n\n function createObservable() {\n return Observable.spawn.call(this, fn.apply(this, arguments));\n }\n };\n\n var spawn = Observable.spawn = function () {\n var gen = arguments[0], self = this, args = [];\n for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n\n return new AnonymousObservable(function (o) {\n var g = new CompositeDisposable();\n\n if (isFunction(gen)) { gen = gen.apply(self, args); }\n if (!gen || !isFunction(gen.next)) {\n o.onNext(gen);\n return o.onCompleted();\n }\n\n processGenerator();\n\n function processGenerator(res) {\n var ret = tryCatch(gen.next).call(gen, res);\n if (ret === errorObj) { return o.onError(ret.e); }\n next(ret);\n }\n\n function onError(err) {\n var ret = tryCatch(gen.next).call(gen, err);\n if (ret === errorObj) { return o.onError(ret.e); }\n next(ret);\n }\n\n function next(ret) {\n if (ret.done) {\n o.onNext(ret.value);\n o.onCompleted();\n return;\n }\n var value = toObservable.call(self, ret.value);\n if (Observable.isObservable(value)) {\n g.add(value.subscribe(processGenerator, onError));\n } else {\n onError(new TypeError('type not supported'));\n }\n }\n\n return g;\n });\n };\n\n function toObservable(obj) {\n if (!obj) { return obj; }\n if (Observable.isObservable(obj)) { return obj; }\n if (isPromise(obj)) { return Observable.fromPromise(obj); }\n if (isGeneratorFunction(obj) || isGenerator(obj)) { return spawn.call(this, obj); }\n if (isFunction(obj)) { return thunkToObservable.call(this, obj); }\n if (isArrayLike(obj) || isIterable(obj)) { return arrayToObservable.call(this, obj); }\n if (isObject(obj)) {return objectToObservable.call(this, obj);}\n return obj;\n }\n\n function arrayToObservable (obj) {\n return Observable.from(obj)\n .flatMap(toObservable)\n .toArray();\n }\n\n function objectToObservable (obj) {\n var results = new obj.constructor(), keys = Object.keys(obj), observables = [];\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i];\n var observable = toObservable.call(this, obj[key]);\n\n if(observable && Observable.isObservable(observable)) {\n defer(observable, key);\n } else {\n results[key] = obj[key];\n }\n }\n\n return Observable.forkJoin.apply(Observable, observables).map(function() {\n return results;\n });\n\n\n function defer (observable, key) {\n results[key] = undefined;\n observables.push(observable.map(function (next) {\n results[key] = next;\n }));\n }\n }\n\n function thunkToObservable(fn) {\n var self = this;\n return new AnonymousObservable(function (o) {\n fn.call(self, function () {\n var err = arguments[0], res = arguments[1];\n if (err) { return o.onError(err); }\n if (arguments.length > 2) {\n var args = [];\n for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n res = args;\n }\n o.onNext(res);\n o.onCompleted();\n });\n });\n }\n\n function isGenerator(obj) {\n return isFunction (obj.next) && isFunction (obj.throw);\n }\n\n function isGeneratorFunction(obj) {\n var ctor = obj.constructor;\n if (!ctor) { return false; }\n if (ctor.name === 'GeneratorFunction' || ctor.displayName === 'GeneratorFunction') { return true; }\n return isGenerator(ctor.prototype);\n }\n\n function isObject(val) {\n return Object == val.constructor;\n }\n\n /**\n * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.\n *\n * @example\n * var res = Rx.Observable.start(function () { console.log('hello'); });\n * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);\n * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);\n *\n * @param {Function} func Function to run asynchronously.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n *\n * Remarks\n * * The function is called immediately, not during the subscription of the resulting sequence.\n * * Multiple subscriptions to the resulting sequence can observe the function's result.\n */\n Observable.start = function (func, context, scheduler) {\n return observableToAsync(func, context, scheduler)();\n };\n\n /**\n * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.\n * @param {Function} function Function to convert to an asynchronous function.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Function} Asynchronous function.\n */\n var observableToAsync = Observable.toAsync = function (func, context, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return function () {\n var args = arguments,\n subject = new AsyncSubject();\n\n scheduler.schedule(null, function () {\n var result;\n try {\n result = func.apply(context, args);\n } catch (e) {\n subject.onError(e);\n return;\n }\n subject.onNext(result);\n subject.onCompleted();\n });\n return subject.asObservable();\n };\n };\n\nfunction createCbObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createCbHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createCbHandler(o, ctx, selector) {\n return function handler () {\n var len = arguments.length, results = new Array(len);\n for(var i = 0; i < len; i++) { results[i] = arguments[i]; }\n\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a callback function to an observable sequence.\n *\n * @param {Function} fn Function with a callback as the last parameter to convert to an Observable sequence.\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.\n * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.\n */\nObservable.fromCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createCbObservable(fn, ctx, selector, args);\n };\n};\n\nfunction createNodeObservable(fn, ctx, selector, args) {\n var o = new AsyncSubject();\n\n args.push(createNodeHandler(o, ctx, selector));\n fn.apply(ctx, args);\n\n return o.asObservable();\n}\n\nfunction createNodeHandler(o, ctx, selector) {\n return function handler () {\n var err = arguments[0];\n if (err) { return o.onError(err); }\n\n var len = arguments.length, results = [];\n for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }\n\n if (isFunction(selector)) {\n var results = tryCatch(selector).apply(ctx, results);\n if (results === errorObj) { return o.onError(results.e); }\n o.onNext(results);\n } else {\n if (results.length <= 1) {\n o.onNext(results[0]);\n } else {\n o.onNext(results);\n }\n }\n\n o.onCompleted();\n };\n}\n\n/**\n * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.\n * @param {Function} fn The function to call\n * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.\n * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.\n */\nObservable.fromNodeCallback = function (fn, ctx, selector) {\n return function () {\n typeof ctx === 'undefined' && (ctx = this); \n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return createNodeObservable(fn, ctx, selector, args);\n };\n};\n\n function ListenDisposable(e, n, fn) {\n this._e = e;\n this._n = n;\n this._fn = fn;\n this._e.addEventListener(this._n, this._fn, false);\n this.isDisposed = false;\n }\n ListenDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this._e.removeEventListener(this._n, this._fn, false);\n this.isDisposed = true;\n }\n };\n\n function createEventListener (el, eventName, handler) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var elemToString = Object.prototype.toString.call(el);\n if (elemToString === '[object NodeList]' || elemToString === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler));\n }\n } else if (el) {\n disposables.add(new ListenDisposable(el, eventName, handler));\n }\n\n return disposables;\n }\n\n /**\n * Configuration option to determine whether to use native events only\n */\n Rx.config.useNativeEvents = false;\n\n function eventHandler(o, selector) {\n return function handler () {\n var results = arguments[0];\n if (isFunction(selector)) {\n results = tryCatch(selector).apply(null, arguments);\n if (results === errorObj) { return o.onError(results.e); }\n }\n o.onNext(results);\n };\n }\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n Observable.fromEvent = function (element, eventName, selector) {\n // Node.js specific\n if (element.addListener) {\n return fromEventPattern(\n function (h) { element.addListener(eventName, h); },\n function (h) { element.removeListener(eventName, h); },\n selector);\n }\n\n // Use only if non-native events are allowed\n if (!Rx.config.useNativeEvents) {\n // Handles jq, Angular.js, Zepto, Marionette, Ember.js\n if (typeof element.on === 'function' && typeof element.off === 'function') {\n return fromEventPattern(\n function (h) { element.on(eventName, h); },\n function (h) { element.off(eventName, h); },\n selector);\n }\n }\n\n return new AnonymousObservable(function (o) {\n return createEventListener(\n element,\n eventName,\n eventHandler(o, selector));\n }).publish().refCount();\n };\n\n /**\n * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.\n * @param {Function} addHandler The function to add a handler to the emitter.\n * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @param {Scheduler} [scheduler] A scheduler used to schedule the remove handler.\n * @returns {Observable} An observable sequence which wraps an event from an event emitter\n */\n var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (o) {\n function innerHandler () {\n var result = arguments[0];\n if (isFunction(selector)) {\n result = tryCatch(selector).apply(null, arguments);\n if (result === errorObj) { return o.onError(result.e); }\n }\n o.onNext(result);\n }\n\n var returnValue = addHandler(innerHandler);\n return disposableCreate(function () {\n isFunction(removeHandler) && removeHandler(innerHandler, returnValue);\n });\n }).publish().refCount();\n };\n\n /**\n * Invokes the asynchronous function, surfacing the result through an observable sequence.\n * @param {Function} functionAsync Asynchronous function which returns a Promise to run.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n */\n Observable.startAsync = function (functionAsync) {\n var promise = tryCatch(functionAsync)();\n if (promise === errorObj) { return observableThrow(promise.e); }\n return observableFromPromise(promise);\n };\n\n var PausableObservable = (function (__super__) {\n inherits(PausableObservable, __super__);\n function PausableObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this);\n }\n\n PausableObservable.prototype._subscribe = function (o) {\n var conn = this.source.publish(),\n subscription = conn.subscribe(o),\n connection = disposableEmpty;\n\n var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {\n if (b) {\n connection = conn.connect();\n } else {\n connection.dispose();\n connection = disposableEmpty;\n }\n });\n\n return new NAryDisposable([subscription, connection, pausable]);\n };\n\n PausableObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausable(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausable = function (pauser) {\n return new PausableObservable(this, pauser);\n };\n\n function combineLatestSource(source, subject, resultSelector) {\n return new AnonymousObservable(function (o) {\n var hasValue = [false, false],\n hasValueAll = false,\n isDone = false,\n values = new Array(2),\n err;\n\n function next(x, i) {\n values[i] = x;\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n if (err) { return o.onError(err); }\n var res = tryCatch(resultSelector).apply(null, values);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n }\n isDone && values[1] && o.onCompleted();\n }\n\n return new BinaryDisposable(\n source.subscribe(\n function (x) {\n next(x, 0);\n },\n function (e) {\n if (values[1]) {\n o.onError(e);\n } else {\n err = e;\n }\n },\n function () {\n isDone = true;\n values[1] && o.onCompleted();\n }),\n subject.subscribe(\n function (x) {\n next(x, 1);\n },\n function (e) { o.onError(e); },\n function () {\n isDone = true;\n next(true, 1);\n })\n );\n }, source);\n }\n\n var PausableBufferedObservable = (function (__super__) {\n inherits(PausableBufferedObservable, __super__);\n function PausableBufferedObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this);\n }\n\n PausableBufferedObservable.prototype._subscribe = function (o) {\n var q = [], previousShouldFire;\n\n function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } }\n\n var subscription =\n combineLatestSource(\n this.source,\n this.pauser.startWith(false).distinctUntilChanged(),\n function (data, shouldFire) {\n return { data: data, shouldFire: shouldFire };\n })\n .subscribe(\n function (results) {\n if (previousShouldFire !== undefined && results.shouldFire !== previousShouldFire) {\n previousShouldFire = results.shouldFire;\n // change in shouldFire\n if (results.shouldFire) { drainQueue(); }\n } else {\n previousShouldFire = results.shouldFire;\n // new data\n if (results.shouldFire) {\n o.onNext(results.data);\n } else {\n q.push(results.data);\n }\n }\n },\n function (err) {\n drainQueue();\n o.onError(err);\n },\n function () {\n drainQueue();\n o.onCompleted();\n }\n );\n return subscription; \n };\n\n PausableBufferedObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableBufferedObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableBufferedObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,\n * and yields the values that were buffered while paused.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausableBuffered(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausableBuffered = function (subject) {\n return new PausableBufferedObservable(this, subject);\n };\n\n var ControlledObservable = (function (__super__) {\n inherits(ControlledObservable, __super__);\n function ControlledObservable (source, enableQueue, scheduler) {\n __super__.call(this);\n this.subject = new ControlledSubject(enableQueue, scheduler);\n this.source = source.multicast(this.subject).refCount();\n }\n\n ControlledObservable.prototype._subscribe = function (o) {\n return this.source.subscribe(o);\n };\n\n ControlledObservable.prototype.request = function (numberOfItems) {\n return this.subject.request(numberOfItems == null ? -1 : numberOfItems);\n };\n\n return ControlledObservable;\n\n }(Observable));\n\n var ControlledSubject = (function (__super__) {\n inherits(ControlledSubject, __super__);\n function ControlledSubject(enableQueue, scheduler) {\n enableQueue == null && (enableQueue = true);\n\n __super__.call(this);\n this.subject = new Subject();\n this.enableQueue = enableQueue;\n this.queue = enableQueue ? [] : null;\n this.requestedCount = 0;\n this.requestedDisposable = null;\n this.error = null;\n this.hasFailed = false;\n this.hasCompleted = false;\n this.scheduler = scheduler || currentThreadScheduler;\n }\n\n addProperties(ControlledSubject.prototype, Observer, {\n _subscribe: function (o) {\n return this.subject.subscribe(o);\n },\n onCompleted: function () {\n this.hasCompleted = true;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onCompleted();\n this.disposeCurrentRequest();\n } else {\n this.queue.push(Notification.createOnCompleted());\n }\n },\n onError: function (error) {\n this.hasFailed = true;\n this.error = error;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onError(error);\n this.disposeCurrentRequest();\n } else {\n this.queue.push(Notification.createOnError(error));\n }\n },\n onNext: function (value) {\n if (this.requestedCount <= 0) {\n this.enableQueue && this.queue.push(Notification.createOnNext(value));\n } else {\n (this.requestedCount-- === 0) && this.disposeCurrentRequest();\n this.subject.onNext(value);\n }\n },\n _processRequest: function (numberOfItems) {\n if (this.enableQueue) {\n while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) {\n var first = this.queue.shift();\n first.accept(this.subject);\n if (first.kind === 'N') {\n numberOfItems--;\n } else {\n this.disposeCurrentRequest();\n this.queue = [];\n }\n }\n }\n\n return numberOfItems;\n },\n request: function (number) {\n this.disposeCurrentRequest();\n var self = this;\n\n this.requestedDisposable = this.scheduler.schedule(number,\n function(s, i) {\n var remaining = self._processRequest(i);\n var stopped = self.hasCompleted || self.hasFailed;\n if (!stopped && remaining > 0) {\n self.requestedCount = remaining;\n\n return disposableCreate(function () {\n self.requestedCount = 0;\n });\n // Scheduled item is still in progress. Return a new\n // disposable to allow the request to be interrupted\n // via dispose.\n }\n });\n\n return this.requestedDisposable;\n },\n disposeCurrentRequest: function () {\n if (this.requestedDisposable) {\n this.requestedDisposable.dispose();\n this.requestedDisposable = null;\n }\n }\n });\n\n return ControlledSubject;\n }(Observable));\n\n /**\n * Attaches a controller to the observable sequence with the ability to queue.\n * @example\n * var source = Rx.Observable.interval(100).controlled();\n * source.request(3); // Reads 3 values\n * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request\n * @param {Scheduler} scheduler determines how the requests will be scheduled\n * @returns {Observable} The observable sequence which only propagates values on request.\n */\n observableProto.controlled = function (enableQueue, scheduler) {\n\n if (enableQueue && isScheduler(enableQueue)) {\n scheduler = enableQueue;\n enableQueue = true;\n }\n\n if (enableQueue == null) { enableQueue = true; }\n return new ControlledObservable(this, enableQueue, scheduler);\n };\n\n var StopAndWaitObservable = (function (__super__) {\n inherits(StopAndWaitObservable, __super__);\n function StopAndWaitObservable (source) {\n __super__.call(this);\n this.source = source;\n }\n\n function scheduleMethod(s, self) {\n self.source.request(1);\n }\n\n StopAndWaitObservable.prototype._subscribe = function (o) {\n this.subscription = this.source.subscribe(new StopAndWaitObserver(o, this, this.subscription));\n return new BinaryDisposable(\n this.subscription,\n defaultScheduler.schedule(this, scheduleMethod)\n );\n };\n\n var StopAndWaitObserver = (function (__sub__) {\n inherits(StopAndWaitObserver, __sub__);\n function StopAndWaitObserver (observer, observable, cancel) {\n __sub__.call(this);\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.scheduleDisposable = null;\n }\n\n StopAndWaitObserver.prototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n StopAndWaitObserver.prototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n function innerScheduleMethod(s, self) {\n self.observable.source.request(1);\n }\n\n StopAndWaitObserver.prototype.next = function (value) {\n this.observer.onNext(value);\n this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod);\n };\n\n StopAndWaitObservable.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n if (this.scheduleDisposable) {\n this.scheduleDisposable.dispose();\n this.scheduleDisposable = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return StopAndWaitObserver;\n }(AbstractObserver));\n\n return StopAndWaitObservable;\n }(Observable));\n\n\n /**\n * Attaches a stop and wait observable to the current observable.\n * @returns {Observable} A stop and wait observable.\n */\n ControlledObservable.prototype.stopAndWait = function () {\n return new StopAndWaitObservable(this);\n };\n\n var WindowedObservable = (function (__super__) {\n inherits(WindowedObservable, __super__);\n function WindowedObservable(source, windowSize) {\n __super__.call(this);\n this.source = source;\n this.windowSize = windowSize;\n }\n\n function scheduleMethod(s, self) {\n self.source.request(self.windowSize);\n }\n\n WindowedObservable.prototype._subscribe = function (o) {\n this.subscription = this.source.subscribe(new WindowedObserver(o, this, this.subscription));\n return new BinaryDisposable(\n this.subscription,\n defaultScheduler.schedule(this, scheduleMethod)\n );\n };\n\n var WindowedObserver = (function (__sub__) {\n inherits(WindowedObserver, __sub__);\n function WindowedObserver(observer, observable, cancel) {\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.received = 0;\n this.scheduleDisposable = null;\n __sub__.call(this);\n }\n\n WindowedObserver.prototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n WindowedObserver.prototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n function innerScheduleMethod(s, self) {\n self.observable.source.request(self.observable.windowSize);\n }\n\n WindowedObserver.prototype.next = function (value) {\n this.observer.onNext(value);\n this.received = ++this.received % this.observable.windowSize;\n this.received === 0 && (this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod));\n };\n\n WindowedObserver.prototype.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n if (this.scheduleDisposable) {\n this.scheduleDisposable.dispose();\n this.scheduleDisposable = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return WindowedObserver;\n }(AbstractObserver));\n\n return WindowedObservable;\n }(Observable));\n\n /**\n * Creates a sliding windowed observable based upon the window size.\n * @param {Number} windowSize The number of items in the window\n * @returns {Observable} A windowed observable based upon the window size.\n */\n ControlledObservable.prototype.windowed = function (windowSize) {\n return new WindowedObservable(this, windowSize);\n };\n\n /**\n * Pipes the existing Observable sequence into a Node.js Stream.\n * @param {Stream} dest The destination Node.js stream.\n * @returns {Stream} The destination stream.\n */\n observableProto.pipe = function (dest) {\n var source = this.pausableBuffered();\n\n function onDrain() {\n source.resume();\n }\n\n dest.addListener('drain', onDrain);\n\n source.subscribe(\n function (x) {\n !dest.write(String(x)) && source.pause();\n },\n function (err) {\n dest.emit('error', err);\n },\n function () {\n // Hack check because STDIO is not closable\n !dest._isStdio && dest.end();\n dest.removeListener('drain', onDrain);\n });\n\n source.resume();\n\n return dest;\n };\n\n var MulticastObservable = (function (__super__) {\n inherits(MulticastObservable, __super__);\n function MulticastObservable(source, fn1, fn2) {\n this.source = source;\n this._fn1 = fn1;\n this._fn2 = fn2;\n __super__.call(this);\n }\n\n MulticastObservable.prototype.subscribeCore = function (o) {\n var connectable = this.source.multicast(this._fn1());\n return new BinaryDisposable(this._fn2(connectable).subscribe(o), connectable.connect());\n };\n\n return MulticastObservable;\n }(ObservableBase));\n\n /**\n * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each\n * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's\n * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.\n *\n * @example\n * 1 - res = source.multicast(observable);\n * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });\n *\n * @param {Function|Subject} subjectOrSubjectSelector\n * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.\n * Or:\n * Subject to push source elements into.\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.value = null;\n this.error = null;\n }\n });\n\n return BehaviorSubject;\n }(Observable));\n\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.\n */\n var ReplaySubject = Rx.ReplaySubject = (function (__super__) {\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function createRemovableDisposable(subject, observer) {\n return disposableCreate(function () {\n observer.dispose();\n !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);\n });\n }\n\n inherits(ReplaySubject, __super__);\n\n /**\n * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.\n * @param {Number} [bufferSize] Maximum element count of the replay buffer.\n * @param {Number} [windowSize] Maximum time length of the replay buffer.\n * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.\n */\n function ReplaySubject(bufferSize, windowSize, scheduler) {\n this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;\n this.windowSize = windowSize == null ? maxSafeInteger : windowSize;\n this.scheduler = scheduler || currentThreadScheduler;\n this.q = [];\n this.observers = [];\n this.isStopped = false;\n this.isDisposed = false;\n this.hasError = false;\n this.error = null;\n __super__.call(this);\n }\n\n addProperties(ReplaySubject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n checkDisposed(this);\n var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so);\n\n this._trim(this.scheduler.now());\n this.observers.push(so);\n\n for (var i = 0, len = this.q.length; i < len; i++) {\n so.onNext(this.q[i].value);\n }\n\n if (this.hasError) {\n so.onError(this.error);\n } else if (this.isStopped) {\n so.onCompleted();\n }\n\n so.ensureActive();\n return subscription;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n return this.observers.length > 0;\n },\n _trim: function (now) {\n while (this.q.length > this.bufferSize) {\n this.q.shift();\n }\n while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {\n this.q.shift();\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n var now = this.scheduler.now();\n this.q.push({ interval: now, value: value });\n this._trim(now);\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onNext(value);\n observer.ensureActive();\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onError(error);\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onCompleted();\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n return ReplaySubject;\n }(Observable));\n\n var RefCountObservable = (function (__super__) {\n inherits(RefCountObservable, __super__);\n function RefCountObservable(source) {\n this.source = source;\n this._count = 0;\n this._connectableSubscription = null;\n __super__.call(this);\n }\n\n RefCountObservable.prototype.subscribeCore = function (o) {\n var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o);\n shouldConnect && (this._connectableSubscription = this.source.connect());\n return new RefCountDisposable(this, subscription);\n };\n\n function RefCountDisposable(p, s) {\n this._p = p;\n this._s = s;\n this.isDisposed = false;\n }\n\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._s.dispose();\n --this._p._count === 0 && this._p._connectableSubscription.dispose();\n }\n };\n\n return RefCountObservable;\n }(ObservableBase));\n\n var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {\n inherits(ConnectableObservable, __super__);\n function ConnectableObservable(source, subject) {\n this.source = source;\n this._hasSubscription = false;\n this._subscription = null;\n this._sourceObservable = source.asObservable();\n this._subject = subject;\n __super__.call(this);\n }\n\n function ConnectDisposable(parent) {\n this._p = parent;\n this.isDisposed = false;\n }\n\n ConnectDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n this._p._hasSubscription = false;\n }\n };\n\n ConnectableObservable.prototype.connect = function () {\n if (!this._hasSubscription) {\n this._hasSubscription = true;\n this._subscription = new BinaryDisposable(\n this._sourceObservable.subscribe(this._subject),\n new ConnectDisposable(this)\n );\n }\n return this._subscription;\n };\n\n ConnectableObservable.prototype._subscribe = function (o) {\n return this._subject.subscribe(o);\n };\n\n ConnectableObservable.prototype.refCount = function () {\n return new RefCountObservable(this);\n };\n\n return ConnectableObservable;\n }(Observable));\n\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence\n * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`)\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source.\n */\n observableProto.singleInstance = function() {\n var source = this, hasObservable = false, observable;\n\n function getObservable() {\n if (!hasObservable) {\n hasObservable = true;\n observable = source.finally(function() { hasObservable = false; }).publish().refCount();\n }\n return observable;\n }\n\n return new AnonymousObservable(function(o) {\n return getObservable().subscribe(o);\n });\n };\n\n /**\n * Correlates the elements of two sequences based on overlapping durations.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable();\n var leftDone = false, rightDone = false;\n var leftId = 0, rightId = 0;\n var leftMap = new Map(), rightMap = new Map();\n var handleError = function (e) { o.onError(e); };\n\n group.add(left.subscribe(\n function (value) {\n var id = leftId++, md = new SingleAssignmentDisposable();\n\n leftMap.set(id, value);\n group.add(md);\n\n var duration = tryCatch(leftDurationSelector)(value);\n if (duration === errorObj) { return o.onError(duration.e); }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n handleError,\n function () {\n leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted();\n group.remove(md);\n }));\n\n rightMap.forEach(function (v) {\n var result = tryCatch(resultSelector)(value, v);\n if (result === errorObj) { return o.onError(result.e); }\n o.onNext(result);\n });\n },\n handleError,\n function () {\n leftDone = true;\n (rightDone || leftMap.size === 0) && o.onCompleted();\n })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++, md = new SingleAssignmentDisposable();\n\n rightMap.set(id, value);\n group.add(md);\n\n var duration = tryCatch(rightDurationSelector)(value);\n if (duration === errorObj) { return o.onError(duration.e); }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n handleError,\n function () {\n rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted();\n group.remove(md);\n }));\n\n leftMap.forEach(function (v) {\n var result = tryCatch(resultSelector)(v, value);\n if (result === errorObj) { return o.onError(result.e); }\n o.onNext(result);\n });\n },\n handleError,\n function () {\n rightDone = true;\n (leftDone || rightMap.size === 0) && o.onCompleted();\n })\n );\n return group;\n }, left);\n };\n\n /**\n * Correlates the elements of two sequences based on overlapping durations, and groups the results.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable();\n var r = new RefCountDisposable(group);\n var leftMap = new Map(), rightMap = new Map();\n var leftId = 0, rightId = 0;\n var handleError = function (e) { return function (v) { v.onError(e); }; };\n\n function handleError(e) { };\n\n group.add(left.subscribe(\n function (value) {\n var s = new Subject();\n var id = leftId++;\n leftMap.set(id, s);\n\n var result = tryCatch(resultSelector)(value, addRef(s, r));\n if (result === errorObj) {\n leftMap.forEach(handleError(result.e));\n return o.onError(result.e);\n }\n o.onNext(result);\n\n rightMap.forEach(function (v) { s.onNext(v); });\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var duration = tryCatch(leftDurationSelector)(value);\n if (duration === errorObj) {\n leftMap.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n leftMap['delete'](id) && s.onCompleted();\n group.remove(md);\n }));\n },\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () { o.onCompleted(); })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n rightMap.set(id, value);\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var duration = tryCatch(rightDurationSelector)(value);\n if (duration === errorObj) {\n leftMap.forEach(handleError(duration.e));\n return o.onError(duration.e);\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n },\n function () {\n rightMap['delete'](id);\n group.remove(md);\n }));\n\n leftMap.forEach(function (v) { v.onNext(value); });\n },\n function (e) {\n leftMap.forEach(handleError(e));\n o.onError(e);\n })\n );\n\n return r;\n }, left);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers.\n * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.buffer = function () {\n return this.window.apply(this, arguments)\n .flatMap(toArray);\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows.\n *\n * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) {\n if (arguments.length === 1 && typeof arguments[0] !== 'function') {\n return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector);\n }\n return typeof windowOpeningsOrClosingSelector === 'function' ?\n observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) :\n observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector);\n };\n\n function observableWindowWithOpenings(windowOpenings, windowClosingSelector) {\n return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) {\n return win;\n });\n }\n\n function observableWindowWithBoundaries(windowBoundaries) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var win = new Subject(),\n d = new CompositeDisposable(),\n r = new RefCountDisposable(d);\n\n observer.onNext(addRef(win, r));\n\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries));\n\n d.add(windowBoundaries.subscribe(function (w) {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n return r;\n }, source);\n }\n\n function observableWindowWithClosingSelector(windowClosingSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n r = new RefCountDisposable(d),\n win = new Subject();\n observer.onNext(addRef(win, r));\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n function createWindowClose () {\n var windowClose;\n try {\n windowClose = windowClosingSelector();\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(windowClose) && (windowClose = observableFromPromise(windowClose));\n\n var m1 = new SingleAssignmentDisposable();\n m.setDisposable(m1);\n m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n createWindowClose();\n }));\n }\n\n createWindowClose();\n return r;\n }, source);\n }\n\n /**\n * Returns a new observable that triggers on the second and subsequent triggerings of the input observable.\n * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.\n * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.\n * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.\n */\n observableProto.pairwise = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var previous, hasPrevious = false;\n return source.subscribe(\n function (x) {\n if (hasPrevious) {\n observer.onNext([previous, x]);\n } else {\n hasPrevious = true;\n }\n previous = x;\n },\n observer.onError.bind(observer),\n observer.onCompleted.bind(observer));\n }, source);\n };\n\n /**\n * Returns two observables which partition the observations of the source by the given function.\n * The first will trigger observations for those values for which the predicate returns true.\n * The second will trigger observations for those values where the predicate returns false.\n * The predicate is executed once for each subscribed observer.\n * Both also propagate all error observations arising from the source and each completes\n * when the source completes.\n * @param {Function} predicate\n * The function to determine which output Observable will trigger a particular observation.\n * @returns {Array}\n * An array of observables. The first triggers when the predicate returns true,\n * and the second triggers when the predicate returns false.\n */\n observableProto.partition = function(predicate, thisArg) {\n return [\n this.filter(predicate, thisArg),\n this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); })\n ];\n };\n\n var WhileEnumerable = (function(__super__) {\n inherits(WhileEnumerable, __super__);\n function WhileEnumerable(c, s) {\n this.c = c;\n this.s = s;\n }\n WhileEnumerable.prototype[$iterator$] = function () {\n var self = this;\n return {\n next: function () {\n return self.c() ?\n { done: false, value: self.s } :\n { done: true, value: void 0 };\n }\n };\n };\n return WhileEnumerable;\n }(Enumerable));\n \n function enumerableWhile(condition, source) {\n return new WhileEnumerable(condition, source);\n } \n\n /**\n * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.\n * This operator allows for a fluent style of writing queries that use the same sequence multiple times.\n *\n * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.letBind = observableProto['let'] = function (func) {\n return func(this);\n };\n\n /**\n * Determines whether an observable collection contains values. \n *\n * @example\n * 1 - res = Rx.Observable.if(condition, obs1);\n * 2 - res = Rx.Observable.if(condition, obs1, obs2);\n * 3 - res = Rx.Observable.if(condition, obs1, scheduler);\n * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.\n * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.\n * @returns {Observable} An observable sequence which is either the thenSource or elseSource.\n */\n Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) {\n return observableDefer(function () {\n elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());\n\n isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));\n isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));\n\n // Assume a scheduler for empty only\n typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));\n return condition() ? thenSource : elseSourceOrScheduler;\n });\n };\n\n /**\n * Concatenates the observable sequences obtained by running the specified result selector for each element in source.\n * There is an alias for this method called 'forIn' for browsers 0) {\n isOwner = !isAcquired;\n isAcquired = true;\n }\n if (isOwner) {\n m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) {\n var work;\n if (q.length > 0) {\n work = q.shift();\n } else {\n isAcquired = false;\n return;\n }\n var m1 = new SingleAssignmentDisposable();\n d.add(m1);\n m1.setDisposable(work.subscribe(function (x) {\n o.onNext(x);\n var result = null;\n try {\n result = selector(x);\n } catch (e) {\n o.onError(e);\n }\n q.push(result);\n activeCount++;\n ensureActive();\n }, function (e) { o.onError(e); }, function () {\n d.remove(m1);\n activeCount--;\n if (activeCount === 0) {\n o.onCompleted();\n }\n }));\n self();\n }));\n }\n };\n\n q.push(source);\n activeCount++;\n ensureActive();\n return d;\n }, this);\n };\n\n /**\n * Runs all observable sequences in parallel and collect their last elements.\n *\n * @example\n * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);\n * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);\n * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.\n */\n Observable.forkJoin = function () {\n var allSources = [];\n if (Array.isArray(arguments[0])) {\n allSources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (subscriber) {\n var count = allSources.length;\n if (count === 0) {\n subscriber.onCompleted();\n return disposableEmpty;\n }\n var group = new CompositeDisposable(),\n finished = false,\n hasResults = new Array(count),\n hasCompleted = new Array(count),\n results = new Array(count);\n\n for (var idx = 0; idx < count; idx++) {\n (function (i) {\n var source = allSources[i];\n isPromise(source) && (source = observableFromPromise(source));\n group.add(\n source.subscribe(\n function (value) {\n if (!finished) {\n hasResults[i] = true;\n results[i] = value;\n }\n },\n function (e) {\n finished = true;\n subscriber.onError(e);\n group.dispose();\n },\n function () {\n if (!finished) {\n if (!hasResults[i]) {\n subscriber.onCompleted();\n return;\n }\n hasCompleted[i] = true;\n for (var ix = 0; ix < count; ix++) {\n if (!hasCompleted[ix]) { return; }\n }\n finished = true;\n subscriber.onNext(results);\n subscriber.onCompleted();\n }\n }));\n })(idx);\n }\n\n return group;\n });\n };\n\n /**\n * Runs two observable sequences in parallel and combines their last elemenets.\n * @param {Observable} second Second observable sequence.\n * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.\n * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.\n */\n observableProto.forkJoin = function (second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (observer) {\n var leftStopped = false, rightStopped = false,\n hasLeft = false, hasRight = false,\n lastLeft, lastRight,\n leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(second) && (second = observableFromPromise(second));\n\n leftSubscription.setDisposable(\n first.subscribe(function (left) {\n hasLeft = true;\n lastLeft = left;\n }, function (err) {\n rightSubscription.dispose();\n observer.onError(err);\n }, function () {\n leftStopped = true;\n if (rightStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result = tryCatch(resultSelector)(lastLeft, lastRight);\n if (result === errorObj) { return observer.onError(e); }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n rightSubscription.setDisposable(\n second.subscribe(function (right) {\n hasRight = true;\n lastRight = right;\n }, function (err) {\n leftSubscription.dispose();\n observer.onError(err);\n }, function () {\n rightStopped = true;\n if (leftStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result = tryCatch(resultSelector)(lastLeft, lastRight);\n if (result === errorObj) { return observer.onError(result.e); }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n return new BinaryDisposable(leftSubscription, rightSubscription);\n }, first);\n };\n\n /**\n * Comonadic bind operator.\n * @param {Function} selector A transform function to apply to each element.\n * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.\n * @returns {Observable} An observable sequence which results from the comonadic bind operation.\n */\n observableProto.manySelect = observableProto.extend = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return observableDefer(function () {\n var chain;\n\n return source\n .map(function (x) {\n var curr = new ChainObservable(x);\n\n chain && chain.onNext(x);\n chain = curr;\n\n return curr;\n })\n .tap(\n noop,\n function (e) { chain && chain.onError(e); },\n function () { chain && chain.onCompleted(); }\n )\n .observeOn(scheduler)\n .map(selector);\n }, source);\n };\n\n var ChainObservable = (function (__super__) {\n inherits(ChainObservable, __super__);\n function ChainObservable(head) {\n __super__.call(this);\n this.head = head;\n this.tail = new AsyncSubject();\n }\n\n addProperties(ChainObservable.prototype, Observer, {\n _subscribe: function (o) {\n var g = new CompositeDisposable();\n g.add(currentThreadScheduler.schedule(this, function (_, self) {\n o.onNext(self.head);\n g.add(self.tail.mergeAll().subscribe(o));\n }));\n\n return g;\n },\n onCompleted: function () {\n this.onNext(Observable.empty());\n },\n onError: function (e) {\n this.onNext(Observable['throw'](e));\n },\n onNext: function (v) {\n this.tail.onNext(v);\n this.tail.onCompleted();\n }\n });\n\n return ChainObservable;\n\n }(Observable));\n\n var Map = root.Map || (function () {\n function Map() {\n this.size = 0;\n this._values = [];\n this._keys = [];\n }\n\n Map.prototype['delete'] = function (key) {\n var i = this._keys.indexOf(key);\n if (i === -1) { return false; }\n this._values.splice(i, 1);\n this._keys.splice(i, 1);\n this.size--;\n return true;\n };\n\n Map.prototype.get = function (key) {\n var i = this._keys.indexOf(key);\n return i === -1 ? undefined : this._values[i];\n };\n\n Map.prototype.set = function (key, value) {\n var i = this._keys.indexOf(key);\n if (i === -1) {\n this._keys.push(key);\n this._values.push(value);\n this.size++;\n } else {\n this._values[i] = value;\n }\n return this;\n };\n\n Map.prototype.forEach = function (cb, thisArg) {\n for (var i = 0; i < this.size; i++) {\n cb.call(thisArg, this._values[i], this._keys[i]);\n }\n };\n\n return Map;\n }());\n\n /**\n * @constructor\n * Represents a join pattern over observable sequences.\n */\n function Pattern(patterns) {\n this.patterns = patterns;\n }\n\n /**\n * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.\n * @param other Observable sequence to match in addition to the current pattern.\n * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.\n */\n Pattern.prototype.and = function (other) {\n return new Pattern(this.patterns.concat(other));\n };\n\n /**\n * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.\n * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.\n * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n Pattern.prototype.thenDo = function (selector) {\n return new Plan(this, selector);\n };\n\n function Plan(expression, selector) {\n this.expression = expression;\n this.selector = selector;\n }\n\n Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {\n var self = this;\n var joinObservers = [];\n for (var i = 0, len = this.expression.patterns.length; i < len; i++) {\n joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));\n }\n var activePlan = new ActivePlan(joinObservers, function () {\n var result;\n try {\n result = self.selector.apply(self, arguments);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n }, function () {\n for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {\n joinObservers[j].removeActivePlan(activePlan);\n }\n deactivate(activePlan);\n });\n for (i = 0, len = joinObservers.length; i < len; i++) {\n joinObservers[i].addActivePlan(activePlan);\n }\n return activePlan;\n };\n\n function planCreateObserver(externalSubscriptions, observable, onError) {\n var entry = externalSubscriptions.get(observable);\n if (!entry) {\n var observer = new JoinObserver(observable, onError);\n externalSubscriptions.set(observable, observer);\n return observer;\n }\n return entry;\n }\n\n function ActivePlan(joinObserverArray, onNext, onCompleted) {\n this.joinObserverArray = joinObserverArray;\n this.onNext = onNext;\n this.onCompleted = onCompleted;\n this.joinObservers = new Map();\n for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {\n var joinObserver = this.joinObserverArray[i];\n this.joinObservers.set(joinObserver, joinObserver);\n }\n }\n\n ActivePlan.prototype.dequeue = function () {\n this.joinObservers.forEach(function (v) { v.queue.shift(); });\n };\n\n ActivePlan.prototype.match = function () {\n var i, len, hasValues = true;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n if (this.joinObserverArray[i].queue.length === 0) {\n hasValues = false;\n break;\n }\n }\n if (hasValues) {\n var firstValues = [],\n isCompleted = false;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n firstValues.push(this.joinObserverArray[i].queue[0]);\n this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);\n }\n if (isCompleted) {\n this.onCompleted();\n } else {\n this.dequeue();\n var values = [];\n for (i = 0, len = firstValues.length; i < firstValues.length; i++) {\n values.push(firstValues[i].value);\n }\n this.onNext.apply(this, values);\n }\n }\n };\n\n var JoinObserver = (function (__super__) {\n inherits(JoinObserver, __super__);\n\n function JoinObserver(source, onError) {\n __super__.call(this);\n this.source = source;\n this.onError = onError;\n this.queue = [];\n this.activePlans = [];\n this.subscription = new SingleAssignmentDisposable();\n this.isDisposed = false;\n }\n\n var JoinObserverPrototype = JoinObserver.prototype;\n\n JoinObserverPrototype.next = function (notification) {\n if (!this.isDisposed) {\n if (notification.kind === 'E') {\n return this.onError(notification.error);\n }\n this.queue.push(notification);\n var activePlans = this.activePlans.slice(0);\n for (var i = 0, len = activePlans.length; i < len; i++) {\n activePlans[i].match();\n }\n }\n };\n\n JoinObserverPrototype.error = noop;\n JoinObserverPrototype.completed = noop;\n\n JoinObserverPrototype.addActivePlan = function (activePlan) {\n this.activePlans.push(activePlan);\n };\n\n JoinObserverPrototype.subscribe = function () {\n this.subscription.setDisposable(this.source.materialize().subscribe(this));\n };\n\n JoinObserverPrototype.removeActivePlan = function (activePlan) {\n this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);\n this.activePlans.length === 0 && this.dispose();\n };\n\n JoinObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n if (!this.isDisposed) {\n this.isDisposed = true;\n this.subscription.dispose();\n }\n };\n\n return JoinObserver;\n } (AbstractObserver));\n\n /**\n * Creates a pattern that matches when both observable sequences have an available value.\n *\n * @param right Observable sequence to match with the current sequence.\n * @return {Pattern} Pattern object that matches when both observable sequences have an available value.\n */\n observableProto.and = function (right) {\n return new Pattern([this, right]);\n };\n\n /**\n * Matches when the observable sequence has an available value and projects the value.\n *\n * @param {Function} selector Selector that will be invoked for values in the source sequence.\n * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n observableProto.thenDo = function (selector) {\n return new Pattern([this]).thenDo(selector);\n };\n\n /**\n * Joins together the results from several patterns.\n *\n * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.\n * @returns {Observable} Observable sequence with the results form matching several patterns.\n */\n Observable.when = function () {\n var len = arguments.length, plans;\n if (Array.isArray(arguments[0])) {\n plans = arguments[0];\n } else {\n plans = new Array(len);\n for(var i = 0; i < len; i++) { plans[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var activePlans = [],\n externalSubscriptions = new Map();\n var outObserver = observerCreate(\n function (x) { o.onNext(x); },\n function (err) {\n externalSubscriptions.forEach(function (v) { v.onError(err); });\n o.onError(err);\n },\n function (x) { o.onCompleted(); }\n );\n try {\n for (var i = 0, len = plans.length; i < len; i++) {\n activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {\n var idx = activePlans.indexOf(activePlan);\n activePlans.splice(idx, 1);\n activePlans.length === 0 && o.onCompleted();\n }));\n }\n } catch (e) {\n observableThrow(e).subscribe(o);\n }\n var group = new CompositeDisposable();\n externalSubscriptions.forEach(function (joinObserver) {\n joinObserver.subscribe();\n group.add(joinObserver);\n });\n\n return group;\n });\n };\n\n var TimerObservable = (function(__super__) {\n inherits(TimerObservable, __super__);\n function TimerObservable(dt, s) {\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n TimerObservable.prototype.subscribeCore = function (o) {\n return this._s.scheduleFuture(o, this._dt, scheduleMethod);\n };\n\n function scheduleMethod(s, o) {\n o.onNext(0);\n o.onCompleted();\n }\n\n return TimerObservable;\n }(ObservableBase));\n\n function _observableTimer(dueTime, scheduler) {\n return new TimerObservable(dueTime, scheduler);\n }\n\n function observableTimerDateAndPeriod(dueTime, period, scheduler) {\n return new AnonymousObservable(function (observer) {\n var d = dueTime, p = normalizeTime(period);\n return scheduler.scheduleRecursiveFuture(0, d, function (count, self) {\n if (p > 0) {\n var now = scheduler.now();\n d = d + p;\n d <= now && (d = now + p);\n }\n observer.onNext(count);\n self(count + 1, new Date(d));\n });\n });\n }\n\n function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) {\n return dueTime === period ?\n new AnonymousObservable(function (observer) {\n return scheduler.schedulePeriodic(0, period, function (count) {\n observer.onNext(count);\n return count + 1;\n });\n }) :\n observableDefer(function () {\n return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler);\n });\n }\n\n /**\n * Returns an observable sequence that produces a value after each period.\n *\n * @example\n * 1 - res = Rx.Observable.interval(1000);\n * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);\n *\n * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.\n * @returns {Observable} An observable sequence that produces a value after each period.\n */\n var observableinterval = Observable.interval = function (period, scheduler) {\n return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler);\n };\n\n /**\n * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.\n * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.\n */\n var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) {\n var period;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n if (periodOrScheduler != null && typeof periodOrScheduler === 'number') {\n period = periodOrScheduler;\n } else if (isScheduler(periodOrScheduler)) {\n scheduler = periodOrScheduler;\n }\n if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) {\n return _observableTimer(dueTime, scheduler);\n }\n if (dueTime instanceof Date && period !== undefined) {\n return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler);\n }\n return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler);\n };\n\n function observableDelayRelative(source, dueTime, scheduler) {\n return new AnonymousObservable(function (o) {\n var active = false,\n cancelable = new SerialDisposable(),\n exception = null,\n q = [],\n running = false,\n subscription;\n subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) {\n var d, shouldRun;\n if (notification.value.kind === 'E') {\n q = [];\n q.push(notification);\n exception = notification.value.error;\n shouldRun = !running;\n } else {\n q.push({ value: notification.value, timestamp: notification.timestamp + dueTime });\n shouldRun = !active;\n active = true;\n }\n if (shouldRun) {\n if (exception !== null) {\n o.onError(exception);\n } else {\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) {\n var e, recurseDueTime, result, shouldRecurse;\n if (exception !== null) {\n return;\n }\n running = true;\n do {\n result = null;\n if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) {\n result = q.shift().value;\n }\n if (result !== null) {\n result.accept(o);\n }\n } while (result !== null);\n shouldRecurse = false;\n recurseDueTime = 0;\n if (q.length > 0) {\n shouldRecurse = true;\n recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now());\n } else {\n active = false;\n }\n e = exception;\n running = false;\n if (e !== null) {\n o.onError(e);\n } else if (shouldRecurse) {\n self(null, recurseDueTime);\n }\n }));\n }\n }\n });\n return new BinaryDisposable(subscription, cancelable);\n }, source);\n }\n\n function observableDelayAbsolute(source, dueTime, scheduler) {\n return observableDefer(function () {\n return observableDelayRelative(source, dueTime - scheduler.now(), scheduler);\n });\n }\n\n function delayWithSelector(source, subscriptionDelay, delayDurationSelector) {\n var subDelay, selector;\n if (isFunction(subscriptionDelay)) {\n selector = subscriptionDelay;\n } else {\n subDelay = subscriptionDelay;\n selector = delayDurationSelector;\n }\n return new AnonymousObservable(function (o) {\n var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();\n\n function start() {\n subscription.setDisposable(source.subscribe(\n function (x) {\n var delay = tryCatch(selector)(x);\n if (delay === errorObj) { return o.onError(delay.e); }\n var d = new SingleAssignmentDisposable();\n delays.add(d);\n d.setDisposable(delay.subscribe(\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(x);\n delays.remove(d);\n done();\n }\n ));\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n subscription.dispose();\n done();\n }\n ));\n }\n\n function done () {\n atEnd && delays.length === 0 && o.onCompleted();\n }\n\n if (!subDelay) {\n start();\n } else {\n subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start));\n }\n\n return new BinaryDisposable(subscription, delays);\n }, this);\n }\n\n /**\n * Time shifts the observable sequence by dueTime.\n * The relative time intervals between the values are preserved.\n *\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delay = function () {\n var firstArg = arguments[0];\n if (typeof firstArg === 'number' || firstArg instanceof Date) {\n var dueTime = firstArg, scheduler = arguments[1];\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return dueTime instanceof Date ?\n observableDelayAbsolute(this, dueTime, scheduler) :\n observableDelayRelative(this, dueTime, scheduler);\n } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) {\n return delayWithSelector(this, firstArg, arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n var DebounceObservable = (function (__super__) {\n inherits(DebounceObservable, __super__);\n function DebounceObservable(source, dt, s) {\n isScheduler(s) || (s = defaultScheduler);\n this.source = source;\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n DebounceObservable.prototype.subscribeCore = function (o) {\n var cancelable = new SerialDisposable();\n return new BinaryDisposable(\n this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)),\n cancelable);\n };\n\n return DebounceObservable;\n }(ObservableBase));\n\n var DebounceObserver = (function (__super__) {\n inherits(DebounceObserver, __super__);\n function DebounceObserver(observer, source, dueTime, scheduler, cancelable) {\n this._o = observer;\n this._s = source;\n this._d = dueTime;\n this._scheduler = scheduler;\n this._c = cancelable;\n this._v = null;\n this._hv = false;\n this._id = 0;\n __super__.call(this);\n }\n\n DebounceObserver.prototype.next = function (x) {\n this._hv = true;\n this._v = x;\n var currentId = ++this._id, d = new SingleAssignmentDisposable();\n this._c.setDisposable(d);\n d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) {\n self._hv && self._id === currentId && self._o.onNext(x);\n self._hv = false;\n }));\n };\n\n DebounceObserver.prototype.error = function (e) {\n this._c.dispose();\n this._o.onError(e);\n this._hv = false;\n this._id++;\n };\n\n DebounceObserver.prototype.completed = function () {\n this._c.dispose();\n this._hv && this._o.onNext(this._v);\n this._o.onCompleted();\n this._hv = false;\n this._id++;\n };\n\n return DebounceObserver;\n }(AbstractObserver));\n\n function debounceWithSelector(source, durationSelector) {\n return new AnonymousObservable(function (o) {\n var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;\n var subscription = source.subscribe(\n function (x) {\n var throttle = tryCatch(durationSelector)(x);\n if (throttle === errorObj) { return o.onError(throttle.e); }\n\n isPromise(throttle) && (throttle = observableFromPromise(throttle));\n\n hasValue = true;\n value = x;\n id++;\n var currentid = id, d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(throttle.subscribe(\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n },\n function (e) { o.onError(e); },\n function () {\n hasValue && id === currentid && o.onNext(value);\n hasValue = false;\n d.dispose();\n }\n ));\n },\n function (e) {\n cancelable.dispose();\n o.onError(e);\n hasValue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasValue && o.onNext(value);\n o.onCompleted();\n hasValue = false;\n id++;\n }\n );\n return new BinaryDisposable(subscription, cancelable);\n }, source);\n }\n\n observableProto.debounce = function () {\n if (isFunction (arguments[0])) {\n return debounceWithSelector(this, arguments[0]);\n } else if (typeof arguments[0] === 'number') {\n return new DebounceObservable(this, arguments[0], arguments[1]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.\n * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n var source = this, timeShift;\n timeShiftOrScheduler == null && (timeShift = timeSpan);\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n if (typeof timeShiftOrScheduler === 'number') {\n timeShift = timeShiftOrScheduler;\n } else if (isScheduler(timeShiftOrScheduler)) {\n timeShift = timeSpan;\n scheduler = timeShiftOrScheduler;\n }\n return new AnonymousObservable(function (observer) {\n var groupDisposable,\n nextShift = timeShift,\n nextSpan = timeSpan,\n q = [],\n refCountDisposable,\n timerD = new SerialDisposable(),\n totalTime = 0;\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n function createTimer () {\n var m = new SingleAssignmentDisposable(),\n isSpan = false,\n isShift = false;\n timerD.setDisposable(m);\n if (nextSpan === nextShift) {\n isSpan = true;\n isShift = true;\n } else if (nextSpan < nextShift) {\n isSpan = true;\n } else {\n isShift = true;\n }\n var newTotalTime = isSpan ? nextSpan : nextShift,\n ts = newTotalTime - totalTime;\n totalTime = newTotalTime;\n if (isSpan) {\n nextSpan += timeShift;\n }\n if (isShift) {\n nextShift += timeShift;\n }\n m.setDisposable(scheduler.scheduleFuture(null, ts, function () {\n if (isShift) {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n isSpan && q.shift().onCompleted();\n createTimer();\n }));\n };\n q.push(new Subject());\n observer.onNext(addRef(q[0], refCountDisposable));\n createTimer();\n groupDisposable.add(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n },\n function (e) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); }\n observer.onError(e);\n },\n function () {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n /**\n * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a window.\n * @param {Number} count Maximum element count of a window.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new AnonymousObservable(function (observer) {\n var timerD = new SerialDisposable(),\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n n = 0,\n windowId = 0,\n s = new Subject();\n\n function createTimer(id) {\n var m = new SingleAssignmentDisposable();\n timerD.setDisposable(m);\n m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () {\n if (id !== windowId) { return; }\n n = 0;\n var newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(newId);\n }));\n }\n\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(0);\n\n groupDisposable.add(source.subscribe(\n function (x) {\n var newId = 0, newWindow = false;\n s.onNext(x);\n if (++n === count) {\n newWindow = true;\n n = 0;\n newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n }\n newWindow && createTimer(newId);\n },\n function (e) {\n s.onError(e);\n observer.onError(e);\n }, function () {\n s.onCompleted();\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.\n * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.\n * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray);\n };\n\n function toArray(x) { return x.toArray(); }\n\n /**\n * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a buffer.\n * @param {Number} count Maximum element count of a buffer.\n * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) {\n return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray);\n };\n\n var TimeIntervalObservable = (function (__super__) {\n inherits(TimeIntervalObservable, __super__);\n function TimeIntervalObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n TimeIntervalObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TimeIntervalObserver(o, this._s));\n };\n\n return TimeIntervalObservable;\n }(ObservableBase));\n\n var TimeIntervalObserver = (function (__super__) {\n inherits(TimeIntervalObserver, __super__);\n\n function TimeIntervalObserver(o, s) {\n this._o = o;\n this._s = s;\n this._l = s.now();\n __super__.call(this);\n }\n\n TimeIntervalObserver.prototype.next = function (x) {\n var now = this._s.now(), span = now - this._l;\n this._l = now;\n this._o.onNext({ value: x, interval: span });\n };\n TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); };\n TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return TimeIntervalObserver;\n }(AbstractObserver));\n\n /**\n * Records the time interval between consecutive values in an observable sequence.\n *\n * @example\n * 1 - res = source.timeInterval();\n * 2 - res = source.timeInterval(Rx.Scheduler.timeout);\n *\n * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence with time interval information on values.\n */\n observableProto.timeInterval = function (scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TimeIntervalObservable(this, scheduler);\n };\n\n var TimestampObservable = (function (__super__) {\n inherits(TimestampObservable, __super__);\n function TimestampObservable(source, s) {\n this.source = source;\n this._s = s;\n __super__.call(this);\n }\n\n TimestampObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TimestampObserver(o, this._s));\n };\n\n return TimestampObservable;\n }(ObservableBase));\n\n var TimestampObserver = (function (__super__) {\n inherits(TimestampObserver, __super__);\n function TimestampObserver(o, s) {\n this._o = o;\n this._s = s;\n __super__.call(this);\n }\n\n TimestampObserver.prototype.next = function (x) {\n this._o.onNext({ value: x, timestamp: this._s.now() });\n };\n\n TimestampObserver.prototype.error = function (e) {\n this._o.onError(e);\n };\n\n TimestampObserver.prototype.completed = function () {\n this._o.onCompleted();\n };\n\n return TimestampObserver;\n }(AbstractObserver));\n\n /**\n * Records the timestamp for each value in an observable sequence.\n *\n * @example\n * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }\n * 2 - res = source.timestamp(Rx.Scheduler.default);\n *\n * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.\n * @returns {Observable} An observable sequence with timestamp information on values.\n */\n observableProto.timestamp = function (scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TimestampObservable(this, scheduler);\n };\n\n function sampleObservable(source, sampler) {\n return new AnonymousObservable(function (o) {\n var atEnd = false, value, hasValue = false;\n\n function sampleSubscribe() {\n if (hasValue) {\n hasValue = false;\n o.onNext(value);\n }\n atEnd && o.onCompleted();\n }\n\n var sourceSubscription = new SingleAssignmentDisposable();\n sourceSubscription.setDisposable(source.subscribe(\n function (newValue) {\n hasValue = true;\n value = newValue;\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n sourceSubscription.dispose();\n }\n ));\n\n return new BinaryDisposable(\n sourceSubscription,\n sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe)\n );\n }, source);\n }\n\n /**\n * Samples the observable sequence at each interval.\n *\n * @example\n * 1 - res = source.sample(sampleObservable); // Sampler tick sequence\n * 2 - res = source.sample(5000); // 5 seconds\n * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds\n *\n * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.\n * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Sampled observable sequence.\n */\n observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return typeof intervalOrSampler === 'number' ?\n sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :\n sampleObservable(this, intervalOrSampler);\n };\n\n var TimeoutError = Rx.TimeoutError = function(message) {\n this.message = message || 'Timeout has occurred';\n this.name = 'TimeoutError';\n Error.call(this);\n };\n TimeoutError.prototype = Object.create(Error.prototype);\n\n function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) {\n if (isFunction(firstTimeout)) {\n other = timeoutDurationSelector;\n timeoutDurationSelector = firstTimeout;\n firstTimeout = observableNever();\n }\n other || (other = observableThrow(new TimeoutError()));\n return new AnonymousObservable(function (o) {\n var subscription = new SerialDisposable(),\n timer = new SerialDisposable(),\n original = new SingleAssignmentDisposable();\n\n subscription.setDisposable(original);\n\n var id = 0, switched = false;\n\n function setTimer(timeout) {\n var myId = id, d = new SingleAssignmentDisposable();\n\n function timerWins() {\n switched = (myId === id);\n return switched;\n }\n\n timer.setDisposable(d);\n d.setDisposable(timeout.subscribe(function () {\n timerWins() && subscription.setDisposable(other.subscribe(o));\n d.dispose();\n }, function (e) {\n timerWins() && o.onError(e);\n }, function () {\n timerWins() && subscription.setDisposable(other.subscribe(o));\n }));\n };\n\n setTimer(firstTimeout);\n\n function oWins() {\n var res = !switched;\n if (res) { id++; }\n return res;\n }\n\n original.setDisposable(source.subscribe(function (x) {\n if (oWins()) {\n o.onNext(x);\n var timeout = tryCatch(timeoutDurationSelector)(x);\n if (timeout === errorObj) { return o.onError(timeout.e); }\n setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);\n }\n }, function (e) {\n oWins() && o.onError(e);\n }, function () {\n oWins() && o.onCompleted();\n }));\n return new BinaryDisposable(subscription, timer);\n }, source);\n }\n\n function timeout(source, dueTime, other, scheduler) {\n if (isScheduler(other)) {\n scheduler = other;\n other = observableThrow(new TimeoutError());\n }\n if (other instanceof Error) { other = observableThrow(other); }\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n\n return new AnonymousObservable(function (o) {\n var id = 0,\n original = new SingleAssignmentDisposable(),\n subscription = new SerialDisposable(),\n switched = false,\n timer = new SerialDisposable();\n\n subscription.setDisposable(original);\n\n function createTimer() {\n var myId = id;\n timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () {\n switched = id === myId;\n if (switched) {\n isPromise(other) && (other = observableFromPromise(other));\n subscription.setDisposable(other.subscribe(o));\n }\n }));\n }\n\n createTimer();\n\n original.setDisposable(source.subscribe(function (x) {\n if (!switched) {\n id++;\n o.onNext(x);\n createTimer();\n }\n }, function (e) {\n if (!switched) {\n id++;\n o.onError(e);\n }\n }, function () {\n if (!switched) {\n id++;\n o.onCompleted();\n }\n }));\n return new BinaryDisposable(subscription, timer);\n }, source);\n }\n\n observableProto.timeout = function () {\n var firstArg = arguments[0];\n if (firstArg instanceof Date || typeof firstArg === 'number') {\n return timeout(this, firstArg, arguments[1], arguments[2]);\n } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) {\n return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]);\n } else {\n throw new Error('Invalid arguments');\n }\n };\n\n var GenerateAbsoluteObservable = (function (__super__) {\n inherits(GenerateAbsoluteObservable, __super__);\n function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._timeFn = timeFn;\n this._s = s;\n this._first = true;\n this._hasResult = false;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n self._hasResult && self._o.onNext(self._state);\n\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n self._hasResult = tryCatch(self._cndFn)(self._state);\n if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); }\n if (self._hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n var time = tryCatch(self._timeFn)(self._state);\n if (time === errorObj) { return self._o.onError(time.e); }\n recurse(self, time);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateAbsoluteObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive);\n };\n\n return GenerateAbsoluteObservable;\n }(ObservableBase));\n\n /**\n * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithAbsoluteTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return new Date(); }\n * });\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler);\n };\n\n var GenerateRelativeObservable = (function (__super__) {\n inherits(GenerateRelativeObservable, __super__);\n function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) {\n this._state = state;\n this._cndFn = cndFn;\n this._itrFn = itrFn;\n this._resFn = resFn;\n this._timeFn = timeFn;\n this._s = s;\n this._first = true;\n this._hasResult = false;\n __super__.call(this);\n }\n\n function scheduleRecursive(self, recurse) {\n self._hasResult && self._o.onNext(self._state);\n\n if (self._first) {\n self._first = false;\n } else {\n self._state = tryCatch(self._itrFn)(self._state);\n if (self._state === errorObj) { return self._o.onError(self._state.e); }\n }\n self._hasResult = tryCatch(self._cndFn)(self._state);\n if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); }\n if (self._hasResult) {\n var result = tryCatch(self._resFn)(self._state);\n if (result === errorObj) { return self._o.onError(result.e); }\n var time = tryCatch(self._timeFn)(self._state);\n if (time === errorObj) { return self._o.onError(time.e); }\n recurse(self, time);\n } else {\n self._o.onCompleted();\n }\n }\n\n GenerateRelativeObservable.prototype.subscribeCore = function (o) {\n this._o = o;\n return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive);\n };\n\n return GenerateRelativeObservable;\n }(ObservableBase));\n\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithRelativeTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return 500; }\n * );\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler);\n };\n\n var DelaySubscription = (function(__super__) {\n inherits(DelaySubscription, __super__);\n function DelaySubscription(source, dt, s) {\n this.source = source;\n this._dt = dt;\n this._s = s;\n __super__.call(this);\n }\n\n DelaySubscription.prototype.subscribeCore = function (o) {\n var d = new SerialDisposable();\n\n d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod));\n\n return d;\n };\n\n function scheduleMethod(s, state) {\n var source = state[0], o = state[1], d = state[2];\n d.setDisposable(source.subscribe(o));\n }\n\n return DelaySubscription;\n }(ObservableBase));\n\n /**\n * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.delaySubscription(5000); // 5s\n * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds\n *\n * @param {Number} dueTime Relative or absolute time shift of the subscription.\n * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delaySubscription = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new DelaySubscription(this, dueTime, scheduler);\n };\n\n var SkipLastWithTimeObservable = (function (__super__) {\n inherits(SkipLastWithTimeObservable, __super__);\n function SkipLastWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n SkipLastWithTimeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new SkipLastWithTimeObserver(o, this));\n };\n\n return SkipLastWithTimeObservable;\n }(ObservableBase));\n\n var SkipLastWithTimeObserver = (function (__super__) {\n inherits(SkipLastWithTimeObserver, __super__);\n\n function SkipLastWithTimeObserver(o, p) {\n this._o = o;\n this._s = p._s;\n this._d = p._d;\n this._q = [];\n __super__.call(this);\n }\n\n SkipLastWithTimeObserver.prototype.next = function (x) {\n var now = this._s.now();\n this._q.push({ interval: now, value: x });\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._o.onNext(this._q.shift().value);\n }\n };\n SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipLastWithTimeObserver.prototype.completed = function () {\n var now = this._s.now();\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._o.onNext(this._q.shift().value);\n }\n this._o.onCompleted();\n };\n\n return SkipLastWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for skipping elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.\n */\n observableProto.skipLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipLastWithTimeObservable(this, duration, scheduler);\n };\n\n var TakeLastWithTimeObservable = (function (__super__) {\n inherits(TakeLastWithTimeObservable, __super__);\n function TakeLastWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n TakeLastWithTimeObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s));\n };\n\n return TakeLastWithTimeObservable;\n }(ObservableBase));\n\n var TakeLastWithTimeObserver = (function (__super__) {\n inherits(TakeLastWithTimeObserver, __super__);\n\n function TakeLastWithTimeObserver(o, d, s) {\n this._o = o;\n this._d = d;\n this._s = s;\n this._q = [];\n __super__.call(this);\n }\n\n TakeLastWithTimeObserver.prototype.next = function (x) {\n var now = this._s.now();\n this._q.push({ interval: now, value: x });\n while (this._q.length > 0 && now - this._q[0].interval >= this._d) {\n this._q.shift();\n }\n };\n TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n TakeLastWithTimeObserver.prototype.completed = function () {\n var now = this._s.now();\n while (this._q.length > 0) {\n var next = this._q.shift();\n if (now - next.interval <= this._d) { this._o.onNext(next.value); }\n }\n this._o.onCompleted();\n };\n\n return TakeLastWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TakeLastWithTimeObservable(this, duration, scheduler);\n };\n\n /**\n * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastBufferWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now(), res = [];\n while (q.length > 0) {\n var next = q.shift();\n now - next.interval <= duration && res.push(next.value);\n }\n o.onNext(res);\n o.onCompleted();\n });\n }, source);\n };\n\n var TakeWithTimeObservable = (function (__super__) {\n inherits(TakeWithTimeObservable, __super__);\n function TakeWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n __super__.call(this);\n }\n\n function scheduleMethod(s, o) {\n o.onCompleted();\n }\n\n TakeWithTimeObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(\n this._s.scheduleFuture(o, this._d, scheduleMethod),\n this.source.subscribe(o)\n );\n };\n\n return TakeWithTimeObservable;\n }(ObservableBase));\n\n /**\n * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.takeWithTime(5000, [optional scheduler]);\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.\n */\n observableProto.takeWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new TakeWithTimeObservable(this, duration, scheduler);\n };\n\n var SkipWithTimeObservable = (function (__super__) {\n inherits(SkipWithTimeObservable, __super__);\n function SkipWithTimeObservable(source, d, s) {\n this.source = source;\n this._d = d;\n this._s = s;\n this._open = false;\n __super__.call(this);\n }\n\n function scheduleMethod(s, self) {\n self._open = true;\n }\n\n SkipWithTimeObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(\n this._s.scheduleFuture(this, this._d, scheduleMethod),\n this.source.subscribe(new SkipWithTimeObserver(o, this))\n );\n };\n\n return SkipWithTimeObservable;\n }(ObservableBase));\n\n var SkipWithTimeObserver = (function (__super__) {\n inherits(SkipWithTimeObserver, __super__);\n\n function SkipWithTimeObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };\n SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipWithTimeObserver;\n }(AbstractObserver));\n\n /**\n * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.\n * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded\n * may not execute immediately, despite the zero due time.\n *\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.\n * @param {Number} duration Duration for skipping elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.\n */\n observableProto.skipWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipWithTimeObservable(this, duration, scheduler);\n };\n\n var SkipUntilWithTimeObservable = (function (__super__) {\n inherits(SkipUntilWithTimeObservable, __super__);\n function SkipUntilWithTimeObservable(source, startTime, scheduler) {\n this.source = source;\n this._st = startTime;\n this._s = scheduler;\n __super__.call(this);\n }\n\n function scheduleMethod(s, state) {\n state._open = true;\n }\n\n SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) {\n this._open = false;\n return new BinaryDisposable(\n this._s.scheduleFuture(this, this._st, scheduleMethod),\n this.source.subscribe(new SkipUntilWithTimeObserver(o, this))\n );\n };\n\n return SkipUntilWithTimeObservable;\n }(ObservableBase));\n\n var SkipUntilWithTimeObserver = (function (__super__) {\n inherits(SkipUntilWithTimeObserver, __super__);\n\n function SkipUntilWithTimeObserver(o, p) {\n this._o = o;\n this._p = p;\n __super__.call(this);\n }\n\n SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); };\n SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); };\n SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); };\n\n return SkipUntilWithTimeObserver;\n }(AbstractObserver));\n\n\n /**\n * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.\n *\n * @examples\n * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);\n * 2 - res = source.skipUntilWithTime(5000, [scheduler]);\n * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped until the specified start time.\n */\n observableProto.skipUntilWithTime = function (startTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n return new SkipUntilWithTimeObservable(this, startTime, scheduler);\n };\n\n /**\n * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.\n * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on.\n * @returns {Observable} An observable sequence with the elements taken until the specified end time.\n */\n observableProto.takeUntilWithTime = function (endTime, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n var source = this;\n return new AnonymousObservable(function (o) {\n return new BinaryDisposable(\n scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }),\n source.subscribe(o));\n }, source);\n };\n\n /**\n * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.\n * @param {Number} windowDuration time to wait before emitting another item after emitting the last item\n * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.\n * @returns {Observable} An Observable that performs the throttle operation.\n */\n observableProto.throttle = function (windowDuration, scheduler) {\n isScheduler(scheduler) || (scheduler = defaultScheduler);\n var duration = +windowDuration || 0;\n if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var lastOnNext = 0;\n return source.subscribe(\n function (x) {\n var now = scheduler.now();\n if (lastOnNext === 0 || now - lastOnNext >= duration) {\n lastOnNext = now;\n o.onNext(x);\n }\n },function (e) { o.onError(e); }, function () { o.onCompleted(); }\n );\n }, source);\n };\n\n var TransduceObserver = (function (__super__) {\n inherits(TransduceObserver, __super__);\n function TransduceObserver(o, xform) {\n this._o = o;\n this._xform = xform;\n __super__.call(this);\n }\n\n TransduceObserver.prototype.next = function (x) {\n var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x);\n if (res === errorObj) { this._o.onError(res.e); }\n };\n\n TransduceObserver.prototype.error = function (e) { this._o.onError(e); };\n\n TransduceObserver.prototype.completed = function () {\n this._xform['@@transducer/result'](this._o);\n };\n\n return TransduceObserver;\n }(AbstractObserver));\n\n function transformForObserver(o) {\n return {\n '@@transducer/init': function() {\n return o;\n },\n '@@transducer/step': function(obs, input) {\n return obs.onNext(input);\n },\n '@@transducer/result': function(obs) {\n return obs.onCompleted();\n }\n };\n }\n\n /**\n * Executes a transducer to transform the observable sequence\n * @param {Transducer} transducer A transducer to execute\n * @returns {Observable} An Observable sequence containing the results from the transducer.\n */\n observableProto.transduce = function(transducer) {\n var source = this;\n return new AnonymousObservable(function(o) {\n var xform = transducer(transformForObserver(o));\n return source.subscribe(new TransduceObserver(o, xform));\n }, source);\n };\n\n /**\n * Performs a exclusive waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @returns {Observable} A exclusive observable with only the results that happen when subscribed.\n */\n observableProto.switchFirst = function () {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var hasCurrent = false,\n isStopped = false,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n if (!hasCurrent) {\n hasCurrent = true;\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n var innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) { o.onError(e); },\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n isStopped && g.length === 1 && o.onCompleted();\n }));\n }\n },\n function (e) { o.onError(e); },\n function () {\n isStopped = true;\n !hasCurrent && g.length === 1 && o.onCompleted();\n }));\n\n return g;\n }, this);\n };\n\nobservableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst();\n};\n\nRx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) {\n return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit);\n};\n /** Provides a set of extension methods for virtual time scheduling. */\n var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) {\n inherits(VirtualTimeScheduler, __super__);\n\n /**\n * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.\n *\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function VirtualTimeScheduler(initialClock, comparer) {\n this.clock = initialClock;\n this.comparer = comparer;\n this.isEnabled = false;\n this.queue = new PriorityQueue(1024);\n __super__.call(this);\n }\n\n var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;\n\n VirtualTimeSchedulerPrototype.now = function () {\n return this.toAbsoluteTime(this.clock);\n };\n\n VirtualTimeSchedulerPrototype.schedule = function (state, action) {\n return this.scheduleAbsolute(state, this.clock, action);\n };\n\n VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) {\n var dt = dueTime instanceof Date ?\n this.toRelativeTime(dueTime - this.now()) :\n this.toRelativeTime(dueTime);\n\n return this.scheduleRelative(state, dt, action);\n };\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n VirtualTimeSchedulerPrototype.add = notImplemented;\n\n /**\n * Converts an absolute time to a number\n * @param {Any} The absolute time.\n * @returns {Number} The absolute time in ms\n */\n VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented;\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented;\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) {\n var s = new SchedulePeriodicRecursive(this, state, period, action);\n return s.start();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) {\n var runAt = this.add(this.clock, dueTime);\n return this.scheduleAbsolute(state, runAt, action);\n };\n\n /**\n * Starts the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.start = function () {\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n }\n };\n\n /**\n * Stops the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.stop = function () {\n this.isEnabled = false;\n };\n\n /**\n * Advances the scheduler's clock to the specified time, running all work till that point.\n * @param {Number} time Absolute time to advance the scheduler's clock to.\n */\n VirtualTimeSchedulerPrototype.advanceTo = function (time) {\n var dueToClock = this.comparer(this.clock, time);\n if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null && this.comparer(next.dueTime, time) <= 0) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n this.clock = time;\n }\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.advanceBy = function (time) {\n var dt = this.add(this.clock, time),\n dueToClock = this.comparer(this.clock, dt);\n if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n\n this.advanceTo(dt);\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.sleep = function (time) {\n var dt = this.add(this.clock, time);\n if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); }\n\n this.clock = dt;\n };\n\n /**\n * Gets the next scheduled item to be executed.\n * @returns {ScheduledItem} The next scheduled item.\n */\n VirtualTimeSchedulerPrototype.getNext = function () {\n while (this.queue.length > 0) {\n var next = this.queue.peek();\n if (next.isCancelled()) {\n this.queue.dequeue();\n } else {\n return next;\n }\n }\n return null;\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) {\n var self = this;\n\n function run(scheduler, state1) {\n self.queue.remove(si);\n return action(scheduler, state1);\n }\n\n var si = new ScheduledItem(this, state, run, dueTime, this.comparer);\n this.queue.enqueue(si);\n\n return si.disposable;\n };\n\n return VirtualTimeScheduler;\n }(Scheduler));\n\n /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */\n Rx.HistoricalScheduler = (function (__super__) {\n inherits(HistoricalScheduler, __super__);\n\n /**\n * Creates a new historical scheduler with the specified initial clock value.\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function HistoricalScheduler(initialClock, comparer) {\n var clock = initialClock == null ? 0 : initialClock;\n var cmp = comparer || defaultSubComparer;\n __super__.call(this, clock, cmp);\n }\n\n var HistoricalSchedulerProto = HistoricalScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n HistoricalSchedulerProto.add = function (absolute, relative) {\n return absolute + relative;\n };\n\n HistoricalSchedulerProto.toAbsoluteTime = function (absolute) {\n return new Date(absolute).getTime();\n };\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @memberOf HistoricalScheduler\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n HistoricalSchedulerProto.toRelativeTime = function (timeSpan) {\n return timeSpan;\n };\n\n return HistoricalScheduler;\n }(Rx.VirtualTimeScheduler));\n\nfunction OnNextPredicate(predicate) {\n this.predicate = predicate;\n}\n\nOnNextPredicate.prototype.equals = function (other) {\n if (other === this) { return true; }\n if (other == null) { return false; }\n if (other.kind !== 'N') { return false; }\n return this.predicate(other.value);\n};\n\nfunction OnErrorPredicate(predicate) {\n this.predicate = predicate;\n}\n\nOnErrorPredicate.prototype.equals = function (other) {\n if (other === this) { return true; }\n if (other == null) { return false; }\n if (other.kind !== 'E') { return false; }\n return this.predicate(other.error);\n};\n\nvar ReactiveTest = Rx.ReactiveTest = {\n /** Default virtual time used for creation of observable sequences in unit tests. */\n created: 100,\n /** Default virtual time used to subscribe to observable sequences in unit tests. */\n subscribed: 200,\n /** Default virtual time used to dispose subscriptions in unit tests. */\n disposed: 1000,\n\n /**\n * Factory method for an OnNext notification record at a given time with a given value or a predicate function.\n *\n * 1 - ReactiveTest.onNext(200, 42);\n * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; });\n *\n * @param ticks Recorded virtual time the OnNext notification occurs.\n * @param value Recorded value stored in the OnNext notification or a predicate.\n * @return Recorded OnNext notification.\n */\n onNext: function (ticks, value) {\n return typeof value === 'function' ?\n new Recorded(ticks, new OnNextPredicate(value)) :\n new Recorded(ticks, Notification.createOnNext(value));\n },\n /**\n * Factory method for an OnError notification record at a given time with a given error.\n *\n * 1 - ReactiveTest.onNext(200, new Error('error'));\n * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; });\n *\n * @param ticks Recorded virtual time the OnError notification occurs.\n * @param exception Recorded exception stored in the OnError notification.\n * @return Recorded OnError notification.\n */\n onError: function (ticks, error) {\n return typeof error === 'function' ?\n new Recorded(ticks, new OnErrorPredicate(error)) :\n new Recorded(ticks, Notification.createOnError(error));\n },\n /**\n * Factory method for an OnCompleted notification record at a given time.\n *\n * @param ticks Recorded virtual time the OnCompleted notification occurs.\n * @return Recorded OnCompleted notification.\n */\n onCompleted: function (ticks) {\n return new Recorded(ticks, Notification.createOnCompleted());\n },\n /**\n * Factory method for a subscription record based on a given subscription and disposal time.\n *\n * @param start Virtual time indicating when the subscription was created.\n * @param end Virtual time indicating when the subscription was disposed.\n * @return Subscription object.\n */\n subscribe: function (start, end) {\n return new Subscription(start, end);\n }\n};\n\n /**\n * Creates a new object recording the production of the specified value at the given virtual time.\n *\n * @constructor\n * @param {Number} time Virtual time the value was produced on.\n * @param {Mixed} value Value that was produced.\n * @param {Function} comparer An optional comparer.\n */\n var Recorded = Rx.Recorded = function (time, value, comparer) {\n this.time = time;\n this.value = value;\n this.comparer = comparer || defaultComparer;\n };\n\n /**\n * Checks whether the given recorded object is equal to the current instance.\n *\n * @param {Recorded} other Recorded object to check for equality.\n * @returns {Boolean} true if both objects are equal; false otherwise.\n */\n Recorded.prototype.equals = function (other) {\n return this.time === other.time && this.comparer(this.value, other.value);\n };\n\n /**\n * Returns a string representation of the current Recorded value.\n *\n * @returns {String} String representation of the current Recorded value.\n */\n Recorded.prototype.toString = function () {\n return this.value.toString() + '@' + this.time;\n };\n\n /**\n * Creates a new subscription object with the given virtual subscription and unsubscription time.\n *\n * @constructor\n * @param {Number} subscribe Virtual time at which the subscription occurred.\n * @param {Number} unsubscribe Virtual time at which the unsubscription occurred.\n */\n var Subscription = Rx.Subscription = function (start, end) {\n this.subscribe = start;\n this.unsubscribe = end || Number.MAX_VALUE;\n };\n\n /**\n * Checks whether the given subscription is equal to the current instance.\n * @param other Subscription object to check for equality.\n * @returns {Boolean} true if both objects are equal; false otherwise.\n */\n Subscription.prototype.equals = function (other) {\n return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;\n };\n\n /**\n * Returns a string representation of the current Subscription value.\n * @returns {String} String representation of the current Subscription value.\n */\n Subscription.prototype.toString = function () {\n return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')';\n };\n\n var MockDisposable = Rx.MockDisposable = function (scheduler) {\n this.scheduler = scheduler;\n this.disposes = [];\n this.disposes.push(this.scheduler.clock);\n };\n\n MockDisposable.prototype.dispose = function () {\n this.disposes.push(this.scheduler.clock);\n };\n\n var MockObserver = (function (__super__) {\n inherits(MockObserver, __super__);\n\n function MockObserver(scheduler) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.messages = [];\n }\n\n var MockObserverPrototype = MockObserver.prototype;\n\n MockObserverPrototype.onNext = function (value) {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));\n };\n\n MockObserverPrototype.onError = function (e) {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e)));\n };\n\n MockObserverPrototype.onCompleted = function () {\n this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));\n };\n\n return MockObserver;\n })(Observer);\n\n function MockPromise(scheduler, messages) {\n var self = this;\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n this.observers = [];\n for (var i = 0, len = this.messages.length; i < len; i++) {\n var message = this.messages[i],\n notification = message.value;\n (function (innerNotification) {\n scheduler.scheduleAbsolute(null, message.time, function () {\n var obs = self.observers.slice(0);\n\n for (var j = 0, jLen = obs.length; j < jLen; j++) {\n innerNotification.accept(obs[j]);\n }\n return disposableEmpty;\n });\n })(notification);\n }\n }\n\n MockPromise.prototype.then = function (onResolved, onRejected) {\n var self = this;\n\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n\n var newPromise;\n\n var observer = Rx.Observer.create(\n function (x) {\n var retValue = onResolved(x);\n if (retValue && typeof retValue.then === 'function') {\n newPromise = retValue;\n } else {\n var ticks = self.scheduler.clock;\n newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]);\n }\n var idx = self.observers.indexOf(observer);\n self.observers.splice(idx, 1);\n self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);\n },\n function (err) {\n onRejected(err);\n var idx = self.observers.indexOf(observer);\n self.observers.splice(idx, 1);\n self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock);\n }\n );\n this.observers.push(observer);\n\n return newPromise || new MockPromise(this.scheduler, this.messages);\n };\n\n var HotObservable = (function (__super__) {\n inherits(HotObservable, __super__);\n\n function HotObservable(scheduler, messages) {\n __super__.call(this);\n var message, notification, observable = this;\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n this.observers = [];\n for (var i = 0, len = this.messages.length; i < len; i++) {\n message = this.messages[i];\n notification = message.value;\n (function (innerNotification) {\n scheduler.scheduleAbsolute(null, message.time, function () {\n var obs = observable.observers.slice(0);\n\n for (var j = 0, jLen = obs.length; j < jLen; j++) {\n innerNotification.accept(obs[j]);\n }\n return disposableEmpty;\n });\n })(notification);\n }\n }\n\n HotObservable.prototype._subscribe = function (o) {\n var observable = this;\n this.observers.push(o);\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n return disposableCreate(function () {\n var idx = observable.observers.indexOf(o);\n observable.observers.splice(idx, 1);\n observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);\n });\n };\n\n return HotObservable;\n })(Observable);\n\n var ColdObservable = (function (__super__) {\n inherits(ColdObservable, __super__);\n\n function ColdObservable(scheduler, messages) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.messages = messages;\n this.subscriptions = [];\n }\n\n ColdObservable.prototype._subscribe = function (o) {\n var message, notification, observable = this;\n this.subscriptions.push(new Subscription(this.scheduler.clock));\n var index = this.subscriptions.length - 1;\n var d = new CompositeDisposable();\n for (var i = 0, len = this.messages.length; i < len; i++) {\n message = this.messages[i];\n notification = message.value;\n (function (innerNotification) {\n d.add(observable.scheduler.scheduleRelative(null, message.time, function () {\n innerNotification.accept(o);\n return disposableEmpty;\n }));\n })(notification);\n }\n return disposableCreate(function () {\n observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock);\n d.dispose();\n });\n };\n\n return ColdObservable;\n })(Observable);\n\n /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */\n Rx.TestScheduler = (function (__super__) {\n inherits(TestScheduler, __super__);\n\n function baseComparer(x, y) {\n return x > y ? 1 : (x < y ? -1 : 0);\n }\n\n function TestScheduler() {\n __super__.call(this, 0, baseComparer);\n }\n\n /**\n * Schedules an action to be executed at the specified virtual time.\n *\n * @param state State passed to the action to be executed.\n * @param dueTime Absolute virtual time at which to execute the action.\n * @param action Action to be executed.\n * @return Disposable object used to cancel the scheduled action (best effort).\n */\n TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) {\n dueTime <= this.clock && (dueTime = this.clock + 1);\n return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action);\n };\n /**\n * Adds a relative virtual time to an absolute virtual time value.\n *\n * @param absolute Absolute virtual time value.\n * @param relative Relative virtual time value to add.\n * @return Resulting absolute virtual time sum value.\n */\n TestScheduler.prototype.add = function (absolute, relative) {\n return absolute + relative;\n };\n /**\n * Converts the absolute virtual time value to a DateTimeOffset value.\n *\n * @param absolute Absolute virtual time value to convert.\n * @return Corresponding DateTimeOffset value.\n */\n TestScheduler.prototype.toAbsoluteTime = function (absolute) {\n return new Date(absolute).getTime();\n };\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n *\n * @param timeSpan TimeSpan value to convert.\n * @return Corresponding relative virtual time value.\n */\n TestScheduler.prototype.toRelativeTime = function (timeSpan) {\n return timeSpan;\n };\n /**\n * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription.\n *\n * @param create Factory method to create an observable sequence.\n * @param created Virtual time at which to invoke the factory to create an observable sequence.\n * @param subscribed Virtual time at which to subscribe to the created observable sequence.\n * @param disposed Virtual time at which to dispose the subscription.\n * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active.\n */\n TestScheduler.prototype.startScheduler = function (createFn, settings) {\n settings || (settings = {});\n settings.created == null && (settings.created = ReactiveTest.created);\n settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed);\n settings.disposed == null && (settings.disposed = ReactiveTest.disposed);\n\n var observer = this.createObserver(), source, subscription;\n\n this.scheduleAbsolute(null, settings.created, function () {\n source = createFn();\n return disposableEmpty;\n });\n\n this.scheduleAbsolute(null, settings.subscribed, function () {\n subscription = source.subscribe(observer);\n return disposableEmpty;\n });\n\n this.scheduleAbsolute(null, settings.disposed, function () {\n subscription.dispose();\n return disposableEmpty;\n });\n\n this.start();\n\n return observer;\n };\n\n /**\n * Creates a hot observable using the specified timestamped notification messages either as an array or arguments.\n * @param messages Notifications to surface through the created sequence at their specified absolute virtual times.\n * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications.\n */\n TestScheduler.prototype.createHotObservable = function () {\n var len = arguments.length, args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n args = new Array(len);\n for (var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n return new HotObservable(this, args);\n };\n\n /**\n * Creates a cold observable using the specified timestamped notification messages either as an array or arguments.\n * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time.\n * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications.\n */\n TestScheduler.prototype.createColdObservable = function () {\n var len = arguments.length, args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n args = new Array(len);\n for (var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n return new ColdObservable(this, args);\n };\n\n /**\n * Creates a resolved promise with the given value and ticks\n * @param {Number} ticks The absolute time of the resolution.\n * @param {Any} value The value to yield at the given tick.\n * @returns {MockPromise} A mock Promise which fulfills with the given value.\n */\n TestScheduler.prototype.createResolvedPromise = function (ticks, value) {\n return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]);\n };\n\n /**\n * Creates a rejected promise with the given reason and ticks\n * @param {Number} ticks The absolute time of the resolution.\n * @param {Any} reason The reason for rejection to yield at the given tick.\n * @returns {MockPromise} A mock Promise which rejects with the given reason.\n */\n TestScheduler.prototype.createRejectedPromise = function (ticks, reason) {\n return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]);\n };\n\n /**\n * Creates an observer that records received notification messages and timestamps those.\n * @return Observer that can be used to assert the timing of received notifications.\n */\n TestScheduler.prototype.createObserver = function () {\n return new MockObserver(this);\n };\n\n return TestScheduler;\n })(VirtualTimeScheduler);\n\n var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {\n inherits(AnonymousObservable, __super__);\n\n // Fix subscriber to check for undefined or function returned to decorate as Disposable\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.__subscribe).call(self, ado);\n if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function AnonymousObservable(subscribe, parent) {\n this.source = parent;\n this.__subscribe = subscribe;\n __super__.call(this);\n }\n\n AnonymousObservable.prototype._subscribe = function (o) {\n var ado = new AutoDetachObserver(o), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.schedule(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n };\n\n return AnonymousObservable;\n\n }(Observable));\n\n var AutoDetachObserver = (function (__super__) {\n inherits(AutoDetachObserver, __super__);\n\n function AutoDetachObserver(observer) {\n __super__.call(this);\n this.observer = observer;\n this.m = new SingleAssignmentDisposable();\n }\n\n var AutoDetachObserverPrototype = AutoDetachObserver.prototype;\n\n AutoDetachObserverPrototype.next = function (value) {\n var result = tryCatch(this.observer.onNext).call(this.observer, value);\n if (result === errorObj) {\n this.dispose();\n thrower(result.e);\n }\n };\n\n AutoDetachObserverPrototype.error = function (err) {\n var result = tryCatch(this.observer.onError).call(this.observer, err);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.completed = function () {\n var result = tryCatch(this.observer.onCompleted).call(this.observer);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };\n AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };\n\n AutoDetachObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.m.dispose();\n };\n\n return AutoDetachObserver;\n }(AbstractObserver));\n\n var UnderlyingObservable = (function (__super__) {\n inherits(UnderlyingObservable, __super__);\n function UnderlyingObservable(m, u) {\n this._m = m;\n this._u = u;\n __super__.call(this);\n }\n\n UnderlyingObservable.prototype.subscribeCore = function (o) {\n return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o));\n };\n\n return UnderlyingObservable;\n }(ObservableBase));\n\n var GroupedObservable = (function (__super__) {\n inherits(GroupedObservable, __super__);\n function GroupedObservable(key, underlyingObservable, mergedDisposable) {\n __super__.call(this);\n this.key = key;\n this.underlyingObservable = !mergedDisposable ?\n underlyingObservable :\n new UnderlyingObservable(mergedDisposable, underlyingObservable);\n }\n\n GroupedObservable.prototype._subscribe = function (o) {\n return this.underlyingObservable.subscribe(o);\n };\n\n return GroupedObservable;\n }(Observable));\n\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed observers.\n */\n var Subject = Rx.Subject = (function (__super__) {\n inherits(Subject, __super__);\n function Subject() {\n __super__.call(this);\n this.isDisposed = false;\n this.isStopped = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(Subject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(o);\n return new InnerSubscription(this, o);\n }\n if (this.hasError) {\n o.onError(this.error);\n return disposableEmpty;\n }\n o.onCompleted();\n return disposableEmpty;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (!this.isStopped) {\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n /**\n * Creates a subject from the specified observer and observable.\n * @param {Observer} observer The observer used to send messages to the subject.\n * @param {Observable} observable The observable used to subscribe to messages sent from the subject.\n * @returns {Subject} Subject implemented using the given observer and observable.\n */\n Subject.create = function (observer, observable) {\n return new AnonymousSubject(observer, observable);\n };\n\n return Subject;\n }(Observable));\n\n /**\n * Represents the result of an asynchronous operation.\n * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.\n */\n var AsyncSubject = Rx.AsyncSubject = (function (__super__) {\n inherits(AsyncSubject, __super__);\n\n /**\n * Creates a subject that can only receive one value and that value is cached for all future observations.\n * @constructor\n */\n function AsyncSubject() {\n __super__.call(this);\n this.isDisposed = false;\n this.isStopped = false;\n this.hasValue = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(AsyncSubject.prototype, Observer, {\n _subscribe: function (o) {\n checkDisposed(this);\n\n if (!this.isStopped) {\n this.observers.push(o);\n return new InnerSubscription(this, o);\n }\n\n if (this.hasError) {\n o.onError(this.error);\n } else if (this.hasValue) {\n o.onNext(this.value);\n o.onCompleted();\n } else {\n o.onCompleted();\n }\n\n return disposableEmpty;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n checkDisposed(this);\n return this.observers.length > 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).\n */\n onCompleted: function () {\n var i, len;\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n var os = cloneArray(this.observers), len = os.length;\n\n if (this.hasValue) {\n for (i = 0; i < len; i++) {\n var o = os[i];\n o.onNext(this.value);\n o.onCompleted();\n }\n } else {\n for (i = 0; i < len; i++) {\n os[i].onCompleted();\n }\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the error.\n * @param {Mixed} error The Error to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.\n * @param {Mixed} value The value to store in the subject.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n this.hasValue = true;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.error = null;\n this.value = null;\n }\n });\n\n return AsyncSubject;\n }(Observable));\n\n var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {\n inherits(AnonymousSubject, __super__);\n function AnonymousSubject(observer, observable) {\n this.observer = observer;\n this.observable = observable;\n __super__.call(this);\n }\n\n addProperties(AnonymousSubject.prototype, Observer.prototype, {\n _subscribe: function (o) {\n return this.observable.subscribe(o);\n },\n onCompleted: function () {\n this.observer.onCompleted();\n },\n onError: function (error) {\n this.observer.onError(error);\n },\n onNext: function (value) {\n this.observer.onNext(value);\n }\n });\n\n return AnonymousSubject;\n }(Observable));\n\n /**\n * Used to pause and resume streams.\n */\n Rx.Pauser = (function (__super__) {\n inherits(Pauser, __super__);\n function Pauser() {\n __super__.call(this);\n }\n\n /**\n * Pauses the underlying sequence.\n */\n Pauser.prototype.pause = function () { this.onNext(false); };\n\n /**\n * Resumes the underlying sequence.\n */\n Pauser.prototype.resume = function () { this.onNext(true); };\n\n return Pauser;\n }(Subject));\n\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n root.Rx = Rx;\n\n define(function() {\n return Rx;\n });\n } else if (freeExports && freeModule) {\n // in Node.js or RingoJS\n if (moduleExports) {\n (freeModule.exports = Rx).Rx = Rx;\n } else {\n freeExports.Rx = Rx;\n }\n } else {\n // in a browser or Rhino\n root.Rx = Rx;\n }\n\n // All code before this point will be filtered from stack traces.\n var rEndingLine = captureLine();\n\n}.call(this));\n", + "import ajax from \"./ajax\";\n\nexport default class AjaxAdapter {\n\n constructor(options) {\n this._base = (options && options.base) || \"\";\n };\n\n create(store, type, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n body: JSON.stringify({\n data: store.convert(type, partial)\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"POST\",\n responseType: \"auto\",\n url: this._getUrl(type, null, options)\n }).do(e => store.push(e.response))\n .map(e => store.find(e.response.data.type, e.response.data.id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n destroy(store, type, id, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"DELETE\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.remove(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n load(store, type, id, options) {\n\n if (id && typeof id === \"object\") {\n return this.load(store, type, null, id);\n }\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let source = ajax({\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"GET\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(e => store.push(e.response))\n .map(() => id ? store.find(type, id) : store.findAll(type))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n update(store, type, id, partial, options) {\n\n if (!store._types[type]) {\n throw new Error(`Unknown type '${type}'`);\n }\n\n let data = store.convert(type, id, partial);\n\n let source = ajax({\n body: JSON.stringify({\n data: data\n }),\n crossDomain: true,\n headers: {\n \"Content-Type\": \"application/vnd.api+json\"\n },\n method: \"PATCH\",\n responseType: \"auto\",\n url: this._getUrl(type, id, options)\n }).do(() => store.add(data))\n .map(() => store.find(type, id))\n .publish();\n\n source.connect();\n\n return source;\n\n }\n\n _getUrl(type, id, options) {\n\n let params = [];\n let url = id ? `${this._base}/${type}/${id}` : `${this._base}/${type}`;\n\n if (options) {\n\n if (options.fields) {\n Object.keys(options.fields).forEach(field => {\n options[`fields[${field}]`] = options.fields[field];\n });\n delete options.fields;\n }\n\n params = Object.keys(options).map(key => {\n return key + \"=\" + encodeURIComponent(options[key]);\n }).sort();\n\n if (params.length) {\n url = `${url}?${params.join(\"&\")}`;\n }\n\n }\n\n return url;\n\n }\n\n}\n", + "import Rx from \"rx\";\n\n/**\n *\n * Derived from RxJS-DOM, Copyright (c) Microsoft Open Technologies, Inc:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM\n *\n * The original source file can be viewed here:\n *\n * https://github.com/Reactive-Extensions/RxJS-DOM/blob/fdb169c8bd1612318d530e6e54074b1c9e537906/src/ajax.js\n *\n * Licensed under the Apache License, Version 2.0:\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Modifications from original:\n *\n * - extracted from \"Rx.DOM\" namespace\n * - minor eslinter cleanup (\"var\" to \"let\" etc)\n * - addition of \"auto\" responseType\n *\n */\n\nvar root = (typeof window !== \"undefined\" && window) || this;\n\n// Gets the proper XMLHttpRequest for support for older IE\nfunction getXMLHttpRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n } else {\n let progId;\n try {\n let progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n for(let i = 0; i < 3; i++) {\n try {\n progId = progIds[i];\n if (new root.ActiveXObject(progId)) {\n break;\n }\n } catch(e) { }\n }\n return new root.ActiveXObject(progId);\n } catch (e) {\n throw new Error('XMLHttpRequest is not supported by your browser');\n }\n }\n}\n\n// Get CORS support even for older IE\nfunction getCORSRequest() {\n var xhr = new root.XMLHttpRequest();\n if ('withCredentials' in xhr) {\n return xhr;\n } else if (!!root.XDomainRequest) {\n return new XDomainRequest();\n } else {\n throw new Error('CORS is not supported by your browser');\n }\n}\n\nfunction normalizeAjaxSuccessEvent(e, xhr, settings) {\n var response = ('response' in xhr) ? xhr.response : xhr.responseText;\n if (settings.responseType === 'auto') {\n try {\n response = JSON.parse(response);\n } catch (e) {}\n } else {\n response = settings.responseType === 'json' ? JSON.parse(response) : response;\n }\n return {\n response: response,\n status: xhr.status,\n responseType: xhr.responseType,\n xhr: xhr,\n originalEvent: e\n };\n}\n\nfunction normalizeAjaxErrorEvent(e, xhr, type) {\n return {\n type: type,\n status: xhr.status,\n xhr: xhr,\n originalEvent: e\n };\n}\n\n/**\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = ajax('/products');\n * source = ajax({ url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n * - responseType: \"text\" (default), \"json\" or \"auto\"\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n*/\nexport default function (options) {\n var settings = {\n method: 'GET',\n crossDomain: false,\n async: true,\n headers: {},\n responseType: 'text',\n createXHR: function(){\n return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();\n },\n normalizeError: normalizeAjaxErrorEvent,\n normalizeSuccess: normalizeAjaxSuccessEvent\n };\n\n if(typeof options === 'string') {\n settings.url = options;\n } else {\n for(let prop in options) {\n if(hasOwnProperty.call(options, prop)) {\n settings[prop] = options[prop];\n }\n }\n }\n\n let normalizeError = settings.normalizeError;\n let normalizeSuccess = settings.normalizeSuccess;\n\n if (!settings.crossDomain && !settings.headers['X-Requested-With']) {\n settings.headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n settings.hasContent = settings.body !== undefined;\n\n return new Rx.AnonymousObservable(function (observer) {\n var isDone = false;\n var xhr;\n\n var processResponse = function(xhr, e){\n var status = xhr.status === 1223 ? 204 : xhr.status;\n if ((status >= 200 && status <= 300) || status === 0 || status === '') {\n observer.onNext(normalizeSuccess(e, xhr, settings));\n observer.onCompleted();\n } else {\n observer.onError(normalizeError(e, xhr, 'error'));\n }\n isDone = true;\n };\n\n try {\n xhr = settings.createXHR();;\n } catch (err) {\n observer.onError(err);\n }\n\n try {\n if (settings.user) {\n xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password);\n } else {\n xhr.open(settings.method, settings.url, settings.async);\n }\n\n let headers = settings.headers;\n for (let header in headers) {\n if (hasOwnProperty.call(headers, header)) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n\n if(!!xhr.upload || (!('withCredentials' in xhr) && !!root.XDomainRequest)) {\n xhr.onload = function(e) {\n if(settings.progressObserver) {\n settings.progressObserver.onNext(e);\n settings.progressObserver.onCompleted();\n }\n processResponse(xhr, e);\n };\n\n if(settings.progressObserver) {\n xhr.onprogress = function(e) {\n settings.progressObserver.onNext(e);\n };\n }\n\n xhr.onerror = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'error'));\n isDone = true;\n };\n\n xhr.onabort = function(e) {\n if (settings.progressObserver) {\n settings.progressObserver.onError(e);\n }\n observer.onError(normalizeError(e, xhr, 'abort'));\n isDone = true;\n };\n } else {\n\n xhr.onreadystatechange = function (e) {\n if (xhr.readyState === 4) {\n processResponse(xhr, e);\n }\n };\n }\n\n xhr.send(settings.hasContent && settings.body || null);\n } catch (e) {\n observer.onError(e);\n }\n\n return function () {\n if (!isDone && xhr.readyState !== 4) { xhr.abort(); }\n };\n });\n};\n", + "import \"array.prototype.find\";\nimport Rx from \"rx\";\nimport AjaxAdapter from \"./ajax-adapter\";\n\nexport default class Store {\n\n /**\n * Creates a field definition for an attribute.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.default] - Default value for this field.\n * @return {Object} - Field definition.\n */\n static attr(name, options) {\n if (name && typeof name === 'object') {\n return Store.attr(null, name);\n } else {\n return {\n type: \"attr\",\n default: options && options.default,\n deserialize: function (data, key) {\n return data.attributes && data.attributes[name || key];\n },\n serialize: function (resource, data, key) {\n data.attributes[name || key] = resource[key];\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-one relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasOne(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasOne(null, name);\n } else {\n return {\n type: \"has-one\",\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return null;\n } else if (data.relationships[name].data) {\n return this.find(data.relationships[name].data.type, data.relationships[name].data.id);\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key] === null) {\n data.relationships[name || key] = null;\n } else if (resource[key]) {\n data.relationships[name || key] = {\n data: {\n type: resource[key].type,\n id: resource[key].id\n }\n };\n }\n }\n };\n }\n }\n\n /**\n * Creates a field definition for an has-many relationship.\n *\n * @since 0.1.0\n * @param {string} [name] - Name of the property to map this field from.\n * @param {Object} [options] - An options object.\n * @param {string} [options.inverse] - Name of the inverse relationship.\n * @return {Object} - Field definition.\n */\n static hasMany(name, options) {\n if (name && typeof name === 'object') {\n return Store.hasMany(null, name);\n } else {\n return {\n type: \"has-many\",\n default: [],\n inverse: options && options.inverse,\n deserialize: function (data, key) {\n name = name || key;\n if (data.relationships && data.relationships[name]) {\n if (data.relationships[name].data === null) {\n return [];\n } else if (data.relationships[name].data) {\n return data.relationships[name].data.map((c) => {\n return this.find(c.type, c.id);\n });\n }\n }\n },\n serialize: function serialize(resource, data, key) {\n if (resource[key]) {\n data.relationships[name || key] = {\n data: resource[key].map(x => {\n return { type: x.type, id: x.id };\n })\n };\n }\n }\n };\n }\n }\n\n constructor(adapter) {\n\n this._adapter = adapter;\n this._data = {};\n this._subject = new Rx.Subject();\n this._subscriptions = {};\n this._types = {};\n\n /**\n * An observable that will emit events when any resource in added, updated\n * or removed. The object passed to listeners will be in this format:\n *\n *

    \n     * { name: string, type: string, id: string, resource: object }\n     * 

    \n *\n * You can learn more about RxJS observables at the GitHub repo:\n * https://github.com/Reactive-Extensions/RxJS\n *\n * @type {Rx.Observable}\n * @since 0.6.0\n *\n * @example\n * let store = new Store();\n *\n * store.observable.filter(e => e.name === \"added\").subscribe(event => {\n * console.log(event.name); // \"added\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"updated\").subscribe(event => {\n * console.log(event.name); // \"updated\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // Map {...}\n * });\n *\n * store.observable.filter(e => e.name === \"removed\").subscribe(event => {\n * console.log(event.name); // \"removed\"\n * console.log(event.type); // \"products\"\n * console.log(event.id); // \"1\"\n * console.log(event.resource); // null\n * });\n */\n this.observable = this._subject.asObservable();\n\n }\n\n /**\n * Add an individual resource to the store. This is used internally by the\n * `push()` method.\n *\n * @since 0.1.0\n * @param {!Object} object - A JSON API Resource Object to be added. See:\n http://jsonapi.org/format/#document-resource-objects\n */\n add(object) {\n if (object) {\n if (object.type && object.id) {\n let name = this._data[object.type] && this._data[object.type][object.id] ? \"updated\" : \"added\";\n let resource = this.find(object.type, object.id);\n let definition = this._types[object.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n this._addField(object, resource, definition, fieldName);\n }\n });\n this._subject.onNext({\n name: name,\n type: object.type,\n id: object.id,\n resource: resource\n });\n } else {\n throw new TypeError(`The data must have a type and id`);\n }\n } else {\n throw new TypeError(`You must provide data to add`);\n }\n }\n\n /**\n * Converts the given partial into a JSON API compliant representation.\n *\n * @since 0.5.0\n * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property.\n * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property.\n * @param {!object} partial - The data to convert.\n * @return {object} - JSON API version of the object.\n */\n convert(type, id, partial) {\n if (type && typeof type === \"object\") {\n return this.convert(type.type, type.id, type);\n } else if (id && typeof id === \"object\") {\n return this.convert(type, id.id, id);\n } else {\n let data = {\n type: type,\n attributes: {},\n relationships: {}\n };\n if (id) {\n data.id = id;\n }\n let definition = this._types[data.type];\n Object.keys(definition).forEach(fieldName => {\n if (fieldName[0] !== \"_\") {\n definition[fieldName].serialize(partial, data, fieldName);\n }\n });\n return data;\n }\n }\n\n /**\n * Attempts to create the resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!Object} partial - Data to create the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.create(\"product\", { title: \"A Book\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n create(type, partial, options) {\n if (this._adapter) {\n return this._adapter.create(this, type, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Defines a type of resource.\n *\n * @since 0.2.0\n * @param {!string|string[]} names - Name(s) of the resource.\n * @param {!Object} definition - The resource's definition.\n */\n define(names, definition) {\n names = (names.constructor === Array) ? names : [ names ];\n if (definition) {\n definition._names = names;\n names.forEach(name => {\n if (!this._types[name]) {\n this._types[name] = definition;\n } else {\n throw new Error(`The type '${name}' has already been defined.`);\n }\n });\n } else {\n throw new Error(`You must provide a definition for the type '${names[0]}'.`);\n }\n }\n\n /**\n * Attempts to delete the resource through the adapter and removes it from\n * the store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.destroy(\"product\", \"1\").subscribe(() => {\n * console.log(\"Destroyed!\");\n * });\n */\n destroy(type, id, options) {\n if (this._adapter) {\n return this._adapter.destroy(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Finds a resource by type and id.\n *\n * NOTE: If the resource hasn't been loaded via an add() or push() call it\n * will be automatically created when find is called.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource to find.\n * @param {!string} id - The id of the resource to find.\n * @return {Object} - The resource.\n */\n find(type, id) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n if (id) {\n if (!this._data[type][id]) {\n this._data[type][id] = {\n _dependents: [],\n type: type,\n id: id\n };\n Object.keys(definition).forEach(key => {\n if (key[0] !== \"_\") {\n this._data[type][id][key] = definition[key].default;\n }\n });\n }\n return this._data[type][id];\n } else {\n // throw new TypeError(`You must provide an id`);\n /*eslint-disable*/\n console.warn([\n \"Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n return this.findAll(type);\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Finds all the resources of a given type.\n *\n * @since 0.7.0\n * @param {!string} type - Type of the resource to find.\n * @return {Object[]} - An array of resources.\n */\n findAll(type) {\n if (type) {\n let definition = this._types[type];\n if (definition) {\n if (!this._data[type]) {\n let collection = {};\n definition._names.forEach(t => this._data[t] = collection);\n }\n return Object.keys(this._data[type]).map(x => this._data[type][x]);\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type`);\n }\n }\n\n /**\n * Attempts to load the given resource through the adapter and adds it to the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.load(\"products\", \"1\").subscribe((product) => {\n * console.log(product.title);\n * });\n */\n load(type, id, options) {\n if (!id || typeof id === \"object\") {\n /*eslint-disable*/\n console.warn([\n \"Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n }\n if (this._adapter) {\n return this._adapter.load(this, type, id, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Attempts to load all the resources of the given type through the adapter\n * and adds them to the store if successful.\n *\n * @since 0.7.0\n * @param {!string} type - Type of resource.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.loadAll(\"products\").subscribe((products) => {\n * console.log(products);\n * });\n */\n loadAll(type, options) {\n if (this._adapter) {\n return this._adapter.load(this, type, null, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n /**\n * Unregister an event listener that was registered with on().\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to originally passed to on().\n * @param {string} [id] - ID of the resource to originally passed to on().\n * @param {function} callback - Function originally passed to on().\n */\n off(event, type, id, callback) {\n /*eslint-disable*/\n console.warn([\n \"The `store.off()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.off.call(this, event, type, null, id, callback);\n } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || \"*\"]) {\n this._subscriptions[event][type][id || \"*\"].dispose();\n delete this._subscriptions[event][type][id || \"*\"];\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Register an event listener: \"added\", \"updated\" or \"removed\".\n *\n * @deprecated Use the store.observable property instead of this.\n * @since 0.4.0\n * @param {string} event - Name of the event.\n * @param {string} type - Name of resource to watch.\n * @param {string} [id] - ID of the resource to watch.\n * @param {function} callback - Function to call when the event occurs.\n * @param {Object} [context] - Context in which to call the callback.\n */\n on(event, type, id, callback, context) {\n /*eslint-disable*/\n console.warn([\n \"The `store.on()` method has been deprecated in favour of `store.observable`.\",\n \"For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0\"\n ].join(\"\\n\"));\n /*eslint-enable*/\n if (event === \"added\" || event === \"updated\" || event === \"removed\") {\n if (this._types[type]) {\n if (id && ({}).toString.call(id) === '[object Function]') {\n this.on.call(this, event, type, null, id, callback);\n } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || \"*\"]) {\n let subscription = this._subject.filter(e => e.name === event);\n subscription = subscription.filter(e => this._types[type]._names.indexOf(e.type) !== -1);\n if (id) {\n subscription = subscription.filter(e => e.id === id);\n }\n subscription = subscription.map(e => this.find(e.type, e.id));\n this._subscriptions[event] = this._subscriptions[event] || {};\n if (!this._subscriptions[event][type]) {\n let obj = {};\n this._types[type]._names.forEach(type => {\n this._subscriptions[event][type] = obj;\n });\n }\n this._subscriptions[event][type][id || \"*\"] = subscription.subscribe(callback.bind(context));\n }\n } else {\n throw new Error(`Unknown type '${type}'`);\n }\n } else {\n throw new Error(`Unknown event '${event}'`);\n }\n }\n\n /**\n * Add a JSON API response to the store. This method can be used to handle a\n * successful GET or POST response from the server.\n *\n * @since 0.1.0\n * @param {Object} root - Top Level Object to push. See:\n http://jsonapi.org/format/#document-top-level\n */\n push(root) {\n if (root.data.constructor === Array) {\n root.data.forEach(x => this.add(x));\n } else {\n this.add(root.data);\n }\n if (root.included) {\n root.included.forEach(x => this.add(x));\n }\n }\n\n /**\n * Remove a resource or collection of resources from the store.\n *\n * @since 0.1.0\n * @param {!string} type - Type of the resource(s) to remove.\n * @param {string} [id] - The id of the resource to remove. If omitted all\n * resources of the type will be removed.\n */\n remove(type, id) {\n if (type) {\n if (this._types[type]) {\n if (id) {\n let resource = this._data[type] && this._data[type][id];\n if (resource) {\n this._remove(resource);\n this._subject.onNext({\n name: \"removed\",\n type: type,\n id: id,\n resource: null\n });\n }\n } else {\n Object.keys(this._data[type]).forEach(id => this.remove(type, id));\n }\n } else {\n throw new TypeError(`Unknown type '${type}'`);\n }\n } else {\n throw new TypeError(`You must provide a type to remove`);\n }\n }\n\n /**\n * Attempts to update the resource through the adapter and updates it in the\n * store if successful.\n *\n * @since 0.5.0\n * @param {!string} type - Type of resource.\n * @param {!string} id - ID of resource.\n * @param {!Object} partial - Data to update the resource with.\n * @param {Object} [options] - Options to pass to the adapter.\n * @return {Rx.Observable}\n *\n * @example\n * let adapter = new Store.AjaxAdapter();\n * let store = new Store(adpater);\n * store.update(\"product\", \"1\", { title: \"foo\" }).subscribe((product) => {\n * console.log(product.title);\n * });\n */\n update(type, id, partial, options) {\n if (this._adapter) {\n return this._adapter.update(this, type, id, partial, options);\n } else {\n throw new Error(\"Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`\");\n }\n }\n\n _addField(object, resource, definition, fieldName) {\n var field = definition[fieldName];\n var newValue = field.deserialize.call(this, object, fieldName);\n if (typeof newValue !== \"undefined\") {\n if (field.type === \"has-one\") {\n if (resource[fieldName]) {\n this._removeInverseRelationship(resource, fieldName, resource[fieldName], field);\n }\n if (newValue) {\n this._addInverseRelationship(resource, fieldName, newValue, field);\n }\n } else if (field.type === \"has-many\") {\n resource[fieldName].forEach(r => {\n if (resource[fieldName].indexOf(r) !== -1) {\n this._removeInverseRelationship(resource, fieldName, r, field);\n }\n });\n newValue.forEach(r => {\n this._addInverseRelationship(resource, fieldName, r, field);\n });\n }\n resource[fieldName] = newValue;\n }\n }\n\n _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var sourceDefinition = this._types[sourceResource.type];\n if (targetDefinition) {\n let targetFieldName = [ sourceField.inverse ].concat(sourceDefinition._names).find(x => targetDefinition[x]);\n let targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n targetResource[targetFieldName] = sourceResource;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName });\n if (targetResource[targetFieldName].indexOf(sourceResource) === -1) {\n targetResource[targetFieldName].push(sourceResource);\n }\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n }\n\n _remove(resource) {\n resource._dependents.forEach(dependent => {\n let dependentResource = this._data[dependent.type][dependent.id];\n switch (this._types[dependent.type][dependent.fieldName].type) {\n case \"has-one\": {\n dependentResource[dependent.fieldName] = null;\n break;\n }\n case \"has-many\": {\n let index = dependentResource[dependent.fieldName].indexOf(resource);\n if (index !== -1) {\n dependentResource[dependent.fieldName].splice(index, 1);\n }\n break;\n }\n default: {\n break;\n }\n }\n // TODO: This only needs to be run once for each dependent.\n dependentResource._dependents = dependentResource._dependents.filter(d => {\n return !(d.type === resource.type && d.id === resource.id);\n });\n });\n delete this._data[resource.type][resource.id];\n }\n\n _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) {\n var targetDefinition = this._types[targetResource.type];\n var targetFieldName = sourceField.inverse || sourceResource.type;\n var targetField = targetDefinition && targetDefinition[targetFieldName];\n targetResource._dependents = targetResource._dependents.filter(r => {\n return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName);\n });\n if (targetField) {\n if (targetField.type === \"has-one\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = null;\n } else if (targetField.type === \"has-many\") {\n sourceResource._dependents = sourceResource._dependents.filter(r => {\n return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName);\n });\n targetResource[targetFieldName] = targetResource[targetFieldName].filter(r => {\n return r !== sourceResource;\n });\n } else if (targetField.type === \"attr\") {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is an attribute ('${targetFieldName}')`);\n }\n } else if (sourceField.inverse) {\n throw new Error(`The the inverse relationship for '${sourceFieldName}' is missing ('${sourceField.inverse}')`);\n }\n }\n\n}\n\nStore.Rx = Rx;\nStore.AjaxAdapter = AjaxAdapter;\n" + ] +} \ No newline at end of file diff --git a/releases/v0.7.0/store.js b/releases/v0.7.0/store.js new file mode 100644 index 0000000..fbe02a5 --- /dev/null +++ b/releases/v0.7.0/store.js @@ -0,0 +1,823 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +require("array.prototype.find"); + +var _rx = require("rx"); + +var _rx2 = _interopRequireDefault(_rx); + +var _ajaxAdapter = require("./ajax-adapter"); + +var _ajaxAdapter2 = _interopRequireDefault(_ajaxAdapter); + +var Store = (function () { + _createClass(Store, null, [{ + key: "attr", + + /** + * Creates a field definition for an attribute. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.default] - Default value for this field. + * @return {Object} - Field definition. + */ + value: function attr(name, options) { + if (name && typeof name === 'object') { + return Store.attr(null, name); + } else { + return { + type: "attr", + "default": options && options["default"], + deserialize: function deserialize(data, key) { + return data.attributes && data.attributes[name || key]; + }, + serialize: function serialize(resource, data, key) { + data.attributes[name || key] = resource[key]; + } + }; + } + } + + /** + * Creates a field definition for an has-one relationship. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.inverse] - Name of the inverse relationship. + * @return {Object} - Field definition. + */ + }, { + key: "hasOne", + value: function hasOne(name, options) { + if (name && typeof name === 'object') { + return Store.hasOne(null, name); + } else { + return { + type: "has-one", + inverse: options && options.inverse, + deserialize: function deserialize(data, key) { + name = name || key; + if (data.relationships && data.relationships[name]) { + if (data.relationships[name].data === null) { + return null; + } else if (data.relationships[name].data) { + return this.find(data.relationships[name].data.type, data.relationships[name].data.id); + } + } + }, + serialize: function serialize(resource, data, key) { + if (resource[key] === null) { + data.relationships[name || key] = null; + } else if (resource[key]) { + data.relationships[name || key] = { + data: { + type: resource[key].type, + id: resource[key].id + } + }; + } + } + }; + } + } + + /** + * Creates a field definition for an has-many relationship. + * + * @since 0.1.0 + * @param {string} [name] - Name of the property to map this field from. + * @param {Object} [options] - An options object. + * @param {string} [options.inverse] - Name of the inverse relationship. + * @return {Object} - Field definition. + */ + }, { + key: "hasMany", + value: function hasMany(name, options) { + if (name && typeof name === 'object') { + return Store.hasMany(null, name); + } else { + return { + type: "has-many", + "default": [], + inverse: options && options.inverse, + deserialize: function deserialize(data, key) { + var _this = this; + + name = name || key; + if (data.relationships && data.relationships[name]) { + if (data.relationships[name].data === null) { + return []; + } else if (data.relationships[name].data) { + return data.relationships[name].data.map(function (c) { + return _this.find(c.type, c.id); + }); + } + } + }, + serialize: function serialize(resource, data, key) { + if (resource[key]) { + data.relationships[name || key] = { + data: resource[key].map(function (x) { + return { type: x.type, id: x.id }; + }) + }; + } + } + }; + } + } + }]); + + function Store(adapter) { + _classCallCheck(this, Store); + + this._adapter = adapter; + this._data = {}; + this._subject = new _rx2["default"].Subject(); + this._subscriptions = {}; + this._types = {}; + + /** + * An observable that will emit events when any resource in added, updated + * or removed. The object passed to listeners will be in this format: + * + *

    +     * { name: string, type: string, id: string, resource: object }
    +     * 

    + * + * You can learn more about RxJS observables at the GitHub repo: + * https://github.com/Reactive-Extensions/RxJS + * + * @type {Rx.Observable} + * @since 0.6.0 + * + * @example + * let store = new Store(); + * + * store.observable.filter(e => e.name === "added").subscribe(event => { + * console.log(event.name); // "added" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // Map {...} + * }); + * + * store.observable.filter(e => e.name === "updated").subscribe(event => { + * console.log(event.name); // "updated" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // Map {...} + * }); + * + * store.observable.filter(e => e.name === "removed").subscribe(event => { + * console.log(event.name); // "removed" + * console.log(event.type); // "products" + * console.log(event.id); // "1" + * console.log(event.resource); // null + * }); + */ + this.observable = this._subject.asObservable(); + } + + /** + * Add an individual resource to the store. This is used internally by the + * `push()` method. + * + * @since 0.1.0 + * @param {!Object} object - A JSON API Resource Object to be added. See: + http://jsonapi.org/format/#document-resource-objects + */ + + _createClass(Store, [{ + key: "add", + value: function add(object) { + var _this2 = this; + + if (object) { + if (object.type && object.id) { + (function () { + var name = _this2._data[object.type] && _this2._data[object.type][object.id] ? "updated" : "added"; + var resource = _this2.find(object.type, object.id); + var definition = _this2._types[object.type]; + Object.keys(definition).forEach(function (fieldName) { + if (fieldName[0] !== "_") { + _this2._addField(object, resource, definition, fieldName); + } + }); + _this2._subject.onNext({ + name: name, + type: object.type, + id: object.id, + resource: resource + }); + })(); + } else { + throw new TypeError("The data must have a type and id"); + } + } else { + throw new TypeError("You must provide data to add"); + } + } + + /** + * Converts the given partial into a JSON API compliant representation. + * + * @since 0.5.0 + * @param {!string} [type] - The type of the resource. This can be omitted if the partial includes a type property. + * @param {!string} [id] - The id of the resource. This can be omitted if the partial includes an id property. + * @param {!object} partial - The data to convert. + * @return {object} - JSON API version of the object. + */ + }, { + key: "convert", + value: function convert(type, id, partial) { + var _this3 = this; + + if (type && typeof type === "object") { + return this.convert(type.type, type.id, type); + } else if (id && typeof id === "object") { + return this.convert(type, id.id, id); + } else { + var _ret2 = (function () { + var data = { + type: type, + attributes: {}, + relationships: {} + }; + if (id) { + data.id = id; + } + var definition = _this3._types[data.type]; + Object.keys(definition).forEach(function (fieldName) { + if (fieldName[0] !== "_") { + definition[fieldName].serialize(partial, data, fieldName); + } + }); + return { + v: data + }; + })(); + + if (typeof _ret2 === "object") return _ret2.v; + } + } + + /** + * Attempts to create the resource through the adapter and adds it to the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!Object} partial - Data to create the resource with. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.create("product", { title: "A Book" }).subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "create", + value: function create(type, partial, options) { + if (this._adapter) { + return this._adapter.create(this, type, partial, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Defines a type of resource. + * + * @since 0.2.0 + * @param {!string|string[]} names - Name(s) of the resource. + * @param {!Object} definition - The resource's definition. + */ + }, { + key: "define", + value: function define(names, definition) { + var _this4 = this; + + names = names.constructor === Array ? names : [names]; + if (definition) { + definition._names = names; + names.forEach(function (name) { + if (!_this4._types[name]) { + _this4._types[name] = definition; + } else { + throw new Error("The type '" + name + "' has already been defined."); + } + }); + } else { + throw new Error("You must provide a definition for the type '" + names[0] + "'."); + } + } + + /** + * Attempts to delete the resource through the adapter and removes it from + * the store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.destroy("product", "1").subscribe(() => { + * console.log("Destroyed!"); + * }); + */ + }, { + key: "destroy", + value: function destroy(type, id, options) { + if (this._adapter) { + return this._adapter.destroy(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Finds a resource by type and id. + * + * NOTE: If the resource hasn't been loaded via an add() or push() call it + * will be automatically created when find is called. + * + * @since 0.1.0 + * @param {!string} type - Type of the resource to find. + * @param {!string} id - The id of the resource to find. + * @return {Object} - The resource. + */ + }, { + key: "find", + value: function find(type, id) { + var _this5 = this; + + if (type) { + var _ret3 = (function () { + var definition = _this5._types[type]; + if (definition) { + if (!_this5._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this5._data[t] = collection; + }); + })(); + } + if (id) { + if (!_this5._data[type][id]) { + _this5._data[type][id] = { + _dependents: [], + type: type, + id: id + }; + Object.keys(definition).forEach(function (key) { + if (key[0] !== "_") { + _this5._data[type][id][key] = definition[key]["default"]; + } + }); + } + return { + v: _this5._data[type][id] + }; + } else { + // throw new TypeError(`You must provide an id`); + /*eslint-disable*/ + console.warn(["Using the `store.find()` method to find an entire collection has been deprecated in favour of `store.findAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + return { + v: _this5.findAll(type) + }; + } + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + })(); + + if (typeof _ret3 === "object") return _ret3.v; + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Finds all the resources of a given type. + * + * @since 0.7.0 + * @param {!string} type - Type of the resource to find. + * @return {Object[]} - An array of resources. + */ + }, { + key: "findAll", + value: function findAll(type) { + var _this6 = this; + + if (type) { + var definition = this._types[type]; + if (definition) { + if (!this._data[type]) { + (function () { + var collection = {}; + definition._names.forEach(function (t) { + return _this6._data[t] = collection; + }); + })(); + } + return Object.keys(this._data[type]).map(function (x) { + return _this6._data[type][x]; + }); + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type"); + } + } + + /** + * Attempts to load the given resource through the adapter and adds it to the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.load("products", "1").subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "load", + value: function load(type, id, options) { + if (!id || typeof id === "object") { + /*eslint-disable*/ + console.warn(["Using the `store.load()` method to load an entire collection has been deprecated in favour of `store.loadAll()`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.7.0"].join("\n")); + /*eslint-enable*/ + } + if (this._adapter) { + return this._adapter.load(this, type, id, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Attempts to load all the resources of the given type through the adapter + * and adds them to the store if successful. + * + * @since 0.7.0 + * @param {!string} type - Type of resource. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.loadAll("products").subscribe((products) => { + * console.log(products); + * }); + */ + }, { + key: "loadAll", + value: function loadAll(type, options) { + if (this._adapter) { + return this._adapter.load(this, type, null, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + + /** + * Unregister an event listener that was registered with on(). + * + * @deprecated Use the store.observable property instead of this. + * @since 0.4.0 + * @param {string} event - Name of the event. + * @param {string} type - Name of resource to originally passed to on(). + * @param {string} [id] - ID of the resource to originally passed to on(). + * @param {function} callback - Function originally passed to on(). + */ + }, { + key: "off", + value: function off(event, type, id, callback) { + /*eslint-disable*/ + console.warn(["The `store.off()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ + if (event === "added" || event === "updated" || event === "removed") { + if (this._types[type]) { + if (id && ({}).toString.call(id) === '[object Function]') { + this.off.call(this, event, type, null, id, callback); + } else if (this._subscriptions[event] && this._subscriptions[event][type] && this._subscriptions[event][type][id || "*"]) { + this._subscriptions[event][type][id || "*"].dispose(); + delete this._subscriptions[event][type][id || "*"]; + } + } else { + throw new Error("Unknown type '" + type + "'"); + } + } else { + throw new Error("Unknown event '" + event + "'"); + } + } + + /** + * Register an event listener: "added", "updated" or "removed". + * + * @deprecated Use the store.observable property instead of this. + * @since 0.4.0 + * @param {string} event - Name of the event. + * @param {string} type - Name of resource to watch. + * @param {string} [id] - ID of the resource to watch. + * @param {function} callback - Function to call when the event occurs. + * @param {Object} [context] - Context in which to call the callback. + */ + }, { + key: "on", + value: function on(event, type, id, callback, context) { + var _this7 = this; + + /*eslint-disable*/ + console.warn(["The `store.on()` method has been deprecated in favour of `store.observable`.", "For more information see: https://github.com/haydn/json-api-store/releases/tag/v0.6.0"].join("\n")); + /*eslint-enable*/ + if (event === "added" || event === "updated" || event === "removed") { + if (this._types[type]) { + if (id && ({}).toString.call(id) === '[object Function]') { + this.on.call(this, event, type, null, id, callback); + } else if (!this._subscriptions[event] || !this._subscriptions[event][type] || !this._subscriptions[event][type][id || "*"]) { + var subscription = this._subject.filter(function (e) { + return e.name === event; + }); + subscription = subscription.filter(function (e) { + return _this7._types[type]._names.indexOf(e.type) !== -1; + }); + if (id) { + subscription = subscription.filter(function (e) { + return e.id === id; + }); + } + subscription = subscription.map(function (e) { + return _this7.find(e.type, e.id); + }); + this._subscriptions[event] = this._subscriptions[event] || {}; + if (!this._subscriptions[event][type]) { + (function () { + var obj = {}; + _this7._types[type]._names.forEach(function (type) { + _this7._subscriptions[event][type] = obj; + }); + })(); + } + this._subscriptions[event][type][id || "*"] = subscription.subscribe(callback.bind(context)); + } + } else { + throw new Error("Unknown type '" + type + "'"); + } + } else { + throw new Error("Unknown event '" + event + "'"); + } + } + + /** + * Add a JSON API response to the store. This method can be used to handle a + * successful GET or POST response from the server. + * + * @since 0.1.0 + * @param {Object} root - Top Level Object to push. See: + http://jsonapi.org/format/#document-top-level + */ + }, { + key: "push", + value: function push(root) { + var _this8 = this; + + if (root.data.constructor === Array) { + root.data.forEach(function (x) { + return _this8.add(x); + }); + } else { + this.add(root.data); + } + if (root.included) { + root.included.forEach(function (x) { + return _this8.add(x); + }); + } + } + + /** + * Remove a resource or collection of resources from the store. + * + * @since 0.1.0 + * @param {!string} type - Type of the resource(s) to remove. + * @param {string} [id] - The id of the resource to remove. If omitted all + * resources of the type will be removed. + */ + }, { + key: "remove", + value: function remove(type, id) { + var _this9 = this; + + if (type) { + if (this._types[type]) { + if (id) { + var resource = this._data[type] && this._data[type][id]; + if (resource) { + this._remove(resource); + this._subject.onNext({ + name: "removed", + type: type, + id: id, + resource: null + }); + } + } else { + Object.keys(this._data[type]).forEach(function (id) { + return _this9.remove(type, id); + }); + } + } else { + throw new TypeError("Unknown type '" + type + "'"); + } + } else { + throw new TypeError("You must provide a type to remove"); + } + } + + /** + * Attempts to update the resource through the adapter and updates it in the + * store if successful. + * + * @since 0.5.0 + * @param {!string} type - Type of resource. + * @param {!string} id - ID of resource. + * @param {!Object} partial - Data to update the resource with. + * @param {Object} [options] - Options to pass to the adapter. + * @return {Rx.Observable} + * + * @example + * let adapter = new Store.AjaxAdapter(); + * let store = new Store(adpater); + * store.update("product", "1", { title: "foo" }).subscribe((product) => { + * console.log(product.title); + * }); + */ + }, { + key: "update", + value: function update(type, id, partial, options) { + if (this._adapter) { + return this._adapter.update(this, type, id, partial, options); + } else { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + } + }, { + key: "_addField", + value: function _addField(object, resource, definition, fieldName) { + var _this10 = this; + + var field = definition[fieldName]; + var newValue = field.deserialize.call(this, object, fieldName); + if (typeof newValue !== "undefined") { + if (field.type === "has-one") { + if (resource[fieldName]) { + this._removeInverseRelationship(resource, fieldName, resource[fieldName], field); + } + if (newValue) { + this._addInverseRelationship(resource, fieldName, newValue, field); + } + } else if (field.type === "has-many") { + resource[fieldName].forEach(function (r) { + if (resource[fieldName].indexOf(r) !== -1) { + _this10._removeInverseRelationship(resource, fieldName, r, field); + } + }); + newValue.forEach(function (r) { + _this10._addInverseRelationship(resource, fieldName, r, field); + }); + } + resource[fieldName] = newValue; + } + } + }, { + key: "_addInverseRelationship", + value: function _addInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) { + var targetDefinition = this._types[targetResource.type]; + var sourceDefinition = this._types[sourceResource.type]; + if (targetDefinition) { + var targetFieldName = [sourceField.inverse].concat(sourceDefinition._names).find(function (x) { + return targetDefinition[x]; + }); + var targetField = targetDefinition && targetDefinition[targetFieldName]; + targetResource._dependents.push({ type: sourceResource.type, id: sourceResource.id, fieldName: sourceFieldName }); + if (targetField) { + if (targetField.type === "has-one") { + sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName }); + targetResource[targetFieldName] = sourceResource; + } else if (targetField.type === "has-many") { + sourceResource._dependents.push({ type: targetResource.type, id: targetResource.id, fieldName: targetFieldName }); + if (targetResource[targetFieldName].indexOf(sourceResource) === -1) { + targetResource[targetFieldName].push(sourceResource); + } + } else if (targetField.type === "attr") { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is an attribute ('" + targetFieldName + "')"); + } + } else if (sourceField.inverse) { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is missing ('" + sourceField.inverse + "')"); + } + } + } + }, { + key: "_remove", + value: function _remove(resource) { + var _this11 = this; + + resource._dependents.forEach(function (dependent) { + var dependentResource = _this11._data[dependent.type][dependent.id]; + switch (_this11._types[dependent.type][dependent.fieldName].type) { + case "has-one": + { + dependentResource[dependent.fieldName] = null; + break; + } + case "has-many": + { + var index = dependentResource[dependent.fieldName].indexOf(resource); + if (index !== -1) { + dependentResource[dependent.fieldName].splice(index, 1); + } + break; + } + default: + { + break; + } + } + // TODO: This only needs to be run once for each dependent. + dependentResource._dependents = dependentResource._dependents.filter(function (d) { + return !(d.type === resource.type && d.id === resource.id); + }); + }); + delete this._data[resource.type][resource.id]; + } + }, { + key: "_removeInverseRelationship", + value: function _removeInverseRelationship(sourceResource, sourceFieldName, targetResource, sourceField) { + var targetDefinition = this._types[targetResource.type]; + var targetFieldName = sourceField.inverse || sourceResource.type; + var targetField = targetDefinition && targetDefinition[targetFieldName]; + targetResource._dependents = targetResource._dependents.filter(function (r) { + return !(r.type === sourceResource.type && r.id === sourceResource.id && r.fieldName === sourceFieldName); + }); + if (targetField) { + if (targetField.type === "has-one") { + sourceResource._dependents = sourceResource._dependents.filter(function (r) { + return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName); + }); + targetResource[targetFieldName] = null; + } else if (targetField.type === "has-many") { + sourceResource._dependents = sourceResource._dependents.filter(function (r) { + return !(r.type === targetResource.type && r.id === targetResource.id && r.fieldName === targetFieldName); + }); + targetResource[targetFieldName] = targetResource[targetFieldName].filter(function (r) { + return r !== sourceResource; + }); + } else if (targetField.type === "attr") { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is an attribute ('" + targetFieldName + "')"); + } + } else if (sourceField.inverse) { + throw new Error("The the inverse relationship for '" + sourceFieldName + "' is missing ('" + sourceField.inverse + "')"); + } + } + }]); + + return Store; +})(); + +exports["default"] = Store; + +Store.Rx = _rx2["default"]; +Store.AjaxAdapter = _ajaxAdapter2["default"]; +module.exports = exports["default"]; diff --git a/releases/v0.7.0/store.prod.js b/releases/v0.7.0/store.prod.js new file mode 100644 index 0000000..2a995d7 --- /dev/null +++ b/releases/v0.7.0/store.prod.js @@ -0,0 +1,12147 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Store = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o +// For all details and docs: https://github.com/paulmillr/array.prototype.find +// Fixes and tests supplied by Duncan Hall +(function(globals){ + if (Array.prototype.find) return; + + var find = function(predicate) { + var list = Object(this); + var length = list.length < 0 ? 0 : list.length >>> 0; // ES.ToUint32; + if (length === 0) return undefined; + if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') { + throw new TypeError('Array#find: predicate must be a function'); + } + var thisArg = arguments[1]; + for (var i = 0, value; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) return value; + } + return undefined; + }; + + if (Object.defineProperty) { + try { + Object.defineProperty(Array.prototype, 'find', { + value: find, configurable: true, enumerable: false, writable: true + }); + } catch(e) {} + } + + if (!Array.prototype.find) { + Array.prototype.find = find; + } +})(this); + +},{}],2:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = setTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + clearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + setTimeout(drainQueue, 0); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],3:[function(require,module,exports){ +(function (process,global){ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +;(function (undefined) { + + var objectTypes = { + 'function': true, + 'object': true + }; + + var + freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports, + freeSelf = objectTypes[typeof self] && self.Object && self, + freeWindow = objectTypes[typeof window] && window && window.Object && window, + freeModule = objectTypes[typeof module] && module && !module.nodeType && module, + moduleExports = freeModule && freeModule.exports === freeExports && freeExports, + freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global; + + var root = root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; + + var Rx = { + internals: {}, + config: { + Promise: root.Promise + }, + helpers: { } + }; + + // Defaults + var noop = Rx.helpers.noop = function () { }, + identity = Rx.helpers.identity = function (x) { return x; }, + defaultNow = Rx.helpers.defaultNow = Date.now, + defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); }, + defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); }, + defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); }, + defaultError = Rx.helpers.defaultError = function (err) { throw err; }, + isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; }, + isFunction = Rx.helpers.isFunction = (function () { + + var isFn = function (value) { + return typeof value == 'function' || false; + } + + // fallback for older versions of Chrome and Safari + if (isFn(/x/)) { + isFn = function(value) { + return typeof value == 'function' && toString.call(value) == '[object Function]'; + }; + } + + return isFn; + }()); + + function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;} + + var errorObj = {e: {}}; + + function tryCatcherGen(tryCatchTarget) { + return function tryCatcher() { + try { + return tryCatchTarget.apply(this, arguments); + } catch (e) { + errorObj.e = e; + return errorObj; + } + }; + } + + var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { + if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } + return tryCatcherGen(fn); + }; + + function thrower(e) { + throw e; + } + + Rx.config.longStackSupport = false; + var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })(); + hasStacks = !!stacks.e && !!stacks.e.stack; + + // All code after this point will be filtered from stack traces reported by RxJS + var rStartingLine = captureLine(), rFileName; + + var STACK_JUMP_SEPARATOR = 'From previous event:'; + + function makeStackTraceLong(error, observable) { + // If possible, transform the error stack trace by removing Node and RxJS + // cruft, then concatenating with the stack trace of `observable`. + if (hasStacks && + observable.stack && + typeof error === 'object' && + error !== null && + error.stack && + error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1 + ) { + var stacks = []; + for (var o = observable; !!o; o = o.source) { + if (o.stack) { + stacks.unshift(o.stack); + } + } + stacks.unshift(error.stack); + + var concatedStacks = stacks.join('\n' + STACK_JUMP_SEPARATOR + '\n'); + error.stack = filterStackString(concatedStacks); + } + } + + function filterStackString(stackString) { + var lines = stackString.split('\n'), desiredLines = []; + for (var i = 0, len = lines.length; i < len; i++) { + var line = lines[i]; + + if (!isInternalFrame(line) && !isNodeFrame(line) && line) { + desiredLines.push(line); + } + } + return desiredLines.join('\n'); + } + + function isInternalFrame(stackLine) { + var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine); + if (!fileNameAndLineNumber) { + return false; + } + var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1]; + + return fileName === rFileName && + lineNumber >= rStartingLine && + lineNumber <= rEndingLine; + } + + function isNodeFrame(stackLine) { + return stackLine.indexOf('(module.js:') !== -1 || + stackLine.indexOf('(node.js:') !== -1; + } + + function captureLine() { + if (!hasStacks) { return; } + + try { + throw new Error(); + } catch (e) { + var lines = e.stack.split('\n'); + var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2]; + var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine); + if (!fileNameAndLineNumber) { return; } + + rFileName = fileNameAndLineNumber[0]; + return fileNameAndLineNumber[1]; + } + } + + function getFileNameAndLineNumber(stackLine) { + // Named functions: 'at functionName (filename:lineNumber:columnNumber)' + var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine); + if (attempt1) { return [attempt1[1], Number(attempt1[2])]; } + + // Anonymous functions: 'at filename:lineNumber:columnNumber' + var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine); + if (attempt2) { return [attempt2[1], Number(attempt2[2])]; } + + // Firefox style: 'function@filename:lineNumber or @filename:lineNumber' + var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine); + if (attempt3) { return [attempt3[1], Number(attempt3[2])]; } + } + + var EmptyError = Rx.EmptyError = function() { + this.message = 'Sequence contains no elements.'; + this.name = 'EmptyError'; + Error.call(this); + }; + EmptyError.prototype = Object.create(Error.prototype); + + var ObjectDisposedError = Rx.ObjectDisposedError = function() { + this.message = 'Object has been disposed'; + this.name = 'ObjectDisposedError'; + Error.call(this); + }; + ObjectDisposedError.prototype = Object.create(Error.prototype); + + var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () { + this.message = 'Argument out of range'; + this.name = 'ArgumentOutOfRangeError'; + Error.call(this); + }; + ArgumentOutOfRangeError.prototype = Object.create(Error.prototype); + + var NotSupportedError = Rx.NotSupportedError = function (message) { + this.message = message || 'This operation is not supported'; + this.name = 'NotSupportedError'; + Error.call(this); + }; + NotSupportedError.prototype = Object.create(Error.prototype); + + var NotImplementedError = Rx.NotImplementedError = function (message) { + this.message = message || 'This operation is not implemented'; + this.name = 'NotImplementedError'; + Error.call(this); + }; + NotImplementedError.prototype = Object.create(Error.prototype); + + var notImplemented = Rx.helpers.notImplemented = function () { + throw new NotImplementedError(); + }; + + var notSupported = Rx.helpers.notSupported = function () { + throw new NotSupportedError(); + }; + + // Shim in iterator support + var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || + '_es6shim_iterator_'; + // Bug for mozilla version + if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; + } + + var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined }; + + var isIterable = Rx.helpers.isIterable = function (o) { + return o[$iterator$] !== undefined; + } + + var isArrayLike = Rx.helpers.isArrayLike = function (o) { + return o && o.length !== undefined; + } + + Rx.helpers.iterator = $iterator$; + + var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) { + if (typeof thisArg === 'undefined') { return func; } + switch(argCount) { + case 0: + return function() { + return func.call(thisArg) + }; + case 1: + return function(arg) { + return func.call(thisArg, arg); + } + case 2: + return function(value, index) { + return func.call(thisArg, value, index); + }; + case 3: + return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + } + + return function() { + return func.apply(thisArg, arguments); + }; + }; + + /** Used to determine if values are of the language type Object */ + var dontEnums = ['toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor'], + dontEnumsLength = dontEnums.length; + + /** `Object#toString` result shortcuts */ + var argsClass = '[object Arguments]', + arrayClass = '[object Array]', + boolClass = '[object Boolean]', + dateClass = '[object Date]', + errorClass = '[object Error]', + funcClass = '[object Function]', + numberClass = '[object Number]', + objectClass = '[object Object]', + regexpClass = '[object RegExp]', + stringClass = '[object String]'; + + var toString = Object.prototype.toString, + hasOwnProperty = Object.prototype.hasOwnProperty, + supportsArgsClass = toString.call(arguments) == argsClass, // For less -1); + } + }); + } + } + stackA.pop(); + stackB.pop(); + + return result; + } + + var hasProp = {}.hasOwnProperty, + slice = Array.prototype.slice; + + var inherits = Rx.internals.inherits = function (child, parent) { + function __() { this.constructor = child; } + __.prototype = parent.prototype; + child.prototype = new __(); + }; + + var addProperties = Rx.internals.addProperties = function (obj) { + for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } + for (var idx = 0, ln = sources.length; idx < ln; idx++) { + var source = sources[idx]; + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }; + + // Rx Utils + var addRef = Rx.internals.addRef = function (xs, r) { + return new AnonymousObservable(function (observer) { + return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer)); + }); + }; + + function arrayInitialize(count, factory) { + var a = new Array(count); + for (var i = 0; i < count; i++) { + a[i] = factory(); + } + return a; + } + + function IndexedItem(id, value) { + this.id = id; + this.value = value; + } + + IndexedItem.prototype.compareTo = function (other) { + var c = this.value.compareTo(other.value); + c === 0 && (c = this.id - other.id); + return c; + }; + + var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) { + this.items = new Array(capacity); + this.length = 0; + }; + + var priorityProto = PriorityQueue.prototype; + priorityProto.isHigherPriority = function (left, right) { + return this.items[left].compareTo(this.items[right]) < 0; + }; + + priorityProto.percolate = function (index) { + if (index >= this.length || index < 0) { return; } + var parent = index - 1 >> 1; + if (parent < 0 || parent === index) { return; } + if (this.isHigherPriority(index, parent)) { + var temp = this.items[index]; + this.items[index] = this.items[parent]; + this.items[parent] = temp; + this.percolate(parent); + } + }; + + priorityProto.heapify = function (index) { + +index || (index = 0); + if (index >= this.length || index < 0) { return; } + var left = 2 * index + 1, + right = 2 * index + 2, + first = index; + if (left < this.length && this.isHigherPriority(left, first)) { + first = left; + } + if (right < this.length && this.isHigherPriority(right, first)) { + first = right; + } + if (first !== index) { + var temp = this.items[index]; + this.items[index] = this.items[first]; + this.items[first] = temp; + this.heapify(first); + } + }; + + priorityProto.peek = function () { return this.items[0].value; }; + + priorityProto.removeAt = function (index) { + this.items[index] = this.items[--this.length]; + this.items[this.length] = undefined; + this.heapify(); + }; + + priorityProto.dequeue = function () { + var result = this.peek(); + this.removeAt(0); + return result; + }; + + priorityProto.enqueue = function (item) { + var index = this.length++; + this.items[index] = new IndexedItem(PriorityQueue.count++, item); + this.percolate(index); + }; + + priorityProto.remove = function (item) { + for (var i = 0; i < this.length; i++) { + if (this.items[i].value === item) { + this.removeAt(i); + return true; + } + } + return false; + }; + PriorityQueue.count = 0; + + /** + * Represents a group of disposable resources that are disposed together. + * @constructor + */ + var CompositeDisposable = Rx.CompositeDisposable = function () { + var args = [], i, len; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + len = args.length; + } else { + len = arguments.length; + args = new Array(len); + for(i = 0; i < len; i++) { args[i] = arguments[i]; } + } + this.disposables = args; + this.isDisposed = false; + this.length = args.length; + }; + + var CompositeDisposablePrototype = CompositeDisposable.prototype; + + /** + * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. + * @param {Mixed} item Disposable to add. + */ + CompositeDisposablePrototype.add = function (item) { + if (this.isDisposed) { + item.dispose(); + } else { + this.disposables.push(item); + this.length++; + } + }; + + /** + * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. + * @param {Mixed} item Disposable to remove. + * @returns {Boolean} true if found; false otherwise. + */ + CompositeDisposablePrototype.remove = function (item) { + var shouldDispose = false; + if (!this.isDisposed) { + var idx = this.disposables.indexOf(item); + if (idx !== -1) { + shouldDispose = true; + this.disposables.splice(idx, 1); + this.length--; + item.dispose(); + } + } + return shouldDispose; + }; + + /** + * Disposes all disposables in the group and removes them from the group. + */ + CompositeDisposablePrototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var len = this.disposables.length, currentDisposables = new Array(len); + for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } + this.disposables = []; + this.length = 0; + + for (i = 0; i < len; i++) { + currentDisposables[i].dispose(); + } + } + }; + + /** + * Provides a set of static methods for creating Disposables. + * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. + */ + var Disposable = Rx.Disposable = function (action) { + this.isDisposed = false; + this.action = action || noop; + }; + + /** Performs the task of cleaning up resources. */ + Disposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.action(); + this.isDisposed = true; + } + }; + + /** + * Creates a disposable object that invokes the specified action when disposed. + * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. + * @return {Disposable} The disposable object that runs the given action upon disposal. + */ + var disposableCreate = Disposable.create = function (action) { return new Disposable(action); }; + + /** + * Gets the disposable that does nothing when disposed. + */ + var disposableEmpty = Disposable.empty = { dispose: noop }; + + /** + * Validates whether the given object is a disposable + * @param {Object} Object to test whether it has a dispose method + * @returns {Boolean} true if a disposable object, else false. + */ + var isDisposable = Disposable.isDisposable = function (d) { + return d && isFunction(d.dispose); + }; + + var checkDisposed = Disposable.checkDisposed = function (disposable) { + if (disposable.isDisposed) { throw new ObjectDisposedError(); } + }; + + var disposableFixup = Disposable._fixup = function (result) { + return isDisposable(result) ? result : disposableEmpty; + }; + + // Single assignment + var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () { + this.isDisposed = false; + this.current = null; + }; + SingleAssignmentDisposable.prototype.getDisposable = function () { + return this.current; + }; + SingleAssignmentDisposable.prototype.setDisposable = function (value) { + if (this.current) { throw new Error('Disposable has already been assigned'); } + var shouldDispose = this.isDisposed; + !shouldDispose && (this.current = value); + shouldDispose && value && value.dispose(); + }; + SingleAssignmentDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old = this.current; + this.current = null; + old && old.dispose(); + } + }; + + // Multiple assignment disposable + var SerialDisposable = Rx.SerialDisposable = function () { + this.isDisposed = false; + this.current = null; + }; + SerialDisposable.prototype.getDisposable = function () { + return this.current; + }; + SerialDisposable.prototype.setDisposable = function (value) { + var shouldDispose = this.isDisposed; + if (!shouldDispose) { + var old = this.current; + this.current = value; + } + old && old.dispose(); + shouldDispose && value && value.dispose(); + }; + SerialDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old = this.current; + this.current = null; + } + old && old.dispose(); + }; + + var BinaryDisposable = Rx.BinaryDisposable = function (first, second) { + this._first = first; + this._second = second; + this.isDisposed = false; + }; + + BinaryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + var old1 = this._first; + this._first = null; + old1 && old1.dispose(); + var old2 = this._second; + this._second = null; + old2 && old2.dispose(); + } + }; + + var NAryDisposable = Rx.NAryDisposable = function (disposables) { + this._disposables = disposables; + this.isDisposed = false; + }; + + NAryDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + for (var i = 0, len = this._disposables.length; i < len; i++) { + this._disposables[i].dispose(); + } + this._disposables.length = 0; + } + }; + + /** + * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. + */ + var RefCountDisposable = Rx.RefCountDisposable = (function () { + + function InnerDisposable(disposable) { + this.disposable = disposable; + this.disposable.count++; + this.isInnerDisposed = false; + } + + InnerDisposable.prototype.dispose = function () { + if (!this.disposable.isDisposed && !this.isInnerDisposed) { + this.isInnerDisposed = true; + this.disposable.count--; + if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) { + this.disposable.isDisposed = true; + this.disposable.underlyingDisposable.dispose(); + } + } + }; + + /** + * Initializes a new instance of the RefCountDisposable with the specified disposable. + * @constructor + * @param {Disposable} disposable Underlying disposable. + */ + function RefCountDisposable(disposable) { + this.underlyingDisposable = disposable; + this.isDisposed = false; + this.isPrimaryDisposed = false; + this.count = 0; + } + + /** + * Disposes the underlying disposable only when all dependent disposables have been disposed + */ + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed && !this.isPrimaryDisposed) { + this.isPrimaryDisposed = true; + if (this.count === 0) { + this.isDisposed = true; + this.underlyingDisposable.dispose(); + } + } + }; + + /** + * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable. + * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime. + */ + RefCountDisposable.prototype.getDisposable = function () { + return this.isDisposed ? disposableEmpty : new InnerDisposable(this); + }; + + return RefCountDisposable; + })(); + + function ScheduledDisposable(scheduler, disposable) { + this.scheduler = scheduler; + this.disposable = disposable; + this.isDisposed = false; + } + + function scheduleItem(s, self) { + if (!self.isDisposed) { + self.isDisposed = true; + self.disposable.dispose(); + } + } + + ScheduledDisposable.prototype.dispose = function () { + this.scheduler.schedule(this, scheduleItem); + }; + + var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) { + this.scheduler = scheduler; + this.state = state; + this.action = action; + this.dueTime = dueTime; + this.comparer = comparer || defaultSubComparer; + this.disposable = new SingleAssignmentDisposable(); + } + + ScheduledItem.prototype.invoke = function () { + this.disposable.setDisposable(this.invokeCore()); + }; + + ScheduledItem.prototype.compareTo = function (other) { + return this.comparer(this.dueTime, other.dueTime); + }; + + ScheduledItem.prototype.isCancelled = function () { + return this.disposable.isDisposed; + }; + + ScheduledItem.prototype.invokeCore = function () { + return disposableFixup(this.action(this.scheduler, this.state)); + }; + + /** Provides a set of static properties to access commonly used schedulers. */ + var Scheduler = Rx.Scheduler = (function () { + + function Scheduler() { } + + /** Determines whether the given object is a scheduler */ + Scheduler.isScheduler = function (s) { + return s instanceof Scheduler; + }; + + var schedulerProto = Scheduler.prototype; + + /** + * Schedules an action to be executed. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.schedule = function (state, action) { + throw new NotImplementedError(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param state State passed to the action to be executed. + * @param {Function} action Action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime; + dt instanceof Date && (dt = dt - this.now()); + dt = Scheduler.normalize(dt); + + if (dt === 0) { return this.schedule(state, action); } + + return this._scheduleFuture(state, dt, action); + }; + + schedulerProto._scheduleFuture = function (state, dueTime, action) { + throw new NotImplementedError(); + }; + + /** Gets the current time according to the local machine's system clock. */ + Scheduler.now = defaultNow; + + /** Gets the current time according to the local machine's system clock. */ + Scheduler.prototype.now = defaultNow; + + /** + * Normalizes the specified TimeSpan value to a positive value. + * @param {Number} timeSpan The time span value to normalize. + * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0 + */ + Scheduler.normalize = function (timeSpan) { + timeSpan < 0 && (timeSpan = 0); + return timeSpan; + }; + + return Scheduler; + }()); + + var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler; + + (function (schedulerProto) { + + function invokeRecImmediate(scheduler, pair) { + var state = pair[0], action = pair[1], group = new CompositeDisposable(); + action(state, innerAction); + return group; + + function innerAction(state2) { + var isAdded = false, isDone = false; + + var d = scheduler.schedule(state2, scheduleWork); + if (!isDone) { + group.add(d); + isAdded = true; + } + + function scheduleWork(_, state3) { + if (isAdded) { + group.remove(d); + } else { + isDone = true; + } + action(state3, innerAction); + return disposableEmpty; + } + } + } + + function invokeRecDate(scheduler, pair) { + var state = pair[0], action = pair[1], group = new CompositeDisposable(); + action(state, innerAction); + return group; + + function innerAction(state2, dueTime1) { + var isAdded = false, isDone = false; + + var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork); + if (!isDone) { + group.add(d); + isAdded = true; + } + + function scheduleWork(_, state3) { + if (isAdded) { + group.remove(d); + } else { + isDone = true; + } + action(state3, innerAction); + return disposableEmpty; + } + } + } + + /** + * Schedules an action to be executed recursively. + * @param {Mixed} state State passed to the action to be executed. + * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleRecursive = function (state, action) { + return this.schedule([state, action], invokeRecImmediate); + }; + + /** + * Schedules an action to be executed recursively after a specified relative or absolute due time. + * @param {Mixed} state State passed to the action to be executed. + * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. + * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) { + return this.scheduleFuture([state, action], dueTime, invokeRecDate); + }; + + }(Scheduler.prototype)); + + (function (schedulerProto) { + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + Scheduler.prototype.schedulePeriodic = function(state, period, action) { + if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); } + period = normalizeTime(period); + var s = state, id = root.setInterval(function () { s = action(s); }, period); + return disposableCreate(function () { root.clearInterval(id); }); + }; + + }(Scheduler.prototype)); + + (function (schedulerProto) { + /** + * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions. + * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false. + * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling. + */ + schedulerProto.catchError = schedulerProto['catch'] = function (handler) { + return new CatchScheduler(this, handler); + }; + }(Scheduler.prototype)); + + var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () { + function tick(command, recurse) { + recurse(0, this._period); + try { + this._state = this._action(this._state); + } catch (e) { + this._cancel.dispose(); + throw e; + } + } + + function SchedulePeriodicRecursive(scheduler, state, period, action) { + this._scheduler = scheduler; + this._state = state; + this._period = period; + this._action = action; + } + + SchedulePeriodicRecursive.prototype.start = function () { + var d = new SingleAssignmentDisposable(); + this._cancel = d; + d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, tick.bind(this))); + + return d; + }; + + return SchedulePeriodicRecursive; + }()); + + /** Gets a scheduler that schedules work immediately on the current thread. */ + var ImmediateScheduler = (function (__super__) { + inherits(ImmediateScheduler, __super__); + function ImmediateScheduler() { + __super__.call(this); + } + + ImmediateScheduler.prototype.schedule = function (state, action) { + return disposableFixup(action(this, state)); + }; + + return ImmediateScheduler; + }(Scheduler)); + + var immediateScheduler = Scheduler.immediate = new ImmediateScheduler(); + + /** + * Gets a scheduler that schedules work as soon as possible on the current thread. + */ + var CurrentThreadScheduler = (function (__super__) { + var queue; + + function runTrampoline () { + while (queue.length > 0) { + var item = queue.dequeue(); + !item.isCancelled() && item.invoke(); + } + } + + inherits(CurrentThreadScheduler, __super__); + function CurrentThreadScheduler() { + __super__.call(this); + } + + CurrentThreadScheduler.prototype.schedule = function (state, action) { + var si = new ScheduledItem(this, state, action, this.now()); + + if (!queue) { + queue = new PriorityQueue(4); + queue.enqueue(si); + + var result = tryCatch(runTrampoline)(); + queue = null; + if (result === errorObj) { thrower(result.e); } + } else { + queue.enqueue(si); + } + return si.disposable; + }; + + CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; }; + + return CurrentThreadScheduler; + }(Scheduler)); + + var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler(); + + var scheduleMethod, clearMethod; + + var localTimer = (function () { + var localSetTimeout, localClearTimeout = noop; + if (!!root.setTimeout) { + localSetTimeout = root.setTimeout; + localClearTimeout = root.clearTimeout; + } else if (!!root.WScript) { + localSetTimeout = function (fn, time) { + root.WScript.Sleep(time); + fn(); + }; + } else { + throw new NotSupportedError(); + } + + return { + setTimeout: localSetTimeout, + clearTimeout: localClearTimeout + }; + }()); + var localSetTimeout = localTimer.setTimeout, + localClearTimeout = localTimer.clearTimeout; + + (function () { + + var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false; + + clearMethod = function (handle) { + delete tasksByHandle[handle]; + }; + + function runTask(handle) { + if (currentlyRunning) { + localSetTimeout(function () { runTask(handle); }, 0); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunning = true; + var result = tryCatch(task)(); + clearMethod(handle); + currentlyRunning = false; + if (result === errorObj) { thrower(result.e); } + } + } + } + + var reNative = new RegExp('^' + + String(toString) + .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + .replace(/toString| for [^\]]+/g, '.*?') + '$' + ); + + var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' && + !reNative.test(setImmediate) && setImmediate; + + function postMessageSupported () { + // Ensure not in a worker + if (!root.postMessage || root.importScripts) { return false; } + var isAsync = false, oldHandler = root.onmessage; + // Test for async + root.onmessage = function () { isAsync = true; }; + root.postMessage('', '*'); + root.onmessage = oldHandler; + + return isAsync; + } + + // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout + if (isFunction(setImmediate)) { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + setImmediate(function () { runTask(id); }); + + return id; + }; + } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + process.nextTick(function () { runTask(id); }); + + return id; + }; + } else if (postMessageSupported()) { + var MSG_PREFIX = 'ms.rx.schedule' + Math.random(); + + function onGlobalPostMessage(event) { + // Only if we're a match to avoid any other global events + if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) { + runTask(event.data.substring(MSG_PREFIX.length)); + } + } + + if (root.addEventListener) { + root.addEventListener('message', onGlobalPostMessage, false); + } else if (root.attachEvent) { + root.attachEvent('onmessage', onGlobalPostMessage); + } else { + root.onmessage = onGlobalPostMessage; + } + + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + root.postMessage(MSG_PREFIX + currentId, '*'); + return id; + }; + } else if (!!root.MessageChannel) { + var channel = new root.MessageChannel(); + + channel.port1.onmessage = function (e) { runTask(e.data); }; + + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + channel.port2.postMessage(id); + return id; + }; + } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) { + + scheduleMethod = function (action) { + var scriptElement = root.document.createElement('script'); + var id = nextHandle++; + tasksByHandle[id] = action; + + scriptElement.onreadystatechange = function () { + runTask(id); + scriptElement.onreadystatechange = null; + scriptElement.parentNode.removeChild(scriptElement); + scriptElement = null; + }; + root.document.documentElement.appendChild(scriptElement); + return id; + }; + + } else { + scheduleMethod = function (action) { + var id = nextHandle++; + tasksByHandle[id] = action; + localSetTimeout(function () { + runTask(id); + }, 0); + + return id; + }; + } + }()); + + /** + * Gets a scheduler that schedules work via a timed callback based upon platform. + */ + var DefaultScheduler = (function (__super__) { + inherits(DefaultScheduler, __super__); + function DefaultScheduler() { + __super__.call(this); + } + + function DefaultSchedulerDisposable(id) { + this._id = id; + this.isDisposed = false; + } + + DefaultSchedulerDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + localClearTimeout(this._id); + } + }; + + DefaultScheduler.prototype.schedule = function (state, action) { + var scheduler = this, disposable = new SingleAssignmentDisposable(); + var id = scheduleMethod(function () { + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); + }); + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; + + DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable(); + if (dt === 0) { return scheduler.schedule(state, action); } + var id = localSetTimeout(function () { + !disposable.isDisposed && disposable.setDisposable(disposableFixup(action(scheduler, state))); + }, dt); + return new BinaryDisposable(disposable, new DefaultSchedulerDisposable(id)); + }; + + return DefaultScheduler; + }(Scheduler)); + + var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler(); + + var CatchScheduler = (function (__super__) { + inherits(CatchScheduler, __super__); + + function CatchScheduler(scheduler, handler) { + this._scheduler = scheduler; + this._handler = handler; + this._recursiveOriginal = null; + this._recursiveWrapper = null; + __super__.call(this); + } + + CatchScheduler.prototype.schedule = function (state, action) { + return this._scheduler.schedule(state, this._wrap(action)); + }; + + CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) { + return this._scheduler.schedule(state, dueTime, this._wrap(action)); + }; + + CatchScheduler.prototype.now = function () { return this._scheduler.now(); }; + + CatchScheduler.prototype._clone = function (scheduler) { + return new CatchScheduler(scheduler, this._handler); + }; + + CatchScheduler.prototype._wrap = function (action) { + var parent = this; + return function (self, state) { + var res = tryCatch(action)(parent._getRecursiveWrapper(self), state); + if (res === errorObj) { + if (!parent._handler(res.e)) { thrower(res.e); } + return disposableEmpty; + } + return disposableFixup(ret); + }; + }; + + CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { + if (this._recursiveOriginal !== scheduler) { + this._recursiveOriginal = scheduler; + var wrapper = this._clone(scheduler); + wrapper._recursiveOriginal = scheduler; + wrapper._recursiveWrapper = wrapper; + this._recursiveWrapper = wrapper; + } + return this._recursiveWrapper; + }; + + CatchScheduler.prototype.schedulePeriodic = function (state, period, action) { + var self = this, failed = false, d = new SingleAssignmentDisposable(); + + d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) { + if (failed) { return null; } + var res = tryCatch(action)(state1); + if (res === errorObj) { + failed = true; + if (!self._handler(res.e)) { thrower(res.e); } + d.dispose(); + return null; + } + return ret; + })); + + return d; + }; + + return CatchScheduler; + }(Scheduler)); + + /** + * Represents a notification to an observer. + */ + var Notification = Rx.Notification = (function () { + function Notification() { + + } + + Notification.prototype._accept = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + Notification.prototype._acceptObservable = function (onNext, onError, onCompleted) { + throw new NotImplementedError(); + }; + + /** + * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. + * + * @memberOf Notification + * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on.. + * @param {Function} onError Delegate to invoke for an OnError notification. + * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification. + * @returns {Any} Result produced by the observation. + */ + Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) { + return observerOrOnNext && typeof observerOrOnNext === 'object' ? + this._acceptObservable(observerOrOnNext) : + this._accept(observerOrOnNext, onError, onCompleted); + }; + + /** + * Returns an observable sequence with a single notification. + * + * @memberOf Notifications + * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on. + * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription. + */ + Notification.prototype.toObservable = function (scheduler) { + var self = this; + isScheduler(scheduler) || (scheduler = immediateScheduler); + return new AnonymousObservable(function (o) { + return scheduler.schedule(self, function (_, notification) { + notification._acceptObservable(o); + notification.kind === 'N' && o.onCompleted(); + }); + }); + }; + + return Notification; + })(); + + var OnNextNotification = (function (__super__) { + inherits(OnNextNotification, __super__); + function OnNextNotification(value) { + this.value = value; + this.kind = 'N'; + } + + OnNextNotification.prototype._accept = function (onNext) { + return onNext(this.value); + }; + + OnNextNotification.prototype._acceptObservable = function (o) { + return o.onNext(this.value); + }; + + OnNextNotification.prototype.toString = function () { + return 'OnNext(' + this.value + ')'; + }; + + return OnNextNotification; + }(Notification)); + + var OnErrorNotification = (function (__super__) { + inherits(OnErrorNotification, __super__); + function OnErrorNotification(error) { + this.error = error; + this.kind = 'E'; + } + + OnErrorNotification.prototype._accept = function (onNext, onError) { + return onError(this.error); + }; + + OnErrorNotification.prototype._acceptObservable = function (o) { + return o.onError(this.error); + }; + + OnErrorNotification.prototype.toString = function () { + return 'OnError(' + this.error + ')'; + }; + + return OnErrorNotification; + }(Notification)); + + var OnCompletedNotification = (function (__super__) { + inherits(OnCompletedNotification, __super__); + function OnCompletedNotification() { + this.kind = 'C'; + } + + OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) { + return onCompleted(); + }; + + OnCompletedNotification.prototype._acceptObservable = function (o) { + return o.onCompleted(); + }; + + OnCompletedNotification.prototype.toString = function () { + return 'OnCompleted()'; + }; + + return OnCompletedNotification; + }(Notification)); + + /** + * Creates an object that represents an OnNext notification to an observer. + * @param {Any} value The value contained in the notification. + * @returns {Notification} The OnNext notification containing the value. + */ + var notificationCreateOnNext = Notification.createOnNext = function (value) { + return new OnNextNotification(value); + }; + + /** + * Creates an object that represents an OnError notification to an observer. + * @param {Any} error The exception contained in the notification. + * @returns {Notification} The OnError notification containing the exception. + */ + var notificationCreateOnError = Notification.createOnError = function (error) { + return new OnErrorNotification(error); + }; + + /** + * Creates an object that represents an OnCompleted notification to an observer. + * @returns {Notification} The OnCompleted notification. + */ + var notificationCreateOnCompleted = Notification.createOnCompleted = function () { + return new OnCompletedNotification(); + }; + + /** + * Supports push-style iteration over an observable sequence. + */ + var Observer = Rx.Observer = function () { }; + + /** + * Creates a notification callback from an observer. + * @returns The action that forwards its input notification to the underlying observer. + */ + Observer.prototype.toNotifier = function () { + var observer = this; + return function (n) { return n.accept(observer); }; + }; + + /** + * Hides the identity of an observer. + * @returns An observer that hides the identity of the specified observer. + */ + Observer.prototype.asObserver = function () { + var self = this; + return new AnonymousObserver( + function (x) { self.onNext(x); }, + function (err) { self.onError(err); }, + function () { self.onCompleted(); }); + }; + + /** + * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods. + * If a violation is detected, an Error is thrown from the offending observer method call. + * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer. + */ + Observer.prototype.checked = function () { return new CheckedObserver(this); }; + + /** + * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions. + * @param {Function} [onNext] Observer's OnNext action implementation. + * @param {Function} [onError] Observer's OnError action implementation. + * @param {Function} [onCompleted] Observer's OnCompleted action implementation. + * @returns {Observer} The observer object implemented using the given actions. + */ + var observerCreate = Observer.create = function (onNext, onError, onCompleted) { + onNext || (onNext = noop); + onError || (onError = defaultError); + onCompleted || (onCompleted = noop); + return new AnonymousObserver(onNext, onError, onCompleted); + }; + + /** + * Creates an observer from a notification callback. + * @param {Function} handler Action that handles a notification. + * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives. + */ + Observer.fromNotifier = function (handler, thisArg) { + var cb = bindCallback(handler, thisArg, 1); + return new AnonymousObserver(function (x) { + return cb(notificationCreateOnNext(x)); + }, function (e) { + return cb(notificationCreateOnError(e)); + }, function () { + return cb(notificationCreateOnCompleted()); + }); + }; + + /** + * Schedules the invocation of observer methods on the given scheduler. + * @param {Scheduler} scheduler Scheduler to schedule observer messages on. + * @returns {Observer} Observer whose messages are scheduled on the given scheduler. + */ + Observer.prototype.notifyOn = function (scheduler) { + return new ObserveOnObserver(scheduler, this); + }; + + Observer.prototype.makeSafe = function(disposable) { + return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable); + }; + + /** + * Abstract base class for implementations of the Observer class. + * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages. + */ + var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) { + inherits(AbstractObserver, __super__); + + /** + * Creates a new observer in a non-stopped state. + */ + function AbstractObserver() { + this.isStopped = false; + } + + // Must be implemented by other observers + AbstractObserver.prototype.next = notImplemented; + AbstractObserver.prototype.error = notImplemented; + AbstractObserver.prototype.completed = notImplemented; + + /** + * Notifies the observer of a new element in the sequence. + * @param {Any} value Next element in the sequence. + */ + AbstractObserver.prototype.onNext = function (value) { + !this.isStopped && this.next(value); + }; + + /** + * Notifies the observer that an exception has occurred. + * @param {Any} error The error that has occurred. + */ + AbstractObserver.prototype.onError = function (error) { + if (!this.isStopped) { + this.isStopped = true; + this.error(error); + } + }; + + /** + * Notifies the observer of the end of the sequence. + */ + AbstractObserver.prototype.onCompleted = function () { + if (!this.isStopped) { + this.isStopped = true; + this.completed(); + } + }; + + /** + * Disposes the observer, causing it to transition to the stopped state. + */ + AbstractObserver.prototype.dispose = function () { this.isStopped = true; }; + + AbstractObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.error(e); + return true; + } + + return false; + }; + + return AbstractObserver; + }(Observer)); + + /** + * Class to create an Observer instance from delegate-based implementations of the on* methods. + */ + var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) { + inherits(AnonymousObserver, __super__); + + /** + * Creates an observer from the specified OnNext, OnError, and OnCompleted actions. + * @param {Any} onNext Observer's OnNext action implementation. + * @param {Any} onError Observer's OnError action implementation. + * @param {Any} onCompleted Observer's OnCompleted action implementation. + */ + function AnonymousObserver(onNext, onError, onCompleted) { + __super__.call(this); + this._onNext = onNext; + this._onError = onError; + this._onCompleted = onCompleted; + } + + /** + * Calls the onNext action. + * @param {Any} value Next element in the sequence. + */ + AnonymousObserver.prototype.next = function (value) { + this._onNext(value); + }; + + /** + * Calls the onError action. + * @param {Any} error The error that has occurred. + */ + AnonymousObserver.prototype.error = function (error) { + this._onError(error); + }; + + /** + * Calls the onCompleted action. + */ + AnonymousObserver.prototype.completed = function () { + this._onCompleted(); + }; + + return AnonymousObserver; + }(AbstractObserver)); + + var CheckedObserver = (function (__super__) { + inherits(CheckedObserver, __super__); + + function CheckedObserver(observer) { + __super__.call(this); + this._observer = observer; + this._state = 0; // 0 - idle, 1 - busy, 2 - done + } + + var CheckedObserverPrototype = CheckedObserver.prototype; + + CheckedObserverPrototype.onNext = function (value) { + this.checkAccess(); + var res = tryCatch(this._observer.onNext).call(this._observer, value); + this._state = 0; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.onError = function (err) { + this.checkAccess(); + var res = tryCatch(this._observer.onError).call(this._observer, err); + this._state = 2; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.onCompleted = function () { + this.checkAccess(); + var res = tryCatch(this._observer.onCompleted).call(this._observer); + this._state = 2; + res === errorObj && thrower(res.e); + }; + + CheckedObserverPrototype.checkAccess = function () { + if (this._state === 1) { throw new Error('Re-entrancy detected'); } + if (this._state === 2) { throw new Error('Observer completed'); } + if (this._state === 0) { this._state = 1; } + }; + + return CheckedObserver; + }(Observer)); + + var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) { + inherits(ScheduledObserver, __super__); + + function ScheduledObserver(scheduler, observer) { + __super__.call(this); + this.scheduler = scheduler; + this.observer = observer; + this.isAcquired = false; + this.hasFaulted = false; + this.queue = []; + this.disposable = new SerialDisposable(); + } + + ScheduledObserver.prototype.next = function (value) { + var self = this; + this.queue.push(function () { self.observer.onNext(value); }); + }; + + ScheduledObserver.prototype.error = function (e) { + var self = this; + this.queue.push(function () { self.observer.onError(e); }); + }; + + ScheduledObserver.prototype.completed = function () { + var self = this; + this.queue.push(function () { self.observer.onCompleted(); }); + }; + + ScheduledObserver.prototype.ensureActive = function () { + var isOwner = false; + if (!this.hasFaulted && this.queue.length > 0) { + isOwner = !this.isAcquired; + this.isAcquired = true; + } + if (isOwner) { + this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, function (parent, self) { + var work; + if (parent.queue.length > 0) { + work = parent.queue.shift(); + } else { + parent.isAcquired = false; + return; + } + var res = tryCatch(work)(); + if (res === errorObj) { + parent.queue = []; + parent.hasFaulted = true; + return thrower(res.e); + } + self(parent); + })); + } + }; + + ScheduledObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this.disposable.dispose(); + }; + + return ScheduledObserver; + }(AbstractObserver)); + + var ObserveOnObserver = (function (__super__) { + inherits(ObserveOnObserver, __super__); + + function ObserveOnObserver(scheduler, observer, cancel) { + __super__.call(this, scheduler, observer); + this._cancel = cancel; + } + + ObserveOnObserver.prototype.next = function (value) { + __super__.prototype.next.call(this, value); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.error = function (e) { + __super__.prototype.error.call(this, e); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.completed = function () { + __super__.prototype.completed.call(this); + this.ensureActive(); + }; + + ObserveOnObserver.prototype.dispose = function () { + __super__.prototype.dispose.call(this); + this._cancel && this._cancel.dispose(); + this._cancel = null; + }; + + return ObserveOnObserver; + })(ScheduledObserver); + + var observableProto; + + /** + * Represents a push-style collection. + */ + var Observable = Rx.Observable = (function () { + + function makeSubscribe(self, subscribe) { + return function (o) { + var oldOnError = o.onError; + o.onError = function (e) { + makeStackTraceLong(e, self); + oldOnError.call(o, e); + }; + + return subscribe.call(self, o); + }; + } + + function Observable() { + if (Rx.config.longStackSupport && hasStacks) { + var oldSubscribe = this._subscribe; + var e = tryCatch(thrower)(new Error()).e; + this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); + this._subscribe = makeSubscribe(this, oldSubscribe); + } + } + + observableProto = Observable.prototype; + + /** + * Determines whether the given object is an Observable + * @param {Any} An object to determine whether it is an Observable + * @returns {Boolean} true if an Observable, else false. + */ + Observable.isObservable = function (o) { + return o && isFunction(o.subscribe); + }; + + /** + * Subscribes an o to the observable sequence. + * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. + * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { + return this._subscribe(typeof oOrOnNext === 'object' ? + oOrOnNext : + observerCreate(oOrOnNext, onError, onCompleted)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onNext The function to invoke on each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnNext = function (onNext, thisArg) { + return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); + }; + + /** + * Subscribes to an exceptional condition in the sequence with an optional "this" argument. + * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnError = function (onError, thisArg) { + return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); + }; + + /** + * Subscribes to the next value in the sequence with an optional "this" argument. + * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. + */ + observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { + return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); + }; + + return Observable; + })(); + + var ObservableBase = Rx.ObservableBase = (function (__super__) { + inherits(ObservableBase, __super__); + + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.subscribeCore).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function ObservableBase() { + __super__.call(this); + } + + ObservableBase.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + ObservableBase.prototype.subscribeCore = notImplemented; + + return ObservableBase; + }(Observable)); + +var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) { + + inherits(FlatMapObservable, __super__); + + function FlatMapObservable(source, selector, resultSelector, thisArg) { + this.resultSelector = isFunction(resultSelector) ? resultSelector : null; + this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); + this.source = source; + __super__.call(this); + } + + FlatMapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(observer, selector, resultSelector, source) { + this.i = 0; + this.selector = selector; + this.resultSelector = resultSelector; + this.source = source; + this.o = observer; + AbstractObserver.call(this); + } + + InnerObserver.prototype._wrapResult = function(result, x, i) { + return this.resultSelector ? + result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : + result; + }; + + InnerObserver.prototype.next = function(x) { + var i = this.i++; + var result = tryCatch(this.selector)(x, i, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result)); + this.o.onNext(this._wrapResult(result, x, i)); + }; + + InnerObserver.prototype.error = function(e) { this.o.onError(e); }; + + InnerObserver.prototype.onCompleted = function() { this.o.onCompleted(); }; + + return FlatMapObservable; + +}(ObservableBase)); + + var Enumerable = Rx.internals.Enumerable = function () { }; + + function IsDisposedDisposable(state) { + this._s = state; + this.isDisposed = false; + } + + IsDisposedDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.isDisposed = true; + } + }; + + var ConcatEnumerableObservable = (function(__super__) { + inherits(ConcatEnumerableObservable, __super__); + function ConcatEnumerableObservable(sources) { + this.sources = sources; + __super__.call(this); + } + + ConcatEnumerableObservable.prototype.subscribeCore = function (o) { + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(this.sources[$iterator$](), function (e, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + return o.onCompleted(); + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e))); + }); + + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, s, e) { + this._o = o; + this._s = s; + this._e = e; + AbstractObserver.call(this); + } + InnerObserver.prototype.onNext = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.onError = function (e) { this._o.onError(e); }; + InnerObserver.prototype.onCompleted = function () { this._s(this._e); }; + + return ConcatEnumerableObservable; + }(ObservableBase)); + + Enumerable.prototype.concat = function () { + return new ConcatEnumerableObservable(this); + }; + + var CatchErrorObservable = (function(__super__) { + inherits(CatchErrorObservable, __super__); + function CatchErrorObservable(sources) { + this.sources = sources; + __super__.call(this); + } + + CatchErrorObservable.prototype.subscribeCore = function (o) { + var e = this.sources[$iterator$](); + + var state = { isDisposed: false }, subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (lastException, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + return lastException !== null ? o.onError(lastException) : o.onCompleted(); + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(currentValue.subscribe(new InnerObserver(o, self))); + }); + return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, recurse) { + this._o = o; + this._recurse = recurse; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this._o.onNext(x); }; + InnerObserver.prototype.error = function (e) { this._recurse(e); }; + InnerObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return CatchErrorObservable; + }(ObservableBase)); + + Enumerable.prototype.catchError = function () { + return new CatchErrorObservable(this); + }; + + Enumerable.prototype.catchErrorWhen = function (notificationHandler) { + var sources = this; + return new AnonymousObservable(function (o) { + var exceptions = new Subject(), + notifier = new Subject(), + handled = notificationHandler(exceptions), + notificationDisposable = handled.subscribe(notifier); + + var e = sources[$iterator$](); + + var state = { isDisposed: false }, + lastException, + subscription = new SerialDisposable(); + var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, self) { + if (state.isDisposed) { return; } + var currentItem = tryCatch(e.next).call(e); + if (currentItem === errorObj) { return o.onError(currentItem.e); } + + if (currentItem.done) { + if (lastException) { + o.onError(lastException); + } else { + o.onCompleted(); + } + return; + } + + // Check if promise + var currentValue = currentItem.value; + isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); + + var outer = new SingleAssignmentDisposable(); + var inner = new SingleAssignmentDisposable(); + subscription.setDisposable(new BinaryDisposable(inner, outer)); + outer.setDisposable(currentValue.subscribe( + function(x) { o.onNext(x); }, + function (exn) { + inner.setDisposable(notifier.subscribe(self, function(ex) { + o.onError(ex); + }, function() { + o.onCompleted(); + })); + + exceptions.onNext(exn); + }, + function() { o.onCompleted(); })); + }); + + return new NAryDisposable([notificationDisposable, subscription, cancelable, new IsDisposedDisposable(state)]); + }); + }; + + var RepeatEnumerable = (function (__super__) { + inherits(RepeatEnumerable, __super__); + + function RepeatEnumerable(v, c) { + this.v = v; + this.c = c == null ? -1 : c; + } + RepeatEnumerable.prototype[$iterator$] = function () { + return new RepeatEnumerator(this); + }; + + function RepeatEnumerator(p) { + this.v = p.v; + this.l = p.c; + } + RepeatEnumerator.prototype.next = function () { + if (this.l === 0) { return doneEnumerator; } + if (this.l > 0) { this.l--; } + return { done: false, value: this.v }; + }; + + return RepeatEnumerable; + }(Enumerable)); + + var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) { + return new RepeatEnumerable(value, repeatCount); + }; + + var OfEnumerable = (function(__super__) { + inherits(OfEnumerable, __super__); + function OfEnumerable(s, fn, thisArg) { + this.s = s; + this.fn = fn ? bindCallback(fn, thisArg, 3) : null; + } + OfEnumerable.prototype[$iterator$] = function () { + return new OfEnumerator(this); + }; + + function OfEnumerator(p) { + this.i = -1; + this.s = p.s; + this.l = this.s.length; + this.fn = p.fn; + } + OfEnumerator.prototype.next = function () { + return ++this.i < this.l ? + { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } : + doneEnumerator; + }; + + return OfEnumerable; + }(Enumerable)); + + var enumerableOf = Enumerable.of = function (source, selector, thisArg) { + return new OfEnumerable(source, selector, thisArg); + }; + +var ObserveOnObservable = (function (__super__) { + inherits(ObserveOnObservable, __super__); + function ObserveOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + ObserveOnObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new ObserveOnObserver(this._s, o)); + }; + + return ObserveOnObservable; +}(ObservableBase)); + + /** + * Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + * + * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects + * that require to be run on a scheduler, use subscribeOn. + * + * @param {Scheduler} scheduler Scheduler to notify observers on. + * @returns {Observable} The source sequence whose observations happen on the specified scheduler. + */ + observableProto.observeOn = function (scheduler) { + return new ObserveOnObservable(this, scheduler); + }; + + var SubscribeOnObservable = (function (__super__) { + inherits(SubscribeOnObservable, __super__); + function SubscribeOnObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + function scheduleMethod(scheduler, state) { + var source = state[0], d = state[1], o = state[2]; + d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o))); + } + + SubscribeOnObservable.prototype.subscribeCore = function (o) { + var m = new SingleAssignmentDisposable(), d = new SerialDisposable(); + d.setDisposable(m); + m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod)); + return d; + }; + + return SubscribeOnObservable; + }(ObservableBase)); + + /** + * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used; + * see the remarks section for more information on the distinction between subscribeOn and observeOn. + + * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer + * callbacks on a scheduler, use observeOn. + + * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on. + * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + observableProto.subscribeOn = function (scheduler) { + return new SubscribeOnObservable(this, scheduler); + }; + + var FromPromiseObservable = (function(__super__) { + inherits(FromPromiseObservable, __super__); + function FromPromiseObservable(p) { + this.p = p; + __super__.call(this); + } + + FromPromiseObservable.prototype.subscribeCore = function(o) { + this.p + .then(function (data) { + o.onNext(data); + o.onCompleted(); + }, function (err) { + o.onError(err); + }); + return disposableEmpty; + }; + + return FromPromiseObservable; + }(ObservableBase)); + + /** + * Converts a Promise to an Observable sequence + * @param {Promise} An ES6 Compliant promise. + * @returns {Observable} An Observable sequence which wraps the existing promise success and failure. + */ + var observableFromPromise = Observable.fromPromise = function (promise) { + return new FromPromiseObservable(promise); + }; + + /* + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence. + */ + observableProto.toPromise = function (promiseCtor) { + promiseCtor || (promiseCtor = Rx.config.Promise); + if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); } + var source = this; + return new promiseCtor(function (resolve, reject) { + // No cancellation can be done + var value; + source.subscribe(function (v) { + value = v; + }, reject, function () { + resolve(value); + }); + }); + }; + + var ToArrayObservable = (function(__super__) { + inherits(ToArrayObservable, __super__); + function ToArrayObservable(source) { + this.source = source; + __super__.call(this); + } + + ToArrayObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o) { + this.o = o; + this.a = []; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function (x) { this.a.push(x); }; + InnerObserver.prototype.error = function (e) { this.o.onError(e); }; + InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); }; + + return ToArrayObservable; + }(ObservableBase)); + + /** + * Creates an array from an observable sequence. + * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. + */ + observableProto.toArray = function () { + return new ToArrayObservable(this); + }; + + /** + * Creates an observable sequence from a specified subscribe method implementation. + * @example + * var res = Rx.Observable.create(function (observer) { return function () { } ); + * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } ); + * var res = Rx.Observable.create(function (observer) { } ); + * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable. + * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method. + */ + Observable.create = function (subscribe, parent) { + return new AnonymousObservable(subscribe, parent); + }; + + var Defer = (function(__super__) { + inherits(Defer, __super__); + function Defer(factory) { + this._f = factory; + __super__.call(this); + } + + Defer.prototype.subscribeCore = function (o) { + var result = tryCatch(this._f)(); + if (result === errorObj) { return observableThrow(result.e).subscribe(o);} + isPromise(result) && (result = observableFromPromise(result)); + return result.subscribe(o); + }; + + return Defer; + }(ObservableBase)); + + /** + * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. + * + * @example + * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); }); + * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise. + * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function. + */ + var observableDefer = Observable.defer = function (observableFactory) { + return new Defer(observableFactory); + }; + + var EmptyObservable = (function(__super__) { + inherits(EmptyObservable, __super__); + function EmptyObservable(scheduler) { + this.scheduler = scheduler; + __super__.call(this); + } + + EmptyObservable.prototype.subscribeCore = function (observer) { + var sink = new EmptySink(observer, this.scheduler); + return sink.run(); + }; + + function EmptySink(observer, scheduler) { + this.observer = observer; + this.scheduler = scheduler; + } + + function scheduleItem(s, state) { + state.onCompleted(); + return disposableEmpty; + } + + EmptySink.prototype.run = function () { + var state = this.observer; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); + }; + + return EmptyObservable; + }(ObservableBase)); + + var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler); + + /** + * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message. + * + * @example + * var res = Rx.Observable.empty(); + * var res = Rx.Observable.empty(Rx.Scheduler.timeout); + * @param {Scheduler} [scheduler] Scheduler to send the termination call on. + * @returns {Observable} An observable sequence with no elements. + */ + var observableEmpty = Observable.empty = function (scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler); + }; + + var FromObservable = (function(__super__) { + inherits(FromObservable, __super__); + function FromObservable(iterable, mapper, scheduler) { + this.iterable = iterable; + this.mapper = mapper; + this.scheduler = scheduler; + __super__.call(this); + } + + FromObservable.prototype.subscribeCore = function (o) { + var sink = new FromSink(o, this); + return sink.run(); + }; + + return FromObservable; + }(ObservableBase)); + + var FromSink = (function () { + function FromSink(o, parent) { + this.o = o; + this.parent = parent; + } + + FromSink.prototype.run = function () { + var list = Object(this.parent.iterable), + it = getIterable(list), + o = this.o, + mapper = this.parent.mapper; + + function loopRecursive(i, recurse) { + var next = tryCatch(it.next).call(it); + if (next === errorObj) { return o.onError(next.e); } + if (next.done) { return o.onCompleted(); } + + var result = next.value; + + if (isFunction(mapper)) { + result = tryCatch(mapper)(result, i); + if (result === errorObj) { return o.onError(result.e); } + } + + o.onNext(result); + recurse(i + 1); + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + return FromSink; + }()); + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function StringIterable(s) { + this._s = s; + } + + StringIterable.prototype[$iterator$] = function () { + return new StringIterator(this._s); + }; + + function StringIterator(s) { + this._s = s; + this._l = s.length; + this._i = 0; + } + + StringIterator.prototype[$iterator$] = function () { + return this; + }; + + StringIterator.prototype.next = function () { + return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator; + }; + + function ArrayIterable(a) { + this._a = a; + } + + ArrayIterable.prototype[$iterator$] = function () { + return new ArrayIterator(this._a); + }; + + function ArrayIterator(a) { + this._a = a; + this._l = toLength(a); + this._i = 0; + } + + ArrayIterator.prototype[$iterator$] = function () { + return this; + }; + + ArrayIterator.prototype.next = function () { + return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator; + }; + + function numberIsFinite(value) { + return typeof value === 'number' && root.isFinite(value); + } + + function isNan(n) { + return n !== n; + } + + function getIterable(o) { + var i = o[$iterator$], it; + if (!i && typeof o === 'string') { + it = new StringIterable(o); + return it[$iterator$](); + } + if (!i && o.length !== undefined) { + it = new ArrayIterable(o); + return it[$iterator$](); + } + if (!i) { throw new TypeError('Object is not iterable'); } + return o[$iterator$](); + } + + function sign(value) { + var number = +value; + if (number === 0) { return number; } + if (isNaN(number)) { return number; } + return number < 0 ? -1 : 1; + } + + function toLength(o) { + var len = +o.length; + if (isNaN(len)) { return 0; } + if (len === 0 || !numberIsFinite(len)) { return len; } + len = sign(len) * Math.floor(Math.abs(len)); + if (len <= 0) { return 0; } + if (len > maxSafeInteger) { return maxSafeInteger; } + return len; + } + + /** + * This method creates a new Observable sequence from an array-like or iterable object. + * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence. + * @param {Function} [mapFn] Map function to call on every element of the array. + * @param {Any} [thisArg] The context to use calling the mapFn if provided. + * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) { + if (iterable == null) { + throw new Error('iterable cannot be null.') + } + if (mapFn && !isFunction(mapFn)) { + throw new Error('mapFn when provided must be a function'); + } + if (mapFn) { + var mapper = bindCallback(mapFn, thisArg, 2); + } + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromObservable(iterable, mapper, scheduler); + } + + var FromArrayObservable = (function(__super__) { + inherits(FromArrayObservable, __super__); + function FromArrayObservable(args, scheduler) { + this.args = args; + this.scheduler = scheduler; + __super__.call(this); + } + + FromArrayObservable.prototype.subscribeCore = function (observer) { + var sink = new FromArraySink(observer, this); + return sink.run(); + }; + + return FromArrayObservable; + }(ObservableBase)); + + function FromArraySink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + FromArraySink.prototype.run = function () { + var observer = this.observer, args = this.parent.args, len = args.length; + function loopRecursive(i, recurse) { + if (i < len) { + observer.onNext(args[i]); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + /** + * Converts an array to an observable sequence, using an optional scheduler to enumerate the array. + * @deprecated use Observable.from or Observable.of + * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. + * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence. + */ + var observableFromArray = Observable.fromArray = function (array, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromArrayObservable(array, scheduler) + }; + + var GenerateObservable = (function (__super__) { + inherits(GenerateObservable, __super__); + function GenerateObservable(state, cndFn, itrFn, resFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._s = s; + this._first = true; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + var hasResult = tryCatch(self._cndFn)(self._state); + if (hasResult === errorObj) { return self._o.onError(hasResult.e); } + if (hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + self._o.onNext(result); + recurse(self); + } else { + self._o.onCompleted(); + } + } + + GenerateObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursive(this, scheduleRecursive); + }; + + return GenerateObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. + * + * @example + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }); + * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout); + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread. + * @returns {Observable} The generated sequence. + */ + Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler); + }; + + function observableOf (scheduler, array) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new FromArrayObservable(array, scheduler); + } + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. + */ + Observable.of = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return new FromArrayObservable(args, currentThreadScheduler); + }; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments. + * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. + */ + Observable.ofWithScheduler = function (scheduler) { + var len = arguments.length, args = new Array(len - 1); + for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; } + return new FromArrayObservable(args, scheduler); + }; + + /** + * Creates an Observable sequence from changes to an array using Array.observe. + * @param {Array} array An array to observe changes. + * @returns {Observable} An observable sequence containing changes to an array from Array.observe. + */ + Observable.ofArrayChanges = function(array) { + if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); } + if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Array.observe(array, observerFn); + + return function () { + Array.unobserve(array, observerFn); + }; + }); + }; + + /** + * Creates an Observable sequence from changes to an object using Object.observe. + * @param {Object} obj An object to observe changes. + * @returns {Observable} An observable sequence containing changes to an object from Object.observe. + */ + Observable.ofObjectChanges = function(obj) { + if (obj == null) { throw new TypeError('object must not be null or undefined.'); } + if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') } + return new AnonymousObservable(function(observer) { + function observerFn(changes) { + for(var i = 0, len = changes.length; i < len; i++) { + observer.onNext(changes[i]); + } + } + + Object.observe(obj, observerFn); + + return function () { + Object.unobserve(obj, observerFn); + }; + }); + }; + + var NeverObservable = (function(__super__) { + inherits(NeverObservable, __super__); + function NeverObservable() { + __super__.call(this); + } + + NeverObservable.prototype.subscribeCore = function (observer) { + return disposableEmpty; + }; + + return NeverObservable; + }(ObservableBase)); + + var NEVER_OBSERVABLE = new NeverObservable(); + + /** + * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). + * @returns {Observable} An observable sequence whose observers will never get called. + */ + var observableNever = Observable.never = function () { + return NEVER_OBSERVABLE; + }; + + var PairsObservable = (function(__super__) { + inherits(PairsObservable, __super__); + function PairsObservable(obj, scheduler) { + this.obj = obj; + this.keys = Object.keys(obj); + this.scheduler = scheduler; + __super__.call(this); + } + + PairsObservable.prototype.subscribeCore = function (observer) { + var sink = new PairsSink(observer, this); + return sink.run(); + }; + + return PairsObservable; + }(ObservableBase)); + + function PairsSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + PairsSink.prototype.run = function () { + var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length; + function loopRecursive(i, recurse) { + if (i < len) { + var key = keys[i]; + observer.onNext([key, obj[key]]); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + /** + * Convert an object into an observable sequence of [key, value] pairs. + * @param {Object} obj The object to inspect. + * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. + * @returns {Observable} An observable sequence of [key, value] pairs from the object. + */ + Observable.pairs = function (obj, scheduler) { + scheduler || (scheduler = currentThreadScheduler); + return new PairsObservable(obj, scheduler); + }; + + var RangeObservable = (function(__super__) { + inherits(RangeObservable, __super__); + function RangeObservable(start, count, scheduler) { + this.start = start; + this.rangeCount = count; + this.scheduler = scheduler; + __super__.call(this); + } + + RangeObservable.prototype.subscribeCore = function (observer) { + var sink = new RangeSink(observer, this); + return sink.run(); + }; + + return RangeObservable; + }(ObservableBase)); + + var RangeSink = (function () { + function RangeSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + RangeSink.prototype.run = function () { + var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer; + function loopRecursive(i, recurse) { + if (i < count) { + observer.onNext(start + i); + recurse(i + 1); + } else { + observer.onCompleted(); + } + } + + return this.parent.scheduler.scheduleRecursive(0, loopRecursive); + }; + + return RangeSink; + }()); + + /** + * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages. + * @param {Number} start The value of the first integer in the sequence. + * @param {Number} count The number of sequential integers to generate. + * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread. + * @returns {Observable} An observable sequence that contains a range of sequential integral numbers. + */ + Observable.range = function (start, count, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new RangeObservable(start, count, scheduler); + }; + + var RepeatObservable = (function(__super__) { + inherits(RepeatObservable, __super__); + function RepeatObservable(value, repeatCount, scheduler) { + this.value = value; + this.repeatCount = repeatCount == null ? -1 : repeatCount; + this.scheduler = scheduler; + __super__.call(this); + } + + RepeatObservable.prototype.subscribeCore = function (observer) { + var sink = new RepeatSink(observer, this); + return sink.run(); + }; + + return RepeatObservable; + }(ObservableBase)); + + function RepeatSink(observer, parent) { + this.observer = observer; + this.parent = parent; + } + + RepeatSink.prototype.run = function () { + var observer = this.observer, value = this.parent.value; + function loopRecursive(i, recurse) { + if (i === -1 || i > 0) { + observer.onNext(value); + i > 0 && i--; + } + if (i === 0) { return observer.onCompleted(); } + recurse(i); + } + + return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive); + }; + + /** + * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages. + * @param {Mixed} value Element to repeat. + * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely. + * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate. + * @returns {Observable} An observable sequence that repeats the given element the specified number of times. + */ + Observable.repeat = function (value, repeatCount, scheduler) { + isScheduler(scheduler) || (scheduler = currentThreadScheduler); + return new RepeatObservable(value, repeatCount, scheduler); + }; + + var JustObservable = (function(__super__) { + inherits(JustObservable, __super__); + function JustObservable(value, scheduler) { + this.value = value; + this.scheduler = scheduler; + __super__.call(this); + } + + JustObservable.prototype.subscribeCore = function (observer) { + var sink = new JustSink(observer, this.value, this.scheduler); + return sink.run(); + }; + + function JustSink(observer, value, scheduler) { + this.observer = observer; + this.value = value; + this.scheduler = scheduler; + } + + function scheduleItem(s, state) { + var value = state[0], observer = state[1]; + observer.onNext(value); + observer.onCompleted(); + return disposableEmpty; + } + + JustSink.prototype.run = function () { + var state = [this.value, this.observer]; + return this.scheduler === immediateScheduler ? + scheduleItem(null, state) : + this.scheduler.schedule(state, scheduleItem); + }; + + return JustObservable; + }(ObservableBase)); + + /** + * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages. + * There is an alias called 'just' or browsers 0) { + parent.handleSubscribe(parent.q.shift()); + } else { + parent.activeCount--; + parent.done && parent.activeCount === 0 && parent.o.onCompleted(); + } + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeObserver; + }()); + + + + + + /** + * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences. + * Or merges two observable sequences into a single observable sequence. + * + * @example + * 1 - merged = sources.merge(1); + * 2 - merged = source.merge(otherSource); + * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.merge = function (maxConcurrentOrOther) { + return typeof maxConcurrentOrOther !== 'number' ? + observableMerge(this, maxConcurrentOrOther) : + new MergeObservable(this, maxConcurrentOrOther); + }; + + /** + * Merges all the observable sequences into a single observable sequence. + * The scheduler is optional and if not specified, the immediate scheduler is used. + * @returns {Observable} The observable sequence that merges the elements of the observable sequences. + */ + var observableMerge = Observable.merge = function () { + var scheduler, sources = [], i, len = arguments.length; + if (!arguments[0]) { + scheduler = immediateScheduler; + for(i = 1; i < len; i++) { sources.push(arguments[i]); } + } else if (isScheduler(arguments[0])) { + scheduler = arguments[0]; + for(i = 1; i < len; i++) { sources.push(arguments[i]); } + } else { + scheduler = immediateScheduler; + for(i = 0; i < len; i++) { sources.push(arguments[i]); } + } + if (Array.isArray(sources[0])) { + sources = sources[0]; + } + return observableOf(scheduler, sources).mergeAll(); + }; + + var MergeAllObservable = (function (__super__) { + inherits(MergeAllObservable, __super__); + + function MergeAllObservable(source) { + this.source = source; + __super__.call(this); + } + + MergeAllObservable.prototype.subscribeCore = function (observer) { + var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); + g.add(m); + m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g))); + return g; + }; + + function MergeAllObserver(o, g) { + this.o = o; + this.g = g; + this.isStopped = false; + this.done = false; + } + MergeAllObserver.prototype.onNext = function(innerSource) { + if(this.isStopped) { return; } + var sad = new SingleAssignmentDisposable(); + this.g.add(sad); + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); + }; + MergeAllObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + } + }; + MergeAllObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.done = true; + this.g.length === 1 && this.o.onCompleted(); + } + }; + MergeAllObserver.prototype.dispose = function() { this.isStopped = true; }; + MergeAllObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + + return false; + }; + + function InnerObserver(parent, sad) { + this.parent = parent; + this.sad = sad; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } }; + InnerObserver.prototype.onError = function (e) { + if(!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + var parent = this.parent; + this.isStopped = true; + parent.g.remove(this.sad); + parent.done && parent.g.length === 1 && parent.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.parent.o.onError(e); + return true; + } + + return false; + }; + + return MergeAllObservable; + }(ObservableBase)); + + /** + * Merges an observable sequence of observable sequences into an observable sequence. + * @returns {Observable} The observable sequence that merges the elements of the inner sequences. + */ + observableProto.mergeAll = function () { + return new MergeAllObservable(this); + }; + + var CompositeError = Rx.CompositeError = function(errors) { + this.name = "NotImplementedError"; + this.innerErrors = errors; + this.message = 'This contains multiple errors. Check the innerErrors'; + Error.call(this); + } + CompositeError.prototype = Error.prototype; + + /** + * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to + * receive all successfully emitted items from all of the source Observables without being interrupted by + * an error notification from one of them. + * + * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an + * error via the Observer's onError, mergeDelayError will refrain from propagating that + * error notification until all of the merged Observables have finished emitting items. + * @param {Array | Arguments} args Arguments or an array to merge. + * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable + */ + Observable.mergeDelayError = function() { + var args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + var len = arguments.length; + args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + var source = observableOf(null, args); + + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(), + m = new SingleAssignmentDisposable(), + isStopped = false, + errors = []; + + function setCompletion() { + if (errors.length === 0) { + o.onCompleted(); + } else if (errors.length === 1) { + o.onError(errors[0]); + } else { + o.onError(new CompositeError(errors)); + } + } + + group.add(m); + + m.setDisposable(source.subscribe( + function (innerSource) { + var innerSubscription = new SingleAssignmentDisposable(); + group.add(innerSubscription); + + // Check for promises support + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { + errors.push(e); + group.remove(innerSubscription); + isStopped && group.length === 1 && setCompletion(); + }, + function () { + group.remove(innerSubscription); + isStopped && group.length === 1 && setCompletion(); + })); + }, + function (e) { + errors.push(e); + isStopped = true; + group.length === 1 && setCompletion(); + }, + function () { + isStopped = true; + group.length === 1 && setCompletion(); + })); + return group; + }); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates. + * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally. + */ + observableProto.onErrorResumeNext = function (second) { + if (!second) { throw new Error('Second observable is required'); } + return onErrorResumeNext([this, second]); + }; + + /** + * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. + * + * @example + * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs); + * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]); + * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. + */ + var onErrorResumeNext = Observable.onErrorResumeNext = function () { + var sources = []; + if (Array.isArray(arguments[0])) { + sources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } + } + return new AnonymousObservable(function (observer) { + var pos = 0, subscription = new SerialDisposable(), + cancelable = immediateScheduler.scheduleRecursive(null, function (_, self) { + var current, d; + if (pos < sources.length) { + current = sources[pos++]; + isPromise(current) && (current = observableFromPromise(current)); + d = new SingleAssignmentDisposable(); + subscription.setDisposable(d); + d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self)); + } else { + observer.onCompleted(); + } + }); + return new BinaryDisposable(subscription, cancelable); + }); + }; + + var SkipUntilObservable = (function(__super__) { + inherits(SkipUntilObservable, __super__); + + function SkipUntilObservable(source, other) { + this._s = source; + this._o = isPromise(other) ? observableFromPromise(other) : other; + this._open = false; + __super__.call(this); + } + + SkipUntilObservable.prototype.subscribeCore = function(o) { + var leftSubscription = new SingleAssignmentDisposable(); + leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this))); + + isPromise(this._o) && (this._o = observableFromPromise(this._o)); + + var rightSubscription = new SingleAssignmentDisposable(); + rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription))); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }; + + return SkipUntilObservable; + }(ObservableBase)); + + var SkipUntilSourceObserver = (function(__super__) { + inherits(SkipUntilSourceObserver, __super__); + function SkipUntilSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilSourceObserver.prototype.next = function (x) { + this._p._open && this._o.onNext(x); + }; + + SkipUntilSourceObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + SkipUntilSourceObserver.prototype.onCompleted = function () { + this._p._open && this._o.onCompleted(); + }; + + return SkipUntilSourceObserver; + }(AbstractObserver)); + + var SkipUntilOtherObserver = (function(__super__) { + inherits(SkipUntilOtherObserver, __super__); + function SkipUntilOtherObserver(o, p, r) { + this._o = o; + this._p = p; + this._r = r; + __super__.call(this); + } + + SkipUntilOtherObserver.prototype.next = function () { + this._p._open = true; + this._r.dispose(); + }; + + SkipUntilOtherObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + SkipUntilOtherObserver.prototype.onCompleted = function () { + this._r.dispose(); + }; + + return SkipUntilOtherObserver; + }(AbstractObserver)); + + /** + * Returns the values from the source observable sequence only after the other observable sequence produces a value. + * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence. + * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation. + */ + observableProto.skipUntil = function (other) { + return new SkipUntilObservable(this, other); + }; + + var SwitchObservable = (function(__super__) { + inherits(SwitchObservable, __super__); + function SwitchObservable(source) { + this.source = source; + __super__.call(this); + } + + SwitchObservable.prototype.subscribeCore = function (o) { + var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner)); + return new BinaryDisposable(s, inner); + }; + + inherits(SwitchObserver, AbstractObserver); + function SwitchObserver(o, inner) { + this.o = o; + this.inner = inner; + this.stopped = false; + this.latest = 0; + this.hasLatest = false; + AbstractObserver.call(this); + } + + SwitchObserver.prototype.next = function (innerSource) { + var d = new SingleAssignmentDisposable(), id = ++this.latest; + this.hasLatest = true; + this.inner.setDisposable(d); + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + d.setDisposable(innerSource.subscribe(new InnerObserver(this, id))); + }; + + SwitchObserver.prototype.error = function (e) { + this.o.onError(e); + }; + + SwitchObserver.prototype.completed = function () { + this.stopped = true; + !this.hasLatest && this.o.onCompleted(); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(parent, id) { + this.parent = parent; + this.id = id; + AbstractObserver.call(this); + } + InnerObserver.prototype.next = function (x) { + this.parent.latest === this.id && this.parent.o.onNext(x); + }; + + InnerObserver.prototype.error = function (e) { + this.parent.latest === this.id && this.parent.o.onError(e); + }; + + InnerObserver.prototype.completed = function () { + if (this.parent.latest === this.id) { + this.parent.hasLatest = false; + this.parent.isStopped && this.parent.o.onCompleted(); + } + }; + + return SwitchObservable; + }(ObservableBase)); + + /** + * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + observableProto['switch'] = observableProto.switchLatest = function () { + return new SwitchObservable(this); + }; + + var TakeUntilObservable = (function(__super__) { + inherits(TakeUntilObservable, __super__); + + function TakeUntilObservable(source, other) { + this.source = source; + this.other = isPromise(other) ? observableFromPromise(other) : other; + __super__.call(this); + } + + TakeUntilObservable.prototype.subscribeCore = function(o) { + return new BinaryDisposable( + this.source.subscribe(o), + this.other.subscribe(new TakeUntilObserver(o)) + ); + }; + + return TakeUntilObservable; + }(ObservableBase)); + + var TakeUntilObserver = (function(__super__) { + inherits(TakeUntilObserver, __super__); + function TakeUntilObserver(o) { + this._o = o; + __super__.call(this); + } + + TakeUntilObserver.prototype.next = function () { + this._o.onCompleted(); + }; + + TakeUntilObserver.prototype.error = function (err) { + this._o.onError(err); + }; + + TakeUntilObserver.prototype.onCompleted = noop; + + return TakeUntilObserver; + }(AbstractObserver)); + + /** + * Returns the values from the source observable sequence until the other observable sequence produces a value. + * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence. + * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + */ + observableProto.takeUntil = function (other) { + return new TakeUntilObservable(this, other); + }; + + function falseFactory() { return false; } + function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; + } + + var WithLatestFromObservable = (function(__super__) { + inherits(WithLatestFromObservable, __super__); + function WithLatestFromObservable(source, sources, resultSelector) { + var len = sources.length; + this._s = source; + this._ss = sources; + this._cb = resultSelector; + this._hv = arrayInitialize(len, falseFactory); + this._hvAll = false; + this._v = new Array(len); + __super__.call(this); + } + + WithLatestFromObservable.prototype.subscribeCore = function (o) { + var n = this._ss.length, subscriptions = new Array(n + 1); + for (var i = 0; i < n; i++) { + var other = this._ss[i], sad = new SingleAssignmentDisposable(); + isPromise(other) && (other = observableFromPromise(other)); + sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, this))); + subscriptions[i] = sad; + } + + var sad = new SingleAssignmentDisposable(); + sad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this))); + subscriptions[n] = sad; + + return new NAryDisposable(subscriptions); + }; + + return WithLatestFromObservable; + }(ObservableBase)); + + var WithLatestFromOtherObserver = (function (__super__) { + inherits(WithLatestFromOtherObserver, __super__); + function WithLatestFromOtherObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + WithLatestFromOtherObserver.prototype.next = function (x) { + this._p._v[this._i] = x; + this._p._hv[this._i] = true; + this._p._hvAll = this._p._hv.every(identity); + }; + + WithLatestFromOtherObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromOtherObserver.prototype.completed = noop; + + return WithLatestFromOtherObserver; + }(AbstractObserver)); + + var WithLatestFromSourceObserver = (function (__super__) { + inherits(WithLatestFromSourceObserver, __super__); + function WithLatestFromSourceObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + WithLatestFromSourceObserver.prototype.next = function (x) { + var allValues = [x].concat(this._p._v); + if (!this._p._hvAll) { return; } + var res = tryCatch(this._p._cb).apply(null, allValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + }; + + WithLatestFromSourceObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + WithLatestFromSourceObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return WithLatestFromSourceObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element. + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + observableProto.withLatestFrom = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + + return new WithLatestFromObservable(this, args, resultSelector); + }; + + function falseFactory() { return false; } + function emptyArrayFactory() { return []; } + + var ZipObservable = (function(__super__) { + inherits(ZipObservable, __super__); + function ZipObservable(sources, resultSelector) { + var len = sources.length; + this._s = sources; + this._cb = resultSelector; + this._done = arrayInitialize(len, falseFactory); + this._q = arrayInitialize(len, emptyArrayFactory); + __super__.call(this); + } + + ZipObservable.prototype.subscribeCore = function(observer) { + var n = this._s.length, subscriptions = new Array(n); + + for (var i = 0; i < n; i++) { + var source = this._s[i], sad = new SingleAssignmentDisposable(); + subscriptions[i] = sad; + isPromise(source) && (source = observableFromPromise(source)); + sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this))); + } + + return new NAryDisposable(subscriptions); + }; + + return ZipObservable; + }(ObservableBase)); + + var ZipObserver = (function (__super__) { + inherits(ZipObserver, __super__); + function ZipObserver(o, i, p) { + this._o = o; + this._i = i; + this._p = p; + __super__.call(this); + } + + ZipObserver.prototype.next = function (x) { + this._p._q[this._i].push(x); + if (this._p._q.every(function (x) { return x.length > 0; })) { + var queuedValues = this._p._q.map(function (x) { return x.shift(); }); + var res = tryCatch(this._p._cb).apply(null, queuedValues); + if (res === errorObj) { return this._o.onError(res.e); } + this._o.onNext(res); + } else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) { + this._o.onCompleted(); + } + }; + + ZipObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ZipObserver.prototype.completed = function () { + this._p._done[this._i] = true; + this._p._done.every(identity) && this._o.onCompleted(); + }; + + return ZipObserver; + }(AbstractObserver)); + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. + * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. + * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. + */ + observableProto.zip = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + Array.isArray(args[0]) && (args = args[0]); + + var parent = this; + args.unshift(parent); + + return new ZipObservable(args, resultSelector); + }; + + /** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + * @param arguments Observable sources. + * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources. + * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + Observable.zip = function () { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + if (Array.isArray(args[0])) { + args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0]; + } + var first = args.shift(); + return first.zip.apply(first, args); + }; + +function falseFactory() { return false; } +function emptyArrayFactory() { return []; } +function argumentsToArray() { + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return args; +} + +/** + * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. + * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. + * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. + */ +observableProto.zipIterable = function () { + if (arguments.length === 0) { throw new Error('invalid arguments'); } + + var len = arguments.length, args = new Array(len); + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; + + var parent = this; + args.unshift(parent); + return new AnonymousObservable(function (o) { + var n = args.length, + queues = arrayInitialize(n, emptyArrayFactory), + isDone = arrayInitialize(n, falseFactory); + + var subscriptions = new Array(n); + for (var idx = 0; idx < n; idx++) { + (function (i) { + var source = args[i], sad = new SingleAssignmentDisposable(); + + (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source)); + + sad.setDisposable(source.subscribe(function (x) { + queues[i].push(x); + if (queues.every(function (x) { return x.length > 0; })) { + var queuedValues = queues.map(function (x) { return x.shift(); }), + res = tryCatch(resultSelector).apply(parent, queuedValues); + if (res === errorObj) { return o.onError(res.e); } + o.onNext(res); + } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { + o.onCompleted(); + } + }, function (e) { o.onError(e); }, function () { + isDone[i] = true; + isDone.every(identity) && o.onCompleted(); + })); + subscriptions[i] = sad; + })(idx); + } + + return new CompositeDisposable(subscriptions); + }, parent); +}; + + function asObservable(source) { + return function subscribe(o) { return source.subscribe(o); }; + } + + /** + * Hides the identity of an observable sequence. + * @returns {Observable} An observable sequence that hides the identity of the source sequence. + */ + observableProto.asObservable = function () { + return new AnonymousObservable(asObservable(this), this); + }; + + function toArray(x) { return x.toArray(); } + function notEmpty(x) { return x.length > 0; } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information. + * @param {Number} count Length of each buffer. + * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithCount = function (count, skip) { + typeof skip !== 'number' && (skip = count); + return this.windowWithCount(count, skip) + .flatMap(toArray) + .filter(notEmpty); + }; + + var DematerializeObservable = (function (__super__) { + inherits(DematerializeObservable, __super__); + function DematerializeObservable(source) { + this.source = source; + __super__.call(this); + } + + DematerializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DematerializeObserver(o)); + }; + + return DematerializeObservable; + }(ObservableBase)); + + var DematerializeObserver = (function (__super__) { + inherits(DematerializeObserver, __super__); + + function DematerializeObserver(o) { + this._o = o; + __super__.call(this); + } + + DematerializeObserver.prototype.next = function (x) { x.accept(this._o); }; + DematerializeObserver.prototype.error = function (e) { this._o.onError(e); }; + DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DematerializeObserver; + }(AbstractObserver)); + + /** + * Dematerializes the explicit notification values of an observable sequence as implicit notifications. + * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. + */ + observableProto.dematerialize = function () { + return new DematerializeObservable(this); + }; + + var DistinctUntilChangedObservable = (function(__super__) { + inherits(DistinctUntilChangedObservable, __super__); + function DistinctUntilChangedObservable(source, keyFn, comparer) { + this.source = source; + this.keyFn = keyFn; + this.comparer = comparer; + __super__.call(this); + } + + DistinctUntilChangedObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer)); + }; + + return DistinctUntilChangedObservable; + }(ObservableBase)); + + var DistinctUntilChangedObserver = (function(__super__) { + inherits(DistinctUntilChangedObserver, __super__); + function DistinctUntilChangedObserver(o, keyFn, comparer) { + this.o = o; + this.keyFn = keyFn; + this.comparer = comparer; + this.hasCurrentKey = false; + this.currentKey = null; + __super__.call(this); + } + + DistinctUntilChangedObserver.prototype.next = function (x) { + var key = x, comparerEquals; + if (isFunction(this.keyFn)) { + key = tryCatch(this.keyFn)(x); + if (key === errorObj) { return this.o.onError(key.e); } + } + if (this.hasCurrentKey) { + comparerEquals = tryCatch(this.comparer)(this.currentKey, key); + if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); } + } + if (!this.hasCurrentKey || !comparerEquals) { + this.hasCurrentKey = true; + this.currentKey = key; + this.o.onNext(x); + } + }; + DistinctUntilChangedObserver.prototype.error = function(e) { + this.o.onError(e); + }; + DistinctUntilChangedObserver.prototype.completed = function () { + this.o.onCompleted(); + }; + + return DistinctUntilChangedObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer. + * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value. + * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function. + * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. + */ + observableProto.distinctUntilChanged = function (keyFn, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctUntilChangedObservable(this, keyFn, comparer); + }; + + var TapObservable = (function(__super__) { + inherits(TapObservable,__super__); + function TapObservable(source, observerOrOnNext, onError, onCompleted) { + this.source = source; + this._oN = observerOrOnNext; + this._oE = onError; + this._oC = onCompleted; + __super__.call(this); + } + + TapObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new InnerObserver(o, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, p) { + this.o = o; + this.t = !p._oN || isFunction(p._oN) ? + observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) : + p._oN; + this.isStopped = false; + AbstractObserver.call(this); + } + InnerObserver.prototype.next = function(x) { + var res = tryCatch(this.t.onNext).call(this.t, x); + if (res === errorObj) { this.o.onError(res.e); } + this.o.onNext(x); + }; + InnerObserver.prototype.error = function(err) { + var res = tryCatch(this.t.onError).call(this.t, err); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onError(err); + }; + InnerObserver.prototype.completed = function() { + var res = tryCatch(this.t.onCompleted).call(this.t); + if (res === errorObj) { return this.o.onError(res.e); } + this.o.onCompleted(); + }; + + return TapObservable; + }(ObservableBase)); + + /** + * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o. + * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. + * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) { + return new TapObservable(this, observerOrOnNext, onError, onCompleted); + }; + + /** + * Invokes an action for each element in the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onNext Action to invoke for each element in the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) { + return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext); + }; + + /** + * Invokes an action upon exceptional termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) { + return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError); + }; + + /** + * Invokes an action upon graceful termination of the observable sequence. + * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. + * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} The source sequence with the side-effecting behavior applied. + */ + observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) { + return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted); + }; + + /** + * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. + * @param {Function} finallyAction Action to invoke after the source observable sequence terminates. + * @returns {Observable} Source sequence with the action-invoking termination behavior applied. + */ + observableProto['finally'] = function (action) { + var source = this; + return new AnonymousObservable(function (observer) { + var subscription = tryCatch(source.subscribe).call(source, observer); + if (subscription === errorObj) { + action(); + return thrower(subscription.e); + } + return disposableCreate(function () { + var r = tryCatch(subscription.dispose).call(subscription); + action(); + r === errorObj && thrower(r.e); + }); + }, this); + }; + + var IgnoreElementsObservable = (function(__super__) { + inherits(IgnoreElementsObservable, __super__); + + function IgnoreElementsObservable(source) { + this.source = source; + __super__.call(this); + } + + IgnoreElementsObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o)); + }; + + function InnerObserver(o) { + this.o = o; + this.isStopped = false; + } + InnerObserver.prototype.onNext = noop; + InnerObserver.prototype.onError = function (err) { + if(!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }; + InnerObserver.prototype.onCompleted = function () { + if(!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.observer.onError(e); + return true; + } + + return false; + }; + + return IgnoreElementsObservable; + }(ObservableBase)); + + /** + * Ignores all elements in an observable sequence leaving only the termination messages. + * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence. + */ + observableProto.ignoreElements = function () { + return new IgnoreElementsObservable(this); + }; + + var MaterializeObservable = (function (__super__) { + inherits(MaterializeObservable, __super__); + function MaterializeObservable(source, fn) { + this.source = source; + __super__.call(this); + } + + MaterializeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new MaterializeObserver(o)); + }; + + return MaterializeObservable; + }(ObservableBase)); + + var MaterializeObserver = (function (__super__) { + inherits(MaterializeObserver, __super__); + + function MaterializeObserver(o) { + this._o = o; + __super__.call(this); + } + + MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) }; + MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); }; + MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); }; + + return MaterializeObserver; + }(AbstractObserver)); + + /** + * Materializes the implicit notifications of an observable sequence as explicit notification values. + * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence. + */ + observableProto.materialize = function () { + return new MaterializeObservable(this); + }; + + /** + * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely. + * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely. + * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly. + */ + observableProto.repeat = function (repeatCount) { + return enumerableRepeat(this, repeatCount).concat(); + }; + + /** + * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely. + * Note if you encounter an error and want it to retry once, then you must use .retry(2); + * + * @example + * var res = retried = retry.repeat(); + * var res = retried = retry.repeat(2); + * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely. + * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + observableProto.retry = function (retryCount) { + return enumerableRepeat(this, retryCount).catchError(); + }; + + /** + * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. + * if the notifier completes, the observable sequence completes. + * + * @example + * var timer = Observable.timer(500); + * var source = observable.retryWhen(timer); + * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively. + * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + observableProto.retryWhen = function (notifier) { + return enumerableRepeat(this).catchErrorWhen(notifier); + }; + var ScanObservable = (function(__super__) { + inherits(ScanObservable, __super__); + function ScanObservable(source, accumulator, hasSeed, seed) { + this.source = source; + this.accumulator = accumulator; + this.hasSeed = hasSeed; + this.seed = seed; + __super__.call(this); + } + + ScanObservable.prototype.subscribeCore = function(o) { + return this.source.subscribe(new ScanObserver(o,this)); + }; + + return ScanObservable; + }(ObservableBase)); + + var ScanObserver = (function (__super__) { + inherits(ScanObserver, __super__); + function ScanObserver(o, parent) { + this._o = o; + this._p = parent; + this._fn = parent.accumulator; + this._hs = parent.hasSeed; + this._s = parent.seed; + this._ha = false; + this._a = null; + this._hv = false; + this._i = 0; + __super__.call(this); + } + + ScanObserver.prototype.next = function (x) { + !this._hv && (this._hv = true); + if (this._ha) { + this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); + } else { + this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; + this._ha = true; + } + if (this._a === errorObj) { return this._o.onError(this._a.e); } + this._o.onNext(this._a); + this._i++; + }; + + ScanObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + ScanObserver.prototype.completed = function () { + !this._hv && this._hs && this._o.onNext(this._s); + this._o.onCompleted(); + }; + + return ScanObserver; + }(AbstractObserver)); + + /** + * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. + * For aggregation behavior with no intermediate results, see Observable.aggregate. + * @param {Mixed} [seed] The initial accumulator value. + * @param {Function} accumulator An accumulator function to be invoked on each element. + * @returns {Observable} An observable sequence containing the accumulated values. + */ + observableProto.scan = function () { + var hasSeed = false, seed, accumulator = arguments[0]; + if (arguments.length === 2) { + hasSeed = true; + seed = arguments[1]; + } + return new ScanObservable(this, accumulator, hasSeed, seed); + }; + + var SkipLastObservable = (function (__super__) { + inherits(SkipLastObservable, __super__); + function SkipLastObservable(source, c) { + this.source = source; + this._c = c; + __super__.call(this); + } + + SkipLastObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastObserver(o, this._c)); + }; + + return SkipLastObservable; + }(ObservableBase)); + + var SkipLastObserver = (function (__super__) { + inherits(SkipLastObserver, __super__); + function SkipLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + SkipLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._o.onNext(this._q.shift()); + }; + + SkipLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + SkipLastObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return SkipLastObserver; + }(AbstractObserver)); + + /** + * Bypasses a specified number of elements at the end of an observable sequence. + * @description + * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are + * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed. + * @param count Number of elements to bypass at the end of the source sequence. + * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end. + */ + observableProto.skipLast = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + return new SkipLastObservable(this, count); + }; + + /** + * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend. + * @example + * var res = source.startWith(1, 2, 3); + * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3); + * @param {Arguments} args The specified values to prepend to the observable sequence + * @returns {Observable} The source sequence prepended with the specified values. + */ + observableProto.startWith = function () { + var values, scheduler, start = 0; + if (!!arguments.length && isScheduler(arguments[0])) { + scheduler = arguments[0]; + start = 1; + } else { + scheduler = immediateScheduler; + } + for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); } + return enumerableOf([observableFromArray(args, scheduler), this]).concat(); + }; + + var TakeLastObserver = (function (__super__) { + inherits(TakeLastObserver, __super__); + function TakeLastObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastObserver.prototype.completed = function () { + while (this._q.length > 0) { this._o.onNext(this._q.shift()); } + this._o.onCompleted(); + }; + + return TakeLastObserver; + }(AbstractObserver)); + + /** + * Returns a specified number of contiguous elements from the end of an observable sequence. + * @description + * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of + * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence. + */ + observableProto.takeLast = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastObserver(o, count)); + }, source); + }; + + var TakeLastBufferObserver = (function (__super__) { + inherits(TakeLastBufferObserver, __super__); + function TakeLastBufferObserver(o, c) { + this._o = o; + this._c = c; + this._q = []; + __super__.call(this); + } + + TakeLastBufferObserver.prototype.next = function (x) { + this._q.push(x); + this._q.length > this._c && this._q.shift(); + }; + + TakeLastBufferObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TakeLastBufferObserver.prototype.completed = function () { + this._o.onNext(this._q); + this._o.onCompleted(); + }; + + return TakeLastBufferObserver; + }(AbstractObserver)); + + /** + * Returns an array with the specified number of contiguous elements from the end of an observable sequence. + * + * @description + * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the + * source sequence, this buffer is produced on the result sequence. + * @param {Number} count Number of elements to take from the end of the source sequence. + * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence. + */ + observableProto.takeLastBuffer = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + var source = this; + return new AnonymousObservable(function (o) { + return source.subscribe(new TakeLastBufferObserver(o, count)); + }, source); + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on element count information. + * @param {Number} count Length of each window. + * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithCount = function (count, skip) { + var source = this; + +count || (count = 0); + Math.abs(count) === Infinity && (count = 0); + if (count <= 0) { throw new ArgumentOutOfRangeError(); } + skip == null && (skip = count); + +skip || (skip = 0); + Math.abs(skip) === Infinity && (skip = 0); + + if (skip <= 0) { throw new ArgumentOutOfRangeError(); } + return new AnonymousObservable(function (observer) { + var m = new SingleAssignmentDisposable(), + refCountDisposable = new RefCountDisposable(m), + n = 0, + q = []; + + function createWindow () { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + + createWindow(); + + m.setDisposable(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + var c = n - count + 1; + c >= 0 && c % skip === 0 && q.shift().onCompleted(); + ++n % skip === 0 && createWindow(); + }, + function (e) { + while (q.length > 0) { q.shift().onError(e); } + observer.onError(e); + }, + function () { + while (q.length > 0) { q.shift().onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function concatMap(source, selector, thisArg) { + var selectorFunc = bindCallback(selector, thisArg, 3); + return source.map(function (x, i) { + var result = selectorFunc(x, i, source); + isPromise(result) && (result = observableFromPromise(result)); + (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result)); + return result; + }).concatAll(); + } + + /** + * One of the Following: + * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * + * @example + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }); + * Or: + * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence. + * + * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; }); + * Or: + * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence. + * + * var res = source.concatMap(Rx.Observable.fromArray([1,2,3])); + * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the + * source sequence onto which could be either an observable or Promise. + * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element. + */ + observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) { + if (isFunction(selector) && isFunction(resultSelector)) { + return this.concatMap(function (x, i) { + var selectorResult = selector(x, i); + isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult)); + (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult)); + + return selectorResult.map(function (y, i2) { + return resultSelector(x, y, i, i2); + }); + }); + } + return isFunction(selector) ? + concatMap(this, selector, thisArg) : + concatMap(this, function () { return selector; }); + }; + + /** + * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) { + var source = this, + onNextFunc = bindCallback(onNext, thisArg, 2), + onErrorFunc = bindCallback(onError, thisArg, 1), + onCompletedFunc = bindCallback(onCompleted, thisArg, 0); + return new AnonymousObservable(function (observer) { + var index = 0; + return source.subscribe( + function (x) { + var result; + try { + result = onNextFunc(x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onErrorFunc(err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompletedFunc(); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, this).concatAll(); + }; + + var DefaultIfEmptyObserver = (function (__super__) { + inherits(DefaultIfEmptyObserver, __super__); + function DefaultIfEmptyObserver(o, d) { + this._o = o; + this._d = d; + this._f = false; + __super__.call(this); + } + + DefaultIfEmptyObserver.prototype.next = function (x) { + this._f = true; + this._o.onNext(x); + }; + + DefaultIfEmptyObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + DefaultIfEmptyObserver.prototype.completed = function () { + !this._f && this._o.onNext(defaultValue); + this._o.onCompleted(); + }; + + return DefaultIfEmptyObserver; + }(AbstractObserver)); + + /** + * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty. + * + * var res = obs = xs.defaultIfEmpty(); + * 2 - obs = xs.defaultIfEmpty(false); + * + * @memberOf Observable# + * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null. + * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. + */ + observableProto.defaultIfEmpty = function (defaultValue) { + var source = this; + defaultValue === undefined && (defaultValue = null); + return new AnonymousObservable(function (o) { + return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue)); + }, source); + }; + + // Swap out for Array.findIndex + function arrayIndexOfComparer(array, item, comparer) { + for (var i = 0, len = array.length; i < len; i++) { + if (comparer(array[i], item)) { return i; } + } + return -1; + } + + function HashSet(comparer) { + this.comparer = comparer; + this.set = []; + } + HashSet.prototype.push = function(value) { + var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1; + retValue && this.set.push(value); + return retValue; + }; + + var DistinctObservable = (function (__super__) { + inherits(DistinctObservable, __super__); + function DistinctObservable(source, keyFn, cmpFn) { + this.source = source; + this._keyFn = keyFn; + this._cmpFn = cmpFn; + __super__.call(this); + } + + DistinctObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn)); + }; + + return DistinctObservable; + }(ObservableBase)); + + var DistinctObserver = (function (__super__) { + inherits(DistinctObserver, __super__); + function DistinctObserver(o, keyFn, cmpFn) { + this._o = o; + this._keyFn = keyFn; + this._h = new HashSet(cmpFn); + __super__.call(this); + } + + DistinctObserver.prototype.next = function (x) { + var key = x; + if (isFunction(this._keyFn)) { + key = tryCatch(this._keyFn)(x); + if (key === errorObj) { return this._o.onError(key.e); } + } + this._h.push(key) && this._o.onNext(x); + }; + + DistinctObserver.prototype.error = function (e) { this._o.onError(e); }; + DistinctObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return DistinctObserver; + }(AbstractObserver)); + + /** + * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. + * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. + * + * @example + * var res = obs = xs.distinct(); + * 2 - obs = xs.distinct(function (x) { return x.id; }); + * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; }); + * @param {Function} [keySelector] A function to compute the comparison key for each element. + * @param {Function} [comparer] Used to compare items in the collection. + * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. + */ + observableProto.distinct = function (keySelector, comparer) { + comparer || (comparer = defaultComparer); + return new DistinctObservable(this, keySelector, comparer); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. + * + * @example + * var res = observable.groupBy(function (x) { return x.id; }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} [elementSelector] A function to map each source element to an element in an observable group. + * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + */ + observableProto.groupBy = function (keySelector, elementSelector) { + return this.groupByUntil(keySelector, elementSelector, observableNever); + }; + + /** + * Groups the elements of an observable sequence according to a specified key selector function. + * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same + * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request. + * + * @example + * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); }); + * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }); + * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); }); + * @param {Function} keySelector A function to extract the key for each element. + * @param {Function} durationSelector A function to signal the expiration of a group. + * @returns {Observable} + * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. + * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered. + * + */ + observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) { + var source = this; + return new AnonymousObservable(function (o) { + var map = new Map(), + groupDisposable = new CompositeDisposable(), + refCountDisposable = new RefCountDisposable(groupDisposable), + handleError = function (e) { return function (item) { item.onError(e); }; }; + + groupDisposable.add( + source.subscribe(function (x) { + var key = tryCatch(keySelector)(x); + if (key === errorObj) { + map.forEach(handleError(key.e)); + return o.onError(key.e); + } + + var fireNewMapEntry = false, writer = map.get(key); + if (writer === undefined) { + writer = new Subject(); + map.set(key, writer); + fireNewMapEntry = true; + } + + if (fireNewMapEntry) { + var group = new GroupedObservable(key, writer, refCountDisposable), + durationGroup = new GroupedObservable(key, writer); + var duration = tryCatch(durationSelector)(durationGroup); + if (duration === errorObj) { + map.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + o.onNext(group); + + var md = new SingleAssignmentDisposable(); + groupDisposable.add(md); + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, + function () { + if (map['delete'](key)) { writer.onCompleted(); } + groupDisposable.remove(md); + })); + } + + var element = x; + if (isFunction(elementSelector)) { + element = tryCatch(elementSelector)(x); + if (element === errorObj) { + map.forEach(handleError(element.e)); + return o.onError(element.e); + } + } + + writer.onNext(element); + }, function (e) { + map.forEach(handleError(e)); + o.onError(e); + }, function () { + map.forEach(function (item) { item.onCompleted(); }); + o.onCompleted(); + })); + + return refCountDisposable; + }, source); + }; + + var MapObservable = (function (__super__) { + inherits(MapObservable, __super__); + + function MapObservable(source, selector, thisArg) { + this.source = source; + this.selector = bindCallback(selector, thisArg, 3); + __super__.call(this); + } + + function innerMap(selector, self) { + return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); } + } + + MapObservable.prototype.internalMap = function (selector, thisArg) { + return new MapObservable(this.source, innerMap(selector, this), thisArg); + }; + + MapObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.selector, this)); + }; + + inherits(InnerObserver, AbstractObserver); + function InnerObserver(o, selector, source) { + this.o = o; + this.selector = selector; + this.source = source; + this.i = 0; + AbstractObserver.call(this); + } + + InnerObserver.prototype.next = function(x) { + var result = tryCatch(this.selector)(x, this.i++, this.source); + if (result === errorObj) { return this.o.onError(result.e); } + this.o.onNext(result); + }; + + InnerObserver.prototype.error = function (e) { + this.o.onError(e); + }; + + InnerObserver.prototype.completed = function () { + this.o.onCompleted(); + }; + + return MapObservable; + + }(ObservableBase)); + + /** + * Projects each element of an observable sequence into a new form by incorporating the element's index. + * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source. + */ + observableProto.map = observableProto.select = function (selector, thisArg) { + var selectorFn = typeof selector === 'function' ? selector : function () { return selector; }; + return this instanceof MapObservable ? + this.internalMap(selectorFn, thisArg) : + new MapObservable(this, selectorFn, thisArg); + }; + + function plucker(args, len) { + return function mapper(x) { + var currentProp = x; + for (var i = 0; i < len; i++) { + var p = currentProp[args[i]]; + if (typeof p !== 'undefined') { + currentProp = p; + } else { + return undefined; + } + } + return currentProp; + } + } + + /** + * Retrieves the value of a specified nested property from all elements in + * the Observable sequence. + * @param {Arguments} arguments The nested properties to pluck. + * @returns {Observable} Returns a new Observable sequence of property values. + */ + observableProto.pluck = function () { + var len = arguments.length, args = new Array(len); + if (len === 0) { throw new Error('List of properties cannot be empty.'); } + for(var i = 0; i < len; i++) { args[i] = arguments[i]; } + return this.map(plucker(args, len)); + }; + +observableProto.flatMap = observableProto.selectMany = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll(); +}; + + +// +//Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { +// return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +//}; +// + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) { + var source = this; + return new AnonymousObservable(function (observer) { + var index = 0; + + return source.subscribe( + function (x) { + var result; + try { + result = onNext.call(thisArg, x, index++); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + }, + function (err) { + var result; + try { + result = onError.call(thisArg, err); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }, + function () { + var result; + try { + result = onCompleted.call(thisArg); + } catch (e) { + observer.onError(e); + return; + } + isPromise(result) && (result = observableFromPromise(result)); + observer.onNext(result); + observer.onCompleted(); + }); + }, source).mergeAll(); + }; + +Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); +}; + var SkipObservable = (function(__super__) { + inherits(SkipObservable, __super__); + function SkipObservable(source, count) { + this.source = source; + this.skipCount = count; + __super__.call(this); + } + + SkipObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.skipCount)); + }; + + function InnerObserver(o, c) { + this.c = c; + this.r = c; + this.o = o; + this.isStopped = false; + } + InnerObserver.prototype.onNext = function (x) { + if (this.isStopped) { return; } + if (this.r <= 0) { + this.o.onNext(x); + } else { + this.r--; + } + }; + InnerObserver.prototype.onError = function(e) { + if (!this.isStopped) { this.isStopped = true; this.o.onError(e); } + }; + InnerObserver.prototype.onCompleted = function() { + if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); } + }; + InnerObserver.prototype.dispose = function() { this.isStopped = true; }; + InnerObserver.prototype.fail = function(e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + }; + + return SkipObservable; + }(ObservableBase)); + + /** + * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. + * @param {Number} count The number of elements to skip before returning the remaining elements. + * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence. + */ + observableProto.skip = function (count) { + if (count < 0) { throw new ArgumentOutOfRangeError(); } + return new SkipObservable(this, count); + }; + var SkipWhileObservable = (function (__super__) { + inherits(SkipWhileObservable, __super__); + function SkipWhileObservable(source, fn) { + this.source = source; + this._fn = fn; + __super__.call(this); + } + + SkipWhileObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipWhileObserver(o, this)); + }; + + return SkipWhileObservable; + }(ObservableBase)); + + var SkipWhileObserver = (function (__super__) { + inherits(SkipWhileObserver, __super__); + + function SkipWhileObserver(o, p) { + this._o = o; + this._p = p; + this._i = 0; + this._r = false; + __super__.call(this); + } + + SkipWhileObserver.prototype.next = function (x) { + if (!this._r) { + var res = tryCatch(this._p._fn)(x, this._i++, this._p); + if (res === errorObj) { return this._o.onError(res.e); } + this._r = !res; + } + this._r && this._o.onNext(x); + }; + SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWhileObserver; + }(AbstractObserver)); + + /** + * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + * The element's index is used in the logic of the predicate function. + * + * var res = source.skipWhile(function (value) { return value < 10; }); + * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; }); + * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element. + * @param {Any} [thisArg] Object to use as this when executing callback. + * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. + */ + observableProto.skipWhile = function (predicate, thisArg) { + var fn = bindCallback(predicate, thisArg, 3); + return new SkipWhileObservable(this, fn); + }; + + var TakeObservable = (function(__super__) { + inherits(TakeObservable, __super__); + + function TakeObservable(source, count) { + this.source = source; + this.takeCount = count; + __super__.call(this); + } + + TakeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new InnerObserver(o, this.takeCount)); + }; + + function InnerObserver(o, c) { + this.o = o; + this.c = c; + this.r = c; + this.isStopped = false; + } + InnerObserver.prototype = { + onNext: function (x) { + if (this.isStopped) { return; } + if (this.r-- > 0) { + this.o.onNext(x); + this.r <= 0 && this.o.onCompleted(); + } + }, + onError: function (err) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(err); + } + }, + onCompleted: function () { + if (!this.isStopped) { + this.isStopped = true; + this.o.onCompleted(); + } + }, + dispose: function () { this.isStopped = true; }, + fail: function (e) { + if (!this.isStopped) { + this.isStopped = true; + this.o.onError(e); + return true; + } + return false; + } + }; + + return TakeObservable; + }(ObservableBase)); + + /** + * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0). + * @param {Number} count The number of elements to return. + * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.value = null; + this.error = null; + } + }); + + return BehaviorSubject; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. + */ + var ReplaySubject = Rx.ReplaySubject = (function (__super__) { + + var maxSafeInteger = Math.pow(2, 53) - 1; + + function createRemovableDisposable(subject, observer) { + return disposableCreate(function () { + observer.dispose(); + !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); + }); + } + + inherits(ReplaySubject, __super__); + + /** + * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. + * @param {Number} [bufferSize] Maximum element count of the replay buffer. + * @param {Number} [windowSize] Maximum time length of the replay buffer. + * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. + */ + function ReplaySubject(bufferSize, windowSize, scheduler) { + this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; + this.windowSize = windowSize == null ? maxSafeInteger : windowSize; + this.scheduler = scheduler || currentThreadScheduler; + this.q = []; + this.observers = []; + this.isStopped = false; + this.isDisposed = false; + this.hasError = false; + this.error = null; + __super__.call(this); + } + + addProperties(ReplaySubject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so); + + this._trim(this.scheduler.now()); + this.observers.push(so); + + for (var i = 0, len = this.q.length; i < len; i++) { + so.onNext(this.q[i].value); + } + + if (this.hasError) { + so.onError(this.error); + } else if (this.isStopped) { + so.onCompleted(); + } + + so.ensureActive(); + return subscription; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + return this.observers.length > 0; + }, + _trim: function (now) { + while (this.q.length > this.bufferSize) { + this.q.shift(); + } + while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { + this.q.shift(); + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + var now = this.scheduler.now(); + this.q.push({ interval: now, value: value }); + this._trim(now); + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onNext(value); + observer.ensureActive(); + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + this.error = error; + this.hasError = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onError(error); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (this.isStopped) { return; } + this.isStopped = true; + var now = this.scheduler.now(); + this._trim(now); + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + var observer = os[i]; + observer.onCompleted(); + observer.ensureActive(); + } + this.observers.length = 0; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + return ReplaySubject; + }(Observable)); + + var RefCountObservable = (function (__super__) { + inherits(RefCountObservable, __super__); + function RefCountObservable(source) { + this.source = source; + this._count = 0; + this._connectableSubscription = null; + __super__.call(this); + } + + RefCountObservable.prototype.subscribeCore = function (o) { + var shouldConnect = ++this._count === 1, subscription = this.source.subscribe(o); + shouldConnect && (this._connectableSubscription = this.source.connect()); + return new RefCountDisposable(this, subscription); + }; + + function RefCountDisposable(p, s) { + this._p = p; + this._s = s; + this.isDisposed = false; + } + + RefCountDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._s.dispose(); + --this._p._count === 0 && this._p._connectableSubscription.dispose(); + } + }; + + return RefCountObservable; + }(ObservableBase)); + + var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { + inherits(ConnectableObservable, __super__); + function ConnectableObservable(source, subject) { + this.source = source; + this._hasSubscription = false; + this._subscription = null; + this._sourceObservable = source.asObservable(); + this._subject = subject; + __super__.call(this); + } + + function ConnectDisposable(parent) { + this._p = parent; + this.isDisposed = false; + } + + ConnectDisposable.prototype.dispose = function () { + if (!this.isDisposed) { + this.isDisposed = true; + this._p._hasSubscription = false; + } + }; + + ConnectableObservable.prototype.connect = function () { + if (!this._hasSubscription) { + this._hasSubscription = true; + this._subscription = new BinaryDisposable( + this._sourceObservable.subscribe(this._subject), + new ConnectDisposable(this) + ); + } + return this._subscription; + }; + + ConnectableObservable.prototype._subscribe = function (o) { + return this._subject.subscribe(o); + }; + + ConnectableObservable.prototype.refCount = function () { + return new RefCountObservable(this); + }; + + return ConnectableObservable; + }(Observable)); + + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence + * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`) + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source. + */ + observableProto.singleInstance = function() { + var source = this, hasObservable = false, observable; + + function getObservable() { + if (!hasObservable) { + hasObservable = true; + observable = source.finally(function() { hasObservable = false; }).publish().refCount(); + } + return observable; + } + + return new AnonymousObservable(function(o) { + return getObservable().subscribe(o); + }); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var leftDone = false, rightDone = false; + var leftId = 0, rightId = 0; + var leftMap = new Map(), rightMap = new Map(); + var handleError = function (e) { o.onError(e); }; + + group.add(left.subscribe( + function (value) { + var id = leftId++, md = new SingleAssignmentDisposable(); + + leftMap.set(id, value); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted(); + group.remove(md); + })); + + rightMap.forEach(function (v) { + var result = tryCatch(resultSelector)(value, v); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + leftDone = true; + (rightDone || leftMap.size === 0) && o.onCompleted(); + }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++, md = new SingleAssignmentDisposable(); + + rightMap.set(id, value); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { return o.onError(duration.e); } + + md.setDisposable(duration.take(1).subscribe( + noop, + handleError, + function () { + rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted(); + group.remove(md); + })); + + leftMap.forEach(function (v) { + var result = tryCatch(resultSelector)(v, value); + if (result === errorObj) { return o.onError(result.e); } + o.onNext(result); + }); + }, + handleError, + function () { + rightDone = true; + (leftDone || rightMap.size === 0) && o.onCompleted(); + }) + ); + return group; + }, left); + }; + + /** + * Correlates the elements of two sequences based on overlapping durations, and groups the results. + * + * @param {Observable} right The right observable sequence to join elements for. + * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. + * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. + * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. + * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. + */ + observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { + var left = this; + return new AnonymousObservable(function (o) { + var group = new CompositeDisposable(); + var r = new RefCountDisposable(group); + var leftMap = new Map(), rightMap = new Map(); + var leftId = 0, rightId = 0; + var handleError = function (e) { return function (v) { v.onError(e); }; }; + + function handleError(e) { }; + + group.add(left.subscribe( + function (value) { + var s = new Subject(); + var id = leftId++; + leftMap.set(id, s); + + var result = tryCatch(resultSelector)(value, addRef(s, r)); + if (result === errorObj) { + leftMap.forEach(handleError(result.e)); + return o.onError(result.e); + } + o.onNext(result); + + rightMap.forEach(function (v) { s.onNext(v); }); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(leftDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + leftMap['delete'](id) && s.onCompleted(); + group.remove(md); + })); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { o.onCompleted(); }) + ); + + group.add(right.subscribe( + function (value) { + var id = rightId++; + rightMap.set(id, value); + + var md = new SingleAssignmentDisposable(); + group.add(md); + + var duration = tryCatch(rightDurationSelector)(value); + if (duration === errorObj) { + leftMap.forEach(handleError(duration.e)); + return o.onError(duration.e); + } + + md.setDisposable(duration.take(1).subscribe( + noop, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }, + function () { + rightMap['delete'](id); + group.remove(md); + })); + + leftMap.forEach(function (v) { v.onNext(value); }); + }, + function (e) { + leftMap.forEach(handleError(e)); + o.onError(e); + }) + ); + + return r; + }, left); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers. + * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.buffer = function () { + return this.window.apply(this, arguments) + .flatMap(toArray); + }; + + /** + * Projects each element of an observable sequence into zero or more windows. + * + * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). + * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { + if (arguments.length === 1 && typeof arguments[0] !== 'function') { + return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector); + } + return typeof windowOpeningsOrClosingSelector === 'function' ? + observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) : + observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector); + }; + + function observableWindowWithOpenings(windowOpenings, windowClosingSelector) { + return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) { + return win; + }); + } + + function observableWindowWithBoundaries(windowBoundaries) { + var source = this; + return new AnonymousObservable(function (observer) { + var win = new Subject(), + d = new CompositeDisposable(), + r = new RefCountDisposable(d); + + observer.onNext(addRef(win, r)); + + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries)); + + d.add(windowBoundaries.subscribe(function (w) { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + return r; + }, source); + } + + function observableWindowWithClosingSelector(windowClosingSelector) { + var source = this; + return new AnonymousObservable(function (observer) { + var m = new SerialDisposable(), + d = new CompositeDisposable(m), + r = new RefCountDisposable(d), + win = new Subject(); + observer.onNext(addRef(win, r)); + d.add(source.subscribe(function (x) { + win.onNext(x); + }, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + observer.onCompleted(); + })); + + function createWindowClose () { + var windowClose; + try { + windowClose = windowClosingSelector(); + } catch (e) { + observer.onError(e); + return; + } + + isPromise(windowClose) && (windowClose = observableFromPromise(windowClose)); + + var m1 = new SingleAssignmentDisposable(); + m.setDisposable(m1); + m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) { + win.onError(err); + observer.onError(err); + }, function () { + win.onCompleted(); + win = new Subject(); + observer.onNext(addRef(win, r)); + createWindowClose(); + })); + } + + createWindowClose(); + return r; + }, source); + } + + /** + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. + * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array. + */ + observableProto.pairwise = function () { + var source = this; + return new AnonymousObservable(function (observer) { + var previous, hasPrevious = false; + return source.subscribe( + function (x) { + if (hasPrevious) { + observer.onNext([previous, x]); + } else { + hasPrevious = true; + } + previous = x; + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer)); + }, source); + }; + + /** + * Returns two observables which partition the observations of the source by the given function. + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes + * when the source completes. + * @param {Function} predicate + * The function to determine which output Observable will trigger a particular observation. + * @returns {Array} + * An array of observables. The first triggers when the predicate returns true, + * and the second triggers when the predicate returns false. + */ + observableProto.partition = function(predicate, thisArg) { + return [ + this.filter(predicate, thisArg), + this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); }) + ]; + }; + + var WhileEnumerable = (function(__super__) { + inherits(WhileEnumerable, __super__); + function WhileEnumerable(c, s) { + this.c = c; + this.s = s; + } + WhileEnumerable.prototype[$iterator$] = function () { + var self = this; + return { + next: function () { + return self.c() ? + { done: false, value: self.s } : + { done: true, value: void 0 }; + } + }; + }; + return WhileEnumerable; + }(Enumerable)); + + function enumerableWhile(condition, source) { + return new WhileEnumerable(condition, source); + } + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + observableProto.letBind = observableProto['let'] = function (func) { + return func(this); + }; + + /** + * Determines whether an observable collection contains values. + * + * @example + * 1 - res = Rx.Observable.if(condition, obs1); + * 2 - res = Rx.Observable.if(condition, obs1, obs2); + * 3 - res = Rx.Observable.if(condition, obs1, scheduler); + * @param {Function} condition The condition which determines if the thenSource or elseSource will be run. + * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true. + * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. + * @returns {Observable} An observable sequence which is either the thenSource or elseSource. + */ + Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) { + return observableDefer(function () { + elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty()); + + isPromise(thenSource) && (thenSource = observableFromPromise(thenSource)); + isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler)); + + // Assume a scheduler for empty only + typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler)); + return condition() ? thenSource : elseSourceOrScheduler; + }); + }; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers 0) { + isOwner = !isAcquired; + isAcquired = true; + } + if (isOwner) { + m.setDisposable(scheduler.scheduleRecursive(null, function (_, self) { + var work; + if (q.length > 0) { + work = q.shift(); + } else { + isAcquired = false; + return; + } + var m1 = new SingleAssignmentDisposable(); + d.add(m1); + m1.setDisposable(work.subscribe(function (x) { + o.onNext(x); + var result = null; + try { + result = selector(x); + } catch (e) { + o.onError(e); + } + q.push(result); + activeCount++; + ensureActive(); + }, function (e) { o.onError(e); }, function () { + d.remove(m1); + activeCount--; + if (activeCount === 0) { + o.onCompleted(); + } + })); + self(); + })); + } + }; + + q.push(source); + activeCount++; + ensureActive(); + return d; + }, this); + }; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * 1 - res = Rx.Observable.forkJoin([obs1, obs2]); + * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences. + */ + Observable.forkJoin = function () { + var allSources = []; + if (Array.isArray(arguments[0])) { + allSources = arguments[0]; + } else { + for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); } + } + return new AnonymousObservable(function (subscriber) { + var count = allSources.length; + if (count === 0) { + subscriber.onCompleted(); + return disposableEmpty; + } + var group = new CompositeDisposable(), + finished = false, + hasResults = new Array(count), + hasCompleted = new Array(count), + results = new Array(count); + + for (var idx = 0; idx < count; idx++) { + (function (i) { + var source = allSources[i]; + isPromise(source) && (source = observableFromPromise(source)); + group.add( + source.subscribe( + function (value) { + if (!finished) { + hasResults[i] = true; + results[i] = value; + } + }, + function (e) { + finished = true; + subscriber.onError(e); + group.dispose(); + }, + function () { + if (!finished) { + if (!hasResults[i]) { + subscriber.onCompleted(); + return; + } + hasCompleted[i] = true; + for (var ix = 0; ix < count; ix++) { + if (!hasCompleted[ix]) { return; } + } + finished = true; + subscriber.onNext(results); + subscriber.onCompleted(); + } + })); + })(idx); + } + + return group; + }); + }; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * @param {Observable} second Second observable sequence. + * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + observableProto.forkJoin = function (second, resultSelector) { + var first = this; + return new AnonymousObservable(function (observer) { + var leftStopped = false, rightStopped = false, + hasLeft = false, hasRight = false, + lastLeft, lastRight, + leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable(); + + isPromise(second) && (second = observableFromPromise(second)); + + leftSubscription.setDisposable( + first.subscribe(function (left) { + hasLeft = true; + lastLeft = left; + }, function (err) { + rightSubscription.dispose(); + observer.onError(err); + }, function () { + leftStopped = true; + if (rightStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + rightSubscription.setDisposable( + second.subscribe(function (right) { + hasRight = true; + lastRight = right; + }, function (err) { + leftSubscription.dispose(); + observer.onError(err); + }, function () { + rightStopped = true; + if (leftStopped) { + if (!hasLeft) { + observer.onCompleted(); + } else if (!hasRight) { + observer.onCompleted(); + } else { + var result = tryCatch(resultSelector)(lastLeft, lastRight); + if (result === errorObj) { return observer.onError(result.e); } + observer.onNext(result); + observer.onCompleted(); + } + } + }) + ); + + return new BinaryDisposable(leftSubscription, rightSubscription); + }, first); + }; + + /** + * Comonadic bind operator. + * @param {Function} selector A transform function to apply to each element. + * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns {Observable} An observable sequence which results from the comonadic bind operation. + */ + observableProto.manySelect = observableProto.extend = function (selector, scheduler) { + isScheduler(scheduler) || (scheduler = immediateScheduler); + var source = this; + return observableDefer(function () { + var chain; + + return source + .map(function (x) { + var curr = new ChainObservable(x); + + chain && chain.onNext(x); + chain = curr; + + return curr; + }) + .tap( + noop, + function (e) { chain && chain.onError(e); }, + function () { chain && chain.onCompleted(); } + ) + .observeOn(scheduler) + .map(selector); + }, source); + }; + + var ChainObservable = (function (__super__) { + inherits(ChainObservable, __super__); + function ChainObservable(head) { + __super__.call(this); + this.head = head; + this.tail = new AsyncSubject(); + } + + addProperties(ChainObservable.prototype, Observer, { + _subscribe: function (o) { + var g = new CompositeDisposable(); + g.add(currentThreadScheduler.schedule(this, function (_, self) { + o.onNext(self.head); + g.add(self.tail.mergeAll().subscribe(o)); + })); + + return g; + }, + onCompleted: function () { + this.onNext(Observable.empty()); + }, + onError: function (e) { + this.onNext(Observable['throw'](e)); + }, + onNext: function (v) { + this.tail.onNext(v); + this.tail.onCompleted(); + } + }); + + return ChainObservable; + + }(Observable)); + + var Map = root.Map || (function () { + function Map() { + this.size = 0; + this._values = []; + this._keys = []; + } + + Map.prototype['delete'] = function (key) { + var i = this._keys.indexOf(key); + if (i === -1) { return false; } + this._values.splice(i, 1); + this._keys.splice(i, 1); + this.size--; + return true; + }; + + Map.prototype.get = function (key) { + var i = this._keys.indexOf(key); + return i === -1 ? undefined : this._values[i]; + }; + + Map.prototype.set = function (key, value) { + var i = this._keys.indexOf(key); + if (i === -1) { + this._keys.push(key); + this._values.push(value); + this.size++; + } else { + this._values[i] = value; + } + return this; + }; + + Map.prototype.forEach = function (cb, thisArg) { + for (var i = 0; i < this.size; i++) { + cb.call(thisArg, this._values[i], this._keys[i]); + } + }; + + return Map; + }()); + + /** + * @constructor + * Represents a join pattern over observable sequences. + */ + function Pattern(patterns) { + this.patterns = patterns; + } + + /** + * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. + * @param other Observable sequence to match in addition to the current pattern. + * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value. + */ + Pattern.prototype.and = function (other) { + return new Pattern(this.patterns.concat(other)); + }; + + /** + * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. + * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. + * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + Pattern.prototype.thenDo = function (selector) { + return new Plan(this, selector); + }; + + function Plan(expression, selector) { + this.expression = expression; + this.selector = selector; + } + + Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) { + var self = this; + var joinObservers = []; + for (var i = 0, len = this.expression.patterns.length; i < len; i++) { + joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer))); + } + var activePlan = new ActivePlan(joinObservers, function () { + var result; + try { + result = self.selector.apply(self, arguments); + } catch (e) { + observer.onError(e); + return; + } + observer.onNext(result); + }, function () { + for (var j = 0, jlen = joinObservers.length; j < jlen; j++) { + joinObservers[j].removeActivePlan(activePlan); + } + deactivate(activePlan); + }); + for (i = 0, len = joinObservers.length; i < len; i++) { + joinObservers[i].addActivePlan(activePlan); + } + return activePlan; + }; + + function planCreateObserver(externalSubscriptions, observable, onError) { + var entry = externalSubscriptions.get(observable); + if (!entry) { + var observer = new JoinObserver(observable, onError); + externalSubscriptions.set(observable, observer); + return observer; + } + return entry; + } + + function ActivePlan(joinObserverArray, onNext, onCompleted) { + this.joinObserverArray = joinObserverArray; + this.onNext = onNext; + this.onCompleted = onCompleted; + this.joinObservers = new Map(); + for (var i = 0, len = this.joinObserverArray.length; i < len; i++) { + var joinObserver = this.joinObserverArray[i]; + this.joinObservers.set(joinObserver, joinObserver); + } + } + + ActivePlan.prototype.dequeue = function () { + this.joinObservers.forEach(function (v) { v.queue.shift(); }); + }; + + ActivePlan.prototype.match = function () { + var i, len, hasValues = true; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + if (this.joinObserverArray[i].queue.length === 0) { + hasValues = false; + break; + } + } + if (hasValues) { + var firstValues = [], + isCompleted = false; + for (i = 0, len = this.joinObserverArray.length; i < len; i++) { + firstValues.push(this.joinObserverArray[i].queue[0]); + this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true); + } + if (isCompleted) { + this.onCompleted(); + } else { + this.dequeue(); + var values = []; + for (i = 0, len = firstValues.length; i < firstValues.length; i++) { + values.push(firstValues[i].value); + } + this.onNext.apply(this, values); + } + } + }; + + var JoinObserver = (function (__super__) { + inherits(JoinObserver, __super__); + + function JoinObserver(source, onError) { + __super__.call(this); + this.source = source; + this.onError = onError; + this.queue = []; + this.activePlans = []; + this.subscription = new SingleAssignmentDisposable(); + this.isDisposed = false; + } + + var JoinObserverPrototype = JoinObserver.prototype; + + JoinObserverPrototype.next = function (notification) { + if (!this.isDisposed) { + if (notification.kind === 'E') { + return this.onError(notification.error); + } + this.queue.push(notification); + var activePlans = this.activePlans.slice(0); + for (var i = 0, len = activePlans.length; i < len; i++) { + activePlans[i].match(); + } + } + }; + + JoinObserverPrototype.error = noop; + JoinObserverPrototype.completed = noop; + + JoinObserverPrototype.addActivePlan = function (activePlan) { + this.activePlans.push(activePlan); + }; + + JoinObserverPrototype.subscribe = function () { + this.subscription.setDisposable(this.source.materialize().subscribe(this)); + }; + + JoinObserverPrototype.removeActivePlan = function (activePlan) { + this.activePlans.splice(this.activePlans.indexOf(activePlan), 1); + this.activePlans.length === 0 && this.dispose(); + }; + + JoinObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + if (!this.isDisposed) { + this.isDisposed = true; + this.subscription.dispose(); + } + }; + + return JoinObserver; + } (AbstractObserver)); + + /** + * Creates a pattern that matches when both observable sequences have an available value. + * + * @param right Observable sequence to match with the current sequence. + * @return {Pattern} Pattern object that matches when both observable sequences have an available value. + */ + observableProto.and = function (right) { + return new Pattern([this, right]); + }; + + /** + * Matches when the observable sequence has an available value and projects the value. + * + * @param {Function} selector Selector that will be invoked for values in the source sequence. + * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. + */ + observableProto.thenDo = function (selector) { + return new Pattern([this]).thenDo(selector); + }; + + /** + * Joins together the results from several patterns. + * + * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns. + * @returns {Observable} Observable sequence with the results form matching several patterns. + */ + Observable.when = function () { + var len = arguments.length, plans; + if (Array.isArray(arguments[0])) { + plans = arguments[0]; + } else { + plans = new Array(len); + for(var i = 0; i < len; i++) { plans[i] = arguments[i]; } + } + return new AnonymousObservable(function (o) { + var activePlans = [], + externalSubscriptions = new Map(); + var outObserver = observerCreate( + function (x) { o.onNext(x); }, + function (err) { + externalSubscriptions.forEach(function (v) { v.onError(err); }); + o.onError(err); + }, + function (x) { o.onCompleted(); } + ); + try { + for (var i = 0, len = plans.length; i < len; i++) { + activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) { + var idx = activePlans.indexOf(activePlan); + activePlans.splice(idx, 1); + activePlans.length === 0 && o.onCompleted(); + })); + } + } catch (e) { + observableThrow(e).subscribe(o); + } + var group = new CompositeDisposable(); + externalSubscriptions.forEach(function (joinObserver) { + joinObserver.subscribe(); + group.add(joinObserver); + }); + + return group; + }); + }; + + var TimerObservable = (function(__super__) { + inherits(TimerObservable, __super__); + function TimerObservable(dt, s) { + this._dt = dt; + this._s = s; + __super__.call(this); + } + + TimerObservable.prototype.subscribeCore = function (o) { + return this._s.scheduleFuture(o, this._dt, scheduleMethod); + }; + + function scheduleMethod(s, o) { + o.onNext(0); + o.onCompleted(); + } + + return TimerObservable; + }(ObservableBase)); + + function _observableTimer(dueTime, scheduler) { + return new TimerObservable(dueTime, scheduler); + } + + function observableTimerDateAndPeriod(dueTime, period, scheduler) { + return new AnonymousObservable(function (observer) { + var d = dueTime, p = normalizeTime(period); + return scheduler.scheduleRecursiveFuture(0, d, function (count, self) { + if (p > 0) { + var now = scheduler.now(); + d = d + p; + d <= now && (d = now + p); + } + observer.onNext(count); + self(count + 1, new Date(d)); + }); + }); + } + + function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { + return dueTime === period ? + new AnonymousObservable(function (observer) { + return scheduler.schedulePeriodic(0, period, function (count) { + observer.onNext(count); + return count + 1; + }); + }) : + observableDefer(function () { + return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler); + }); + } + + /** + * Returns an observable sequence that produces a value after each period. + * + * @example + * 1 - res = Rx.Observable.interval(1000); + * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); + * + * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. + * @returns {Observable} An observable sequence that produces a value after each period. + */ + var observableinterval = Observable.interval = function (period, scheduler) { + return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler); + }; + + /** + * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. + * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period. + */ + var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { + var period; + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { + period = periodOrScheduler; + } else if (isScheduler(periodOrScheduler)) { + scheduler = periodOrScheduler; + } + if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) { + return _observableTimer(dueTime, scheduler); + } + if (dueTime instanceof Date && period !== undefined) { + return observableTimerDateAndPeriod(dueTime.getTime(), periodOrScheduler, scheduler); + } + return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); + }; + + function observableDelayRelative(source, dueTime, scheduler) { + return new AnonymousObservable(function (o) { + var active = false, + cancelable = new SerialDisposable(), + exception = null, + q = [], + running = false, + subscription; + subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) { + var d, shouldRun; + if (notification.value.kind === 'E') { + q = []; + q.push(notification); + exception = notification.value.error; + shouldRun = !running; + } else { + q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); + shouldRun = !active; + active = true; + } + if (shouldRun) { + if (exception !== null) { + o.onError(exception); + } else { + d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) { + var e, recurseDueTime, result, shouldRecurse; + if (exception !== null) { + return; + } + running = true; + do { + result = null; + if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) { + result = q.shift().value; + } + if (result !== null) { + result.accept(o); + } + } while (result !== null); + shouldRecurse = false; + recurseDueTime = 0; + if (q.length > 0) { + shouldRecurse = true; + recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now()); + } else { + active = false; + } + e = exception; + running = false; + if (e !== null) { + o.onError(e); + } else if (shouldRecurse) { + self(null, recurseDueTime); + } + })); + } + } + }); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + function observableDelayAbsolute(source, dueTime, scheduler) { + return observableDefer(function () { + return observableDelayRelative(source, dueTime - scheduler.now(), scheduler); + }); + } + + function delayWithSelector(source, subscriptionDelay, delayDurationSelector) { + var subDelay, selector; + if (isFunction(subscriptionDelay)) { + selector = subscriptionDelay; + } else { + subDelay = subscriptionDelay; + selector = delayDurationSelector; + } + return new AnonymousObservable(function (o) { + var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable(); + + function start() { + subscription.setDisposable(source.subscribe( + function (x) { + var delay = tryCatch(selector)(x); + if (delay === errorObj) { return o.onError(delay.e); } + var d = new SingleAssignmentDisposable(); + delays.add(d); + d.setDisposable(delay.subscribe( + function () { + o.onNext(x); + delays.remove(d); + done(); + }, + function (e) { o.onError(e); }, + function () { + o.onNext(x); + delays.remove(d); + done(); + } + )); + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + subscription.dispose(); + done(); + } + )); + } + + function done () { + atEnd && delays.length === 0 && o.onCompleted(); + } + + if (!subDelay) { + start(); + } else { + subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); + } + + return new BinaryDisposable(subscription, delays); + }, this); + } + + /** + * Time shifts the observable sequence by dueTime. + * The relative time intervals between the values are preserved. + * + * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. + * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delay = function () { + var firstArg = arguments[0]; + if (typeof firstArg === 'number' || firstArg instanceof Date) { + var dueTime = firstArg, scheduler = arguments[1]; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return dueTime instanceof Date ? + observableDelayAbsolute(this, dueTime, scheduler) : + observableDelayRelative(this, dueTime, scheduler); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return delayWithSelector(this, firstArg, arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var DebounceObservable = (function (__super__) { + inherits(DebounceObservable, __super__); + function DebounceObservable(source, dt, s) { + isScheduler(s) || (s = defaultScheduler); + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DebounceObservable.prototype.subscribeCore = function (o) { + var cancelable = new SerialDisposable(); + return new BinaryDisposable( + this.source.subscribe(new DebounceObserver(o, this.source, this._dt, this._s, cancelable)), + cancelable); + }; + + return DebounceObservable; + }(ObservableBase)); + + var DebounceObserver = (function (__super__) { + inherits(DebounceObserver, __super__); + function DebounceObserver(observer, source, dueTime, scheduler, cancelable) { + this._o = observer; + this._s = source; + this._d = dueTime; + this._scheduler = scheduler; + this._c = cancelable; + this._v = null; + this._hv = false; + this._id = 0; + __super__.call(this); + } + + DebounceObserver.prototype.next = function (x) { + this._hv = true; + this._v = x; + var currentId = ++this._id, d = new SingleAssignmentDisposable(); + this._c.setDisposable(d); + d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) { + self._hv && self._id === currentId && self._o.onNext(x); + self._hv = false; + })); + }; + + DebounceObserver.prototype.error = function (e) { + this._c.dispose(); + this._o.onError(e); + this._hv = false; + this._id++; + }; + + DebounceObserver.prototype.completed = function () { + this._c.dispose(); + this._hv && this._o.onNext(this._v); + this._o.onCompleted(); + this._hv = false; + this._id++; + }; + + return DebounceObserver; + }(AbstractObserver)); + + function debounceWithSelector(source, durationSelector) { + return new AnonymousObservable(function (o) { + var value, hasValue = false, cancelable = new SerialDisposable(), id = 0; + var subscription = source.subscribe( + function (x) { + var throttle = tryCatch(durationSelector)(x); + if (throttle === errorObj) { return o.onError(throttle.e); } + + isPromise(throttle) && (throttle = observableFromPromise(throttle)); + + hasValue = true; + value = x; + id++; + var currentid = id, d = new SingleAssignmentDisposable(); + cancelable.setDisposable(d); + d.setDisposable(throttle.subscribe( + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + }, + function (e) { o.onError(e); }, + function () { + hasValue && id === currentid && o.onNext(value); + hasValue = false; + d.dispose(); + } + )); + }, + function (e) { + cancelable.dispose(); + o.onError(e); + hasValue = false; + id++; + }, + function () { + cancelable.dispose(); + hasValue && o.onNext(value); + o.onCompleted(); + hasValue = false; + id++; + } + ); + return new BinaryDisposable(subscription, cancelable); + }, source); + } + + observableProto.debounce = function () { + if (isFunction (arguments[0])) { + return debounceWithSelector(this, arguments[0]); + } else if (typeof arguments[0] === 'number') { + return new DebounceObservable(this, arguments[0], arguments[1]); + } else { + throw new Error('Invalid arguments'); + } + }; + + /** + * Projects each element of an observable sequence into zero or more windows which are produced based on timing information. + * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + var source = this, timeShift; + timeShiftOrScheduler == null && (timeShift = timeSpan); + isScheduler(scheduler) || (scheduler = defaultScheduler); + if (typeof timeShiftOrScheduler === 'number') { + timeShift = timeShiftOrScheduler; + } else if (isScheduler(timeShiftOrScheduler)) { + timeShift = timeSpan; + scheduler = timeShiftOrScheduler; + } + return new AnonymousObservable(function (observer) { + var groupDisposable, + nextShift = timeShift, + nextSpan = timeSpan, + q = [], + refCountDisposable, + timerD = new SerialDisposable(), + totalTime = 0; + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable); + + function createTimer () { + var m = new SingleAssignmentDisposable(), + isSpan = false, + isShift = false; + timerD.setDisposable(m); + if (nextSpan === nextShift) { + isSpan = true; + isShift = true; + } else if (nextSpan < nextShift) { + isSpan = true; + } else { + isShift = true; + } + var newTotalTime = isSpan ? nextSpan : nextShift, + ts = newTotalTime - totalTime; + totalTime = newTotalTime; + if (isSpan) { + nextSpan += timeShift; + } + if (isShift) { + nextShift += timeShift; + } + m.setDisposable(scheduler.scheduleFuture(null, ts, function () { + if (isShift) { + var s = new Subject(); + q.push(s); + observer.onNext(addRef(s, refCountDisposable)); + } + isSpan && q.shift().onCompleted(); + createTimer(); + })); + }; + q.push(new Subject()); + observer.onNext(addRef(q[0], refCountDisposable)); + createTimer(); + groupDisposable.add(source.subscribe( + function (x) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } + }, + function (e) { + for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); } + observer.onError(e); + }, + function () { + for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); } + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + /** + * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a window. + * @param {Number} count Maximum element count of a window. + * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of windows. + */ + observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (observer) { + var timerD = new SerialDisposable(), + groupDisposable = new CompositeDisposable(timerD), + refCountDisposable = new RefCountDisposable(groupDisposable), + n = 0, + windowId = 0, + s = new Subject(); + + function createTimer(id) { + var m = new SingleAssignmentDisposable(); + timerD.setDisposable(m); + m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () { + if (id !== windowId) { return; } + n = 0; + var newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + createTimer(newId); + })); + } + + observer.onNext(addRef(s, refCountDisposable)); + createTimer(0); + + groupDisposable.add(source.subscribe( + function (x) { + var newId = 0, newWindow = false; + s.onNext(x); + if (++n === count) { + newWindow = true; + n = 0; + newId = ++windowId; + s.onCompleted(); + s = new Subject(); + observer.onNext(addRef(s, refCountDisposable)); + } + newWindow && createTimer(newId); + }, + function (e) { + s.onError(e); + observer.onError(e); + }, function () { + s.onCompleted(); + observer.onCompleted(); + } + )); + return refCountDisposable; + }, source); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. + * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds). + * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. + * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) { + return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray); + }; + + function toArray(x) { return x.toArray(); } + + /** + * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. + * @param {Number} timeSpan Maximum time length of a buffer. + * @param {Number} count Maximum element count of a buffer. + * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence of buffers. + */ + observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) { + return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray); + }; + + var TimeIntervalObservable = (function (__super__) { + inherits(TimeIntervalObservable, __super__); + function TimeIntervalObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimeIntervalObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimeIntervalObserver(o, this._s)); + }; + + return TimeIntervalObservable; + }(ObservableBase)); + + var TimeIntervalObserver = (function (__super__) { + inherits(TimeIntervalObserver, __super__); + + function TimeIntervalObserver(o, s) { + this._o = o; + this._s = s; + this._l = s.now(); + __super__.call(this); + } + + TimeIntervalObserver.prototype.next = function (x) { + var now = this._s.now(), span = now - this._l; + this._l = now; + this._o.onNext({ value: x, interval: span }); + }; + TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); }; + TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return TimeIntervalObserver; + }(AbstractObserver)); + + /** + * Records the time interval between consecutive values in an observable sequence. + * + * @example + * 1 - res = source.timeInterval(); + * 2 - res = source.timeInterval(Rx.Scheduler.timeout); + * + * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. + * @returns {Observable} An observable sequence with time interval information on values. + */ + observableProto.timeInterval = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimeIntervalObservable(this, scheduler); + }; + + var TimestampObservable = (function (__super__) { + inherits(TimestampObservable, __super__); + function TimestampObservable(source, s) { + this.source = source; + this._s = s; + __super__.call(this); + } + + TimestampObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TimestampObserver(o, this._s)); + }; + + return TimestampObservable; + }(ObservableBase)); + + var TimestampObserver = (function (__super__) { + inherits(TimestampObserver, __super__); + function TimestampObserver(o, s) { + this._o = o; + this._s = s; + __super__.call(this); + } + + TimestampObserver.prototype.next = function (x) { + this._o.onNext({ value: x, timestamp: this._s.now() }); + }; + + TimestampObserver.prototype.error = function (e) { + this._o.onError(e); + }; + + TimestampObserver.prototype.completed = function () { + this._o.onCompleted(); + }; + + return TimestampObserver; + }(AbstractObserver)); + + /** + * Records the timestamp for each value in an observable sequence. + * + * @example + * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } + * 2 - res = source.timestamp(Rx.Scheduler.default); + * + * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used. + * @returns {Observable} An observable sequence with timestamp information on values. + */ + observableProto.timestamp = function (scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TimestampObservable(this, scheduler); + }; + + function sampleObservable(source, sampler) { + return new AnonymousObservable(function (o) { + var atEnd = false, value, hasValue = false; + + function sampleSubscribe() { + if (hasValue) { + hasValue = false; + o.onNext(value); + } + atEnd && o.onCompleted(); + } + + var sourceSubscription = new SingleAssignmentDisposable(); + sourceSubscription.setDisposable(source.subscribe( + function (newValue) { + hasValue = true; + value = newValue; + }, + function (e) { o.onError(e); }, + function () { + atEnd = true; + sourceSubscription.dispose(); + } + )); + + return new BinaryDisposable( + sourceSubscription, + sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe) + ); + }, source); + } + + /** + * Samples the observable sequence at each interval. + * + * @example + * 1 - res = source.sample(sampleObservable); // Sampler tick sequence + * 2 - res = source.sample(5000); // 5 seconds + * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds + * + * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable. + * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Sampled observable sequence. + */ + observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return typeof intervalOrSampler === 'number' ? + sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : + sampleObservable(this, intervalOrSampler); + }; + + var TimeoutError = Rx.TimeoutError = function(message) { + this.message = message || 'Timeout has occurred'; + this.name = 'TimeoutError'; + Error.call(this); + }; + TimeoutError.prototype = Object.create(Error.prototype); + + function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) { + if (isFunction(firstTimeout)) { + other = timeoutDurationSelector; + timeoutDurationSelector = firstTimeout; + firstTimeout = observableNever(); + } + other || (other = observableThrow(new TimeoutError())); + return new AnonymousObservable(function (o) { + var subscription = new SerialDisposable(), + timer = new SerialDisposable(), + original = new SingleAssignmentDisposable(); + + subscription.setDisposable(original); + + var id = 0, switched = false; + + function setTimer(timeout) { + var myId = id, d = new SingleAssignmentDisposable(); + + function timerWins() { + switched = (myId === id); + return switched; + } + + timer.setDisposable(d); + d.setDisposable(timeout.subscribe(function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + d.dispose(); + }, function (e) { + timerWins() && o.onError(e); + }, function () { + timerWins() && subscription.setDisposable(other.subscribe(o)); + })); + }; + + setTimer(firstTimeout); + + function oWins() { + var res = !switched; + if (res) { id++; } + return res; + } + + original.setDisposable(source.subscribe(function (x) { + if (oWins()) { + o.onNext(x); + var timeout = tryCatch(timeoutDurationSelector)(x); + if (timeout === errorObj) { return o.onError(timeout.e); } + setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout); + } + }, function (e) { + oWins() && o.onError(e); + }, function () { + oWins() && o.onCompleted(); + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + function timeout(source, dueTime, other, scheduler) { + if (isScheduler(other)) { + scheduler = other; + other = observableThrow(new TimeoutError()); + } + if (other instanceof Error) { other = observableThrow(other); } + isScheduler(scheduler) || (scheduler = defaultScheduler); + + return new AnonymousObservable(function (o) { + var id = 0, + original = new SingleAssignmentDisposable(), + subscription = new SerialDisposable(), + switched = false, + timer = new SerialDisposable(); + + subscription.setDisposable(original); + + function createTimer() { + var myId = id; + timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () { + switched = id === myId; + if (switched) { + isPromise(other) && (other = observableFromPromise(other)); + subscription.setDisposable(other.subscribe(o)); + } + })); + } + + createTimer(); + + original.setDisposable(source.subscribe(function (x) { + if (!switched) { + id++; + o.onNext(x); + createTimer(); + } + }, function (e) { + if (!switched) { + id++; + o.onError(e); + } + }, function () { + if (!switched) { + id++; + o.onCompleted(); + } + })); + return new BinaryDisposable(subscription, timer); + }, source); + } + + observableProto.timeout = function () { + var firstArg = arguments[0]; + if (firstArg instanceof Date || typeof firstArg === 'number') { + return timeout(this, firstArg, arguments[1], arguments[2]); + } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { + return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); + } else { + throw new Error('Invalid arguments'); + } + }; + + var GenerateAbsoluteObservable = (function (__super__) { + inherits(GenerateAbsoluteObservable, __super__); + function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateAbsoluteObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, new Date(this._s.now()), scheduleRecursive); + }; + + return GenerateAbsoluteObservable; + }(ObservableBase)); + + /** + * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithAbsoluteTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return new Date(); } + * }); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var GenerateRelativeObservable = (function (__super__) { + inherits(GenerateRelativeObservable, __super__); + function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) { + this._state = state; + this._cndFn = cndFn; + this._itrFn = itrFn; + this._resFn = resFn; + this._timeFn = timeFn; + this._s = s; + this._first = true; + this._hasResult = false; + __super__.call(this); + } + + function scheduleRecursive(self, recurse) { + self._hasResult && self._o.onNext(self._state); + + if (self._first) { + self._first = false; + } else { + self._state = tryCatch(self._itrFn)(self._state); + if (self._state === errorObj) { return self._o.onError(self._state.e); } + } + self._hasResult = tryCatch(self._cndFn)(self._state); + if (self._hasResult === errorObj) { return self._o.onError(self._hasResult.e); } + if (self._hasResult) { + var result = tryCatch(self._resFn)(self._state); + if (result === errorObj) { return self._o.onError(result.e); } + var time = tryCatch(self._timeFn)(self._state); + if (time === errorObj) { return self._o.onError(time.e); } + recurse(self, time); + } else { + self._o.onCompleted(); + } + } + + GenerateRelativeObservable.prototype.subscribeCore = function (o) { + this._o = o; + return this._s.scheduleRecursiveFuture(this, 0, scheduleRecursive); + }; + + return GenerateRelativeObservable; + }(ObservableBase)); + + /** + * Generates an observable sequence by iterating a state from an initial state until the condition fails. + * + * @example + * res = source.generateWithRelativeTime(0, + * function (x) { return return true; }, + * function (x) { return x + 1; }, + * function (x) { return x; }, + * function (x) { return 500; } + * ); + * + * @param {Mixed} initialState Initial state. + * @param {Function} condition Condition to terminate generation (upon returning false). + * @param {Function} iterate Iteration step function. + * @param {Function} resultSelector Selector function for results produced in the sequence. + * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. + * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. + * @returns {Observable} The generated sequence. + */ + Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); + }; + + var DelaySubscription = (function(__super__) { + inherits(DelaySubscription, __super__); + function DelaySubscription(source, dt, s) { + this.source = source; + this._dt = dt; + this._s = s; + __super__.call(this); + } + + DelaySubscription.prototype.subscribeCore = function (o) { + var d = new SerialDisposable(); + + d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod)); + + return d; + }; + + function scheduleMethod(s, state) { + var source = state[0], o = state[1], d = state[2]; + d.setDisposable(source.subscribe(o)); + } + + return DelaySubscription; + }(ObservableBase)); + + /** + * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.delaySubscription(5000); // 5s + * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds + * + * @param {Number} dueTime Relative or absolute time shift of the subscription. + * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. + * @returns {Observable} Time-shifted sequence. + */ + observableProto.delaySubscription = function (dueTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new DelaySubscription(this, dueTime, scheduler); + }; + + var SkipLastWithTimeObservable = (function (__super__) { + inherits(SkipLastWithTimeObservable, __super__); + function SkipLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + SkipLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new SkipLastWithTimeObserver(o, this)); + }; + + return SkipLastWithTimeObservable; + }(ObservableBase)); + + var SkipLastWithTimeObserver = (function (__super__) { + inherits(SkipLastWithTimeObserver, __super__); + + function SkipLastWithTimeObserver(o, p) { + this._o = o; + this._s = p._s; + this._d = p._d; + this._q = []; + __super__.call(this); + } + + SkipLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + }; + SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._o.onNext(this._q.shift().value); + } + this._o.onCompleted(); + }; + + return SkipLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for skipping elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence. + */ + observableProto.skipLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipLastWithTimeObservable(this, duration, scheduler); + }; + + var TakeLastWithTimeObservable = (function (__super__) { + inherits(TakeLastWithTimeObservable, __super__); + function TakeLastWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + TakeLastWithTimeObservable.prototype.subscribeCore = function (o) { + return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s)); + }; + + return TakeLastWithTimeObservable; + }(ObservableBase)); + + var TakeLastWithTimeObserver = (function (__super__) { + inherits(TakeLastWithTimeObserver, __super__); + + function TakeLastWithTimeObserver(o, d, s) { + this._o = o; + this._d = d; + this._s = s; + this._q = []; + __super__.call(this); + } + + TakeLastWithTimeObserver.prototype.next = function (x) { + var now = this._s.now(); + this._q.push({ interval: now, value: x }); + while (this._q.length > 0 && now - this._q[0].interval >= this._d) { + this._q.shift(); + } + }; + TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + TakeLastWithTimeObserver.prototype.completed = function () { + var now = this._s.now(); + while (this._q.length > 0) { + var next = this._q.shift(); + if (now - next.interval <= this._d) { this._o.onNext(next.value); } + } + this._o.onCompleted(); + }; + + return TakeLastWithTimeObserver; + }(AbstractObserver)); + + /** + * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeLastWithTimeObservable(this, duration, scheduler); + }; + + /** + * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the end of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. + */ + observableProto.takeLastBufferWithTime = function (duration, scheduler) { + var source = this; + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new AnonymousObservable(function (o) { + var q = []; + return source.subscribe(function (x) { + var now = scheduler.now(); + q.push({ interval: now, value: x }); + while (q.length > 0 && now - q[0].interval >= duration) { + q.shift(); + } + }, function (e) { o.onError(e); }, function () { + var now = scheduler.now(), res = []; + while (q.length > 0) { + var next = q.shift(); + now - next.interval <= duration && res.push(next.value); + } + o.onNext(res); + o.onCompleted(); + }); + }, source); + }; + + var TakeWithTimeObservable = (function (__super__) { + inherits(TakeWithTimeObservable, __super__); + function TakeWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + __super__.call(this); + } + + function scheduleMethod(s, o) { + o.onCompleted(); + } + + TakeWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(o, this._d, scheduleMethod), + this.source.subscribe(o) + ); + }; + + return TakeWithTimeObservable; + }(ObservableBase)); + + /** + * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * + * @example + * 1 - res = source.takeWithTime(5000, [optional scheduler]); + * @description + * This operator accumulates a queue with a length enough to store elements received during the initial duration window. + * As more elements are received, elements older than the specified duration are taken from the queue and produced on the + * result sequence. This causes elements to be delayed with duration. + * @param {Number} duration Duration for taking elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence. + */ + observableProto.takeWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new TakeWithTimeObservable(this, duration, scheduler); + }; + + var SkipWithTimeObservable = (function (__super__) { + inherits(SkipWithTimeObservable, __super__); + function SkipWithTimeObservable(source, d, s) { + this.source = source; + this._d = d; + this._s = s; + this._open = false; + __super__.call(this); + } + + function scheduleMethod(s, self) { + self._open = true; + } + + SkipWithTimeObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable( + this._s.scheduleFuture(this, this._d, scheduleMethod), + this.source.subscribe(new SkipWithTimeObserver(o, this)) + ); + }; + + return SkipWithTimeObservable; + }(ObservableBase)); + + var SkipWithTimeObserver = (function (__super__) { + inherits(SkipWithTimeObserver, __super__); + + function SkipWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipWithTimeObserver; + }(AbstractObserver)); + + /** + * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + * @description + * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. + * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded + * may not execute immediately, despite the zero due time. + * + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. + * @param {Number} duration Duration for skipping elements from the start of the sequence. + * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence. + */ + observableProto.skipWithTime = function (duration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipWithTimeObservable(this, duration, scheduler); + }; + + var SkipUntilWithTimeObservable = (function (__super__) { + inherits(SkipUntilWithTimeObservable, __super__); + function SkipUntilWithTimeObservable(source, startTime, scheduler) { + this.source = source; + this._st = startTime; + this._s = scheduler; + __super__.call(this); + } + + function scheduleMethod(s, state) { + state._open = true; + } + + SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) { + this._open = false; + return new BinaryDisposable( + this._s.scheduleFuture(this, this._st, scheduleMethod), + this.source.subscribe(new SkipUntilWithTimeObserver(o, this)) + ); + }; + + return SkipUntilWithTimeObservable; + }(ObservableBase)); + + var SkipUntilWithTimeObserver = (function (__super__) { + inherits(SkipUntilWithTimeObserver, __super__); + + function SkipUntilWithTimeObserver(o, p) { + this._o = o; + this._p = p; + __super__.call(this); + } + + SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; + SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; + SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; + + return SkipUntilWithTimeObserver; + }(AbstractObserver)); + + + /** + * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. + * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time. + * + * @examples + * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]); + * 2 - res = source.skipUntilWithTime(5000, [scheduler]); + * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. + * @returns {Observable} An observable sequence with the elements skipped until the specified start time. + */ + observableProto.skipUntilWithTime = function (startTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + return new SkipUntilWithTimeObservable(this, startTime, scheduler); + }; + + /** + * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. + * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. + * @param {Scheduler} [scheduler] Scheduler to run the timer on. + * @returns {Observable} An observable sequence with the elements taken until the specified end time. + */ + observableProto.takeUntilWithTime = function (endTime, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var source = this; + return new AnonymousObservable(function (o) { + return new BinaryDisposable( + scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }), + source.subscribe(o)); + }, source); + }; + + /** + * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. + * @param {Number} windowDuration time to wait before emitting another item after emitting the last item + * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout. + * @returns {Observable} An Observable that performs the throttle operation. + */ + observableProto.throttle = function (windowDuration, scheduler) { + isScheduler(scheduler) || (scheduler = defaultScheduler); + var duration = +windowDuration || 0; + if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } + var source = this; + return new AnonymousObservable(function (o) { + var lastOnNext = 0; + return source.subscribe( + function (x) { + var now = scheduler.now(); + if (lastOnNext === 0 || now - lastOnNext >= duration) { + lastOnNext = now; + o.onNext(x); + } + },function (e) { o.onError(e); }, function () { o.onCompleted(); } + ); + }, source); + }; + + var TransduceObserver = (function (__super__) { + inherits(TransduceObserver, __super__); + function TransduceObserver(o, xform) { + this._o = o; + this._xform = xform; + __super__.call(this); + } + + TransduceObserver.prototype.next = function (x) { + var res = tryCatch(this._xform['@@transducer/step']).call(this._xform, this._o, x); + if (res === errorObj) { this._o.onError(res.e); } + }; + + TransduceObserver.prototype.error = function (e) { this._o.onError(e); }; + + TransduceObserver.prototype.completed = function () { + this._xform['@@transducer/result'](this._o); + }; + + return TransduceObserver; + }(AbstractObserver)); + + function transformForObserver(o) { + return { + '@@transducer/init': function() { + return o; + }, + '@@transducer/step': function(obs, input) { + return obs.onNext(input); + }, + '@@transducer/result': function(obs) { + return obs.onCompleted(); + } + }; + } + + /** + * Executes a transducer to transform the observable sequence + * @param {Transducer} transducer A transducer to execute + * @returns {Observable} An Observable sequence containing the results from the transducer. + */ + observableProto.transduce = function(transducer) { + var source = this; + return new AnonymousObservable(function(o) { + var xform = transducer(transformForObserver(o)); + return source.subscribe(new TransduceObserver(o, xform)); + }, source); + }; + + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * @returns {Observable} A exclusive observable with only the results that happen when subscribed. + */ + observableProto.switchFirst = function () { + var sources = this; + return new AnonymousObservable(function (o) { + var hasCurrent = false, + isStopped = false, + m = new SingleAssignmentDisposable(), + g = new CompositeDisposable(); + + g.add(m); + + m.setDisposable(sources.subscribe( + function (innerSource) { + if (!hasCurrent) { + hasCurrent = true; + + isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); + + var innerSubscription = new SingleAssignmentDisposable(); + g.add(innerSubscription); + + innerSubscription.setDisposable(innerSource.subscribe( + function (x) { o.onNext(x); }, + function (e) { o.onError(e); }, + function () { + g.remove(innerSubscription); + hasCurrent = false; + isStopped && g.length === 1 && o.onCompleted(); + })); + } + }, + function (e) { o.onError(e); }, + function () { + isStopped = true; + !hasCurrent && g.length === 1 && o.onCompleted(); + })); + + return g; + }, this); + }; + +observableProto.flatMapFirst = observableProto.selectManyFirst = function(selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst(); +}; + +Rx.Observable.prototype.flatMapWithMaxConcurrent = function(limit, selector, resultSelector, thisArg) { + return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); +}; + /** Provides a set of extension methods for virtual time scheduling. */ + var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) { + inherits(VirtualTimeScheduler, __super__); + + /** + * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer. + * + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function VirtualTimeScheduler(initialClock, comparer) { + this.clock = initialClock; + this.comparer = comparer; + this.isEnabled = false; + this.queue = new PriorityQueue(1024); + __super__.call(this); + } + + var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype; + + VirtualTimeSchedulerPrototype.now = function () { + return this.toAbsoluteTime(this.clock); + }; + + VirtualTimeSchedulerPrototype.schedule = function (state, action) { + return this.scheduleAbsolute(state, this.clock, action); + }; + + VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) { + var dt = dueTime instanceof Date ? + this.toRelativeTime(dueTime - this.now()) : + this.toRelativeTime(dueTime); + + return this.scheduleRelative(state, dt, action); + }; + + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + VirtualTimeSchedulerPrototype.add = notImplemented; + + /** + * Converts an absolute time to a number + * @param {Any} The absolute time. + * @returns {Number} The absolute time in ms + */ + VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented; + + /** + * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling. + * @param {Mixed} state Initial state passed to the action upon the first iteration. + * @param {Number} period Period for running the work periodically. + * @param {Function} action Action to be executed, potentially updating the state. + * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). + */ + VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) { + var s = new SchedulePeriodicRecursive(this, state, period, action); + return s.start(); + }; + + /** + * Schedules an action to be executed after dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Relative time after which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) { + var runAt = this.add(this.clock, dueTime); + return this.scheduleAbsolute(state, runAt, action); + }; + + /** + * Starts the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.start = function () { + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + } + }; + + /** + * Stops the virtual time scheduler. + */ + VirtualTimeSchedulerPrototype.stop = function () { + this.isEnabled = false; + }; + + /** + * Advances the scheduler's clock to the specified time, running all work till that point. + * @param {Number} time Absolute time to advance the scheduler's clock to. + */ + VirtualTimeSchedulerPrototype.advanceTo = function (time) { + var dueToClock = this.comparer(this.clock, time); + if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + if (!this.isEnabled) { + this.isEnabled = true; + do { + var next = this.getNext(); + if (next !== null && this.comparer(next.dueTime, time) <= 0) { + this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); + next.invoke(); + } else { + this.isEnabled = false; + } + } while (this.isEnabled); + this.clock = time; + } + }; + + /** + * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.advanceBy = function (time) { + var dt = this.add(this.clock, time), + dueToClock = this.comparer(this.clock, dt); + if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); } + if (dueToClock === 0) { return; } + + this.advanceTo(dt); + }; + + /** + * Advances the scheduler's clock by the specified relative time. + * @param {Number} time Relative time to advance the scheduler's clock by. + */ + VirtualTimeSchedulerPrototype.sleep = function (time) { + var dt = this.add(this.clock, time); + if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); } + + this.clock = dt; + }; + + /** + * Gets the next scheduled item to be executed. + * @returns {ScheduledItem} The next scheduled item. + */ + VirtualTimeSchedulerPrototype.getNext = function () { + while (this.queue.length > 0) { + var next = this.queue.peek(); + if (next.isCancelled()) { + this.queue.dequeue(); + } else { + return next; + } + } + return null; + }; + + /** + * Schedules an action to be executed at dueTime. + * @param {Mixed} state State passed to the action to be executed. + * @param {Number} dueTime Absolute time at which to execute the action. + * @param {Function} action Action to be executed. + * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). + */ + VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) { + var self = this; + + function run(scheduler, state1) { + self.queue.remove(si); + return action(scheduler, state1); + } + + var si = new ScheduledItem(this, state, run, dueTime, this.comparer); + this.queue.enqueue(si); + + return si.disposable; + }; + + return VirtualTimeScheduler; + }(Scheduler)); + + /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */ + Rx.HistoricalScheduler = (function (__super__) { + inherits(HistoricalScheduler, __super__); + + /** + * Creates a new historical scheduler with the specified initial clock value. + * @constructor + * @param {Number} initialClock Initial value for the clock. + * @param {Function} comparer Comparer to determine causality of events based on absolute time. + */ + function HistoricalScheduler(initialClock, comparer) { + var clock = initialClock == null ? 0 : initialClock; + var cmp = comparer || defaultSubComparer; + __super__.call(this, clock, cmp); + } + + var HistoricalSchedulerProto = HistoricalScheduler.prototype; + + /** + * Adds a relative time value to an absolute time value. + * @param {Number} absolute Absolute virtual time value. + * @param {Number} relative Relative virtual time value to add. + * @return {Number} Resulting absolute virtual time sum value. + */ + HistoricalSchedulerProto.add = function (absolute, relative) { + return absolute + relative; + }; + + HistoricalSchedulerProto.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + + /** + * Converts the TimeSpan value to a relative virtual time value. + * @memberOf HistoricalScheduler + * @param {Number} timeSpan TimeSpan value to convert. + * @return {Number} Corresponding relative virtual time value. + */ + HistoricalSchedulerProto.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + + return HistoricalScheduler; + }(Rx.VirtualTimeScheduler)); + +function OnNextPredicate(predicate) { + this.predicate = predicate; +} + +OnNextPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'N') { return false; } + return this.predicate(other.value); +}; + +function OnErrorPredicate(predicate) { + this.predicate = predicate; +} + +OnErrorPredicate.prototype.equals = function (other) { + if (other === this) { return true; } + if (other == null) { return false; } + if (other.kind !== 'E') { return false; } + return this.predicate(other.error); +}; + +var ReactiveTest = Rx.ReactiveTest = { + /** Default virtual time used for creation of observable sequences in unit tests. */ + created: 100, + /** Default virtual time used to subscribe to observable sequences in unit tests. */ + subscribed: 200, + /** Default virtual time used to dispose subscriptions in unit tests. */ + disposed: 1000, + + /** + * Factory method for an OnNext notification record at a given time with a given value or a predicate function. + * + * 1 - ReactiveTest.onNext(200, 42); + * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); + * + * @param ticks Recorded virtual time the OnNext notification occurs. + * @param value Recorded value stored in the OnNext notification or a predicate. + * @return Recorded OnNext notification. + */ + onNext: function (ticks, value) { + return typeof value === 'function' ? + new Recorded(ticks, new OnNextPredicate(value)) : + new Recorded(ticks, Notification.createOnNext(value)); + }, + /** + * Factory method for an OnError notification record at a given time with a given error. + * + * 1 - ReactiveTest.onNext(200, new Error('error')); + * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); + * + * @param ticks Recorded virtual time the OnError notification occurs. + * @param exception Recorded exception stored in the OnError notification. + * @return Recorded OnError notification. + */ + onError: function (ticks, error) { + return typeof error === 'function' ? + new Recorded(ticks, new OnErrorPredicate(error)) : + new Recorded(ticks, Notification.createOnError(error)); + }, + /** + * Factory method for an OnCompleted notification record at a given time. + * + * @param ticks Recorded virtual time the OnCompleted notification occurs. + * @return Recorded OnCompleted notification. + */ + onCompleted: function (ticks) { + return new Recorded(ticks, Notification.createOnCompleted()); + }, + /** + * Factory method for a subscription record based on a given subscription and disposal time. + * + * @param start Virtual time indicating when the subscription was created. + * @param end Virtual time indicating when the subscription was disposed. + * @return Subscription object. + */ + subscribe: function (start, end) { + return new Subscription(start, end); + } +}; + + /** + * Creates a new object recording the production of the specified value at the given virtual time. + * + * @constructor + * @param {Number} time Virtual time the value was produced on. + * @param {Mixed} value Value that was produced. + * @param {Function} comparer An optional comparer. + */ + var Recorded = Rx.Recorded = function (time, value, comparer) { + this.time = time; + this.value = value; + this.comparer = comparer || defaultComparer; + }; + + /** + * Checks whether the given recorded object is equal to the current instance. + * + * @param {Recorded} other Recorded object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Recorded.prototype.equals = function (other) { + return this.time === other.time && this.comparer(this.value, other.value); + }; + + /** + * Returns a string representation of the current Recorded value. + * + * @returns {String} String representation of the current Recorded value. + */ + Recorded.prototype.toString = function () { + return this.value.toString() + '@' + this.time; + }; + + /** + * Creates a new subscription object with the given virtual subscription and unsubscription time. + * + * @constructor + * @param {Number} subscribe Virtual time at which the subscription occurred. + * @param {Number} unsubscribe Virtual time at which the unsubscription occurred. + */ + var Subscription = Rx.Subscription = function (start, end) { + this.subscribe = start; + this.unsubscribe = end || Number.MAX_VALUE; + }; + + /** + * Checks whether the given subscription is equal to the current instance. + * @param other Subscription object to check for equality. + * @returns {Boolean} true if both objects are equal; false otherwise. + */ + Subscription.prototype.equals = function (other) { + return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; + }; + + /** + * Returns a string representation of the current Subscription value. + * @returns {String} String representation of the current Subscription value. + */ + Subscription.prototype.toString = function () { + return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')'; + }; + + var MockDisposable = Rx.MockDisposable = function (scheduler) { + this.scheduler = scheduler; + this.disposes = []; + this.disposes.push(this.scheduler.clock); + }; + + MockDisposable.prototype.dispose = function () { + this.disposes.push(this.scheduler.clock); + }; + + var MockObserver = (function (__super__) { + inherits(MockObserver, __super__); + + function MockObserver(scheduler) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = []; + } + + var MockObserverPrototype = MockObserver.prototype; + + MockObserverPrototype.onNext = function (value) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value))); + }; + + MockObserverPrototype.onError = function (e) { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e))); + }; + + MockObserverPrototype.onCompleted = function () { + this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted())); + }; + + return MockObserver; + })(Observer); + + function MockPromise(scheduler, messages) { + var self = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + var message = this.messages[i], + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = self.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; + }); + })(notification); + } + } + + MockPromise.prototype.then = function (onResolved, onRejected) { + var self = this; + + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + + var newPromise; + + var observer = Rx.Observer.create( + function (x) { + var retValue = onResolved(x); + if (retValue && typeof retValue.then === 'function') { + newPromise = retValue; + } else { + var ticks = self.scheduler.clock; + newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]); + } + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + }, + function (err) { + onRejected(err); + var idx = self.observers.indexOf(observer); + self.observers.splice(idx, 1); + self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); + } + ); + this.observers.push(observer); + + return newPromise || new MockPromise(this.scheduler, this.messages); + }; + + var HotObservable = (function (__super__) { + inherits(HotObservable, __super__); + + function HotObservable(scheduler, messages) { + __super__.call(this); + var message, notification, observable = this; + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + this.observers = []; + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + scheduler.scheduleAbsolute(null, message.time, function () { + var obs = observable.observers.slice(0); + + for (var j = 0, jLen = obs.length; j < jLen; j++) { + innerNotification.accept(obs[j]); + } + return disposableEmpty; + }); + })(notification); + } + } + + HotObservable.prototype._subscribe = function (o) { + var observable = this; + this.observers.push(o); + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + return disposableCreate(function () { + var idx = observable.observers.indexOf(o); + observable.observers.splice(idx, 1); + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + }); + }; + + return HotObservable; + })(Observable); + + var ColdObservable = (function (__super__) { + inherits(ColdObservable, __super__); + + function ColdObservable(scheduler, messages) { + __super__.call(this); + this.scheduler = scheduler; + this.messages = messages; + this.subscriptions = []; + } + + ColdObservable.prototype._subscribe = function (o) { + var message, notification, observable = this; + this.subscriptions.push(new Subscription(this.scheduler.clock)); + var index = this.subscriptions.length - 1; + var d = new CompositeDisposable(); + for (var i = 0, len = this.messages.length; i < len; i++) { + message = this.messages[i]; + notification = message.value; + (function (innerNotification) { + d.add(observable.scheduler.scheduleRelative(null, message.time, function () { + innerNotification.accept(o); + return disposableEmpty; + })); + })(notification); + } + return disposableCreate(function () { + observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); + d.dispose(); + }); + }; + + return ColdObservable; + })(Observable); + + /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ + Rx.TestScheduler = (function (__super__) { + inherits(TestScheduler, __super__); + + function baseComparer(x, y) { + return x > y ? 1 : (x < y ? -1 : 0); + } + + function TestScheduler() { + __super__.call(this, 0, baseComparer); + } + + /** + * Schedules an action to be executed at the specified virtual time. + * + * @param state State passed to the action to be executed. + * @param dueTime Absolute virtual time at which to execute the action. + * @param action Action to be executed. + * @return Disposable object used to cancel the scheduled action (best effort). + */ + TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) { + dueTime <= this.clock && (dueTime = this.clock + 1); + return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action); + }; + /** + * Adds a relative virtual time to an absolute virtual time value. + * + * @param absolute Absolute virtual time value. + * @param relative Relative virtual time value to add. + * @return Resulting absolute virtual time sum value. + */ + TestScheduler.prototype.add = function (absolute, relative) { + return absolute + relative; + }; + /** + * Converts the absolute virtual time value to a DateTimeOffset value. + * + * @param absolute Absolute virtual time value to convert. + * @return Corresponding DateTimeOffset value. + */ + TestScheduler.prototype.toAbsoluteTime = function (absolute) { + return new Date(absolute).getTime(); + }; + /** + * Converts the TimeSpan value to a relative virtual time value. + * + * @param timeSpan TimeSpan value to convert. + * @return Corresponding relative virtual time value. + */ + TestScheduler.prototype.toRelativeTime = function (timeSpan) { + return timeSpan; + }; + /** + * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. + * + * @param create Factory method to create an observable sequence. + * @param created Virtual time at which to invoke the factory to create an observable sequence. + * @param subscribed Virtual time at which to subscribe to the created observable sequence. + * @param disposed Virtual time at which to dispose the subscription. + * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. + */ + TestScheduler.prototype.startScheduler = function (createFn, settings) { + settings || (settings = {}); + settings.created == null && (settings.created = ReactiveTest.created); + settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed); + settings.disposed == null && (settings.disposed = ReactiveTest.disposed); + + var observer = this.createObserver(), source, subscription; + + this.scheduleAbsolute(null, settings.created, function () { + source = createFn(); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.subscribed, function () { + subscription = source.subscribe(observer); + return disposableEmpty; + }); + + this.scheduleAbsolute(null, settings.disposed, function () { + subscription.dispose(); + return disposableEmpty; + }); + + this.start(); + + return observer; + }; + + /** + * Creates a hot observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified absolute virtual times. + * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createHotObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new HotObservable(this, args); + }; + + /** + * Creates a cold observable using the specified timestamped notification messages either as an array or arguments. + * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. + * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. + */ + TestScheduler.prototype.createColdObservable = function () { + var len = arguments.length, args; + if (Array.isArray(arguments[0])) { + args = arguments[0]; + } else { + args = new Array(len); + for (var i = 0; i < len; i++) { args[i] = arguments[i]; } + } + return new ColdObservable(this, args); + }; + + /** + * Creates a resolved promise with the given value and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} value The value to yield at the given tick. + * @returns {MockPromise} A mock Promise which fulfills with the given value. + */ + TestScheduler.prototype.createResolvedPromise = function (ticks, value) { + return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]); + }; + + /** + * Creates a rejected promise with the given reason and ticks + * @param {Number} ticks The absolute time of the resolution. + * @param {Any} reason The reason for rejection to yield at the given tick. + * @returns {MockPromise} A mock Promise which rejects with the given reason. + */ + TestScheduler.prototype.createRejectedPromise = function (ticks, reason) { + return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]); + }; + + /** + * Creates an observer that records received notification messages and timestamps those. + * @return Observer that can be used to assert the timing of received notifications. + */ + TestScheduler.prototype.createObserver = function () { + return new MockObserver(this); + }; + + return TestScheduler; + })(VirtualTimeScheduler); + + var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) { + inherits(AnonymousObservable, __super__); + + // Fix subscriber to check for undefined or function returned to decorate as Disposable + function fixSubscriber(subscriber) { + return subscriber && isFunction(subscriber.dispose) ? subscriber : + isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; + } + + function setDisposable(s, state) { + var ado = state[0], self = state[1]; + var sub = tryCatch(self.__subscribe).call(self, ado); + if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } + ado.setDisposable(fixSubscriber(sub)); + } + + function AnonymousObservable(subscribe, parent) { + this.source = parent; + this.__subscribe = subscribe; + __super__.call(this); + } + + AnonymousObservable.prototype._subscribe = function (o) { + var ado = new AutoDetachObserver(o), state = [ado, this]; + + if (currentThreadScheduler.scheduleRequired()) { + currentThreadScheduler.schedule(state, setDisposable); + } else { + setDisposable(null, state); + } + return ado; + }; + + return AnonymousObservable; + + }(Observable)); + + var AutoDetachObserver = (function (__super__) { + inherits(AutoDetachObserver, __super__); + + function AutoDetachObserver(observer) { + __super__.call(this); + this.observer = observer; + this.m = new SingleAssignmentDisposable(); + } + + var AutoDetachObserverPrototype = AutoDetachObserver.prototype; + + AutoDetachObserverPrototype.next = function (value) { + var result = tryCatch(this.observer.onNext).call(this.observer, value); + if (result === errorObj) { + this.dispose(); + thrower(result.e); + } + }; + + AutoDetachObserverPrototype.error = function (err) { + var result = tryCatch(this.observer.onError).call(this.observer, err); + this.dispose(); + result === errorObj && thrower(result.e); + }; + + AutoDetachObserverPrototype.completed = function () { + var result = tryCatch(this.observer.onCompleted).call(this.observer); + this.dispose(); + result === errorObj && thrower(result.e); + }; + + AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); }; + AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); }; + + AutoDetachObserverPrototype.dispose = function () { + __super__.prototype.dispose.call(this); + this.m.dispose(); + }; + + return AutoDetachObserver; + }(AbstractObserver)); + + var UnderlyingObservable = (function (__super__) { + inherits(UnderlyingObservable, __super__); + function UnderlyingObservable(m, u) { + this._m = m; + this._u = u; + __super__.call(this); + } + + UnderlyingObservable.prototype.subscribeCore = function (o) { + return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o)); + }; + + return UnderlyingObservable; + }(ObservableBase)); + + var GroupedObservable = (function (__super__) { + inherits(GroupedObservable, __super__); + function GroupedObservable(key, underlyingObservable, mergedDisposable) { + __super__.call(this); + this.key = key; + this.underlyingObservable = !mergedDisposable ? + underlyingObservable : + new UnderlyingObservable(mergedDisposable, underlyingObservable); + } + + GroupedObservable.prototype._subscribe = function (o) { + return this.underlyingObservable.subscribe(o); + }; + + return GroupedObservable; + }(Observable)); + + /** + * Represents an object that is both an observable sequence as well as an observer. + * Each notification is broadcasted to all subscribed observers. + */ + var Subject = Rx.Subject = (function (__super__) { + inherits(Subject, __super__); + function Subject() { + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; + this.observers = []; + this.hasError = false; + } + + addProperties(Subject.prototype, Observer.prototype, { + _subscribe: function (o) { + checkDisposed(this); + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + if (this.hasError) { + o.onError(this.error); + return disposableEmpty; + } + o.onCompleted(); + return disposableEmpty; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { return this.observers.length > 0; }, + /** + * Notifies all subscribed observers about the end of the sequence. + */ + onCompleted: function () { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onCompleted(); + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the exception. + * @param {Mixed} error The exception to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + this.error = error; + this.hasError = true; + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the arrival of the specified element in the sequence. + * @param {Mixed} value The value to send to all observers. + */ + onNext: function (value) { + checkDisposed(this); + if (!this.isStopped) { + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onNext(value); + } + } + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + } + }); + + /** + * Creates a subject from the specified observer and observable. + * @param {Observer} observer The observer used to send messages to the subject. + * @param {Observable} observable The observable used to subscribe to messages sent from the subject. + * @returns {Subject} Subject implemented using the given observer and observable. + */ + Subject.create = function (observer, observable) { + return new AnonymousSubject(observer, observable); + }; + + return Subject; + }(Observable)); + + /** + * Represents the result of an asynchronous operation. + * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers. + */ + var AsyncSubject = Rx.AsyncSubject = (function (__super__) { + inherits(AsyncSubject, __super__); + + /** + * Creates a subject that can only receive one value and that value is cached for all future observations. + * @constructor + */ + function AsyncSubject() { + __super__.call(this); + this.isDisposed = false; + this.isStopped = false; + this.hasValue = false; + this.observers = []; + this.hasError = false; + } + + addProperties(AsyncSubject.prototype, Observer, { + _subscribe: function (o) { + checkDisposed(this); + + if (!this.isStopped) { + this.observers.push(o); + return new InnerSubscription(this, o); + } + + if (this.hasError) { + o.onError(this.error); + } else if (this.hasValue) { + o.onNext(this.value); + o.onCompleted(); + } else { + o.onCompleted(); + } + + return disposableEmpty; + }, + /** + * Indicates whether the subject has observers subscribed to it. + * @returns {Boolean} Indicates whether the subject has observers subscribed to it. + */ + hasObservers: function () { + checkDisposed(this); + return this.observers.length > 0; + }, + /** + * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any). + */ + onCompleted: function () { + var i, len; + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + var os = cloneArray(this.observers), len = os.length; + + if (this.hasValue) { + for (i = 0; i < len; i++) { + var o = os[i]; + o.onNext(this.value); + o.onCompleted(); + } + } else { + for (i = 0; i < len; i++) { + os[i].onCompleted(); + } + } + + this.observers.length = 0; + } + }, + /** + * Notifies all subscribed observers about the error. + * @param {Mixed} error The Error to send to all observers. + */ + onError: function (error) { + checkDisposed(this); + if (!this.isStopped) { + this.isStopped = true; + this.hasError = true; + this.error = error; + + for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { + os[i].onError(error); + } + + this.observers.length = 0; + } + }, + /** + * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers. + * @param {Mixed} value The value to store in the subject. + */ + onNext: function (value) { + checkDisposed(this); + if (this.isStopped) { return; } + this.value = value; + this.hasValue = true; + }, + /** + * Unsubscribe all observers and release resources. + */ + dispose: function () { + this.isDisposed = true; + this.observers = null; + this.error = null; + this.value = null; + } + }); + + return AsyncSubject; + }(Observable)); + + var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) { + inherits(AnonymousSubject, __super__); + function AnonymousSubject(observer, observable) { + this.observer = observer; + this.observable = observable; + __super__.call(this); + } + + addProperties(AnonymousSubject.prototype, Observer.prototype, { + _subscribe: function (o) { + return this.observable.subscribe(o); + }, + onCompleted: function () { + this.observer.onCompleted(); + }, + onError: function (error) { + this.observer.onError(error); + }, + onNext: function (value) { + this.observer.onNext(value); + } + }); + + return AnonymousSubject; + }(Observable)); + + /** + * Used to pause and resume streams. + */ + Rx.Pauser = (function (__super__) { + inherits(Pauser, __super__); + function Pauser() { + __super__.call(this); + } + + /** + * Pauses the underlying sequence. + */ + Pauser.prototype.pause = function () { this.onNext(false); }; + + /** + * Resumes the underlying sequence. + */ + Pauser.prototype.resume = function () { this.onNext(true); }; + + return Pauser; + }(Subject)); + + if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { + root.Rx = Rx; + + define(function() { + return Rx; + }); + } else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { + (freeModule.exports = Rx).Rx = Rx; + } else { + freeExports.Rx = Rx; + } + } else { + // in a browser or Rhino + root.Rx = Rx; + } + + // All code before this point will be filtered from stack traces. + var rEndingLine = captureLine(); + +}.call(this)); + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":2}],4:[function(require,module,exports){ +"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,n){for(var t=0;tt;t++)try{if(e=r[t],new root.ActiveXObject(e))break}catch(o){}return new root.ActiveXObject(e)}catch(o){throw new Error("XMLHttpRequest is not supported by your browser")}}function getCORSRequest(){var e=new root.XMLHttpRequest;if("withCredentials"in e)return e;if(root.XDomainRequest)return new XDomainRequest;throw new Error("CORS is not supported by your browser")}function normalizeAjaxSuccessEvent(e,r,t){var o="response"in r?r.response:r.responseText;if("auto"===t.responseType)try{o=JSON.parse(o)}catch(e){}else o="json"===t.responseType?JSON.parse(o):o;return{response:o,status:r.status,responseType:r.responseType,xhr:r,originalEvent:e}}function normalizeAjaxErrorEvent(e,r,t){return{type:t,status:r.status,xhr:r,originalEvent:e}}Object.defineProperty(exports,"__esModule",{value:!0});var _rx=require("rx"),_rx2=_interopRequireDefault(_rx),root="undefined"!=typeof window&&window||void 0;exports["default"]=function(e){var r={method:"GET",crossDomain:!1,async:!0,headers:{},responseType:"text",createXHR:function(){return this.crossDomain?getCORSRequest():getXMLHttpRequest()},normalizeError:normalizeAjaxErrorEvent,normalizeSuccess:normalizeAjaxSuccessEvent};if("string"==typeof e)r.url=e;else for(var t in e)hasOwnProperty.call(e,t)&&(r[t]=e[t]);var o=r.normalizeError,s=r.normalizeSuccess;return r.crossDomain||r.headers["X-Requested-With"]||(r.headers["X-Requested-With"]="XMLHttpRequest"),r.hasContent=void 0!==r.body,new _rx2["default"].AnonymousObservable(function(e){var t,n=!1,a=function(t,a){var u=1223===t.status?204:t.status;u>=200&&300>=u||0===u||""===u?(e.onNext(s(a,t,r)),e.onCompleted()):e.onError(o(a,t,"error")),n=!0};try{t=r.createXHR()}catch(u){e.onError(u)}try{r.user?t.open(r.method,r.url,r.async,r.user,r.password):t.open(r.method,r.url,r.async);var i=r.headers;for(var p in i)hasOwnProperty.call(i,p)&&t.setRequestHeader(p,i[p]);t.upload||!("withCredentials"in t)&&root.XDomainRequest?(t.onload=function(e){r.progressObserver&&(r.progressObserver.onNext(e),r.progressObserver.onCompleted()),a(t,e)},r.progressObserver&&(t.onprogress=function(e){r.progressObserver.onNext(e)}),t.onerror=function(s){r.progressObserver&&r.progressObserver.onError(s),e.onError(o(s,t,"error")),n=!0},t.onabort=function(s){r.progressObserver&&r.progressObserver.onError(s),e.onError(o(s,t,"abort")),n=!0}):t.onreadystatechange=function(e){4===t.readyState&&a(t,e)},t.send(r.hasContent&&r.body||null)}catch(c){e.onError(c)}return function(){n||4===t.readyState||t.abort()}})},module.exports=exports["default"]; + +},{"rx":3}],6:[function(require,module,exports){ +"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r