major-versions

Get all the major versions within a semver range

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
major-versions
132.2.14 years ago8 years agoMinified + gzip package size for major-versions in KB

Readme

major-versions Build Status Greenkeeper badge
Get all the major versions within a semver range

Installing

$ npm install --save major-versions

Usage

var majors = require('major-versions')
majors('>=2 <5') // => ['2', '3', '4']
majors('>=2 <5 || 10') // => ['2', '3', '4', '10']
majors('<2 >5') // => []

API

majors(range, [maximum]) -> array[string]

range
Required
Type: string
A semver range.
maximum
Type: string
A maximum to apply. An exception will be thrown for an unbounded range (e.g. '>5') if no maximum is provided. The maximum must lie within the range. Most times you'll query a package registry for a specific version (e.g. latest) and use it as the maximum.
majors('>=2', '4.1.2', ['2', '3', '4'])

Caveats

If you pass a range in 0.y.z, the library will throw an exception unless you define a maximum or your range resolves to an exact version.