# both.io

> both

Latest version **0.9.1** (published 2015-05-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install both.io
pnpm add both.io
yarn add both.io
bun add both.io
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2015-05-09 |
| First published | 2015-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michael J. Zoidl |
| Maintainers | michaelzoidl |

## Links

- npm: https://www.npmjs.com/package/both.io
- Repository: https://github.com/michaelzoidl/both.io
- Issues: https://github.com/michaelzoidl/both/issues
- npm.io page: https://npm.io/package/both.io

## Recent versions

- 0.9.1 (latest) — 2015-05-09
- 0.9.0 — 2015-05-09
- 0.8.94 — 2015-05-08
- 0.8.93 — 2015-05-08
- 0.8.92 — 2015-05-08
- 0.8.91 — 2015-05-08
- 0.8.9 — 2015-05-08
- 0.8.8 — 2015-05-08
- 0.8.7 — 2015-05-08
- 0.8.6 — 2015-05-08
- 0.8.5 — 2015-05-08
- 0.8.4 — 2015-05-08
- 0.8.3 — 2015-05-08
- 0.8.2 — 2015-05-08
- 0.8.1 — 2015-05-08
- … 2 more at https://npm.io/package/both.io/versions

## README

![BothIO Logo](http://docs.michaelzoidl.com/GithubLogoPaths.svg)

![](https://img.shields.io/badge/unicorn-approved-blue.svg)
[![Gratipay](http://img.shields.io/gratipay/michaelzoidl.svg)](https://gratipay.com/michaelzoidl/)
[![Build Status](https://travis-ci.org/michaelzoidl/both.io.svg?branch=master)](https://travis-ci.org/michaelzoidl/both.io)
[![bitHound Score](https://www.bithound.io/github/michaelzoidl/both.io/badges/score.svg)](https://www.bithound.io/github/michaelzoidl/both.io)
[![Codacy Badge](https://img.shields.io/codacy/98f77bcc84964e67a2754e563b962d27.svg)](https://www.codacy.com/app/me_1438/both-io)
[![devDependency Status](https://david-dm.org/michaelzoidl/both.io/dev-status.svg)](https://david-dm.org/michaelzoidl/both.io#info=devDependencies)

## What is BothIO?
Simply, it's a library based on the [CQS-Princip](http://en.wikipedia.org/wiki/Command%E2%80%93query_separation), where your methods are separated by **commands** and **queries**.<br><br>
What BothIO makes so special is the NodeJS/Client-Support, so you can execute your commands and queries from your node-side as well as from your client-side.

## Example
```javascript

var myToDoList = [];

// # Define a Command
// Server:
both.command('CreateTodo', function(name, payload, callback){
  myToDoList.push(payload.todoName);
});

// Execute a Command
// Client:
both('CreateTodo', {
  todoName: 'eat some chocolate'
});


// Listen to a defined Command
// Server:
both.on('CreateTodo', function(name, payload){
  console.log('Todo Created:', payload.todoName);
});

// Listen to all Commands
// Client:
both.on(function(commandName, payload){
  console.log('The command', commandName, 'was executed!');
  console.log('with the payload:', payload);
});


// # Add a Callback
// Server:
both.query('GetAllTodos', function(name, payload, callback){
  someDatabase.query('getAllTodos', function(todos){
    callback(todos);
  });
});

// Client:
both('GetAllTodos', {}, function(todos){
  // Use Todos at the client
})

```
[And there's something more planed](https://github.com/michaelzoidl/both.io/blob/master/PLANED.md)

## Battle-Tested
This project is used at the [entertain.io](https://github.com/michaelzoidl/entertain.io) platform.


## Contribute
BothIO uses the new ES6 standard and is tested with mocha, plus we package the code with webpack.
<br><br>
__You want contribute? Here is how you start:__<br>
_Clone repo_<br>
`git clone git@github.com:michaelzoidl/both.io.git`<br>
_Run the unit-tests_<br>
`npm run test`<br>
_Pack the code and save it in the dist-folder_<br>
`npm run pack`<br>
_Develop, it starts a mocha-watcher_<br>
`npm run develop`

---
_Source: https://npm.io/package/both.io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
