nikkatalnikov/apeiron

View on GitHub

Showing 20 of 20 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    this.dataStream = this.service
      .concatMap(data => Observable.of(data))
      .do(() => void 0, err => this.errorStream.next(err))
      .retry()
      .share()
Severity: Major
Found in streamProviders.js and 1 other location - About 2 hrs to fix
streamProviders.js on lines 127..131

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 79.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    this.dataStream = this.service
      .concatMap(data => Observable.of(data))
      .do(() => void 0, err => this.errorStream.next(err))
      .retry()
      .share()
Severity: Major
Found in streamProviders.js and 1 other location - About 2 hrs to fix
streamProviders.js on lines 204..208

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 79.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  groupByMethod(method) {
    const endpoints = Object
      .keys(this.endpoints)
      .filter(x => this.endpoints[x].method === method)

Severity: Major
Found in streamProviders.js and 1 other location - About 1 hr to fix
streamProviders.js on lines 77..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  groupByUrl(url) {
    const endpoints = Object
      .keys(this.endpoints)
      .filter(x => this.endpoints[x].url === url)

Severity: Major
Found in streamProviders.js and 1 other location - About 1 hr to fix
streamProviders.js on lines 69..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if (!Number.isInteger(delay)) {
      this.errorStream.next(new Error(`${delay} is not integer`))
      throw new Error(`${delay} is not integer`)
    }
Severity: Major
Found in streamProviders.js and 1 other location - About 1 hr to fix
streamProviders.js on lines 180..183

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if (!Number.isInteger(delay)) {
      this.errorStream.next(new Error(`${delay} is not integer`))
      throw new Error(`${delay} is not integer`)
    }
Severity: Major
Found in streamProviders.js and 1 other location - About 1 hr to fix
streamProviders.js on lines 56..59

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function fromWebSocket has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  fromWebSocket(endpoint, protocol) {
    const ws = new WebSocket(endpoint, protocol)
    const close = ws.close.bind(ws)

    const observable = Observable.create((wsObservable) => {
Severity: Minor
Found in streamProviders.js - About 1 hr to fix

    Function constructor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(type, ...args) {
        let streamInstance
        switch (type) {
          case STREAM_TYPE.HTTP:
            streamInstance = new HTTPProvider(type, ...args)
    Severity: Minor
    Found in streamAPI.js - About 1 hr to fix

      Function fromWebSocket has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        fromWebSocket(endpoint, protocol) {
          const ws = new WebSocket(endpoint, protocol)
          const close = ws.close.bind(ws)
      
          const observable = Observable.create((wsObservable) => {
      Severity: Minor
      Found in streamProviders.js - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Unable to resolve path to module 'axios'.
      Open

      import axios from 'axios'
      Severity: Minor
      Found in streamProviders.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Unable to resolve path to module 'rxjs'.
      Open

      import { Subscriber, Observable, Subject } from 'rxjs'
      Severity: Minor
      Found in streamProviders.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      HACK found
      Open

          "\"use strict\";\nvar isArray_1 = require('./util/isArray');\nvar isObject_1 = require('./util/isObject');\nvar isFunction_1 = require('./util/isFunction');\nvar tryCatch_1 = require('./util/tryCatch');\nvar errorObject_1 = require('./util/errorObject');\nvar UnsubscriptionError_1 = require('./util/UnsubscriptionError');\n/**\n * Represents a disposable resource, such as the execution of an Observable. A\n * Subscription has one important method, `unsubscribe`, that takes no argument\n * and just disposes the resource held by the subscription.\n *\n * Additionally, subscriptions may be grouped together through the `add()`\n * method, which will attach a child Subscription to the current Subscription.\n * When a Subscription is unsubscribed, all its children (and its grandchildren)\n * will be unsubscribed as well.\n *\n * @class Subscription\n */\nvar Subscription = (function () {\n    /**\n     * @param {function(): void} [unsubscribe] A function describing how to\n     * perform the disposal of resources when the `unsubscribe` method is called.\n     */\n    function Subscription(unsubscribe) {\n        /**\n         * A flag to indicate whether this Subscription has already been unsubscribed.\n         * @type {boolean}\n         */\n        this.closed = false;\n        if (unsubscribe) {\n            this._unsubscribe = unsubscribe;\n        }\n    }\n    /**\n     * Disposes the resources held by the subscription. May, for instance, cancel\n     * an ongoing Observable execution or cancel any other type of work that\n     * started when the Subscription was created.\n     * @return {void}\n     */\n    Subscription.prototype.unsubscribe = function () {\n        var hasErrors = false;\n        var errors;\n        if (this.closed) {\n            return;\n        }\n        this.closed = true;\n        var _a = this, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;\n        this._subscriptions = null;\n        if (isFunction_1.isFunction(_unsubscribe)) {\n            var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);\n            if (trial === errorObject_1.errorObject) {\n                hasErrors = true;\n                (errors = errors || []).push(errorObject_1.errorObject.e);\n            }\n        }\n        if (isArray_1.isArray(_subscriptions)) {\n            var index = -1;\n            var len = _subscriptions.length;\n            while (++index < len) {\n                var sub = _subscriptions[index];\n                if (isObject_1.isObject(sub)) {\n                    var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);\n                    if (trial === errorObject_1.errorObject) {\n                        hasErrors = true;\n                        errors = errors || [];\n                        var err = errorObject_1.errorObject.e;\n                        if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {\n                            errors = errors.concat(err.errors);\n                        }\n                        else {\n                            errors.push(err);\n                        }\n                    }\n                }\n            }\n        }\n        if (hasErrors) {\n            throw new UnsubscriptionError_1.UnsubscriptionError(errors);\n        }\n    };\n    /**\n     * Adds a tear down to be called during the unsubscribe() of this\n     * Subscription.\n     *\n     * If the tear down being added is a subscription that is already\n     * unsubscribed, is the same reference `add` is being called on, or is\n     * `Subscription.EMPTY`, it will not be added.\n     *\n     * If this subscription is already in an `closed` state, the passed\n     * tear down logic will be executed immediately.\n     *\n     * @param {TeardownLogic} teardown The additional logic to execute on\n     * teardown.\n     * @return {Subscription} Returns the Subscription used or created to be\n     * added to the inner subscriptions list. This Subscription can be used with\n     * `remove()` to remove the passed teardown logic from the inner subscriptions\n     * list.\n     */\n    Subscription.prototype.add = function (teardown) {\n        if (!teardown || (teardown === Subscription.EMPTY)) {\n            return Subscription.EMPTY;\n        }\n        if (teardown === this) {\n            return this;\n        }\n        var sub = teardown;\n        switch (typeof teardown) {\n            case 'function':\n                sub = new Subscription(teardown);\n            case 'object':\n                if (sub.closed || typeof sub.unsubscribe !== 'function') {\n                    break;\n                }\n                else if (this.closed) {\n                    sub.unsubscribe();\n                }\n                else {\n                    (this._subscriptions || (this._subscriptions = [])).push(sub);\n                }\n                break;\n            default:\n                throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');\n        }\n        return sub;\n    };\n    /**\n     * Removes a Subscription from the internal list of subscriptions that will\n     * unsubscribe during the unsubscribe process of this Subscription.\n     * @param {Subscription} subscription The subscription to remove.\n     * @return {void}\n     */\n    Subscription.prototype.remove = function (subscription) {\n        // HACK: This might be redundant because of the logic in `add()`\n        if (subscription == null || (subscription === this) || (subscription === Subscription.EMPTY)) {\n            return;\n        }\n        var subscriptions = this._subscriptions;\n        if (subscriptions) {\n            var subscriptionIndex = subscriptions.indexOf(subscription);\n            if (subscriptionIndex !== -1) {\n                subscriptions.splice(subscriptionIndex, 1);\n            }\n        }\n    };\n    Subscription.EMPTY = (function (empty) {\n        empty.closed = true;\n        return empty;\n    }(new Subscription()));\n    return Subscription;\n}());\nexports.Subscription = Subscription;\n//# sourceMappingURL=Subscription.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      TODO found
      Open

          "\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar root_1 = require('../../util/root');\nvar tryCatch_1 = require('../../util/tryCatch');\nvar errorObject_1 = require('../../util/errorObject');\nvar Observable_1 = require('../../Observable');\nvar Subscriber_1 = require('../../Subscriber');\nvar map_1 = require('../../operator/map');\nfunction getCORSRequest() {\n    if (root_1.root.XMLHttpRequest) {\n        var xhr = new root_1.root.XMLHttpRequest();\n        if ('withCredentials' in xhr) {\n            xhr.withCredentials = !!this.withCredentials;\n        }\n        return xhr;\n    }\n    else if (!!root_1.root.XDomainRequest) {\n        return new root_1.root.XDomainRequest();\n    }\n    else {\n        throw new Error('CORS is not supported by your browser');\n    }\n}\nfunction getXMLHttpRequest() {\n    if (root_1.root.XMLHttpRequest) {\n        return new root_1.root.XMLHttpRequest();\n    }\n    else {\n        var progId = void 0;\n        try {\n            var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n            for (var i = 0; i < 3; i++) {\n                try {\n                    progId = progIds[i];\n                    if (new root_1.root.ActiveXObject(progId)) {\n                        break;\n                    }\n                }\n                catch (e) {\n                }\n            }\n            return new root_1.root.ActiveXObject(progId);\n        }\n        catch (e) {\n            throw new Error('XMLHttpRequest is not supported by your browser');\n        }\n    }\n}\nfunction ajaxGet(url, headers) {\n    if (headers === void 0) { headers = null; }\n    return new AjaxObservable({ method: 'GET', url: url, headers: headers });\n}\nexports.ajaxGet = ajaxGet;\n;\nfunction ajaxPost(url, body, headers) {\n    return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });\n}\nexports.ajaxPost = ajaxPost;\n;\nfunction ajaxDelete(url, headers) {\n    return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });\n}\nexports.ajaxDelete = ajaxDelete;\n;\nfunction ajaxPut(url, body, headers) {\n    return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });\n}\nexports.ajaxPut = ajaxPut;\n;\nfunction ajaxGetJSON(url, headers) {\n    return new AjaxObservable({ method: 'GET', url: url, responseType: 'json', headers: headers })\n        .lift(new map_1.MapOperator(function (x, index) { return x.response; }, null));\n}\nexports.ajaxGetJSON = ajaxGetJSON;\n;\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n */\nvar AjaxObservable = (function (_super) {\n    __extends(AjaxObservable, _super);\n    function AjaxObservable(urlOrRequest) {\n        _super.call(this);\n        var request = {\n            async: true,\n            createXHR: function () {\n                return this.crossDomain ? getCORSRequest.call(this) : getXMLHttpRequest();\n            },\n            crossDomain: false,\n            withCredentials: false,\n            headers: {},\n            method: 'GET',\n            responseType: 'json',\n            timeout: 0\n        };\n        if (typeof urlOrRequest === 'string') {\n            request.url = urlOrRequest;\n        }\n        else {\n            for (var prop in urlOrRequest) {\n                if (urlOrRequest.hasOwnProperty(prop)) {\n                    request[prop] = urlOrRequest[prop];\n                }\n            }\n        }\n        this.request = request;\n    }\n    AjaxObservable.prototype._subscribe = function (subscriber) {\n        return new AjaxSubscriber(subscriber, this.request);\n    };\n    /**\n     * Creates an observable for an Ajax request with either a request object with\n     * url, headers, etc or a string for a URL.\n     *\n     * @example\n     * source = Rx.Observable.ajax('/products');\n     * source = Rx.Observable.ajax({ url: 'products', method: 'GET' });\n     *\n     * @param {string|Object} request Can be one of the following:\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     *   - createXHR: a function to override if you need to use an alternate\n     *   XMLHttpRequest implementation.\n     *   - resultSelector: a function to use to alter the output value type of\n     *   the Observable. Gets {@link AjaxResponse} as an argument.\n     * @return {Observable} An observable sequence containing the XMLHttpRequest.\n     * @static true\n     * @name ajax\n     * @owner Observable\n    */\n    AjaxObservable.create = (function () {\n        var create = function (urlOrRequest) {\n            return new AjaxObservable(urlOrRequest);\n        };\n        create.get = ajaxGet;\n        create.post = ajaxPost;\n        create.delete = ajaxDelete;\n        create.put = ajaxPut;\n        create.getJSON = ajaxGetJSON;\n        return create;\n    })();\n    return AjaxObservable;\n}(Observable_1.Observable));\nexports.AjaxObservable = AjaxObservable;\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nvar AjaxSubscriber = (function (_super) {\n    __extends(AjaxSubscriber, _super);\n    function AjaxSubscriber(destination, request) {\n        _super.call(this, destination);\n        this.request = request;\n        this.done = false;\n        var headers = request.headers = request.headers || {};\n        // force CORS if requested\n        if (!request.crossDomain && !headers['X-Requested-With']) {\n            headers['X-Requested-With'] = 'XMLHttpRequest';\n        }\n        // ensure content type is set\n        if (!('Content-Type' in headers) && !(root_1.root.FormData && request.body instanceof root_1.root.FormData) && typeof request.body !== 'undefined') {\n            headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';\n        }\n        // properly serialize body\n        request.body = this.serializeBody(request.body, request.headers['Content-Type']);\n        this.send();\n    }\n    AjaxSubscriber.prototype.next = function (e) {\n        this.done = true;\n        var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;\n        var response = new AjaxResponse(e, xhr, request);\n        destination.next(response);\n    };\n    AjaxSubscriber.prototype.send = function () {\n        var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;\n        var createXHR = request.createXHR;\n        var xhr = tryCatch_1.tryCatch(createXHR).call(request);\n        if (xhr === errorObject_1.errorObject) {\n            this.error(errorObject_1.errorObject.e);\n        }\n        else {\n            this.xhr = xhr;\n            // set up the events before open XHR\n            // https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest\n            // You need to add the event listeners before calling open() on the request.\n            // Otherwise the progress events will not fire.\n            this.setupEvents(xhr, request);\n            // open XHR\n            var result = void 0;\n            if (user) {\n                result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async, user, password);\n            }\n            else {\n                result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async);\n            }\n            if (result === errorObject_1.errorObject) {\n                this.error(errorObject_1.errorObject.e);\n                return null;\n            }\n            // timeout and responseType can be set once the XHR is open\n            xhr.timeout = request.timeout;\n            xhr.responseType = request.responseType;\n            // set headers\n            this.setHeaders(xhr, headers);\n            // finally send the request\n            result = body ? tryCatch_1.tryCatch(xhr.send).call(xhr, body) : tryCatch_1.tryCatch(xhr.send).call(xhr);\n            if (result === errorObject_1.errorObject) {\n                this.error(errorObject_1.errorObject.e);\n                return null;\n            }\n        }\n        return xhr;\n    };\n    AjaxSubscriber.prototype.serializeBody = function (body, contentType) {\n        if (!body || typeof body === 'string') {\n            return body;\n        }\n        else if (root_1.root.FormData && body instanceof root_1.root.FormData) {\n            return body;\n        }\n        if (contentType) {\n            var splitIndex = contentType.indexOf(';');\n            if (splitIndex !== -1) {\n                contentType = contentType.substring(0, splitIndex);\n            }\n        }\n        switch (contentType) {\n            case 'application/x-www-form-urlencoded':\n                return Object.keys(body).map(function (key) { return (encodeURI(key) + \"=\" + encodeURI(body[key])); }).join('&');\n            case 'application/json':\n                return JSON.stringify(body);\n            default:\n                return body;\n        }\n    };\n    AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {\n        for (var key in headers) {\n            if (headers.hasOwnProperty(key)) {\n                xhr.setRequestHeader(key, headers[key]);\n            }\n        }\n    };\n    AjaxSubscriber.prototype.setupEvents = function (xhr, request) {\n        var progressSubscriber = request.progressSubscriber;\n        function xhrTimeout(e) {\n            var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;\n            if (progressSubscriber) {\n                progressSubscriber.error(e);\n            }\n            subscriber.error(new AjaxTimeoutError(this, request)); //TODO: Make betterer.\n        }\n        ;\n        xhr.ontimeout = xhrTimeout;\n        xhrTimeout.request = request;\n        xhrTimeout.subscriber = this;\n        xhrTimeout.progressSubscriber = progressSubscriber;\n        if (xhr.upload && 'withCredentials' in xhr) {\n            if (progressSubscriber) {\n                var xhrProgress_1;\n                xhrProgress_1 = function (e) {\n                    var progressSubscriber = xhrProgress_1.progressSubscriber;\n                    progressSubscriber.next(e);\n                };\n                if (root_1.root.XDomainRequest) {\n                    xhr.onprogress = xhrProgress_1;\n                }\n                else {\n                    xhr.upload.onprogress = xhrProgress_1;\n                }\n                xhrProgress_1.progressSubscriber = progressSubscriber;\n            }\n            var xhrError_1;\n            xhrError_1 = function (e) {\n                var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;\n                if (progressSubscriber) {\n                    progressSubscriber.error(e);\n                }\n                subscriber.error(new AjaxError('ajax error', this, request));\n            };\n            xhr.onerror = xhrError_1;\n            xhrError_1.request = request;\n            xhrError_1.subscriber = this;\n            xhrError_1.progressSubscriber = progressSubscriber;\n        }\n        function xhrReadyStateChange(e) {\n            var _a = xhrReadyStateChange, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;\n            if (this.readyState === 4) {\n                // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)\n                var status_1 = this.status === 1223 ? 204 : this.status;\n                var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);\n                // fix status code when it is 0 (0 status is undocumented).\n                // Occurs when accessing file resources or on Android 4.1 stock browser\n                // while retrieving files from application cache.\n                if (status_1 === 0) {\n                    status_1 = response ? 200 : 0;\n                }\n                if (200 <= status_1 && status_1 < 300) {\n                    if (progressSubscriber) {\n                        progressSubscriber.complete();\n                    }\n                    subscriber.next(e);\n                    subscriber.complete();\n                }\n                else {\n                    if (progressSubscriber) {\n                        progressSubscriber.error(e);\n                    }\n                    subscriber.error(new AjaxError('ajax error ' + status_1, this, request));\n                }\n            }\n        }\n        ;\n        xhr.onreadystatechange = xhrReadyStateChange;\n        xhrReadyStateChange.subscriber = this;\n        xhrReadyStateChange.progressSubscriber = progressSubscriber;\n        xhrReadyStateChange.request = request;\n    };\n    AjaxSubscriber.prototype.unsubscribe = function () {\n        var _a = this, done = _a.done, xhr = _a.xhr;\n        if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {\n            xhr.abort();\n        }\n        _super.prototype.unsubscribe.call(this);\n    };\n    return AjaxSubscriber;\n}(Subscriber_1.Subscriber));\nexports.AjaxSubscriber = AjaxSubscriber;\n/**\n * A normalized AJAX response.\n *\n * @see {@link ajax}\n *\n * @class AjaxResponse\n */\nvar AjaxResponse = (function () {\n    function AjaxResponse(originalEvent, xhr, request) {\n        this.originalEvent = originalEvent;\n        this.xhr = xhr;\n        this.request = request;\n        this.status = xhr.status;\n        this.responseType = xhr.responseType || request.responseType;\n        switch (this.responseType) {\n            case 'json':\n                if ('response' in xhr) {\n                    //IE does not support json as responseType, parse it internally\n                    this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');\n                }\n                else {\n                    this.response = JSON.parse(xhr.responseText || 'null');\n                }\n                break;\n            case 'xml':\n                this.response = xhr.responseXML;\n                break;\n            case 'text':\n            default:\n                this.response = ('response' in xhr) ? xhr.response : xhr.responseText;\n                break;\n        }\n    }\n    return AjaxResponse;\n}());\nexports.AjaxResponse = AjaxResponse;\n/**\n * A normalized AJAX error.\n *\n * @see {@link ajax}\n *\n * @class AjaxError\n */\nvar AjaxError = (function (_super) {\n    __extends(AjaxError, _super);\n    function AjaxError(message, xhr, request) {\n        _super.call(this, message);\n        this.message = message;\n        this.xhr = xhr;\n        this.request = request;\n        this.status = xhr.status;\n    }\n    return AjaxError;\n}(Error));\nexports.AjaxError = AjaxError;\n/**\n * @see {@link ajax}\n *\n * @class AjaxTimeoutError\n */\nvar AjaxTimeoutError = (function (_super) {\n    __extends(AjaxTimeoutError, _super);\n    function AjaxTimeoutError(xhr, request) {\n        _super.call(this, 'ajax timeout', xhr, request);\n    }\n    return AjaxTimeoutError;\n}(AjaxError));\nexports.AjaxTimeoutError = AjaxTimeoutError;\n//# sourceMappingURL=AjaxObservable.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      XXX found
      Open

          "\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar Observable_1 = require('../Observable');\nvar tryCatch_1 = require('../util/tryCatch');\nvar errorObject_1 = require('../util/errorObject');\nvar AsyncSubject_1 = require('../AsyncSubject');\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n */\nvar BoundNodeCallbackObservable = (function (_super) {\n    __extends(BoundNodeCallbackObservable, _super);\n    function BoundNodeCallbackObservable(callbackFunc, selector, args, scheduler) {\n        _super.call(this);\n        this.callbackFunc = callbackFunc;\n        this.selector = selector;\n        this.args = args;\n        this.scheduler = scheduler;\n    }\n    /* tslint:enable:max-line-length */\n    /**\n     * Converts a Node.js-style callback API to a function that returns an\n     * Observable.\n     *\n     * <span class=\"informal\">It's just like {@link bindCallback}, but the\n     * callback is expected to be of type `callback(error, result)`.</span>\n     *\n     * `bindNodeCallback` is not an operator because its input and output are not\n     * Observables. The input is a function `func` with some parameters, but the\n     * last parameter must be a callback function that `func` calls when it is\n     * done. The callback function is expected to follow Node.js conventions,\n     * where the first argument to the callback is an error, while remaining\n     * arguments are the callback result. The output of `bindNodeCallback` is a\n     * function that takes the same parameters as `func`, except the last one (the\n     * callback). When the output function is called with arguments, it will\n     * return an Observable where the results will be delivered to.\n     *\n     * @example <caption>Read a file from the filesystem and get the data as an Observable</caption>\n     * import * as fs from 'fs';\n     * var readFileAsObservable = Rx.Observable.bindNodeCallback(fs.readFile);\n     * var result = readFileAsObservable('./roadNames.txt', 'utf8');\n     * result.subscribe(x => console.log(x), e => console.error(e));\n     *\n     * @see {@link bindCallback}\n     * @see {@link from}\n     * @see {@link fromPromise}\n     *\n     * @param {function} func Function with a callback as the last parameter.\n     * @param {function} [selector] A function which takes the arguments from the\n     * callback and maps those a value to emit on the output Observable.\n     * @param {Scheduler} [scheduler] The scheduler on which to schedule the\n     * callbacks.\n     * @return {function(...params: *): Observable} A function which returns the\n     * Observable that delivers the same values the Node.js callback would\n     * deliver.\n     * @static true\n     * @name bindNodeCallback\n     * @owner Observable\n     */\n    BoundNodeCallbackObservable.create = function (func, selector, scheduler) {\n        if (selector === void 0) { selector = undefined; }\n        return function () {\n            var args = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                args[_i - 0] = arguments[_i];\n            }\n            return new BoundNodeCallbackObservable(func, selector, args, scheduler);\n        };\n    };\n    BoundNodeCallbackObservable.prototype._subscribe = function (subscriber) {\n        var callbackFunc = this.callbackFunc;\n        var args = this.args;\n        var scheduler = this.scheduler;\n        var subject = this.subject;\n        if (!scheduler) {\n            if (!subject) {\n                subject = this.subject = new AsyncSubject_1.AsyncSubject();\n                var handler = function handlerFn() {\n                    var innerArgs = [];\n                    for (var _i = 0; _i < arguments.length; _i++) {\n                        innerArgs[_i - 0] = arguments[_i];\n                    }\n                    var source = handlerFn.source;\n                    var selector = source.selector, subject = source.subject;\n                    var err = innerArgs.shift();\n                    if (err) {\n                        subject.error(err);\n                    }\n                    else if (selector) {\n                        var result_1 = tryCatch_1.tryCatch(selector).apply(this, innerArgs);\n                        if (result_1 === errorObject_1.errorObject) {\n                            subject.error(errorObject_1.errorObject.e);\n                        }\n                        else {\n                            subject.next(result_1);\n                            subject.complete();\n                        }\n                    }\n                    else {\n                        subject.next(innerArgs.length === 1 ? innerArgs[0] : innerArgs);\n                        subject.complete();\n                    }\n                };\n                // use named function instance to avoid closure.\n                handler.source = this;\n                var result = tryCatch_1.tryCatch(callbackFunc).apply(this, args.concat(handler));\n                if (result === errorObject_1.errorObject) {\n                    subject.error(errorObject_1.errorObject.e);\n                }\n            }\n            return subject.subscribe(subscriber);\n        }\n        else {\n            return scheduler.schedule(dispatch, 0, { source: this, subscriber: subscriber });\n        }\n    };\n    return BoundNodeCallbackObservable;\n}(Observable_1.Observable));\nexports.BoundNodeCallbackObservable = BoundNodeCallbackObservable;\nfunction dispatch(state) {\n    var self = this;\n    var source = state.source, subscriber = state.subscriber;\n    // XXX: cast to `any` to access to the private field in `source`.\n    var _a = source, callbackFunc = _a.callbackFunc, args = _a.args, scheduler = _a.scheduler;\n    var subject = source.subject;\n    if (!subject) {\n        subject = source.subject = new AsyncSubject_1.AsyncSubject();\n        var handler = function handlerFn() {\n            var innerArgs = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                innerArgs[_i - 0] = arguments[_i];\n            }\n            var source = handlerFn.source;\n            var selector = source.selector, subject = source.subject;\n            var err = innerArgs.shift();\n            if (err) {\n                subject.error(err);\n            }\n            else if (selector) {\n                var result_2 = tryCatch_1.tryCatch(selector).apply(this, innerArgs);\n                if (result_2 === errorObject_1.errorObject) {\n                    self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject }));\n                }\n                else {\n                    self.add(scheduler.schedule(dispatchNext, 0, { value: result_2, subject: subject }));\n                }\n            }\n            else {\n                var value = innerArgs.length === 1 ? innerArgs[0] : innerArgs;\n                self.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));\n            }\n        };\n        // use named function to pass values in without closure\n        handler.source = source;\n        var result = tryCatch_1.tryCatch(callbackFunc).apply(this, args.concat(handler));\n        if (result === errorObject_1.errorObject) {\n            subject.error(errorObject_1.errorObject.e);\n        }\n    }\n    self.add(subject.subscribe(subscriber));\n}\nfunction dispatchNext(arg) {\n    var value = arg.value, subject = arg.subject;\n    subject.next(value);\n    subject.complete();\n}\nfunction dispatchError(arg) {\n    var err = arg.err, subject = arg.subject;\n    subject.error(err);\n}\n//# sourceMappingURL=BoundNodeCallbackObservable.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      TODO found
      Open

      ####**TODO (Beta-3 release)**
      Severity: Minor
      Found in README.md by fixme

      TODO found
      Open

          "\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar Subject_1 = require('../../Subject');\nvar Subscriber_1 = require('../../Subscriber');\nvar Observable_1 = require('../../Observable');\nvar Subscription_1 = require('../../Subscription');\nvar root_1 = require('../../util/root');\nvar ReplaySubject_1 = require('../../ReplaySubject');\nvar tryCatch_1 = require('../../util/tryCatch');\nvar errorObject_1 = require('../../util/errorObject');\nvar assign_1 = require('../../util/assign');\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n */\nvar WebSocketSubject = (function (_super) {\n    __extends(WebSocketSubject, _super);\n    function WebSocketSubject(urlConfigOrSource, destination) {\n        if (urlConfigOrSource instanceof Observable_1.Observable) {\n            _super.call(this, destination, urlConfigOrSource);\n        }\n        else {\n            _super.call(this);\n            this.WebSocketCtor = root_1.root.WebSocket;\n            this._output = new Subject_1.Subject();\n            if (typeof urlConfigOrSource === 'string') {\n                this.url = urlConfigOrSource;\n            }\n            else {\n                // WARNING: config object could override important members here.\n                assign_1.assign(this, urlConfigOrSource);\n            }\n            if (!this.WebSocketCtor) {\n                throw new Error('no WebSocket constructor can be found');\n            }\n            this.destination = new ReplaySubject_1.ReplaySubject();\n        }\n    }\n    WebSocketSubject.prototype.resultSelector = function (e) {\n        return JSON.parse(e.data);\n    };\n    /**\n     * @param urlConfigOrSource\n     * @return {WebSocketSubject}\n     * @static true\n     * @name webSocket\n     * @owner Observable\n     */\n    WebSocketSubject.create = function (urlConfigOrSource) {\n        return new WebSocketSubject(urlConfigOrSource);\n    };\n    WebSocketSubject.prototype.lift = function (operator) {\n        var sock = new WebSocketSubject(this, this.destination);\n        sock.operator = operator;\n        return sock;\n    };\n    WebSocketSubject.prototype._resetState = function () {\n        this.socket = null;\n        if (!this.source) {\n            this.destination = new ReplaySubject_1.ReplaySubject();\n        }\n        this._output = new Subject_1.Subject();\n    };\n    // TODO: factor this out to be a proper Operator/Subscriber implementation and eliminate closures\n    WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {\n        var self = this;\n        return new Observable_1.Observable(function (observer) {\n            var result = tryCatch_1.tryCatch(subMsg)();\n            if (result === errorObject_1.errorObject) {\n                observer.error(errorObject_1.errorObject.e);\n            }\n            else {\n                self.next(result);\n            }\n            var subscription = self.subscribe(function (x) {\n                var result = tryCatch_1.tryCatch(messageFilter)(x);\n                if (result === errorObject_1.errorObject) {\n                    observer.error(errorObject_1.errorObject.e);\n                }\n                else if (result) {\n                    observer.next(x);\n                }\n            }, function (err) { return observer.error(err); }, function () { return observer.complete(); });\n            return function () {\n                var result = tryCatch_1.tryCatch(unsubMsg)();\n                if (result === errorObject_1.errorObject) {\n                    observer.error(errorObject_1.errorObject.e);\n                }\n                else {\n                    self.next(result);\n                }\n                subscription.unsubscribe();\n            };\n        });\n    };\n    WebSocketSubject.prototype._connectSocket = function () {\n        var _this = this;\n        var WebSocketCtor = this.WebSocketCtor;\n        var observer = this._output;\n        var socket = null;\n        try {\n            socket = this.protocol ?\n                new WebSocketCtor(this.url, this.protocol) :\n                new WebSocketCtor(this.url);\n            this.socket = socket;\n        }\n        catch (e) {\n            observer.error(e);\n            return;\n        }\n        var subscription = new Subscription_1.Subscription(function () {\n            _this.socket = null;\n            if (socket && socket.readyState === 1) {\n                socket.close();\n            }\n        });\n        socket.onopen = function (e) {\n            var openObserver = _this.openObserver;\n            if (openObserver) {\n                openObserver.next(e);\n            }\n            var queue = _this.destination;\n            _this.destination = Subscriber_1.Subscriber.create(function (x) { return socket.readyState === 1 && socket.send(x); }, function (e) {\n                var closingObserver = _this.closingObserver;\n                if (closingObserver) {\n                    closingObserver.next(undefined);\n                }\n                if (e && e.code) {\n                    socket.close(e.code, e.reason);\n                }\n                else {\n                    observer.error(new TypeError('WebSocketSubject.error must be called with an object with an error code, ' +\n                        'and an optional reason: { code: number, reason: string }'));\n                }\n                _this._resetState();\n            }, function () {\n                var closingObserver = _this.closingObserver;\n                if (closingObserver) {\n                    closingObserver.next(undefined);\n                }\n                socket.close();\n                _this._resetState();\n            });\n            if (queue && queue instanceof ReplaySubject_1.ReplaySubject) {\n                subscription.add(queue.subscribe(_this.destination));\n            }\n        };\n        socket.onerror = function (e) {\n            _this._resetState();\n            observer.error(e);\n        };\n        socket.onclose = function (e) {\n            _this._resetState();\n            var closeObserver = _this.closeObserver;\n            if (closeObserver) {\n                closeObserver.next(e);\n            }\n            if (e.wasClean) {\n                observer.complete();\n            }\n            else {\n                observer.error(e);\n            }\n        };\n        socket.onmessage = function (e) {\n            var result = tryCatch_1.tryCatch(_this.resultSelector)(e);\n            if (result === errorObject_1.errorObject) {\n                observer.error(errorObject_1.errorObject.e);\n            }\n            else {\n                observer.next(result);\n            }\n        };\n    };\n    WebSocketSubject.prototype._subscribe = function (subscriber) {\n        var _this = this;\n        var source = this.source;\n        if (source) {\n            return source.subscribe(subscriber);\n        }\n        if (!this.socket) {\n            this._connectSocket();\n        }\n        var subscription = new Subscription_1.Subscription();\n        subscription.add(this._output.subscribe(subscriber));\n        subscription.add(function () {\n            var socket = _this.socket;\n            if (_this._output.observers.length === 0) {\n                if (socket && socket.readyState === 1) {\n                    socket.close();\n                }\n                _this._resetState();\n            }\n        });\n        return subscription;\n    };\n    WebSocketSubject.prototype.unsubscribe = function () {\n        var _a = this, source = _a.source, socket = _a.socket;\n        if (socket && socket.readyState === 1) {\n            socket.close();\n            this._resetState();\n        }\n        _super.prototype.unsubscribe.call(this);\n        if (!source) {\n            this.destination = new ReplaySubject_1.ReplaySubject();\n        }\n    };\n    return WebSocketSubject;\n}(Subject_1.AnonymousSubject));\nexports.WebSocketSubject = WebSocketSubject;\n//# sourceMappingURL=WebSocketSubject.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      TODO found
      Open

      ####**TODO (Beta-4 release)**
      Severity: Minor
      Found in README.md by fixme

      TODO found
      Open

          "\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar Observable_1 = require('../Observable');\nvar Subscription_1 = require('../Subscription');\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n */\nvar FromEventPatternObservable = (function (_super) {\n    __extends(FromEventPatternObservable, _super);\n    function FromEventPatternObservable(addHandler, removeHandler, selector) {\n        _super.call(this);\n        this.addHandler = addHandler;\n        this.removeHandler = removeHandler;\n        this.selector = selector;\n    }\n    /**\n     * Creates an Observable from an API based on addHandler/removeHandler\n     * functions.\n     *\n     * <span class=\"informal\">Converts any addHandler/removeHandler API to an\n     * Observable.</span>\n     *\n     * <img src=\"./img/fromEventPattern.png\" width=\"100%\">\n     *\n     * Creates an Observable by using the `addHandler` and `removeHandler`\n     * functions to add and remove the handlers, with an optional selector\n     * function to project the event arguments to a result. The `addHandler` is\n     * called when the output Observable is subscribed, and `removeHandler` is\n     * called when the Subscription is unsubscribed.\n     *\n     * @example <caption>Emits clicks happening on the DOM document</caption>\n     * function addClickHandler(handler) {\n     *   document.addEventListener('click', handler);\n     * }\n     *\n     * function removeClickHandler(handler) {\n     *   document.removeEventListener('click', handler);\n     * }\n     *\n     * var clicks = Rx.Observable.fromEventPattern(\n     *   addClickHandler,\n     *   removeClickHandler\n     * );\n     * clicks.subscribe(x => console.log(x));\n     *\n     * @see {@link from}\n     * @see {@link fromEvent}\n     *\n     * @param {function(handler: Function): any} addHandler A function that takes\n     * a `handler` function as argument and attaches it somehow to the actual\n     * source of events.\n     * @param {function(handler: Function): void} removeHandler A function that\n     * takes a `handler` function as argument and removes it in case it was\n     * previously attached using `addHandler`.\n     * @param {function(...args: any): T} [selector] An optional function to\n     * post-process results. It takes the arguments from the event handler and\n     * should return a single value.\n     * @return {Observable<T>}\n     * @static true\n     * @name fromEventPattern\n     * @owner Observable\n     */\n    FromEventPatternObservable.create = function (addHandler, removeHandler, selector) {\n        return new FromEventPatternObservable(addHandler, removeHandler, selector);\n    };\n    FromEventPatternObservable.prototype._subscribe = function (subscriber) {\n        var _this = this;\n        var removeHandler = this.removeHandler;\n        var handler = !!this.selector ? function () {\n            var args = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                args[_i - 0] = arguments[_i];\n            }\n            _this._callSelector(subscriber, args);\n        } : function (e) { subscriber.next(e); };\n        this._callAddHandler(handler, subscriber);\n        subscriber.add(new Subscription_1.Subscription(function () {\n            //TODO: determine whether or not to forward to error handler\n            removeHandler(handler);\n        }));\n    };\n    FromEventPatternObservable.prototype._callSelector = function (subscriber, args) {\n        try {\n            var result = this.selector.apply(this, args);\n            subscriber.next(result);\n        }\n        catch (e) {\n            subscriber.error(e);\n        }\n    };\n    FromEventPatternObservable.prototype._callAddHandler = function (handler, errorSubscriber) {\n        try {\n            this.addHandler(handler);\n        }\n        catch (e) {\n            errorSubscriber.error(e);\n        }\n    };\n    return FromEventPatternObservable;\n}(Observable_1.Observable));\nexports.FromEventPatternObservable = FromEventPatternObservable;\n//# sourceMappingURL=FromEventPatternObservable.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      TODO found
      Open

          "\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    function __() { this.constructor = d; }\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar OuterSubscriber_1 = require('../OuterSubscriber');\nvar subscribeToResult_1 = require('../util/subscribeToResult');\n/* tslint:disable:max-line-length */\n/**\n * Projects each source value to the same Observable which is merged multiple\n * times in the output Observable.\n *\n * <span class=\"informal\">It's like {@link mergeMap}, but maps each value always\n * to the same inner Observable.</span>\n *\n * <img src=\"./img/mergeMapTo.png\" width=\"100%\">\n *\n * Maps each source value to the given Observable `innerObservable` regardless\n * of the source value, and then merges those resulting Observables into one\n * single Observable, which is the output Observable.\n *\n * @example <caption>For each click event, start an interval Observable ticking every 1 second</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.mergeMapTo(Rx.Observable.interval(1000));\n * result.subscribe(x => console.log(x));\n *\n * @see {@link concatMapTo}\n * @see {@link merge}\n * @see {@link mergeAll}\n * @see {@link mergeMap}\n * @see {@link mergeScan}\n * @see {@link switchMapTo}\n *\n * @param {Observable} innerObservable An Observable to replace each value from\n * the source Observable.\n * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]\n * A function to produce the value on the output Observable based on the values\n * and the indices of the source (outer) emission and the inner Observable\n * emission. The arguments passed to this function are:\n * - `outerValue`: the value that came from the source\n * - `innerValue`: the value that came from the projected Observable\n * - `outerIndex`: the \"index\" of the value that came from the source\n * - `innerIndex`: the \"index\" of the value from the projected Observable\n * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input\n * Observables being subscribed to concurrently.\n * @return {Observable} An Observable that emits items from the given\n * `innerObservable` (and optionally transformed through `resultSelector`) every\n * time a value is emitted on the source Observable.\n * @method mergeMapTo\n * @owner Observable\n */\nfunction mergeMapTo(innerObservable, resultSelector, concurrent) {\n    if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n    if (typeof resultSelector === 'number') {\n        concurrent = resultSelector;\n        resultSelector = null;\n    }\n    return this.lift(new MergeMapToOperator(innerObservable, resultSelector, concurrent));\n}\nexports.mergeMapTo = mergeMapTo;\n// TODO: Figure out correct signature here: an Operator<Observable<T>, R>\n//       needs to implement call(observer: Subscriber<R>): Subscriber<Observable<T>>\nvar MergeMapToOperator = (function () {\n    function MergeMapToOperator(ish, resultSelector, concurrent) {\n        if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n        this.ish = ish;\n        this.resultSelector = resultSelector;\n        this.concurrent = concurrent;\n    }\n    MergeMapToOperator.prototype.call = function (observer, source) {\n        return source.subscribe(new MergeMapToSubscriber(observer, this.ish, this.resultSelector, this.concurrent));\n    };\n    return MergeMapToOperator;\n}());\nexports.MergeMapToOperator = MergeMapToOperator;\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nvar MergeMapToSubscriber = (function (_super) {\n    __extends(MergeMapToSubscriber, _super);\n    function MergeMapToSubscriber(destination, ish, resultSelector, concurrent) {\n        if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n        _super.call(this, destination);\n        this.ish = ish;\n        this.resultSelector = resultSelector;\n        this.concurrent = concurrent;\n        this.hasCompleted = false;\n        this.buffer = [];\n        this.active = 0;\n        this.index = 0;\n    }\n    MergeMapToSubscriber.prototype._next = function (value) {\n        if (this.active < this.concurrent) {\n            var resultSelector = this.resultSelector;\n            var index = this.index++;\n            var ish = this.ish;\n            var destination = this.destination;\n            this.active++;\n            this._innerSub(ish, destination, resultSelector, value, index);\n        }\n        else {\n            this.buffer.push(value);\n        }\n    };\n    MergeMapToSubscriber.prototype._innerSub = function (ish, destination, resultSelector, value, index) {\n        this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));\n    };\n    MergeMapToSubscriber.prototype._complete = function () {\n        this.hasCompleted = true;\n        if (this.active === 0 && this.buffer.length === 0) {\n            this.destination.complete();\n        }\n    };\n    MergeMapToSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n        var _a = this, resultSelector = _a.resultSelector, destination = _a.destination;\n        if (resultSelector) {\n            this.trySelectResult(outerValue, innerValue, outerIndex, innerIndex);\n        }\n        else {\n            destination.next(innerValue);\n        }\n    };\n    MergeMapToSubscriber.prototype.trySelectResult = function (outerValue, innerValue, outerIndex, innerIndex) {\n        var _a = this, resultSelector = _a.resultSelector, destination = _a.destination;\n        var result;\n        try {\n            result = resultSelector(outerValue, innerValue, outerIndex, innerIndex);\n        }\n        catch (err) {\n            destination.error(err);\n            return;\n        }\n        destination.next(result);\n    };\n    MergeMapToSubscriber.prototype.notifyError = function (err) {\n        this.destination.error(err);\n    };\n    MergeMapToSubscriber.prototype.notifyComplete = function (innerSub) {\n        var buffer = this.buffer;\n        this.remove(innerSub);\n        this.active--;\n        if (buffer.length > 0) {\n            this._next(buffer.shift());\n        }\n        else if (this.active === 0 && this.hasCompleted) {\n            this.destination.complete();\n        }\n    };\n    return MergeMapToSubscriber;\n}(OuterSubscriber_1.OuterSubscriber));\nexports.MergeMapToSubscriber = MergeMapToSubscriber;\n//# sourceMappingURL=mergeMapTo.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme

      HACK found
      Open

          "\"use strict\";\nvar root_1 = require('./util/root');\nvar toSubscriber_1 = require('./util/toSubscriber');\nvar observable_1 = require('./symbol/observable');\n/**\n * A representation of any set of values over any amount of time. This the most basic building block\n * of RxJS.\n *\n * @class Observable<T>\n */\nvar Observable = (function () {\n    /**\n     * @constructor\n     * @param {Function} subscribe the function that is  called when the Observable is\n     * initially subscribed to. This function is given a Subscriber, to which new values\n     * can be `next`ed, or an `error` method can be called to raise an error, or\n     * `complete` can be called to notify of a successful completion.\n     */\n    function Observable(subscribe) {\n        this._isScalar = false;\n        if (subscribe) {\n            this._subscribe = subscribe;\n        }\n    }\n    /**\n     * Creates a new Observable, with this Observable as the source, and the passed\n     * operator defined as the new observable's operator.\n     * @method lift\n     * @param {Operator} operator the operator defining the operation to take on the observable\n     * @return {Observable} a new observable with the Operator applied\n     */\n    Observable.prototype.lift = function (operator) {\n        var observable = new Observable();\n        observable.source = this;\n        observable.operator = operator;\n        return observable;\n    };\n    Observable.prototype.subscribe = function (observerOrNext, error, complete) {\n        var operator = this.operator;\n        var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);\n        if (operator) {\n            operator.call(sink, this.source);\n        }\n        else {\n            sink.add(this._subscribe(sink));\n        }\n        if (sink.syncErrorThrowable) {\n            sink.syncErrorThrowable = false;\n            if (sink.syncErrorThrown) {\n                throw sink.syncErrorValue;\n            }\n        }\n        return sink;\n    };\n    /**\n     * @method forEach\n     * @param {Function} next a handler for each value emitted by the observable\n     * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise\n     * @return {Promise} a promise that either resolves on observable completion or\n     *  rejects with the handled error\n     */\n    Observable.prototype.forEach = function (next, PromiseCtor) {\n        var _this = this;\n        if (!PromiseCtor) {\n            if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {\n                PromiseCtor = root_1.root.Rx.config.Promise;\n            }\n            else if (root_1.root.Promise) {\n                PromiseCtor = root_1.root.Promise;\n            }\n        }\n        if (!PromiseCtor) {\n            throw new Error('no Promise impl found');\n        }\n        return new PromiseCtor(function (resolve, reject) {\n            var subscription = _this.subscribe(function (value) {\n                if (subscription) {\n                    // if there is a subscription, then we can surmise\n                    // the next handling is asynchronous. Any errors thrown\n                    // need to be rejected explicitly and unsubscribe must be\n                    // called manually\n                    try {\n                        next(value);\n                    }\n                    catch (err) {\n                        reject(err);\n                        subscription.unsubscribe();\n                    }\n                }\n                else {\n                    // if there is NO subscription, then we're getting a nexted\n                    // value synchronously during subscription. We can just call it.\n                    // If it errors, Observable's `subscribe` will ensure the\n                    // unsubscription logic is called, then synchronously rethrow the error.\n                    // After that, Promise will trap the error and send it\n                    // down the rejection path.\n                    next(value);\n                }\n            }, reject, resolve);\n        });\n    };\n    Observable.prototype._subscribe = function (subscriber) {\n        return this.source.subscribe(subscriber);\n    };\n    /**\n     * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable\n     * @method Symbol.observable\n     * @return {Observable} this instance of the observable\n     */\n    Observable.prototype[observable_1.$$observable] = function () {\n        return this;\n    };\n    // HACK: Since TypeScript inherits static properties too, we have to\n    // fight against TypeScript here so Subject can have a different static create signature\n    /**\n     * Creates a new cold Observable by calling the Observable constructor\n     * @static true\n     * @owner Observable\n     * @method create\n     * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor\n     * @return {Observable} a new cold observable\n     */\n    Observable.create = function (subscribe) {\n        return new Observable(subscribe);\n    };\n    return Observable;\n}());\nexports.Observable = Observable;\n//# sourceMappingURL=Observable.js.map",
      Severity: Minor
      Found in dist/apeiron.min.js.map by fixme
      Severity
      Category
      Status
      Source
      Language