Skip to content

Instantly share code, notes, and snippets.

@isaacs isaacs/x.js
Last active Nov 25, 2019

Embed
What would you like to do?
const versions = [
'0.0.1-beta.0',
'0.0.1-beta.1',
'0.0.1-beta.2',
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10',
'0.0.1-beta.3clear',
'0.0.2-beta.11'
]
const semver = require('./')
const ranges = [
'<0.0.1-beta.3clear',
'<=0.0.1-beta.3clear',
'<=0.0.1-beta.2',
'>0.0.1-beta.2',
'<=0.0.2-beta.2',
'>0.0.2-beta.2',
]
ranges.forEach(r => {
console.log(r, versions.filter(v => semver.satisfies(v, r)))
console.log(`${r} loose`, versions.filter(v => semver.satisfies(v, r, true)))
})
/* output:
<0.0.1-beta.3clear [
'0.0.1-beta.0',
'0.0.1-beta.1',
'0.0.1-beta.2',
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10'
]
<0.0.1-beta.3clear loose [
'0.0.1-beta.0',
'0.0.1-beta.1',
'0.0.1-beta.2',
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10'
]
<=0.0.1-beta.3clear [
'0.0.1-beta.0',
'0.0.1-beta.1',
'0.0.1-beta.2',
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10',
'0.0.1-beta.3clear'
]
<=0.0.1-beta.3clear loose [
'0.0.1-beta.0',
'0.0.1-beta.1',
'0.0.1-beta.2',
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10',
'0.0.1-beta.3clear'
]
<=0.0.1-beta.2 [ '0.0.1-beta.0', '0.0.1-beta.1', '0.0.1-beta.2' ]
<=0.0.1-beta.2 loose [ '0.0.1-beta.0', '0.0.1-beta.1', '0.0.1-beta.2' ]
>0.0.1-beta.2 [
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10',
'0.0.1-beta.3clear'
]
>0.0.1-beta.2 loose [
'0.0.1-beta.4',
'0.0.1-beta.5',
'0.0.1-beta.6',
'0.0.1-beta.7',
'0.0.1-beta.8',
'0.0.1-beta.10',
'0.0.1-beta.3clear'
]
<=0.0.2-beta.2 []
<=0.0.2-beta.2 loose []
>0.0.2-beta.2 [ '0.0.2-beta.11' ]
>0.0.2-beta.2 loose [ '0.0.2-beta.11' ]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.