{"_id":"reachdown","_rev":"239249","name":"reachdown","description":"Get the inner db of an (abstract-)level(up|down) onion","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"vweevers","email":""}],"time":{"modified":"2023-03-24T16:53:13.000Z","created":"2019-09-07T17:27:00.318Z","1.1.0":"2020-04-04T09:49:07.661Z","1.0.0":"2019-09-07T17:27:00.318Z"},"users":{},"author":{"name":"Vincent Weevers"},"repository":{"type":"git","url":"git+https://github.com/vweevers/reachdown.git"},"versions":{"1.1.0":{"name":"reachdown","version":"1.1.0","description":"Get the inner db of an (abstract-)level(up|down) onion","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && hallmark && node test.js","hallmark":"hallmark --fix"},"dependencies":{},"devDependencies":{"hallmark":"^2.0.0","level-mem":"^5.0.0","standard":"^14.1.0","subleveldown":"^4.1.1","tape":"^4.11.0"},"keywords":["abstract-leveldown","level","levelup"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/reachdown.git"},"bugs":{"url":"https://github.com/vweevers/reachdown/issues"},"homepage":"https://github.com/vweevers/reachdown","gitHead":"afe49b643d559ffa017101db5b8d73c0a1666a87","_id":"reachdown@1.1.0","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"name":"vweevers","email":""}],"dist":{"shasum":"c3b85b459dbd0fe2c79782233a0a38e66a9b5454","size":2795,"noattachment":false,"key":"/reachdown/-/reachdown-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/reachdown/download/reachdown-1.1.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reachdown_1.1.0_1585993747533_0.00850081541964709"},"_hasShrinkwrap":false,"publish_time":1585993747661,"_cnpm_publish_time":1585993747661,"_cnpmcore_publish_time":"2021-12-17T01:22:09.031Z"},"1.0.0":{"name":"reachdown","version":"1.0.0","description":"Get the inner db of an (abstract-)level(up|down) onion","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && node test.js"},"dependencies":{},"devDependencies":{"level-mem":"^5.0.0","standard":"^14.1.0","subleveldown":"^4.1.1","tape":"^4.11.0"},"keywords":["abstract-leveldown","level","levelup"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/reachdown.git"},"bugs":{"url":"https://github.com/vweevers/reachdown/issues"},"homepage":"https://github.com/vweevers/reachdown","gitHead":"dea6326d6d8e1771e3cd25257d481654253094f5","_id":"reachdown@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"name":"vweevers","email":""}],"dist":{"shasum":"c63715190c9a0dd108bea3610bf9690ad0983edb","size":2598,"noattachment":false,"key":"/reachdown/-/reachdown-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/reachdown/download/reachdown-1.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reachdown_1.0.0_1567877220172_0.7486319189561244"},"_hasShrinkwrap":false,"publish_time":1567877220318,"_cnpm_publish_time":1567877220318,"_cnpmcore_publish_time":"2021-12-17T01:22:09.267Z"}},"readme":"# reachdown\n\n> **Get the inner db of an `(abstract-)level(up|down)` onion.**  \n> Useful for modules like `subleveldown` to peel off redundant layers.\n\n[![npm status](http://img.shields.io/npm/v/reachdown.svg)](https://www.npmjs.org/package/reachdown)\n[![node](https://img.shields.io/node/v/reachdown.svg)](https://www.npmjs.org/package/reachdown)\n[![Travis build status](https://img.shields.io/travis/vweevers/reachdown.svg?label=travis)](http://travis-ci.org/vweevers/reachdown)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Example\n\n```js\nconst reachdown = require('reachdown')\nconst db = require('level')('example')\n```\n\nGet the innermost `db`, which in this case is a `leveldown` instance in node or `level-js` in browsers:\n\n```js\nconst down = reachdown(db)\n```\n\nGet a specific layer by [type](#supported-types):\n\n```js\nconst enc = reachdown(db, 'encoding-down')\nconst down = reachdown(enc)\nconst levelup = reachdown(db, 'levelup') // levelup === db\n```\n\nUse a visitor function:\n\n```js\nconst down = reachdown(db, function (db, type) {\n  return db.someProperty && type !== 'levelup'\n})\n```\n\n## API\n\n### `db = reachdown(db[, visit][, strict = false])`\n\nThe `db` argument is required and must be a recent-ish `levelup`, `abstract-leveldown` or `subleveldown` instance. The `visit` argument can be:\n\n- A string, to find the first `db` with a matching type\n- A function, to find the first `db` for which `visit` returns a truthy value\n- Omitted or falsy, to find the innermost `db`.\n\nIf `visit` is non-falsy and no matching `db` is found, `reachdown` returns `null` unless `strict` is `false` in which case it returns the innermost `db`.\n\n### `bool = reachdown.is(db, visit)`\n\nUtility to determine the type of `db` without reaching down. The `visit` argument is the same as above, i.e. a string or a function. Example:\n\n```js\nif (reachdown.is(db, 'levelup')) {\n  // ..\n}\n```\n\nWhich is the same as the following, except that `reachdown.is(..)` also works on older versions that don't have a `type` property:\n\n```js\nif (db.type === 'levelup') {\n  // ..\n}\n```\n\n## Supported Types\n\n- `levelup` (>= 0.0.2 only if db is open, otherwise >= 2.0.0)\n- `encoding-down` (>= 1)\n- `deferred-leveldown` (>= 0.3.0 only if db is open, otherwise >= 2.0.0)\n- `subleveldown` (>= 4)\n- `multileveldown` (TBD)\n- Yours?\n\nImplementations of `abstract-leveldown` can declare a type like so:\n\n```js\nMyLeveldown.prototype.type = 'my-leveldown'\n```\n\nSo that consumers can find that layer:\n\n```js\nvar down = MyLeveldown()\nvar db = levelup(down)\n\nreachdown(db, 'my-leveldown') === down\n```\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install reachdown\n```\n\n## License\n\n[MIT](LICENSE.md) © 2019-present Vincent Weevers\n","_attachments":{},"homepage":"https://github.com/vweevers/reachdown","bugs":{"url":"https://github.com/vweevers/reachdown/issues"},"license":"MIT"}