Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bahamas10/node-stretch

Stretch out the contents of an array like a rubber band
https://github.com/bahamas10/node-stretch

Last synced: about 2 months ago
JSON representation

Stretch out the contents of an array like a rubber band

Awesome Lists containing this project

README

        

stretch
=======

Stretch out the contents of an array like a rubber band

Install
-------

npm install stretch

Example
-------

``` js
> var stretch = require('./')

> stretch(['cat', 'dog'], 4)
[ 'cat', 'cat', 'dog', 'dog' ]
> stretch(['cat', 'dog'], 8)
[ 'cat', 'cat', 'cat', 'cat', 'dog', 'dog', 'dog', 'dog' ]

> stretch([0,1,0], 6)
[ 0, 0, 1, 1, 0, 0 ]
> stretch([0,1,0], 9)
[ 0, 0, 0, 1, 1, 1, 0, 0, 0 ]
> stretch([0,1,0], 12)
[ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 ]

> stretch([0,1,0], 5)
[ 0, 0, 1, 1, 0 ]
```

License
-------

MIT