Skip to content
Browse files

[dist doc] Added LICENSE. Updated package.json and README.md

  • Loading branch information...
1 parent a342272 commit 85dd5483a12c516e87b2b6f42c8985330e3ae676 @indexzero committed Mar 17, 2013
Showing with 123 additions and 7 deletions.
  1. +19 −0 LICENSE
  2. +97 −2 README.md
  3. +7 −5 package.json
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Bradley Meck, Maciej Malecki, Charlie Robbins
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
99 README.md
@@ -1,5 +1,100 @@
# changes
-### UNDER DEVELOPMENT. Not ready. SERIOUSLY.
+A consistent, fault tolerant CouchDB _changes listener with pre-fetch support.
-A consistent, fault tolerant CouchDB _changes listener with pre-fetch support
+## Usage
+
+``` js
+ var Changes = require('changes');
+
+ var changes = new Changes({
+ url: 'http://user:pass@127.0.0.1:5984/database',
+ timeout: {
+ max: 60000,
+ step: 5000
+ }
+ });
+
+ //
+ // Dump changes as they come in.
+ //
+ changes.on('change', function (doc) {
+ console.dir(doc);
+ });
+
+ //
+ // The callback will be called once a _changes
+ // connection has been established or with an
+ // error if the first connection fails.
+ //
+ changes.listen(function (err) {
+ if (err) {
+ console.log('Did not connect to _changes on first attempt');
+ console.dir(err);
+ changes.retry.enabled = false;
+ return process.exit(1);
+ }
+
+ console.log('Listening for _changes');
+ });
+```
+
+## Pre-fetching Views
+
+Often when you establish a connection to `_changes` you also want to know about the other documents in a view before the current `update_seq`. This is supported like this:
+
+```
+ var Changes = require('changes');
+
+ var changes = new Changes({
+ url: 'http://user:pass@127.0.0.1:5984/database',
+ views: {
+ 'important': {
+ path: '_design/Some/_view/name,
+ query: { include_docs: true }
+ }
+ },
+ timeout: {
+ max: 60000,
+ step: 5000
+ }
+ });
+
+ //
+ // All rows from a queries view will be emitted
+ // in the `views:<name>` event **before** the
+ // `_changes` listener starts.
+ //
+ changes.on('views:important', function (rows) {
+ //
+ // Dump any existing "important" rows.
+ //
+ console.dir(rows);
+ });
+
+ //
+ // Dump changes as they come in.
+ //
+ changes.on('change', function (doc) {
+ console.dir(doc);
+ });
+
+ //
+ // The callback will be called once a _changes
+ // connection has been established or with an
+ // error if the first connection fails.
+ //
+ changes.listen(function (err) {
+ if (err) {
+ console.log('Did not connect to _changes on first attempt');
+ console.dir(err);
+ changes.retry.enabled = false;
+ return process.exit(1);
+ }
+
+ console.log('Listening for _changes');
+ });
+```
+
+#### License: MIT
+#### Authors: [Bradley Meck](https://github.com/bmeck), [Maciej Malecki](https://github.com/mmalecki), [Charlie Robbins](https://github.com/indexzero)
View
12 package.json
@@ -10,20 +10,20 @@
],
"contributors": [
{
- "name": "Charlie Robbins",
- "email": "charlie@nodejitsu.com"
- },
- {
"name": "Bradley Meck",
"email": "bradley@nodejitsu.com"
},
{
"name": "Maciej Malecki",
"email": "maciej@nodejitsu.com"
+ },
+ {
+ "name": "Charlie Robbins",
+ "email": "charlie@nodejitsu.com"
}
],
"main": "./lib/changes.js",
- "homepage": "http://github.com/indexzero/follow",
+ "homepage": "http://github.com/indexzero/changes",
"repository": {
"type": "git",
"url": "git://github.com/indexzero/changes"
@@ -32,6 +32,8 @@
"node": "0.8.x | 0.6.x"
},
"dependencies": {
+ "async": "~0.2.6",
+ "qs": "~0.5.4",
"request": "~2.14.0"
}
}

0 comments on commit 85dd548

Please sign in to comment.
Something went wrong with that request. Please try again.