Skip to content

Instantly share code, notes, and snippets.

@Alamin02
Last active June 28, 2020 18:41
Show Gist options
  • Save Alamin02/47b7ebeedb97a086482a0f4d93da2d59 to your computer and use it in GitHub Desktop.
Save Alamin02/47b7ebeedb97a086482a0f4d93da2d59 to your computer and use it in GitHub Desktop.
const content = require('./dummy.json');
function* makeUrlIterator(content) {
const { groups } = content;
for (const group of groups) {
const { data } = group;
for (const entry of data) {
yield entry;
}
}
}
const urlIterator = makeUrlIterator(content);
console.log(urlIterator.next().value);
// Outputs the first value
console.log(urlIterator.next().value);
// Outputs the second value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment