# major-versions

> Get all the major versions within a semver range

Latest version **2.2.1** (published 2019-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install major-versions
pnpm add major-versions
yarn add major-versions
bun add major-versions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2019-03-27 |
| First published | 2015-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | semver, major, range, versions |

## Links

- npm: https://www.npmjs.com/package/major-versions
- Repository: https://github.com/bendrucker/major-versions
- Homepage: https://github.com/bendrucker/major-versions#readme
- Issues: https://github.com/bendrucker/major-versions/issues
- npm.io page: https://npm.io/package/major-versions

## Dependencies (8)

- [pff](https://npm.io/package/pff.md) ~1.0.0
- [semver](https://npm.io/package/semver.md) ^6.0.0
- [array-last](https://npm.io/package/array-last.md) ~1.3.0
- [array-uniq](https://npm.io/package/array-uniq.md) ~2.0.0
- [semver-bounded](https://npm.io/package/semver-bounded.md) ^2.0.2
- [semver-resolves](https://npm.io/package/semver-resolves.md) ^1.1.0
- [semver-conflicts](https://npm.io/package/semver-conflicts.md) ^1.0.0
- [accumulate-values](https://npm.io/package/accumulate-values.md) ~1.0.0

## Recent versions

- 2.2.1 (latest) — 2019-03-27
- 2.2.0 — 2018-11-14
- 2.1.0 — 2018-11-13
- 2.0.1 — 2017-03-21
- 2.0.0 — 2015-06-06
- 1.0.2 — 2015-05-08
- 1.0.1 — 2015-05-01
- 1.0.0 — 2015-05-01

## README

# major-versions [![Build Status](https://travis-ci.org/bendrucker/major-versions.svg?branch=master)](https://travis-ci.org/bendrucker/major-versions) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/major-versions.svg)](https://greenkeeper.io/)

> Get all the major versions within a [semver](https://semver.org/) range

## Installing

```sh
$ npm install --save major-versions
```

## Usage

```js
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.

```js
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.

---
_Source: https://npm.io/package/major-versions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
