# interleaving

> JavaScript functions to combine N arrays of any size, distributing items evenly

Latest version **1.0.0** (published 2016-12-08) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2016-12-08 |
| First published | 2016-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stuart P. Bentley |
| Maintainers | stuartpb |
| Keywords | array, interleave, combine, merge, dovetail, shuffle, riffle, zip |

## Links

- npm: https://www.npmjs.com/package/interleaving
- Repository: https://github.com/stuartpb/interleaving
- Homepage: https://github.com/stuartpb/interleaving#readme
- Issues: https://github.com/stuartpb/interleaving/issues
- npm.io page: https://npm.io/package/interleaving

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-12-08

## README

# interleaving

JavaScript functions to combine N arrays of any size, distributing items evenly

The `interleaving` module exposes two functions:

## interleaving.justify(array1, array2, ...)

Distributes items based on their distance from the final item of the source array. Items from the longest arrays will both appear and finish first, while items from the shortest arrays will both appear and finish last.

Points of equal distance will be placed by the order the arrays are specified, so it is recommended to sort longest arrays first if you wish for this principle to remain consistent.

```
> console.log(interleaving.justify(
>>   ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
>>   ['1', '2', '3', '4'],
>>   ['A', 'B', 'C']));

[ 'a', 'b', '1', 'A', 'c', 'd', '2', 'e', 'B', 'f', '3', 'g', 'h', '4', 'C' ]
```

## interleaving.center(array1, array2, ...)

Distributes items based on their distance along the length of the source array. Items from the longest arrays will appear first and finish last, while items from the shortest arrays will appear last and finish first.

Points of equal distance will be placed by the order the arrays are specified.

```
> console.log(interleaving.center(
>>   ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
>>   ['1', '2', '3', '4'],
>>   ['A', 'B', 'C']));

[ 'a', '1', 'b', 'A', 'c', '2', 'd', 'B', 'e', '3', 'f', 'C', 'g', '4', 'h' ]
```

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