@@ -60,6 +60,12 @@ Options:
6060 Coerce a string into SemVer if possible
6161 (does not imply --loose)
6262
63+ --rtl
64+ Coerce version strings right to left
65+
66+ --ltr
67+ Coerce version strings left to right (default)
68+
6369Program exits successfully if any valid version satisfies
6470all supplied ranges, and prints all satisfying versions.
6571
@@ -399,19 +405,26 @@ range, use the `satisfies(version, range)` function.
399405
400406### Coercion
401407
402- * ` coerce(version) ` : Coerces a string to semver if possible
403-
404- This aims to provide a very forgiving translation of a non-semver
405- string to semver. It looks for the first digit in a string, and
406- consumes all remaining characters which satisfy at least a partial semver
407- (e.g., ` 1 ` , ` 1.2 ` , ` 1.2.3 ` ) up to the max permitted length (256 characters).
408- Longer versions are simply truncated (` 4.6.3.9.2-alpha2 ` becomes ` 4.6.3 ` ).
409- All surrounding text is simply ignored (` v3.4 replaces v3.3.1 ` becomes ` 3.4.0 ` ).
410- Only text which lacks digits will fail coercion (` version one ` is not valid).
411- The maximum length for any semver component considered for coercion is 16 characters;
412- longer components will be ignored (` 10000000000000000.4.7.4 ` becomes ` 4.7.4 ` ).
413- The maximum value for any semver component is ` Integer.MAX_SAFE_INTEGER || (2**53 - 1) ` ;
414- higher value components are invalid (` 9999999999999999.4.7.4 ` is likely invalid).
408+ * ` coerce(version, options) ` : Coerces a string to semver if possible
409+
410+ This aims to provide a very forgiving translation of a non-semver string to
411+ semver. It looks for the first digit in a string, and consumes all
412+ remaining characters which satisfy at least a partial semver (e.g., ` 1 ` ,
413+ ` 1.2 ` , ` 1.2.3 ` ) up to the max permitted length (256 characters). Longer
414+ versions are simply truncated (` 4.6.3.9.2-alpha2 ` becomes ` 4.6.3 ` ). All
415+ surrounding text is simply ignored (` v3.4 replaces v3.3.1 ` becomes
416+ ` 3.4.0 ` ). Only text which lacks digits will fail coercion (` version one `
417+ is not valid). The maximum length for any semver component considered for
418+ coercion is 16 characters; longer components will be ignored
419+ (` 10000000000000000.4.7.4 ` becomes ` 4.7.4 ` ). The maximum value for any
420+ semver component is ` Integer.MAX_SAFE_INTEGER || (2**53 - 1) ` ; higher value
421+ components are invalid (` 9999999999999999.4.7.4 ` is likely invalid).
422+
423+ If the ` options.rtl ` flag is set, then ` coerce ` will return the right-most
424+ coercible tuple that does not share an ending index with a longer coercible
425+ tuple. For example, ` 1.2.3.4 ` will return ` 2.3.4 ` in rtl mode, not
426+ ` 4.0.0 ` . ` 1.2.3/4 ` will return ` 4.0.0 ` , because the ` 4 ` is not a part of
427+ any other overlapping SemVer tuple.
415428
416429### Clean
417430
0 commit comments