Kargi-Sitesi/.angular/cache/18.2.11/babel-webpack/7ea33b49c0512be643c5ea3d80f7ecbdc6a8b9d59ef85d9fe7e67551b379b68e.json

1 line
13 KiB
JSON
Raw Normal View History

2024-10-31 19:07:58 +00:00
{"ast":null,"code":"import { isArray } from './util/isArray';\nimport { isObject } from './util/isObject';\nimport { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nexport class Subscription {\n constructor(unsubscribe) {\n this.closed = false;\n this._parentOrParents = null;\n this._subscriptions = null;\n if (unsubscribe) {\n this._ctorUnsubscribe = true;\n this._unsubscribe = unsubscribe;\n }\n }\n unsubscribe() {\n let errors;\n if (this.closed) {\n return;\n }\n let {\n _parentOrParents,\n _ctorUnsubscribe,\n _unsubscribe,\n _subscriptions\n } = this;\n this.closed = true;\n this._parentOrParents = null;\n this._subscriptions = null;\n if (_parentOrParents instanceof Subscription) {\n _parentOrParents.remove(this);\n } else if (_parentOrParents !== null) {\n for (let index = 0; index < _parentOrParents.length; ++index) {\n const parent = _parentOrParents[index];\n parent.remove(this);\n }\n }\n if (isFunction(_unsubscribe)) {\n if (_ctorUnsubscribe) {\n this._unsubscribe = undefined;\n }\n try {\n _unsubscribe.call(this);\n } catch (e) {\n errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];\n }\n }\n if (isArray(_subscriptions)) {\n let index = -1;\n let len = _subscriptions.length;\n while (++index < len) {\n const sub = _subscriptions[index];\n if (isObject(sub)) {\n try {\n sub.unsubscribe();\n } catch (e) {\n errors = errors || [];\n if (e instanceof UnsubscriptionError) {\n errors = errors.concat(flattenUnsubscriptionErrors(e.errors));\n } else {\n errors.push(e);\n }\n }\n }\n }\n }\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n add(teardown) {\n let subscription = teardown;\n if (!teardown) {\n return Subscription.EMPTY;\n }\n switch (typeof teardown) {\n case 'function':\n subscription = new Subscription(teardown);\n case 'object':\n if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {\n return subscription;\n } else if (this.closed) {\n subscription.unsubscribe();\n return subscription;\n } else if (!(subscription instanceof Subscription)) {\n const tmp = subscription;\n subscription = new Subscription();\n subscription._subscriptions = [tmp];\n }\n break;\n default:\n {\n throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');\n }\n }\n let {\n _parentOrParents\n } = subscription;\n if (_parentOrParents === null) {\n subscription._parentOrParents = this;\n } else if (_parentOrParents instanceof Subscription) {\n if (_parentOrParents === this) {\n return subscription;\n }\n subscription._parentOrParents = [_parentOrParents, this];\n } else if (_parentOrParents.indexOf(this) === -1) {\n _parentOrParents.push(this);\n } else {\n return subscription;\n }\n const subscriptions = this._subscriptions;\n if (subscriptions === null) {\n this._subscriptions = [subscription];\n } else {\n subscriptions.push(subscription);\n }\n return subscription;\n }\n remove(subscription) {\n const subscriptions = this._subscriptions;\n if (subscriptions) {\n const subscriptionIndex = subscriptions.indexOf(subscription);\n if (subscriptionIndex !== -1) {\n subscriptions.splice(subscriptionIndex, 1);\n }\n }\n }\n}\nSubscription.EMPTY = function (empty) {\n empty.closed = true;\n return empty;\n}(new Subscription());\nfunction flattenUnsubscriptionErrors(errors) {\n return errors.reduce((errs, err) => errs.concat(err instanceof Unsubscriptio