Skip to content

Commit 919ba4e

Browse files
committed
Changes Singleton createCb and returnCb to expect err as first argument
1 parent ded58c5 commit 919ba4e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Singleton.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ exports.get = function (key, opts, createCb, returnCb) {
2020
} else if (map[key].t !== null && map[key].t <= Date.now()) {
2121
delete map[key];
2222
} else {
23-
return returnCb(map[key].o);
23+
return returnCb(null, map[key].o);
2424
}
2525
}
2626

27-
createCb(function (value) {
27+
createCb(function (err, value) {
28+
if (err) return returnCb(err);
29+
2830
map[key] = { // object , timeout
2931
o : value,
3032
t : (opts && typeof opts.cache === "number" ? Date.now() + (opts.cache * 1000) : null)
3133
};
32-
return returnCb(map[key].o);
34+
return returnCb(null, map[key].o);
3335
});
3436
};

0 commit comments

Comments
 (0)