{"id":22609023,"url":"https://github.com/bitfinexcom/hypercore-bisect","last_synced_at":"2025-04-11T06:19:33.632Z","repository":{"id":141634155,"uuid":"157417427","full_name":"bitfinexcom/hypercore-bisect","owner":"bitfinexcom","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-05T18:12:57.000Z","size":5,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T04:16:34.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-13T17:12:47.000Z","updated_at":"2022-12-28T19:38:33.000Z","dependencies_parsed_at":"2023-03-13T10:30:27.259Z","dependency_job_id":null,"html_url":"https://github.com/bitfinexcom/hypercore-bisect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fhypercore-bisect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fhypercore-bisect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fhypercore-bisect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fhypercore-bisect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/hypercore-bisect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351861,"owners_count":21089353,"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":[],"created_at":"2024-12-08T15:10:38.776Z","updated_at":"2025-04-11T06:19:33.624Z","avatar_url":"https://github.com/bitfinexcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hypercore-bisect\n\nLookup a data entry in a sequential hypercore by bisecting it.\n\n**Example:**\n\n```js\nconst hc = hypercore(ram, { valueEncoding: 'json' })\n\nhc.append([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], () =\u003e {\n  bisect(hc, 2, (err, seq, entry) =\u003e {\n    if (err) return console.error('ouch', err)\n\n    console.log(seq, entry) // 1, 2\n  })\n})\n```\n\nGet the closest entry if nothing was found, useful for timeframes:\n\n```js\n  const hc = hypercore(ram, { valueEncoding: 'json' })\n\n  hc.append([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], () =\u003e {\n    bisect(hc, 11, { returnClosest: true }, (err, seq, entry) =\u003e {\n      if (err) return console.error('ouch', err)\n\n      console.log(seq, entry) // 9, 10\n    })\n  })\n```\n\n## API\n\n### bisect(feed, compare, [opts], cb)\n\n  - `feed \u003cHypercore\u003e` a hypercore feed\n  - `compare \u003cfunction|Number|String|Boolean|Buffer\u003e` item to search for, or custom compare function\n  - `opts \u003cObject\u003e (optional)`\n    - `returnClosest` if nothing is found, return closest match\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fhypercore-bisect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fhypercore-bisect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fhypercore-bisect/lists"}