0.1.0 • Published 10 years ago

command-buffer v0.1.0

Weekly downloads
77
License
MIT
Repository
github
Last release
10 years ago

NPM NPM

command-buffer is a simple command buffer abstraction library written in JavaScript.

Usage

Browser

<script type="text/javascript" src="command-buffer.js"></script>

Node.js

$ npm install command-buffer
var CommandBuffer = require('command-buffer');

API

var commands = new CommandBuffer(callback);  // callback = function (type, data) {}
commands.pause();
commands.resume();
commands.run(type, data);
commands.schedule(type, data);

Example

var commands = new CommandBuffer(function (type, data) {
  switch (type) {
  case 'send':
    console.log(data);
    break;
  default:
    break;
  }
}, this);

commands.schedule('send', 'something');
// OUTPUT --> something
commands.pause();
commands.schedule('send', 'something else');
commands.run('send', 'something else again');
commands.resume();
// OUTPUT --> something else again
// OUTPUT --> something else

Credits

See the contributors.

License