prefixed-range

0.0.3 • Public • Published

prefixed-range

Creates an array of a prefixed range.

npm install prefixed-range

Usage

const range = require('prefixed-range')

const prefix = 'poof'

range(prefix, 3)
// ['poof0', 'poof1', 'poof2']

API

Create a prefixed range with a length of 3, starting with 0:

range('prefix', 3)
// ['prefix0', 'prefix1', 'prefix2']

Create a prefixed range with a length of 3, starting with 1:

range('prefix', { start: 1, end: 3 })
// ['prefix1', 'prefix2', 'prefix3']

As a convenience you can also append a value as the first element of the resulting array:

range('prefix', { start: 1, end: 3 }, 'poof')
// ['poof', 'prefix1', 'prefix2', 'prefix3']

Which is the same as:

Array.of('poof').concat(range('prefix', { start: 1, end: 3 }))

Readme

Keywords

Package Sidebar

Install

npm i prefixed-range

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • rogerbf