Skip to content

Commit d062593

Browse files
committed
coerce(number) will coerce to a string
1 parent 3dc88f3 commit d062593

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

semver.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,10 @@ function coerce (version, options) {
15411541
return version
15421542
}
15431543

1544+
if (typeof version === 'number') {
1545+
version = String(version)
1546+
}
1547+
15441548
if (typeof version !== 'string') {
15451549
return null
15461550
}

test/coerce.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ test('\ncoerce tests', function (t) {
103103
r('1')(16) + '.' + r('2')(16) + '.' + r('3')(16)],
104104
['1.2.3.' + r('4')(252) + '.5', '1.2.3'],
105105
['1.2.3.' + r('4')(1024), '1.2.3'],
106-
[r('1')(17) + '.4.7.4', '4.7.4']
106+
[r('1')(17) + '.4.7.4', '4.7.4'],
107+
[10, '10.0.0'],
107108
].forEach(function (tuple) {
108109
var input = tuple[0]
109110
var expected = tuple[1]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy