https://github.com/pnpm/version-selector-type
Returns the type of a version selector
https://github.com/pnpm/version-selector-type
Last synced: 3 months ago
JSON representation
Returns the type of a version selector
- Host: GitHub
- URL: https://github.com/pnpm/version-selector-type
- Owner: pnpm
- License: mit
- Created: 2017-12-24T13:52:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-03T06:45:20.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T02:29:52.704Z (3 months ago)
- Language: JavaScript
- Size: 258 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# version-selector-type
> Returns the type and normalized version of a version selector
[](https://www.npmjs.com/package/version-selector-type) [](https://travis-ci.org/pnpm/version-selector-type)
## Installation
```sh
add version-selector-type
```## Usage
```js
'use strict'
const getVersionSelectorType = require('version-selector-type')console.log(getVersionSelectorType('1.0.0'))
//> { normalized: '1.0.0', type: 'version' }console.log(getVersionSelectorType('^1.0.0'))
//> { normalized: '>=1.0.0 <2.0.0', type: 'range' }console.log(getVersionSelectorType('latest'))
//> { normalized: 'latest', type: 'tag' }console.log(getVersionSelectorType('github:zkochan/foo'))
//> nullconsole.log(getVersionSelectorType('1.2.0beta'))
//> { normalized: '1.2.0-beta', type: 'version' }console.log(getVersionSelectorType.strict('1.2.0beta'))
//> { normalized: '1.2.0beta', type: 'tag' }
```## API
### `getVersionSelectorType(selector)`
Returns the type of the version selector and the normalized form of that selector.
Returns `null` in case it is an unknown selector.
Interprets versions and ranges loosely.### `getVersionSelectorType.strict(selector)`
Same as `getVersionSelectorType()` but interprets versions and ranges not loosely.
## License
[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io/)