semver-truncate
Advanced tools
Comparing version 1.1.2 to 2.0.0
10
index.js
'use strict'; | ||
var semver = require('semver'); | ||
const semver = require('semver'); | ||
module.exports = function (version, type) { | ||
if (['major', 'minor', 'patch'].indexOf(type) === -1) { | ||
throw new TypeError('Invalid version type'); | ||
module.exports = (version, type) => { | ||
if (!['major', 'minor', 'patch'].includes(type)) { | ||
throw new TypeError(`Invalid version type: ${version}`); | ||
} | ||
@@ -12,3 +12,3 @@ | ||
if (!version) { | ||
throw new Error('Version ' + version + ' is not valid semver'); | ||
throw new Error(`Version ${version} is not valid semver`); | ||
} | ||
@@ -15,0 +15,0 @@ |
{ | ||
"name": "semver-truncate", | ||
"version": "1.1.2", | ||
"description": "Truncate a semver version: 1.2.3 → 1.2.0", | ||
"license": "MIT", | ||
"repository": "sindresorhus/semver-truncate", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"semver", | ||
"version", | ||
"semantic", | ||
"truncate", | ||
"shorten", | ||
"simplify" | ||
], | ||
"dependencies": { | ||
"semver": "^5.3.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "semver-truncate", | ||
"version": "2.0.0", | ||
"description": "Truncate a semver version: `1.2.3` → `1.2.0`", | ||
"license": "MIT", | ||
"repository": "sindresorhus/semver-truncate", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"semver", | ||
"version", | ||
"semantic", | ||
"truncate", | ||
"shorten", | ||
"simplify" | ||
], | ||
"dependencies": { | ||
"semver": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # semver-truncate [![Build Status](https://travis-ci.org/sindresorhus/semver-truncate.svg?branch=master)](https://travis-ci.org/sindresorhus/semver-truncate) | ||
``` | ||
$ npm install --save semver-truncate | ||
$ npm install semver-truncate | ||
``` | ||
@@ -42,4 +42,3 @@ | ||
Type: `string` | ||
Values: `patch` `minor` `major` | ||
Type: `'patch' | 'minor' | 'major'` | ||
@@ -49,4 +48,12 @@ Version type to truncate to. | ||
## Related | ||
- [latest-semver](https://github.com/sindresorhus/latest-semver) - Get the latest stable semver version from an array of versions | ||
- [to-semver](https://github.com/sindresorhus/to-semver) - Get an array of valid, sorted, and cleaned semver versions from an array of strings | ||
- [semver-regex](https://github.com/sindresorhus/semver-regex) - Regular expression for matching semver versions | ||
- [semver-diff](https://github.com/sindresorhus/semver-diff) - Get the diff type of two semver versions: `0.0.1` `0.0.2` → `patch` | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3999
5
38
57
3
+ Addedsemver@6.3.1(transitive)
- Removedsemver@5.7.2(transitive)
Updatedsemver@^6.0.0