X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Frxjs%2F_esm5%2Finternal%2Foperators%2Fsingle.js;fp=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Frxjs%2F_esm5%2Finternal%2Foperators%2Fsingle.js;h=35de1270c5809c8fc23663cfde4df2af7d8de653;hb=3aba54c891969552833dbc350b3139e944e17a97;hp=0000000000000000000000000000000000000000;hpb=1def8ecce8e6f3aa32e6978d0ba7846a99b8de34;p=dotfiles%2F.git diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/rxjs/_esm5/internal/operators/single.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/rxjs/_esm5/internal/operators/single.js new file mode 100644 index 00000000..35de1270 --- /dev/null +++ b/.config/coc/extensions/node_modules/coc-prettier/node_modules/rxjs/_esm5/internal/operators/single.js @@ -0,0 +1,68 @@ +/** PURE_IMPORTS_START tslib,_Subscriber,_util_EmptyError PURE_IMPORTS_END */ +import * as tslib_1 from "tslib"; +import { Subscriber } from '../Subscriber'; +import { EmptyError } from '../util/EmptyError'; +export function single(predicate) { + return function (source) { return source.lift(new SingleOperator(predicate, source)); }; +} +var SingleOperator = /*@__PURE__*/ (function () { + function SingleOperator(predicate, source) { + this.predicate = predicate; + this.source = source; + } + SingleOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source)); + }; + return SingleOperator; +}()); +var SingleSubscriber = /*@__PURE__*/ (function (_super) { + tslib_1.__extends(SingleSubscriber, _super); + function SingleSubscriber(destination, predicate, source) { + var _this = _super.call(this, destination) || this; + _this.predicate = predicate; + _this.source = source; + _this.seenValue = false; + _this.index = 0; + return _this; + } + SingleSubscriber.prototype.applySingleValue = function (value) { + if (this.seenValue) { + this.destination.error('Sequence contains more than one element'); + } + else { + this.seenValue = true; + this.singleValue = value; + } + }; + SingleSubscriber.prototype._next = function (value) { + var index = this.index++; + if (this.predicate) { + this.tryNext(value, index); + } + else { + this.applySingleValue(value); + } + }; + SingleSubscriber.prototype.tryNext = function (value, index) { + try { + if (this.predicate(value, index, this.source)) { + this.applySingleValue(value); + } + } + catch (err) { + this.destination.error(err); + } + }; + SingleSubscriber.prototype._complete = function () { + var destination = this.destination; + if (this.index > 0) { + destination.next(this.seenValue ? this.singleValue : undefined); + destination.complete(); + } + else { + destination.error(new EmptyError); + } + }; + return SingleSubscriber; +}(Subscriber)); +//# sourceMappingURL=single.js.map