Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] decrement/truncate #48

Open
isaacs opened this issue Sep 5, 2013 · 4 comments
Open

[FEATURE] decrement/truncate #48

isaacs opened this issue Sep 5, 2013 · 4 comments
Labels
Enhancement new feature or improvement

Comments

@isaacs
Copy link
Contributor

isaacs commented Sep 5, 2013

Not pressing or urgent, but mostly for API symmetry, it'd be nice to have truncate/decrement functions.

  1. semver.truncate('1.2.3-foo', 'patch') == '1.2.3'
  2. semver.truncate('1.2.3', 'minor') == '1.2.0'
  3. semver.truncate('1.2.3', 'major') == '1.0.0'
  4. semver.dec('1.2.3-foo', 'patch') == '1.2.2'
  5. semver.dec('1.2.3', 'minor') == '1.1.0'
  6. semver.dec('1.2.3', 'major') == '0.0.0'

Re #46, but the use case presented there turned out to not require this functionality. It's still probably useful, though.

cc @ronkorving

@aschearer
Copy link

Would be handy to have semver.dec. I would like to generate a change log from git based on the current version and the previous version. Not sure of a way to get the previous version short of decrementing the package's version.

@sindresorhus
Copy link

I didn't have time to do a proper patch, but I did a quick module for truncation if anyone else needs it: https://github.com/sindresorhus/semver-truncate

@anko
Copy link

anko commented Sep 14, 2015

What should semver.dec('2.0.0', 'patch') be? 1.99.99? 1.0.0? Something in between? The semver spec doesn't define how to decrement a semver or what it even means. I suspect this is why.

@ypicard
Copy link

ypicard commented Nov 4, 2021

Any news on this?

@darcyclarke darcyclarke changed the title decrement/truncate feature [FEATURE] decrement/truncate Jul 28, 2022
@darcyclarke darcyclarke added the Enhancement new feature or improvement label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement new feature or improvement
Projects
None yet
Development

No branches or pull requests

7 participants
@isaacs @aschearer @sindresorhus @darcyclarke @anko @ypicard and others