Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babble

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babble

Dynamic communication flows between message based actors.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
960
increased by7900%
Maintainers
1
Weekly downloads
 
Created
Source

Babble

Dynamic communication flows between message based actors.

Usage

Install babble via npm:

npm install babble

Example usage:

Simple questions and notifications

var babble = require('../index'),
    babbler = babble.babbler,
    reply = babble.reply,
    run = babble.run;

var emma = babbler('emma'),
    jack = babbler('jack');

emma.listen('ask age', reply(function () {
  return 25;
}));

emma.listen('tell age', run(function (age) {
  console.log(this.from + ' is ' +  age + ' years old');
}));

jack.tell('emma', 'tell age', 27);

jack.ask('emma', 'ask age', run(function (age) {
  console.log(this.from + ' is ' + age + ' years old');
}));

Conversations with multiple messages

var babble = require('babble'),
    babbler = babble.babbler,
    reply = babble.reply,
    run = babble.run,
    decide = babble.decide;

var emma = babbler('emma'),
    jack = babbler('jack');

emma.listen('How are you doing?', decide(function (response) {
    if (Math.random() > 0.2) {
      return reply(function () {
        return 'great';
      });
    }
    else {
      return reply(function () {
        return 'not good';
      }, decide(function (response) {
        if (response == 'Why?') {
          return reply(function () {
            return 'I got my nose smashed in against the wall';
          });
        }
        else if (response == 'I don\'t care') {
          return reply(function () {
            return 'Shut up!';
          })
        }
      }));
    }
  })
);

jack.ask('emma', 'How are you doing?', decide(function (response) {
  if (response == 'mwa') {
    return reply(function () {
      return 'Why?';
    }, run(function (response) {
      console.log(response);
    });
  }
}));

API

TODO: describe API

Test

To execute tests for the library, install the project dependencies once:

npm install

Then, the tests can be executed:

npm test

Keywords

FAQs

Package last updated on 31 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc