# promise-routine

> Wrap a routine of Promise functions in Promise.all

Latest version **2.0.0** (published 2016-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-routine
pnpm add promise-routine
yarn add promise-routine
bun add promise-routine
```

## 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 | 2.0.0 |
| Published | 2016-09-18 |
| First published | 2016-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jamen Marzonie |
| Maintainers | jamen |

## Links

- npm: https://www.npmjs.com/package/promise-routine
- Repository: https://github.com/jamen/promise-routine
- Homepage: https://github.com/jamen/promise-routine#readme
- Issues: https://github.com/jamen/promise-routine/issues
- npm.io page: https://npm.io/package/promise-routine

## Recent versions

- 2.0.0 (latest) — 2016-09-18
- 1.0.0 — 2016-04-06
- 0.2.0 — 2016-03-01
- 0.1.1 — 2016-03-01
- 0.1.0 — 2016-03-01
- 0.0.1 — 2016-03-01

## README

# promise-routine
> Wrap a routine of Promise functions in Promise.all

Repeat a `Promise`-returning function with different arguments and wrap the results in `Promise.all`.
```javascript
const routine = require('promise-routine');
const glob = require('glob');

routine(glob, ['foo/**.js', 'baz/**.css'])
.then(globs => {
  // ...
});
```

## Installation
```shell
$ npm install --save promise-routine
```

## Usage
```javascript
const routine = require('routine');
const promiseFunction = require('...');

routine(promiseFunction, [...])
.then(results => {

});
```
On object methods (or context-sensitive functions), rebind context `this` with a third argument:
```javascript
routine(lib.foo, [...], lib)
.then(results => {

});
```

## API
#### `routine(fn, sets, [context])`
 - `fn` (Function): Function for the routine to use.
 - `sets` (Array): A list of arguments to apply on `fn`, where a sub-array is a list of arguments.
 - `context` (Anything): A context to bind to `this` on `fn`. (Default: `fn`)

_What is the format of `sets`?_: Sets is a 2 dimensional array, where the second level is a list of arguments:
```javascript
// This:
routine(func, [[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
// is equivalent to:
Promise.all([
  func(1, 2, 3),
  func(4, 5, 6),
  func(7, 8, 9)
]);
```
You can also supply non-array sets to supply one argument:
```javascript
// This:
routine(func, [1, 2, 3]);
// is equivalent to:
Promise.all([
  func(1),
  func(2),
  func(3)
]);
```

Returns: `Promise`

## Credits
| ![jamen][avatar] |
|:---:|
| [Jamen Marzonie][github] |

  [avatar]: https://avatars.githubusercontent.com/u/6251703?v=3
  [github]: https://github.com/jamen

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