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
- Host: GitHub
- URL: https://github.com/anko/adjacents
- Owner: anko
- License: isc
- Created: 2015-08-04T20:35:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-02-07T16:44:13.000Z (over 6 years ago)
- Last Synced: 2025-02-04T19:14:40.612Z (over 1 year ago)
- Topics: array, javascript
- Language: LiveScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.markdown
- License: LICENSE
Awesome Lists containing this project
README
# adjacents [][1] [][2] [][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