packages-versions
v2.3.0
Published
A collection of npm packages utils ๐ ..
Downloads
102
Maintainers
Readme
PACKAGES VERSIONS ๐ช
GET ALL VERSIONS OF ANY PACKAGES ๐ ..
I don't intend to make breaking changes to this package ๐๐ป. So, don't be afraid to upgrade โจ. I added Opts argument (Optional) to the function for give you more control ๐ฎ.
Installation
# npm ..
$ npm install packages-versions
# yarn ..
$ yarn add packages-versions
Usage
This is a practical example of how to use.
// you can use any name for this function.
// the result is an array of versions in descending order.
const getPackagesVersions = require ('packages-versions');
// note: you can use the promise way (then/catch)
(async () => {
try {
let list = await getPackagesVersions('packages-versions');
console.log(list);
}catch(err){
console.log(err)
}
})();
// Result:
// [ '2.1.0', '2.0.0', '1.1.1', '1.1.0', '1.0.1', '1.0.0' ]
// the same example with reverse opt.
(async () => {
try {
let list = await getPackagesVersions('packages-versions', { reverse: true });
console.log(list);
}catch(err){
console.log(err)
}
})();
// Result:
// [ '1.0.0', '1.0.1', '1.1.0', '1.1.1', '2.0.0', '2.1.0' ]
// the same example with extract opt.
try {
let list = await getPackagesVersions('packages-versions', { extract: { rc: true } });
console.log(list);
}catch(err){
console.log(err)
}
})();
// Result: // we don't have any rc package.
// []
Options Ref.
| Option | Type | Descriptio |
| ----------- | --------- | --------------------------------------------------------------- |
| reverse
| Boolean | Reverse the order of the results (versions array). |
| extract
| Object | Extract only the type of version you want. |
Note: extract
can contain one, some or all of these values โโin a boolean form (pure: X.X.X, rc: X.X.X-rc, beta: X.X.X-beta, alpha: X.X.X-alpha).
You can combine
reverse
andextract
.
Contributors โจ
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!