{"id":20182152,"url":"https://github.com/nichoth/level-track","last_synced_at":"2025-03-03T06:13:19.265Z","repository":{"id":29912812,"uuid":"33458652","full_name":"nichoth/level-track","owner":"nichoth","description":"receive updates from a set of keys and ranges in leveldb","archived":false,"fork":false,"pushed_at":"2015-04-06T04:33:04.000Z","size":95,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T17:26:40.301Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"substack/level-track","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nichoth.png","metadata":{"files":{"readme":"readme.markdown","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":"2015-04-05T23:23:11.000Z","updated_at":"2022-09-17T20:06:02.000Z","dependencies_parsed_at":"2022-11-21T15:45:16.138Z","dependency_job_id":null,"html_url":"https://github.com/nichoth/level-track","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/nichoth%2Flevel-track","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Flevel-track/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Flevel-track/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Flevel-track/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nichoth","download_url":"https://codeload.github.com/nichoth/level-track/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241616679,"owners_count":19991543,"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-11-14T02:37:46.818Z","updated_at":"2025-03-03T06:13:19.237Z","avatar_url":"https://github.com/nichoth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# level-track\n\nkeep track of all the active queries from a request to route live updates\n\n[![build status](https://secure.travis-ci.org/substack/level-track.png)](http://travis-ci.org/substack/level-track)\n\n# example\n\nIn this example we'll subscribe to the range of keys `\"f\"` through `\"p\"` and the\nsingular key `\"c\"`. The database is then populated with random keys and values\nto show that only keys `\"f\"` through `\"p\"` inclusive and `\"c\"` are captured.\n\n``` js\nvar sub = require('level-sublevel');\nvar db = sub(require('level')('test.db'));\nvar tracker = require('level-track')(db);\nvar through = require('through');\n\nvar t = tracker();\nt.pipe(process.stdout);\n\nt.write('\"c\"\\n');\nt.write('[\"f\",\"p\"]\\n');\n\nsetInterval(function () {\n    var l = Math.floor(Math.random() * 2) + 1;\n    var key = '';\n    for (var i = 0; i \u003c l; i++) {\n        key += String.fromCharCode(Math.random() * 26 + 97);\n    }\n    db.put(key, { n: Math.floor(Math.random() * 100) });\n}, 250);\n```\n\noutput:\n\n```\n{\"type\":\"put\",\"key\":\"jr\",\"value\":{\"n\":92}}\n{\"type\":\"put\",\"key\":\"ft\",\"value\":{\"n\":41}}\n{\"type\":\"put\",\"key\":\"g\",\"value\":{\"n\":32}}\n{\"type\":\"put\",\"key\":\"c\",\"value\":{\"n\":55}}\n{\"type\":\"put\",\"key\":\"kh\",\"value\":{\"n\":60}}\n{\"type\":\"put\",\"key\":\"m\",\"value\":{\"n\":43}}\n{\"type\":\"put\",\"key\":\"p\",\"value\":{\"n\":40}}\n{\"type\":\"put\",\"key\":\"nc\",\"value\":{\"n\":64}}\n{\"type\":\"put\",\"key\":\"l\",\"value\":{\"n\":70}}\n{\"type\":\"put\",\"key\":\"fy\",\"value\":{\"n\":41}}\n{\"type\":\"put\",\"key\":\"kp\",\"value\":{\"n\":98}}\n{\"type\":\"put\",\"key\":\"mk\",\"value\":{\"n\":48}}\n{\"type\":\"put\",\"key\":\"h\",\"value\":{\"n\":27}}\n^C\n```\n\n# protocol\n\nThe tracking protocol is newline-delimited json.\nEach line should match one of these formats:\n\n## \"key\"\n\nReceive updates from a single key.\n\n## [\"startkey\",\"endkey\"]\n\nReceive updates from the range `\"startkey\"` through `\"endkey\"`, inclusive.\n\n## [\"startkey\",\"endkey\",\"sincekey\"]\n\nReceive updates from the range `\"startkey\"` through `\"endkey\"`, inclusive and\npopulate the result stream with data from the exclusive `\"sincekey\"` through\n`\"endkey\"`.\n\nThis form is useful so that no updates slip past due to delays from rendering\nthe initial content and establishing a live connection.\n\n# methods\n\n``` js\nvar tracker = require('level-track')\n```\n\n## var t = tracker(opts)\n\nReturn a duplex stream that expects \ninput of the form documented in the protocol section and produces output of the\nform:\n\n``` json\n{\"type\":\"put\",\"key\":\"h\",\"value\":{\"n\":27}}\n```\n\nwhich is the same format that `db.hooks` and `db.batch()` use.\n\nWhen `opts.objectMode` is true, output is written as objects. Otherwise, output\nis written as newline-delimited lines of json.\n\nYou may also specify an optional `opts.keyMap(key)` function to pre-transform\nkeys. Return the value you want to use for the key.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install level-tracker\n```\n\n# license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Flevel-track","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnichoth%2Flevel-track","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Flevel-track/lists"}