isaacs/node-semver — pull request #41 by agnoster (2013-07-21 17:11:29+00:00)
Title: Add caret operator meaning "compatible with X"

This idea was brought up in issue #38, so I thought I'd take a stab at an implementation, just because I think it's often easier to discuss a concrete implementation than a general idea. Hope that's not too presumptuous — if you closed the issue because you think it's a bad idea in general, feel free to ignore.

The caret operator has rough semantics "compatible with X". Specifically, it allows any version that is *at least* the specified version, but *less than* the next *major* version.

For example, `^1.2.3` is equivalent to `>=1.2.3-0 <2.0.0`.

This seems to me to be the semantics you want most of the time: you have a "known good" version of a package, but you're willing to take any newer versions that promise backwards compatibility.

(As far as the code goes, I basically just took the implementation of tilde and made some alterations. It would be pretty easy to do some refactoring to remove duplication, but this seemed to at least be very *clear* about what's going on. I'd be happy to make improvements if desired.)