{"id":17398448,"url":"https://github.com/vweevers/reachdown","last_synced_at":"2025-04-30T05:22:20.358Z","repository":{"id":60775142,"uuid":"206986665","full_name":"vweevers/reachdown","owner":"vweevers","description":"Get the inner db of an (abstract-)level(up|down) onion.","archived":false,"fork":false,"pushed_at":"2020-05-25T04:13:12.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T01:58:22.066Z","etag":null,"topics":["abstract-leveldown","level","levelup","nodejs","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-07T15:21:33.000Z","updated_at":"2020-05-19T03:26:37.000Z","dependencies_parsed_at":"2022-10-04T16:35:51.188Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/reachdown","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Freachdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Freachdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Freachdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Freachdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/reachdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645987,"owners_count":21620847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-leveldown","level","levelup","nodejs","npm-package"],"created_at":"2024-10-16T14:56:37.608Z","updated_at":"2025-04-30T05:22:20.229Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reachdown\n\n\u003e **Get the inner db of an `(abstract-)level(up|down)` onion.**  \n\u003e 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 \u0026\u0026 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` (\u003e= 0.0.2 only if db is open, otherwise \u003e= 2.0.0)\n- `encoding-down` (\u003e= 1)\n- `deferred-leveldown` (\u003e= 0.3.0 only if db is open, otherwise \u003e= 2.0.0)\n- `subleveldown` (\u003e= 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Freachdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Freachdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Freachdown/lists"}