An open API service indexing awesome lists of open source software.

https://github.com/anko/adjacents

utility function that returns all adjacent pairs of values in an array
https://github.com/anko/adjacents

array javascript

Last synced: about 1 year ago
JSON representation

utility function that returns all adjacent pairs of values in an array

Awesome Lists containing this project

README

          

# adjacents [![](https://img.shields.io/npm/v/adjacents.svg?style=flat-square)][1] [![](https://img.shields.io/travis/anko/adjacents.svg?style=flat-square)][2] [![](https://img.shields.io/david/anko/adjacents?style=flat-square)][3]

A function that returns an array of the pairs of adjacent values in the input
array. “Adjacent” as in *next to each other in the array*.

When there aren't enough elements to form pairs (0 or 1), it'll return an empty
array.

## Example

```js
adjacents([ 1, 2, 3, 4 ])
```

```js
[ [ 1, 2 ], [ 2, 3 ], [ 3, 4 ] ]
```

## License

[ISC][4].

[1]: https://www.npmjs.com/package/adjacents
[2]: https://travis-ci.org/anko/adjacents
[3]: https://david-dm.org/anko/adjacents
[4]: https://en.wikipedia.org/wiki/ISC_license