Skip to content

Commit

Permalink
Close #22 PR: Add clear function.
Browse files Browse the repository at this point in the history
  • Loading branch information
icyflame authored and sindresorhus committed Jun 9, 2015
1 parent 561e689 commit 9539517
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -86,4 +86,8 @@ Configstore.prototype.del = function (key) {
this.all = config;
};

Configstore.prototype.clear = function () {
this.all = {};
}

module.exports = Configstore;
4 changes: 4 additions & 0 deletions readme.md
Expand Up @@ -38,6 +38,10 @@ Get an item.

Delete an item.

### .clear()

Delete all items.

### .all

Get all items as an object or replace the current config with an object:
Expand Down
7 changes: 7 additions & 0 deletions test.js
Expand Up @@ -21,6 +21,13 @@ it('.del()', function () {
assert.notEqual(this.conf.get('foo'), 'bar');
});

it('.clear()', function(){
this.conf.set('foo', 'bar');
this.conf.set('foo1', 'bar1');
this.conf.clear();
assert.equal(this.conf.size, 0);
});

it('.all', function () {
this.conf.set('foo', 'bar');
assert.equal(this.conf.all.foo, 'bar');
Expand Down

0 comments on commit 9539517

Please sign in to comment.