Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/homerchen19/infinite-array

∞ Infinite array index using ES2015 Proxy
https://github.com/homerchen19/infinite-array

Last synced: 1 day ago
JSON representation

∞ Infinite array index using ES2015 Proxy

Awesome Lists containing this project

README

        

# infinite-array [![Build Status](https://travis-ci.org/xxhomey19/infinite-array.svg?branch=master)](https://travis-ci.org/xxhomey19/infinite-array)

Inspired by [sindresorhus/negative-array](https://github.com/sindresorhus/negative-array), `infinite-array` supports index which is negative, positive and even bigger than array's length.

**Support TypeScript recently.**

## Install

```
$ npm install infinite-array
```

## Usage

```js
import infiniteArray from 'infinite-array';

const nba = infiniteArray(['N', 'B', 'A']);

console.log(nba[-6]); // N
console.log(nba[-5]); // B
console.log(nba[-4]); // A
console.log(nba[-3]); // N
console.log(nba[-2]); // B
console.log(nba[-1]); // A
console.log(nba[0]); // N
console.log(nba[1]); // B
console.log(nba[2]); // A
console.log(nba[3]); // N
console.log(nba[4]); // B
console.log(nba[5]); // A
```

## License

MIT © [xxhomey19](https://github.com/xxhomey19)