trg
v0.0.4
Published
Template Range Generators
Downloads
2
Maintainers
Readme
Template Range Generators
ES6 Template String - based generators for a range of numbers or letters.
NOTE: Currently supporting only integers, and only for Node.js 4.0 and later.
Install
$npm install trg
Usage
const IR = require('trg').int; // Integer Range generator
- Simple
{1, 7}
range:
IR`${1}${7}`;
//=> 1234567
- Range
{1, 7}
, with prefix$
and,
separator:
IR`$${1}, ${7}`;
//=> $1, $2, $3, $4, $5, $6, $7
- Reversed range
{7, 1}
, with step2
and,
separator:
IR`${7}, ${1}${2}`;
//=> 7, 5, 3, 1
- Range
{-3, 7}
, with prefix#
, suffix:-)
, separator,
and step2
:
IR`#${-3}, ${7}:-)${2}`;
//=> #-3:-), #-1:-), #1:-), #3:-), #5:-), #7:-)
Template format supported by the integer range generator:
- Optional prefix string
- Starting value integer (required)
- Optional separator string
- Ending value integer (required)
- Optional suffix string
- Optional step integer