Browse files

cart now works with new supermarket (with node-lazy interface)

  • Loading branch information...
1 parent 55c3e99 commit ad15838627097b630b02339848bec1f537e966b5 @pkrumins committed Oct 17, 2010
Showing with 9 additions and 11 deletions.
  1. +9 −11 lib/cart.js
View
20 lib/cart.js
@@ -16,11 +16,12 @@ function Cart(options) {
if (err) throw new Error(err);
self.db = db;
db.filter(
- function (key, item) {
- return item.lastAccess < Date.now() - options.maxAge;
- },
- function (key, item) {
- db.remove(key);
+ function (item) {
+ return item.value.lastAccess < Date.now() - options.maxAge;
+ }
+ ).forEach(
+ function (item) {
+ db.remove(item.key);
}
);
});
@@ -62,12 +63,9 @@ Cart.prototype.length = function (fn) {
Cart.prototype.clear = function (fn) {
this.db.forEach(
- function (err, key, value) {
- this.db.remove(key);
- },
- function () {
- if (fn) fn()
+ function (item) {
+ this.db.remove(item.key);
}
- );
+ ).on('end', function () { if (fn) fn() });
};

0 comments on commit ad15838

Please sign in to comment.