Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor findAndLoad a tiny bit

  • Loading branch information...
commit 5a86ba1fbc95144c5c6d14d06b3abaced86dd453 1 parent b853a28
@maritz authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 lib/retrieve.js
View
20 lib/retrieve.js
@@ -76,14 +76,18 @@ exports.load = function (id, callback) {
exports.findAndLoad = function findAndLoad(searches, callback) {
var self = this;
this.find(searches, function (err, ids) {
- if (err) callback(err, ids);
- if (ids.length == 0) callback("not found", ids);
- if (ids.length > 0) {
- async.map(ids, function (id, done) {
- self.load(id, function (err, props) {
- done(err, this);
- });
- }, callback);
+ if (err) {
+ callback(err, ids);
+ } else if (ids.length === 0) {
+ callback("not found", ids);
+ } else {
+ if (ids.length > 0) {
+ async.map(ids, function (id, done) {
+ self.load(id, function (err) {
+ done(err, self);
+ });
+ }, callback);
+ }
}
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.