Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating storage.get to return all the data if no key is supplied.

  • Loading branch information...
commit 2ae796b41574db9bd7716e36f6162c78f813f398 1 parent 6b373ea
@vesln authored
Showing with 12 additions and 2 deletions.
  1. +2 −1  lib/storage.js
  2. +10 −1 test/storage.test.js
View
3  lib/storage.js
@@ -37,7 +37,8 @@ storage.set = function(key, value, cb) {
* @param {Function} Callback.
*/
storage.get = function(key, cb) {
- cb(this.data[key] || null);
+ if (arguments.length === 2) return cb(this.data[key] || null);
+ key(this.data);
};
/**
View
11 test/storage.test.js
@@ -57,7 +57,16 @@ describe('storage', function() {
done();
})
});
- });
+ });
+
+ it('should return all the stored data when no key is passed', function(done) {
+ storage.set('foo', 'bar', function() {
+ storage.get(function(val) {
+ val.should.eql({foo: 'bar'});
+ done();
+ })
+ });
+ });
});
describe('.del()', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.