Skip to content

Instantly share code, notes, and snippets.

@lifecoder
Created May 6, 2011 22:15
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 lifecoder/959896 to your computer and use it in GitHub Desktop.
Save lifecoder/959896 to your computer and use it in GitHub Desktop.
Named nested functions after return
CategoryRepository.prototype.findAll = function(callback) {
return this.db.collection('categories', onCollectionReady);
function onCollectionReady(error, collection) {
if (error) return callback(error);
collection.find(onCursorReady);
}
function onCursorReady(error, cursor) {
console.log('onCursorReady');
if (error) return callback(error, null);
cursor.toArray(callback);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment