[nodejs] meaning of the semver ~

78 views
Skip to first unread message

Dominic Tarr

unread,
May 30, 2013, 3:52:47 PM5/30/13
to nod...@googlegroups.com
without looking in the documentation or trying it in the repl

what do you expect to be the results of these tests on semver ranges?

A. semver.satisfies('~1.2.3', '1.2.4')

B. semver.satisfies('~1.2', '1.3.0')

C. semver.satisfies('~1.2', '1.2.6')

D. semver.satisfies('1.2', '1.3.0')

E. semver.satisfies('1.2', '1.2.4')

please don't look at the documentation, the question is:

what do you think it means?

Forrest L Norvell

unread,
May 30, 2013, 4:15:27 PM5/30/13
to nod...@googlegroups.com
On Thu, May 30, 2013 at 12:52 PM, Dominic Tarr <domini...@gmail.com> wrote:
without looking in the documentation or trying it in the repl

what do you expect to be the results of these tests on semver ranges?

A. semver.satisfies('~1.2.3', '1.2.4')

true-y
 
B. semver.satisfies('~1.2', '1.3.0')

falsy
 
C. semver.satisfies('~1.2', '1.2.6')

true-y
 
D. semver.satisfies('1.2', '1.3.0')

falsy

E. semver.satisfies('1.2', '1.2.4')

true-y

please don't look at the documentation, the question is:

what do you think it means?

My intuitive understanding (which is probably wrong) is that "~1.2.3" -> "1.2.x" -> "1.2.0 <= version < 1.3". That said, '~' feels squishy to me, so I tend to prefer "1.2.x".

F

Kevin Swiber

unread,
May 30, 2013, 4:45:01 PM5/30/13
to nod...@googlegroups.com
I'd prefer to be very explicit:

>=1.2.0 <2.0.0

I read this as "allow version 1.2.0 or any subsequent version prior to a major API change."

I think this is what the tilde implies, but I would have to look it up more than once… and so would my fellow collaborators, I imagine.

--
Kevin Swiber
@kevinswiber
https://github.com/kevinswiber

Jake Verbaten

unread,
May 30, 2013, 5:24:41 PM5/30/13
to nod...@googlegroups.com
A. semver.satisfies('~1.2.3', '1.2.4')

yes


B. semver.satisfies('~1.2', '1.3.0')

yes


C. semver.satisfies('~1.2', '1.2.6')

yes


D. semver.satisfies('1.2', '1.3.0')

no


E. semver.satisfies('1.2', '1.2.4')

no



--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Michael Schoonmaker

unread,
May 30, 2013, 5:45:49 PM5/30/13
to nod...@googlegroups.com
A. semver.satisfies('~1.2.3', '1.2.4') => true
B. semver.satisfies('~1.2', '1.3.0') => false
C. semver.satisfies('~1.2', '1.2.6') => true
D. semver.satisfies('1.2', '1.3.0') => false
E. semver.satisfies('1.2', '1.2.4') => true

My understanding is similar to Forrest's. ~1.2.3 means 1.2.3 <= version < 1.3.0, whereas ~1.2 means 1.2.0 <= version < 1.3.0

With Forrest's explanation, semver.satisfies('~1.2.3', '1.2.1') would be true, whereas I would expect it to be false. +1 for the "squishiness", however, but I prefer that as an indicator to NPM that patch updates are acceptable while still guaranteeing all the patches in 1.2.3 are present.

Tim Smart

unread,
May 30, 2013, 5:48:59 PM5/30/13
to nod...@googlegroups.com
A - true
B - true
C - true
D - false
E - true

Time to look at the documentation :)

Isaac Schlueter

unread,
May 30, 2013, 6:58:34 PM5/30/13
to nodejs
Also: No looking at the code or running the semver command line util ;)

Alan Gutierrez

unread,
May 30, 2013, 10:59:16 PM5/30/13
to nod...@googlegroups.com
A. Yes.
B. No.
C. Yes.
D. No.
E. No.

--
Alan Gutierrez ~ @bigeasy

Alex Kocharin

unread,
May 31, 2013, 12:29:18 AM5/31/13
to nod...@googlegroups.com

A. false
B. false
C. false
D. false
E. false

'cause you submitted the arguments in a wrong order. ;)

chakrit

unread,
May 31, 2013, 12:36:39 AM5/31/13
to nod...@googlegroups.com
A. YES
B. NO
C. YES
D. NO
E. YES

chakrit

unread,
May 31, 2013, 12:39:19 AM5/31/13
to nod...@googlegroups.com
Meaning:

A: Around this version, so get the most recent version that's still not too far from 1.2
B: 1.3 might have API changes, don't want it. I have programmed against 1.2 so let's stick to that for the moment
C: Around this version, like A
D: 1.2 with whatever patch version's available but not definitely not 1.3
E: like D


On Friday, May 31, 2013 2:52:47 AM UTC+7, Dominic wrote:

dhruvbird

unread,
May 31, 2013, 2:05:48 AM5/31/13
to nod...@googlegroups.com


On Thursday, May 30, 2013 12:52:47 PM UTC-7, Dominic wrote:
without looking in the documentation or trying it in the repl

what do you expect to be the results of these tests on semver ranges?

A. semver.satisfies('~1.2.3', '1.2.4')

True, because 1.2.3 seems to be approximately 1.2.4 


B. semver.satisfies('~1.2', '1.3.0')

False, since 1.3.0 is not approximately 1.2


C. semver.satisfies('~1.2', '1.2.6')

True.
 

D. semver.satisfies('1.2', '1.3.0')

True, since I assume that 1.3.0 is 1.2.x and more.
 

E. semver.satisfies('1.2', '1.2.4')

True again.

 

please don't look at the documentation, the question is:

what do you think it means?

~1.2.3 probably means a version around 1.2.3 with the rev. possibly different. I expect only revisions >= 3 to match though.


 

Dominic Tarr

unread,
May 31, 2013, 4:52:27 AM5/31/13
to nod...@googlegroups.com
10 points for alex kocharin (assuming he didn't cheat)
for the purposes of this survey it's semver.sasisfies(semverRange, semverValue)

Christian Tellnes

unread,
Jun 1, 2013, 11:09:30 AM6/1/13
to nod...@googlegroups.com

A. semver.satisfies('~1.2.3', '1.2.4')
true

B. semver.satisfies('~1.2', '1.3.0') 
true
 
C. semver.satisfies('~1.2', '1.2.6')
true
 
D. semver.satisfies('1.2', '1.3.0')
false
 
E. semver.satisfies('1.2', '1.2.4')
true



--
Sincerely, Christian Vaagland Tellnes
Phone: +4791861617
https://github.com/tellnes
Reply all
Reply to author
Forward
0 new messages