Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "babble", | ||
"version": "0.0.1", | ||
"description": "Conversations over pubsub. Tell, ask, reply", | ||
"version": "0.1.0", | ||
"description": "Distributed conversations over pubsub. Tell, ask, reply", | ||
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)", | ||
@@ -11,4 +11,9 @@ "keywords": [ | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/josdejong/babble.git" | ||
}, | ||
"dependencies": { | ||
"pubsub-js": "~1.4.0" | ||
"pubsub-js": "~1.4.0", | ||
"node-uuid": "~1.4.1" | ||
}, | ||
@@ -15,0 +20,0 @@ "devDependencies": { |
@@ -1,4 +0,83 @@ | ||
babble | ||
====== | ||
# Babble | ||
Conversations over pubsub. Tell, ask, reply. | ||
Distributed conversations over pubsub. Tell, ask, reply. | ||
Babble makes it easy to create dynamic communication flows between peers. | ||
## Usage | ||
Install babble via npm: | ||
npm install babble | ||
Example usage: | ||
### Simple request/response | ||
```js | ||
var babble = require('../index'); | ||
var emma = babble.babbler('emma'), | ||
jack = babble.babbler('jack'); | ||
emma.listen('ask age', function () { | ||
this.reply(25); | ||
}); | ||
emma.listen('tell age', function (age) { | ||
console.log(this.from + ' is ' + age + ' years old'); | ||
}); | ||
jack.tell('emma', 'tell age', 27); | ||
jack.ask('emma', 'ask age', function (age) { | ||
console.log(this.from + ' is ' + age + ' years old'); | ||
}); | ||
``` | ||
### Conversation with multiple replies | ||
```js | ||
var babble = require('babble'); | ||
var emma = babble.babbler('emma'), | ||
jack = babble.babbler('jack'); | ||
emma.listen('How are you doing?', function () { | ||
if (Math.random() > 0.2) { | ||
this.reply('great'); | ||
} | ||
else { | ||
this.reply('not good', function (response) { | ||
if (response == 'Why?') { | ||
this.reply('I got my nose smashed in against the wall'); | ||
} | ||
}); | ||
} | ||
}); | ||
jack.ask('emma', 'How are you doing?', function (response) { | ||
if (response == 'mwa') { | ||
if (Math.random() > 0.5) { | ||
this.reply('Why?', function (response) { | ||
// etc... | ||
}); | ||
} | ||
else { | ||
this.reply('Come, give me a hug'); | ||
} | ||
} | ||
}); | ||
``` | ||
## Test | ||
To execute tests for the library, install the project dependencies once: | ||
npm install | ||
Then, the tests can be executed: | ||
npm test |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
20990
11
259
84
0
2
+ Addednode-uuid@~1.4.1
+ Addednode-uuid@1.4.8(transitive)