@obsidize/rx-map
Version:
ES6 Map with rxjs extensions for change detection
21 lines (20 loc) • 500 B
JavaScript
/**
* Utility for masking RxMap iterators, so that
* the underlying map values cannot be mutated while using them.
*/
export class ProxyIterableIterator {
constructor(source, transform) {
this.source = source;
this.transform = transform;
}
[Symbol.iterator]() {
return this;
}
next() {
const { value, done } = this.source.next();
return {
value: this.transform(value),
done
};
}
}