Giter Club home page Giter Club logo

Comments (7)

coolaj86 avatar coolaj86 commented on August 16, 2024

Wait, found one that works

semver.parseRange("1.0.0 - 2.0.0")

Seems like the others should work too, no?

Still, the output seems awkward. I'm not sure how to interpret it.

[ '1.0.0 - 2.0.0',
  '1.0.0',
  '1',
  '0',
  '0',
  undefined,
  undefined,
  '2.0.0',
  '2',
  '0',
  '0',
  undefined,
  undefined,
  index: 0,
  input: '1.0.0 - 2.0.0' ]

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

Yeah, I think what you want is probably "validRange".

The name is a bit confusing. 'range' in the first one means an X - Y range, whereas 'range' in the second one is any imprecise specification.

from node-semver.

coolaj86 avatar coolaj86 commented on August 16, 2024

I definitely wanted parsed output.

Ideally I want something like this:

semver.parseRange('>= 1.1.7 < 2.0.0 || 1.1.3')

[
    {
        "semver": ">= v1.1.7"
      , "operator": ">="
      , "major": 1
      , "minor": 1
      , "patch": 7
    }
  , {
        "semver": "< v2.0.0"
      , "operator": "<"
      , "major": 2
      , "minor": 0
      , "patch": 0
    }
  , {
        "operator": "||"
    }
  , {
        "semver": "v1.1.3"
      , "operator": "="
      , "major": 1
      , "minor": 1
      , "patch": 3
    }

]

I know one of the RegExp functions allows iterating over a string. I think I could implement it pretty easily once I look that up.

from node-semver.

coolaj86 avatar coolaj86 commented on August 16, 2024

Kapow!

https://github.com/coolaj86/semver-utils/blob/master/semver-utils.js#L32

Any chance of getting this attached to semver as parseFullRange or something like that?

from node-semver.

coolaj86 avatar coolaj86 commented on August 16, 2024

Bump. Would you accept if I added this as parseFullRange and submitted a pull request (assuming I remove all of my semicolons)?

from node-semver.

coolaj86 avatar coolaj86 commented on August 16, 2024

I put this in https://github.com/coolaj86/semver-utils, but I'd still be happy to merge it into yours

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

No longer relevant on 2.0

from node-semver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.