1.0.0 • Published 9 years ago

abbrev-range v1.0.0

Weekly downloads
97
License
MIT
Repository
github
Last release
9 years ago

abbrev-range

Utility method for abbreviating an array of integers into a more human-readable form.

npm Version Build Status Test Coverage Dependency Status

Installation

Install using npm:

$ npm install abbrev-range

Usage

Note: This function assumes the array of values contains integers, and those integers are sorted and contain no duplicates.

var abbrevRange = require('abbrev-range');

abbrevRange([]);                  // ''
abbrevRange([1]);                 // '1'
abbrevRange([1, 2, 3]);           // '1-3'
abbrevRange([1, 2, 3, 5]);        // '1-3, 5'
abbrevRange([1, 3, 5]);           // '1, 3, 5'
abbrevRange([1, 2, 3, 5, 6, 7]);  // '1-3, 5-7'
abbrevRange([1, 2]);              // '1, 2'
abbrevRange([1, 3, 4, 8]);        // '1, 3, 4, 8'

License

MIT