Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Sep 4, 2013
0 parents commit e438f1e
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
level-sets
==========

Buckets of unique keys for level.

`npm install level-sets`

Usage
=====

```
var sets = require('./')
, async = require('async')
, assert = require('assert')
;
var store = sets(__dirname+'/teststore', 'test')
var tests =
[ ['key', 'test1']
, ['key', 'test2']
, ['key', 'test1']
, ['key2', 'test1']
, ['key2', 'test1']
, ['key2', 'test1']
, ['key2', 'test4']
]
async.each(tests, function (k, cb) {
store.put(k[0], k[1], cb)
}, function (e) {
if (e) throw e
store.sum(function (e, total) {
if (e) throw e
assert.equal(total, 4)
store.sum(true, function (e, rows) {
if (e) throw e
assert.equal(rows[0].key, 'key')
assert.equal(rows[1].key, 'key2')
assert.equal(rows[0].total, 2)
assert.equal(rows[1].total, 2)
store.get('key', function (e, arr) {
assert.equal(arr.length, 2)
store.get('key2', function (e, arr) {
assert.equal(arr.length, 2)
})
})
})
})
})
```

0 comments on commit e438f1e

Please sign in to comment.