Skip to content

Instantly share code, notes, and snippets.

@dagda1
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagda1/9340726 to your computer and use it in GitHub Desktop.
Save dagda1/9340726 to your computer and use it in GitHub Desktop.
function BulkLoader(){
this.users = [];
this.companies = [];
this.contacts = [];
};
BulkLoader.prototype.iterator = function * () {
this.users = yield [{name: 'bob', email: 'bob@hotmail.com'}];
this.contacts = yield [{name: 'brian', email: 'brian@hotmail.com'}];
this.companies = yield [{name: 'company', email: 'company@hotmail.com'}];
return this;
};
var iterator = new BulkLoader().iterator()
var users = iterator.next();
var contacts = iterator.next(users.value);
var companies = iterator.next(contacts.value);
var result = iterator.next(companies.value).value;
console.log(result.users);
console.log(result.contacts);
console.log(result.companies);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment