Server IP : 150.95.80.236 / Your IP : 18.226.181.14 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/api-uat.pcu.in.th/node_modules/rxjs/dist/esm5/internal/operators/ |
Upload File : |
import { Observable } from '../Observable'; import { innerFrom } from '../observable/innerFrom'; import { Subject } from '../Subject'; import { operate } from '../util/lift'; import { createOperatorSubscriber, OperatorSubscriber } from './OperatorSubscriber'; export function groupBy(keySelector, elementOrOptions, duration, connector) { return operate(function (source, subscriber) { var element; if (!elementOrOptions || typeof elementOrOptions === 'function') { element = elementOrOptions; } else { (duration = elementOrOptions.duration, element = elementOrOptions.element, connector = elementOrOptions.connector); } var groups = new Map(); var notify = function (cb) { groups.forEach(cb); cb(subscriber); }; var handleError = function (err) { return notify(function (consumer) { return consumer.error(err); }); }; var activeGroups = 0; var teardownAttempted = false; var groupBySourceSubscriber = new OperatorSubscriber(subscriber, function (value) { try { var key_1 = keySelector(value); var group_1 = groups.get(key_1); if (!group_1) { groups.set(key_1, (group_1 = connector ? connector() : new Subject())); var grouped = createGroupedObservable(key_1, group_1); subscriber.next(grouped); if (duration) { var durationSubscriber_1 = createOperatorSubscriber(group_1, function () { group_1.complete(); durationSubscriber_1 === null || durationSubscriber_1 === void 0 ? void 0 : durationSubscriber_1.unsubscribe(); }, undefined, undefined, function () { return groups.delete(key_1); }); groupBySourceSubscriber.add(innerFrom(duration(grouped)).subscribe(durationSubscriber_1)); } } group_1.next(element ? element(value) : value); } catch (err) { handleError(err); } }, function () { return notify(function (consumer) { return consumer.complete(); }); }, handleError, function () { return groups.clear(); }, function () { teardownAttempted = true; return activeGroups === 0; }); source.subscribe(groupBySourceSubscriber); function createGroupedObservable(key, groupSubject) { var result = new Observable(function (groupSubscriber) { activeGroups++; var innerSub = groupSubject.subscribe(groupSubscriber); return function () { innerSub.unsubscribe(); --activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe(); }; }); result.key = key; return result; } }); } //# sourceMappingURL=groupBy.js.map