Socket
Socket
Sign inDemoInstall

behavioral

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    behavioral

Behavioral Programming for JavaScript


Version published
Weekly downloads
7
increased by75%
Maintainers
1
Install size
7.81 kB
Created
Weekly downloads
 

Readme

Source
yarn add behavioral
import BProgram from 'behavioral';

const bp = new BProgram();
let priority = 0;

bp.addBThread('Add hot water 3 times', ++priority, function*() {
  yield {
    request: 'HOT'
  };
  yield {
    request: 'HOT'
  };
  yield {
    request: 'HOT'
  };
});

bp.addBThread('Add cold water 3 times', ++priority, function*() {
  yield {
    request: 'COLD'
  };
  yield {
    request: 'COLD'
  };
  yield {
    request: 'COLD'
  };
});

bp.addBThread('Interleave', ++priority, function*() {
  while (true) {
    yield {
      wait: 'HOT',
      block: 'COLD'
    };
    yield {
      wait: 'COLD',
      block: 'HOT'
    };
  }
});

bp.addBThread('console.log', ++priority, function*() {
  while (true) {
    yield {
      wait: () => true
    };
    console.log(this.lastEvent());
  }
});

bp.run();

FAQs

Last updated on 11 Feb 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc