# 1-of

> Build easily and run distributed task.

Latest version **1.0.1** (published 2017-09-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install 1-of
pnpm add 1-of
yarn add 1-of
bun add 1-of
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-09-07 |
| First published | 2017-09-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bitliner |

## Links

- npm: https://www.npmjs.com/package/1-of
- npm.io page: https://npm.io/package/1-of

## Dependencies (3)

- [kue](https://npm.io/package/kue.md) ^0.11.6
- [my-env](https://npm.io/package/my-env.md) ^1.2.0
- [stream-array](https://npm.io/package/stream-array.md) ^1.1.2

## Recent versions

- 1.0.1 (latest) — 2017-09-07
- 1.0.0 — 2017-09-07

## README

# 1-of

Build easily and run distributed task. 

Based on Redis and Kue.

## Usage

**Create a computing unit**

```
const Computing = require('../').computing;

module.exports = new Computing('double', (input, progress, done) => {
  progress(0, 0, input * 2);
  done();
});
```
NB: you can return more than 1 result by using progress.

**Create a runner**

```
const Runner = require('../').runner;
const streamify = require('stream-array');
const {Transform} = require('stream');



streamify([2, 4, 6]) // stream an array of integer
  .pipe(new Transform({
    objectMode: true,
    transform: function(chunk, encoding, done) {
      console.log('Pushing a number', chunk);
      this.push(chunk);
      done();
    }
  }))
  .pipe(new Runner().asStream('double'))
  .pipe(new Transform({
    objectMode: true,
    transform: function(chunk, encoding, done) {
      console.log('Result is', chunk)
      done();
    }
  }))
  .on('end', () => {
    console.log('End!!!')
  })
```

**Start redis**

`docker run -p 6379:6379 redis`

**Run program**

1. `node example/computing.js`
2. `node example/run.js`

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