Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IterableIterator {
- constructor(obj){
- this.index = 0
- this.data = Object.keys(obj).map((key) => { return { [key]: obj[key] } })
- }
- next = () => {
- if(this.index < this.data.length){
- return { value: this.data[this.index++], done: false }
- } else {
- this.index = 0
- return { value: undefined, done: true }
- }
- }
- [Symbol.iterator] = () => {
- return { next: this.next }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement