github-pages-deploy-action/node_modules/rxjs/_esm2015/internal/util/subscribeToIterable.js

24 lines
693 B
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
import { iterator as Symbol_iterator } from '../symbol/iterator';
export const subscribeToIterable = (iterable) => (subscriber) => {
const iterator = iterable[Symbol_iterator]();
do {
const item = iterator.next();
if (item.done) {
subscriber.complete();
break;
}
subscriber.next(item.value);
if (subscriber.closed) {
break;
}
} while (true);
if (typeof iterator.return === 'function') {
subscriber.add(() => {
if (iterator.return) {
iterator.return();
}
});
}
return subscriber;
};
//# sourceMappingURL=subscribeToIterable.js.map