Skip to content

rogerbf/prefixed-range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 }))

About

create a prefixed range

Resources

Stars

Watchers

Forks

Packages

No packages published