# foreign

> Asnyc map that actualy works. Parallel and Series

Latest version **3.1.2** (published 2022-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install foreign
pnpm add foreign
yarn add foreign
bun add foreign
```

## 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 | 3.1.2 |
| Published | 2022-04-18 |
| First published | 2015-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Maurice Butler |
| Maintainers | mauricebutler |
| Keywords | async, map, parallel, series, for in |

## Links

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

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.1.2 (latest) — 2022-04-18
- 3.1.0 — 2021-05-20
- 3.0.0 — 2020-04-07
- 2.1.0 — 2019-03-13
- 2.0.0 — 2018-01-30
- 1.0.4 — 2016-04-13
- 1.0.3 — 2015-10-21
- 1.0.2 — 2015-06-02
- 1.0.1 — 2015-02-25
- 1.0.0 — 2015-01-27

## README

# foreign

Asnyc map that actualy works. Parallel, Series, Sync and Async

## Usage

```javascript
const foreign = require('foreign');
```

### Parallel

```javascript
const items = [1, 2, 3];

foreign.parallel(
    (item, callback) => {
        somethingAsync(item, callback);
    },
    items,
    (error, result) => {},
);
```

### Series

```javascript
const items = [1, 2, 3];

foreign.series(
    (item, callback) => {
        somethingAsync(item, callback);
    },
    items,
    (error, result) => {},
);
```

### SeriesPromise

```javascript
const items = [1, 2, 3];

const result = foreign.series(async (item) => someAsyncFunction(item), items);
```

### SeriesAll

```javascript
const items = [1, 2, 3];

foreign.seriesAll(
    (item, callback) => {
        somethingAsync(item, callback);
    },
    items,
    (error, result) => {
        // 'error' will always be a either array or object of errors
        // 'result' will always be a either array or object of results
        // depending on the type `items` is.
        //
        // NOTE: `error.length` is not a reliable indicator of number of errors
        //
        // All items will be processed in order even if
        // some return errors. `foreign.series` and `foreign.seriesPromise` will return
        // on first error

        // example error checking:
        if (error) {
            const itemsThatFailed = Object.keys(error);
        }
    },
);
```

### Multiple return values

```javascript
const items = [1, 2, 3];

foreign.series(
    (item, callback) => {
        callback(null, item, 'foo');
    },
    items,
    (error, results) => {
        console.log(results); // [[1, 'foo'], [2, 'foo'], [3, 'foo']]
    },
);
```

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