{"id":15290246,"url":"https://github.com/npm/concurrent-couch-follower","last_synced_at":"2025-10-07T03:32:18.645Z","repository":{"id":57205189,"uuid":"44751120","full_name":"npm/concurrent-couch-follower","owner":"npm","description":"a couch follower wrapper that you can use to be sure you don't miss any documents even if you process them asynchronously.","archived":true,"fork":false,"pushed_at":"2021-06-04T03:25:31.000Z","size":12,"stargazers_count":31,"open_issues_count":6,"forks_count":7,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-01T16:06:33.850Z","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":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.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":"2015-10-22T14:34:25.000Z","updated_at":"2024-04-27T13:49:11.000Z","dependencies_parsed_at":"2022-09-18T01:32:28.502Z","dependency_job_id":null,"html_url":"https://github.com/npm/concurrent-couch-follower","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fconcurrent-couch-follower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fconcurrent-couch-follower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fconcurrent-couch-follower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fconcurrent-couch-follower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/concurrent-couch-follower/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586070,"owners_count":19014028,"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-09-30T16:06:36.227Z","updated_at":"2025-10-07T03:32:13.344Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# concurrent-couch-follower\na couch follower wrapper that you can use to be sure you don't miss any documents even if you process them asynchronously.\n\n```js\nvar changes = require('concurrent-couch-follower')\nvar someAction = require(.....)\n\nvar dataHandler = function(data, done) {\n    someAction(data, function() {\n      done()\n    })\n}\n\nvar configOptions = {\n  db: 'https://url.to.couchdb/registry/_changes',\n  include_docs:true,\n  sequence:'.sequence',\n  now:false,\n  concurrency:5\n}\n\nchanges(dataHandler, configOptions)\n```\n\nAPI\n---\n\n### changes(handler,options)\n\n- handler = function(change,done) \n is a function that is called for every document\n - change, the change from couchdb {seq:sequence,doc:the document,....}\n - done, you must call this function when you are done processing the document.\n\n- options\n  a config object as passed to `changes-stream` but including these additional properties.\n  - `db`, the connection string url pointing to the CouchDB registry to be followed.\n  - `sequence`, the name of the file to persist the sequence id, if this is a function this is passed as a persist function to concurrent-seq-file.\n  - `concurrency`, the maximum number of documents to process at a time.\n  - the `changes-stream` property `since` is populated by the value of the sequence file and cannot be set from outside except if `now` is set to `true`.\n  - `now`, if `true`, set the `changes-stream` property `since` to \"now\" (instead of 0) on the first start (before `.sequence` has been created)\n  - `since` only used, but is required, if you are using a custom backend to save the sequence ids. when you pass a function as sequence.\n\n-  stream = changes(handle,options)\n  - sream , return value is a readable object stream of `data` passed back with `done(err,data)`\n\n- stream.sequence()\n - returns current sequence id saved to disk. useful for logging.\n\n- WARNING! stream.end()\n - this calls destroy on the changes-stream and the through instead of properly ending them.\n    - this triggers a \"premature close\" error from `changes-stream` and is something that just has to be worked on. bind `error` or use `end-of-stream`\n\n\nmore examples\n-------------\n\nsave the sequence ids in a database.\n\n```js\nvar changes = require('concurrent-couch-follower')\nvar someAction = require(.....)\n\nvar dataHandler = function(data, done) {\n    someAction(data, function() {\n      done()\n    })\n}\n\nloadSequenceFromDB(function(err,sequence){\n  var configOptions = {\n    db: 'https://url.to.couchdb/registry/_changes',\n    include_docs:true,\n    sequence:function(seq,cb){\n      saveInDB(seq,cb)\n    },\n    since:sequence,\n    concurrency:5\n  }\n\n  changes(dataHandler, configOptions)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fconcurrent-couch-follower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fconcurrent-couch-follower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fconcurrent-couch-follower/lists"}