{"id":22292619,"url":"https://github.com/ericnorris/node-cdb","last_synced_at":"2025-07-28T23:33:35.510Z","repository":{"id":19848828,"uuid":"23110906","full_name":"ericnorris/node-cdb","owner":"ericnorris","description":"A cdb implementation for node.js","archived":false,"fork":false,"pushed_at":"2018-06-03T22:11:21.000Z","size":40,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-18T19:46:56.057Z","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":"select2/select2","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericnorris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-19T13:21:07.000Z","updated_at":"2024-02-11T20:15:47.000Z","dependencies_parsed_at":"2022-08-25T21:10:22.089Z","dependency_job_id":null,"html_url":"https://github.com/ericnorris/node-cdb","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fnode-cdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fnode-cdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fnode-cdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericnorris%2Fnode-cdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericnorris","download_url":"https://codeload.github.com/ericnorris/node-cdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227963331,"owners_count":17848092,"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-03T17:23:11.102Z","updated_at":"2024-12-03T17:23:11.832Z","avatar_url":"https://github.com/ericnorris.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-constant-db [![Build Status](https://travis-ci.org/ericnorris/node-cdb.svg?branch=master)](https://travis-ci.org/ericnorris/node-cdb)\nA [cdb](http://cr.yp.to/cdb.html) implementation in node.js, supporting both read and write capabilities.\n\n## Installation\n`npm install constant-db`\n\n## Changes from v1.0.0\n* Renamed `getRecord()` to `get()`\n* Renamed `putRecord()` to `put()`\n* Added `getNext()`\n* Dropped promise support\n* Completely rewritten! `get()` calls should be much faster.\n\n## Example\nWritable cdb:\n```javascript\nvar writable = require('constant-db').writable;\n\nvar writer = new writable('./cdbfile');\nwriter.open(function cdbOpened(err) {\n    writer.put('meow', 'hello world');\n    writer.close(function cdbClosed(err) {\n        console.log('hooray!');\n    });\n});\n```\n\nReadable cdb:\n```javascript\nvar readable = require('constant-db').readable;\n\nvar reader = new readable('./cdbfile');\nreader.open(function cdbOpened(err) {\n    reader.get('meow', function gotRecord(err, data) {\n        console.log(data); // results in 'hello world!'\n        \n        reader.close(function cdbClosed(err) {\n            console.log('awesome!');\n        });\n    });\n});\n```\n\n## Documentation\n### Readable cdb\nTo create a new readable instance:\n`new require('constant-db').readable(file);`\n\n`open(callback(err, cdb))`\n\nOpens the file for reading, and immediately caches the header table for the cdb (2048 bytes).\n\n`get(key, [offset], callback(err, data))`\n\nAttempts to find the specified key, and calls the callback with an error (if not found) or the data for that key (if found). If an offset is specified, the cdb will return data for the *nth* record matching that key.\n\n`getNext(callback(err, data))`\n\nContinues the previous `get()` call, finding the next record under the key `get()` was called with. This should be slightly faster than calling `get()` with an offset.\n\n`close(callback(err, cdb))`\n\nCloses the file. No more records can be read after closing.\n\n### Writable cdb\nTo create a new writable instance:\n`new require('constant-cdb').writable(file);`\n\n`open(callback(err, cdb))`\n\nOpens the file for writing. This will overwrite any file that currently exists, or create a new one if necessary.\n\n`put(key, data)`\n\nWrites a record to the cdb.\n\n`close(callback(err, cdb))`\n\nFinalizes the cdb and closes the file. Calling `close()` is necessary to write out the header and subtables required for the cdb!\n\n## Benchmark\n`node benchmarks/cdb-random-benchmark.js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Fnode-cdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericnorris%2Fnode-cdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericnorris%2Fnode-cdb/lists"}