You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
693 B
24 lines
693 B
4 years ago
|
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
|