Skip to content

Commit 1aaf078

Browse files
DevOnSabbaticalisaacs
authored andcommitted
Adding docs for clean
Close #260
1 parent 0aea9ca commit 1aaf078

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,19 @@ The maximum length for any semver component considered for coercion is 16 chara
412412
longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`).
413413
The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`;
414414
higher value components are invalid (`9999999999999999.4.7.4` is likely invalid).
415+
416+
### Clean
417+
418+
* `clean(version)`: Clean a string to be a valid semver if possible
419+
420+
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
421+
422+
ex.
423+
* `s.clean(' = v 2.1.5foo')`: `null`
424+
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
425+
* `s.clean(' = v 2.1.5-foo')`: `null`
426+
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
427+
* `s.clean('=v2.1.5')`: `'2.1.5'`
428+
* `s.clean(' =v2.1.5')`: `2.1.5`
429+
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
430+
* `s.clean('~1.0.0')`: `null`

0 commit comments

Comments
 (0)