Comparing version 0.0.4 to 0.0.5
@@ -612,3 +612,3 @@ const codecs = require('codecs') | ||
async function setKeyToNearestLeaf (node, index, stack) { | ||
const [left, right] = await Promise.all([node.getChildNode(index), node.getChildNode(index + 1)]) | ||
let [left, right] = await Promise.all([node.getChildNode(index), node.getChildNode(index + 1)]) | ||
const [ls, rs] = await Promise.all([leafSize(left, false), leafSize(right, true)]) | ||
@@ -615,0 +615,0 @@ |
@@ -82,2 +82,3 @@ class SubTree { | ||
const child = await top.node.getChildNode(n) | ||
top.node.children[n] = null // unlink to save memory | ||
this.stack.push(new SubTree(child, top)) | ||
@@ -141,3 +142,2 @@ | ||
} | ||
} | ||
@@ -144,0 +144,0 @@ |
{ | ||
"name": "hyperbee", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "An append-only Btree running on a Hypercore.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
121
README.md
@@ -46,1 +46,122 @@ # Hyperbee 🐝 | ||
feed is downloaded to satisfy you queries. | ||
## API | ||
#### `const db = new Hyperbee(feed, [options])` | ||
Make a new Hyperbee instance. `feed` should be a [Hypercore](https://github.com/hypercore-protocol/hypercore). | ||
Options include: | ||
``` | ||
{ | ||
keyEncoding: 'utf-8' | 'binary' | 'ascii', // or some abstract encoding | ||
valueEncoding: <same as above> | ||
} | ||
``` | ||
Note that currently read/diff streams sort based on the *encoded* value of the keys. | ||
#### `await db.put(key, [value])` | ||
Insert a new key. Value can be optional. If you are inserting a series of data atomically, | ||
or you just have a batch of inserts/deletions available using a batch can be much faster | ||
than simply using a series of puts/dels on the db. | ||
#### `{ seq, key, value } = await db.get(key)` | ||
Get a key, value. If the key does not exist, `null` is returned. | ||
`seq` is the hypercore version at which this key was inserted. | ||
#### `await db.del(key)` | ||
Delete a key | ||
#### `batch = db.batch()` | ||
Make a new batch. | ||
#### `await batch.put(key, [value])` | ||
Insert a key into a batch. | ||
#### `{ seq, key, value } = await batch.get(key)` | ||
Get a key, value out of a batch. | ||
#### `await batch.del(key)` | ||
Delete a key into the batch. | ||
#### `await batch.flush()` | ||
Commit the batch to the database. | ||
#### `stream = db.createReadStream([options])` | ||
Make a read stream. All entries in the stream are similar to the ones returned from .get and the | ||
sort order is based on the binary value of the keys. | ||
Options include: | ||
``` js | ||
{ | ||
gt: 'only return keys > than this', | ||
gte: 'only return keys >= than this', | ||
lt: 'only return keys < than this', | ||
lte: 'only return keys <= than this', | ||
reverse: false // set to true to get them in reverse order, | ||
limit: -1 // set to the max number of entries you want | ||
} | ||
``` | ||
#### `const { seq, key, value } = await db.peek([options])` | ||
Similar to doing a read stream and returning the first value, but a bit faster than that. | ||
#### `stream = db.createHistoryStream([options])` | ||
Create a stream of all entries ever inserted or deleted from the db. | ||
Options include: | ||
``` js | ||
{ | ||
reverse: false, // if true get from the newest to the oldest | ||
since: seq // start with this seq | ||
} | ||
```` | ||
#### `stream = db.createDiffStream(otherVersion)` | ||
Efficiently create a stream of the shallow changes between two versions of the db. | ||
Each entry is sorted by key and looks like this: | ||
``` js | ||
{ | ||
left: <the entry in the db>, | ||
right: <the entry in the other version> | ||
} | ||
``` | ||
If an entry exists in db but not in the other version, then `left` is set | ||
and `right` will be null, and vice versa. | ||
If the entries are causally equal (i.e. the have the same seq), they are not | ||
returned, only the diff. | ||
#### `dbCheckout = db.checkout(version)` | ||
Get a readonly db checkout of a previous version. | ||
#### `dbCheckout = db.snapshot()` | ||
Shorthand for getting a checkout for the current version. | ||
#### `db.version` | ||
Current version. | ||
#### `await db.ready()` | ||
Makes sure internal state is loaded. Call this once before checking the version if you haven't called any of the other APIs. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61896
1806
167