{"name":"hyperdb","version":"1.5.0","description":"Distributed scalable database","main":"index.js","dependencies":{"array-lru":"^1.1.1","codecs":"^1.2.0","hypercore":"^6.9.0","hypercore-protocol":"^6.4.0","inherits":"^2.0.3","mutexify":"^1.1.0","once":"^1.4.0","protocol-buffers":"^3.2.1","random-access-file":"^1.8.1","sodium-universal":"^1.4.0","thunky":"^1.0.2","to-buffer":"^1.1.0","unordered-array-remove":"^1.0.2","varint":"^5.0.0"},"devDependencies":{"random-access-memory":"^2.4.0","standard":"^10.0.3","tape":"^4.8.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/hyperdb.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/hyperdb/issues"},"homepage":"https://github.com/mafintosh/hyperdb#readme","gitHead":"dcf9f625abbfc3efc221ba7ef49f4ab74be5a686","_id":"hyperdb@1.5.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"integrity":"sha512-wMnyI1NXjL40Oi77yfn0L2IPJsvUe4g6eJPqo4Bo1UiPiNrd2yplbJyvysybg7mU5+5UbyUqyInY946gfSEi4Q==","shasum":"554f31079f8c7bd5cab6d14b018eb9ee16158697","tarball":"http://registry-npm.ywwl.com/hyperdb/download/hyperdb-1.5.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIERK0xeSHir1Aqux8mqj5jJliAsHVhqHp+3pgRNKwLEcAiBHvEB6OWZdr7HVNr6xZIDZLf3+fvaqMbjGLLsli8+IBg=="}],"size":13776,"noattachment":false,"key":"/hyperdb/-/hyperdb-1.5.0.tgz"},"maintainers":[{"email":"stephen.whitmore@gmail.com","name":"noffle"},{"email":"mathiasbuus@gmail.com","name":"mafintosh"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hyperdb-1.5.0.tgz_1511914456363_0.19567199982702732"},"directories":{},"readme":"# hyperdb\n\nDistributed scalable database.\n\n```\nnpm install hyperdb\n```\n\nRead [ARCHITECTURE.md](ARCHITECTURE.md) for details on how hyperdb works.\n\n## Usage\n\n``` js\nvar hyperdb = require('hyperdb')\n\nvar db = hyperdb('./my.db', {valueEncoding: 'utf-8'})\n\ndb.put('/hello', 'world', function (err) {\n  if (err) throw err\n  db.get('/hello', function (err, nodes) {\n    if (err) throw err\n    console.log('/hello --> ' + nodes[0].value)\n  })\n})\n```\n\n## API\n\n#### `var db = hyperdb(storage, [key], [options])`\n\nCreate a new hyperdb.\n\n`storage` can be a string or a function. If a string like the above example, the\n[random-access-file](https://github.com/mafintosh/random-access-file) storage\nmodule is used; the resulting folder with the data will be whatever `storage` is\nset to.\n\nIf `storage` is a function, it will be called with every filename hyperdb needs\nto operate on. There are many providers for the\n[abstract-random-access](https://github.com/juliangruber/abstract-random-access)\ninterface. e.g.\n\n```js\nvar ram = require('random-access-memory')\nvar feed = hyperdb(function (filename) {\n  // filename will be one of: data, bitfield, tree, signatures, key, secret_key\n  // the data file will contain all your data concattenated.\n\n  // just store all files in ram by returning a random-access-memory instance\n  return ram()\n})\n```\n\n`key` is a `Buffer` containing the local feed's public key. If you do not set\nthis the public key will be loaded from storage. If no key exists a new key pair\nwill be generated.\n\nOptions include:\n\n```js\n{\n  map: node => mappedNode, // map nodes before returning them\n  reduce: (a, b) => someNode, // reduce the nodes array before returning it\n  firstNode: false, // set to true to reduce the nodes array to the first node in it\n  valueEncoding: 'binary' // set the value encoding of the db\n}\n```\n\n#### `db.key`\n\nBuffer containing the public key identifying this hyperdb.\n\nPopulated after `ready` has been emitted. May be `null` before the event.\n\n#### `db.discoveryKey`\n\nBuffer containing a key derived from the db.key.\nIn contrast to `db.key` this key does not allow you to verify the data but can be used to announce or look for peers that are sharing the same hyperdb, without leaking the hyperdb key.\n\nPopulated after `ready` has been emitted. May be `null` before the event.\n\n#### `db.on('ready')`\n\nEmitted exactly once: when the db is fully ready and all static properties have\nbeen set. You do not need to wait for this when calling any async functions.\n\n#### `db.version(callback)`\n\nGet the current version identifier as a buffer for the db.\n\n#### `var checkout = db.checkout(version)`\n\nCheckout the db at an older version. The checkout is a DB instance as well.\nVersion should be a version identifier returned by the `db.version` api or an\narray of nodes returned from `db.heads`.\n\n#### `db.put(key, value, [callback])`\n\nInsert a new value. Will merge any previous values seen for this key.\n\n#### `db.get(key, callback)`\n\nLookup a string `key`. Returns a nodes array with the current values for this key.\nIf there is no current conflicts for this key the array will only contain a single node.\n\n#### `db.del(key, callback)`\n\nDelete a string `key`.\n\n#### `db.batch(batch, [callback])`\n\nInsert a batch of values efficiently, in a single atomic transaction. A batch should be an array of objects that look like this:\n\n``` js\n{\n  type: 'put',\n  key: someKey,\n  value: someValue\n}\n```\n\n`callback`'s parameters are `err, nodes`, where `nodes` is an array of the batched nodes.\n\n#### `db.local`\n\nYour local writable feed. You have to get an owner of the hyperdb to authorize you to have your\nwrites replicate. The first person to create the hyperdb is the first owner.\n\n#### `db.authorize(key, [callback])`\n\nAuthorize another peer to write to the hyperdb.\n\nTo get another peer to authorize you you'd usually do something like\n\n``` js\nmyDb.on('ready', function () {\n  console.log('You local key is ' + myDb.local.key.toString('hex'))\n  console.log('Tell an owner to authorize it')\n})\n```\n\n#### `db.authorized(key, [callback])`\n\nCheck whether a key is authorized to write to the database.\n\n```js\nmyDb.authorized(otherDb.local.key, function (err, auth) {\n  if (err) console.log('err', err)\n  else if (auth === true) console.log('authorized')\n  else console.log('not authorized')\n})\n```\n\n#### `watcher = db.watch(folderOrKey, onchange)`\n\nWatch a folder and get notified anytime a key inside this folder\nhas changed.\n\n```js\ndb.watch('foo/bar', function () {\n  console.log('folder has changed')\n})\n\n...\n\ndb.put('foo/bar/baz', 'hi') // triggers the above\n```\n\nYou can destroy the watcher by calling `watcher.destroy()`.\n\nThe watcher will emit `watching` when it starts watching and `change`\nwhen a change has been detected.\n\nIf a critical error occurs an error will be emitted on the watcher.\n\n#### `var stream = db.createReadStream(prefix[, options])`\n\nCreate a readable stream of nodes stored in the database.\nSet `prefix` to only iterate nodes prefixed with that folder.\n\nOptions include:\n\n```js\n{\n  recursive: true // visit all subfolders.\n                  // set to false to only visit the first node in each folder\n  reverse: true   // read the records in reverse order.\n  gt: false       // visit only strictly nodes that are > than the prefix\n}\n```\n\n#### `var stream = db.createWriteStream()`\n\nCreate a writable stream.\n\nWhere `stream.write(data)` accepts data as an object or an array of objects with the same form as `db.batch()`.\n\n#### `db.list(prefix[, options], callback)`\n\nSame as `createReadStream` but buffers the result to a list that is passed to the\ncallback.\n\n#### `var stream = db.createDiffStream(prefix[, checkout)`\n\nFind out about changes in key/value pairs between the version `checkout` and\ncurrent version prefixed by `prefix`.\n\n`stream` is a readable object stream that outputs modifications like\n\n```js\n{ left: nodes, right: nodes }\n```\n\n`left` are the nodes for a key found in the `db` and `right` are the nodes found in the `checkout`.\nIf no nodes exist in the `db` for the key `left` will be `null` and vice versa.\n\n#### `var stream = db.createHistoryStream([options])`\n\nReturns a readable stream of node objects covering all historic values since the beginning of time.\n\nNodes are emitted in topographic order, meaning if value `v2` was aware of value\n`v1` at its insertion time, `v1` must be emitted before `v2`.\n\nTo emit the nodes in reverse order pass `{reverse: true}` as an option.\n\n#### `var stream = db.createKeyHistoryStream(key)`\n\nReturns a readable stream of node objects covering all historic values for a specific key.\n\nResults are returned with the latest value first.\n\n#### `var stream = db.replicate([options])`\n\nCreate a replication stream. Options include:\n\n``` js\n{\n  live: false // set to true to keep replicating\n}\n```\n\n## License\n\nMIT\n","publish_time":1511914457314,"_cnpm_publish_time":1511914457314,"dist-tags":{"latest":"6.11.1","tmp":"4.22.3"}}