\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26537}{}\doxysection{Install}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26537}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install -\/-\/save semver}
\DoxyCodeLine{````}
\DoxyCodeLine{}
\DoxyCodeLine{\#\# Usage}
\DoxyCodeLine{}
\DoxyCodeLine{As a node module:}
\DoxyCodeLine{}
\DoxyCodeLine{```js}
\DoxyCodeLine{const semver = require('semver')}
\DoxyCodeLine{}
\DoxyCodeLine{semver.valid('1.2.3') // '1.2.3'}
\DoxyCodeLine{semver.valid('a.b.c') // null}
\DoxyCodeLine{semver.clean('  =v1.2.3   ') // '1.2.3'}
\DoxyCodeLine{semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 -\/ 7.2.3') // true}
\DoxyCodeLine{semver.gt('1.2.3', '9.8.7') // false}
\DoxyCodeLine{semver.lt('1.2.3', '9.8.7') // true}
\DoxyCodeLine{semver.minVersion('>=1.0.0') // '1.0.0'}
\DoxyCodeLine{semver.valid(semver.coerce('v2')) // '2.0.0'}
\DoxyCodeLine{semver.valid(semver.coerce('42.6.7.9.3-\/alpha')) // '42.6.7' }

\end{DoxyCode}


As a command-\/line utility\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ semver -\/h}
\DoxyCodeLine{}
\DoxyCodeLine{A JavaScript implementation of the https://semver.org/ specification}
\DoxyCodeLine{Copyright Isaac Z. Schlueter}
\DoxyCodeLine{}
\DoxyCodeLine{Usage: semver [options] <version> [<version> [...]]}
\DoxyCodeLine{Prints valid versions sorted by SemVer precedence}
\DoxyCodeLine{}
\DoxyCodeLine{Options:}
\DoxyCodeLine{-\/r -\/-\/range <range>}
\DoxyCodeLine{        Print versions that match the specified range.}
\DoxyCodeLine{}
\DoxyCodeLine{-\/i -\/-\/increment [<level>]}
\DoxyCodeLine{        Increment a version by the specified level.  Level can}
\DoxyCodeLine{        be one of: major, minor, patch, premajor, preminor,}
\DoxyCodeLine{        prepatch, or prerelease.  Default level is 'patch'.}
\DoxyCodeLine{        Only one version may be specified.}
\DoxyCodeLine{}
\DoxyCodeLine{-\/-\/preid <identifier>}
\DoxyCodeLine{        Identifier to be used to prefix premajor, preminor,}
\DoxyCodeLine{        prepatch or prerelease version increments.}
\DoxyCodeLine{}
\DoxyCodeLine{-\/l -\/-\/loose}
\DoxyCodeLine{        Interpret versions and ranges loosely}
\DoxyCodeLine{}
\DoxyCodeLine{-\/p -\/-\/include-\/prerelease}
\DoxyCodeLine{        Always include prerelease versions in range matching}
\DoxyCodeLine{}
\DoxyCodeLine{-\/c -\/-\/coerce}
\DoxyCodeLine{        Coerce a string into SemVer if possible}
\DoxyCodeLine{        (does not imply -\/-\/loose)}
\DoxyCodeLine{}
\DoxyCodeLine{Program exits successfully if any valid version satisfies}
\DoxyCodeLine{all supplied ranges, and prints all satisfying versions.}
\DoxyCodeLine{}
\DoxyCodeLine{If no satisfying versions are found, then exits failure.}
\DoxyCodeLine{}
\DoxyCodeLine{Versions are printed in ascending order, so supplying}
\DoxyCodeLine{multiple versions to the utility will just sort them. }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26538}{}\doxysection{Versions}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26538}
A \char`\"{}version\char`\"{} is described by the {\ttfamily v2.\+0.\+0} specification found at \href{https://semver.org/}{\texttt{ https\+://semver.\+org/}}.

A leading {\ttfamily \char`\"{}=\char`\"{}} or {\ttfamily \char`\"{}v\char`\"{}} character is stripped off and ignored.\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26539}{}\doxysection{Ranges}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26539}
A {\ttfamily version range} is a set of {\ttfamily comparators} which specify versions that satisfy the range.

A {\ttfamily comparator} is composed of an {\ttfamily operator} and a {\ttfamily version}. The set of primitive {\ttfamily operators} is\+:


\begin{DoxyItemize}
\item {\ttfamily $<$} Less than
\item {\ttfamily $<$=} Less than or equal to
\item {\ttfamily $>$} Greater than
\item {\ttfamily $>$=} Greater than or equal to
\item {\ttfamily =} Equal. If no operator is specified, then equality is assumed, so this operator is optional, but MAY be included.
\end{DoxyItemize}

For example, the comparator {\ttfamily $>$=1.\+2.\+7} would match the versions {\ttfamily 1.\+2.\+7}, {\ttfamily 1.\+2.\+8}, {\ttfamily 2.\+5.\+3}, and {\ttfamily 1.\+3.\+9}, but not the versions {\ttfamily 1.\+2.\+6} or {\ttfamily 1.\+1.\+0}.

Comparators can be joined by whitespace to form a {\ttfamily comparator set}, which is satisfied by the {\bfseries{intersection}} of all of the comparators it includes.

A range is composed of one or more comparator sets, joined by {\ttfamily $\vert$$\vert$}. A version matches a range if and only if every comparator in at least one of the {\ttfamily $\vert$$\vert$}-\/separated comparator sets is satisfied by the version.

For example, the range {\ttfamily $>$=1.\+2.\+7 $<$1.\+3.\+0} would match the versions {\ttfamily 1.\+2.\+7}, {\ttfamily 1.\+2.\+8}, and {\ttfamily 1.\+2.\+99}, but not the versions {\ttfamily 1.\+2.\+6}, {\ttfamily 1.\+3.\+0}, or {\ttfamily 1.\+1.\+0}.

The range {\ttfamily 1.\+2.\+7 $\vert$$\vert$ $>$=1.\+2.\+9 $<$2.\+0.\+0} would match the versions {\ttfamily 1.\+2.\+7}, {\ttfamily 1.\+2.\+9}, and {\ttfamily 1.\+4.\+6}, but not the versions {\ttfamily 1.\+2.\+8} or {\ttfamily 2.\+0.\+0}.\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26540}{}\doxysubsection{Prerelease Tags}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26540}
If a version has a prerelease tag (for example, {\ttfamily 1.\+2.\+3-\/alpha.\+3}) then it will only be allowed to satisfy comparator sets if at least one comparator with the same {\ttfamily \mbox{[}major, minor, patch\mbox{]}} tuple also has a prerelease tag.

For example, the range {\ttfamily $>$1.\+2.\+3-\/alpha.\+3} would be allowed to match the version {\ttfamily 1.\+2.\+3-\/alpha.\+7}, but it would {\itshape not} be satisfied by {\ttfamily 3.\+4.\+5-\/alpha.\+9}, even though {\ttfamily 3.\+4.\+5-\/alpha.\+9} is technically \char`\"{}greater than\char`\"{} {\ttfamily 1.\+2.\+3-\/alpha.\+3} according to the Sem\+Ver sort rules. The version range only accepts prerelease tags on the {\ttfamily 1.\+2.\+3} version. The version {\ttfamily 3.\+4.\+5} {\itshape would} satisfy the range, because it does not have a prerelease flag, and {\ttfamily 3.\+4.\+5} is greater than {\ttfamily 1.\+2.\+3-\/alpha.\+7}.

The purpose for this behavior is twofold. First, prerelease versions frequently are updated very quickly, and contain many breaking changes that are (by the author\textquotesingle{}s design) not yet fit for public consumption. Therefore, by default, they are excluded from range matching semantics.

Second, a user who has opted into using a prerelease version has clearly indicated the intent to use {\itshape that specific} set of alpha/beta/rc versions. By including a prerelease tag in the range, the user is indicating that they are aware of the risk. However, it is still not appropriate to assume that they have opted into taking a similar risk on the {\itshape next} set of prerelease versions.

Note that this behavior can be suppressed (treating all prerelease versions as if they were normal versions, for the purpose of range matching) by setting the {\ttfamily include\+Prerelease} flag on the options object to any \href{https://github.com/npm/node-semver\#functions}{\texttt{ functions}} that do range matching.\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26541}{}\doxysubsubsection{Prerelease Identifiers}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26541}
The method {\ttfamily .inc} takes an additional {\ttfamily identifier} string argument that will append the value of the string as a prerelease identifier\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{semver.inc('1.2.3', 'prerelease', 'beta')}
\DoxyCodeLine{// '1.2.4-\/beta.0' }

\end{DoxyCode}


command-\/line example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ semver 1.2.3 -\/i prerelease -\/-\/preid beta}
\DoxyCodeLine{1.2.4-\/beta.0 }

\end{DoxyCode}


Which then can be used to increment further\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ semver 1.2.4-\/beta.0 -\/i prerelease}
\DoxyCodeLine{1.2.4-\/beta.1 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26542}{}\doxysubsection{Advanced Range Syntax}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26542}
Advanced range syntax desugars to primitive comparators in deterministic ways.

Advanced ranges may be combined in the same way as primitive comparators using white space or {\ttfamily $\vert$$\vert$}.\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26543}{}\doxysubsubsection{Hyphen Ranges $<$tt$>$\+X.\+Y.\+Z -\/ A.\+B.\+C$<$/tt$>$}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26543}
Specifies an inclusive set.


\begin{DoxyItemize}
\item {\ttfamily 1.\+2.\+3 -\/ 2.\+3.\+4} \+:= {\ttfamily $>$=1.\+2.\+3 $<$=2.\+3.\+4}
\end{DoxyItemize}

If a partial version is provided as the first version in the inclusive range, then the missing pieces are replaced with zeroes.


\begin{DoxyItemize}
\item {\ttfamily 1.\+2 -\/ 2.\+3.\+4} \+:= {\ttfamily $>$=1.\+2.\+0 $<$=2.\+3.\+4}
\end{DoxyItemize}

If a partial version is provided as the second version in the inclusive range, then all versions that start with the supplied parts of the tuple are accepted, but nothing that would be greater than the provided tuple parts.


\begin{DoxyItemize}
\item {\ttfamily 1.\+2.\+3 -\/ 2.\+3} \+:= {\ttfamily $>$=1.\+2.\+3 $<$2.\+4.\+0}
\item {\ttfamily 1.\+2.\+3 -\/ 2} \+:= {\ttfamily $>$=1.\+2.\+3 $<$3.\+0.\+0}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26544}{}\doxysubsubsection{X-\/\+Ranges $<$tt$>$1.\+2.\+x$<$/tt$>$ $<$tt$>$1.\+X$<$/tt$>$ $<$tt$>$1.\+2.$\ast$$<$/tt$>$ $<$tt$>$$\ast$$<$/tt$>$}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26544}
Any of {\ttfamily X}, {\ttfamily x}, or {\ttfamily $\ast$} may be used to \char`\"{}stand in\char`\"{} for one of the numeric values in the {\ttfamily \mbox{[}major, minor, patch\mbox{]}} tuple.


\begin{DoxyItemize}
\item {\ttfamily $\ast$} \+:= {\ttfamily $>$=0.\+0.\+0} (Any version satisfies)
\item {\ttfamily 1.\+x} \+:= {\ttfamily $>$=1.\+0.\+0 $<$2.\+0.\+0} (Matching major version)
\item {\ttfamily 1.\+2.\+x} \+:= {\ttfamily $>$=1.\+2.\+0 $<$1.\+3.\+0} (Matching major and minor versions)
\end{DoxyItemize}

A partial version range is treated as an X-\/\+Range, so the special character is in fact optional.


\begin{DoxyItemize}
\item {\ttfamily \char`\"{}\char`\"{}} (empty string) \+:= {\ttfamily $\ast$} \+:= {\ttfamily $>$=0.\+0.\+0}
\item {\ttfamily 1} \+:= {\ttfamily 1.\+x.\+x} \+:= {\ttfamily $>$=1.\+0.\+0 $<$2.\+0.\+0}
\item {\ttfamily 1.\+2} \+:= {\ttfamily 1.\+2.\+x} \+:= {\ttfamily $>$=1.\+2.\+0 $<$1.\+3.\+0}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26545}{}\doxysubsubsection{Tilde Ranges $<$tt$>$$\sim$1.\+2.\+3$<$/tt$>$ $<$tt$>$$\sim$1.\+2$<$/tt$>$ $<$tt$>$$\sim$1$<$/tt$>$}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26545}
Allows patch-\/level changes if a minor version is specified on the comparator. Allows minor-\/level changes if not.


\begin{DoxyItemize}
\item {\ttfamily $\sim$1.2.\+3} \+:= {\ttfamily $>$=1.\+2.\+3 $<$1.(2+1).0} \+:= {\ttfamily $>$=1.\+2.\+3 $<$1.\+3.\+0}
\item {\ttfamily $\sim$1.2} \+:= {\ttfamily $>$=1.\+2.\+0 $<$1.(2+1).0} \+:= {\ttfamily $>$=1.\+2.\+0 $<$1.\+3.\+0} (Same as {\ttfamily 1.\+2.\+x})
\item {\ttfamily $\sim$1} \+:= {\ttfamily $>$=1.\+0.\+0 $<$(1+1).0.\+0} \+:= {\ttfamily $>$=1.\+0.\+0 $<$2.\+0.\+0} (Same as {\ttfamily 1.\+x})
\item {\ttfamily $\sim$0.2.\+3} \+:= {\ttfamily $>$=0.\+2.\+3 $<$0.(2+1).0} \+:= {\ttfamily $>$=0.\+2.\+3 $<$0.\+3.\+0}
\item {\ttfamily $\sim$0.2} \+:= {\ttfamily $>$=0.\+2.\+0 $<$0.(2+1).0} \+:= {\ttfamily $>$=0.\+2.\+0 $<$0.\+3.\+0} (Same as {\ttfamily 0.\+2.\+x})
\item {\ttfamily $\sim$0} \+:= {\ttfamily $>$=0.\+0.\+0 $<$(0+1).0.\+0} \+:= {\ttfamily $>$=0.\+0.\+0 $<$1.\+0.\+0} (Same as {\ttfamily 0.\+x})
\item {\ttfamily $\sim$1.2.\+3-\/beta.\+2} \+:= {\ttfamily $>$=1.\+2.\+3-\/beta.\+2 $<$1.\+3.\+0} Note that prereleases in the {\ttfamily 1.\+2.\+3} version will be allowed, if they are greater than or equal to {\ttfamily beta.\+2}. So, {\ttfamily 1.\+2.\+3-\/beta.\+4} would be allowed, but {\ttfamily 1.\+2.\+4-\/beta.\+2} would not, because it is a prerelease of a different {\ttfamily \mbox{[}major, minor, patch\mbox{]}} tuple.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26546}{}\doxysubsubsection{Caret Ranges $<$tt$>$$^\wedge$1.\+2.\+3$<$/tt$>$ $<$tt$>$$^\wedge$0.\+2.\+5$<$/tt$>$ $<$tt$>$$^\wedge$0.\+0.\+4$<$/tt$>$}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26546}
Allows changes that do not modify the left-\/most non-\/zero digit in the {\ttfamily \mbox{[}major, minor, patch\mbox{]}} tuple. In other words, this allows patch and minor updates for versions {\ttfamily 1.\+0.\+0} and above, patch updates for versions {\ttfamily 0.\+X $>$=0.\+1.\+0}, and {\itshape no} updates for versions {\ttfamily 0.\+0.\+X}.

Many authors treat a {\ttfamily 0.\+x} version as if the {\ttfamily x} were the major \char`\"{}breaking-\/change\char`\"{} indicator.

Caret ranges are ideal when an author may make breaking changes between {\ttfamily 0.\+2.\+4} and {\ttfamily 0.\+3.\+0} releases, which is a common practice. However, it presumes that there will {\itshape not} be breaking changes between {\ttfamily 0.\+2.\+4} and {\ttfamily 0.\+2.\+5}. It allows for changes that are presumed to be additive (but non-\/breaking), according to commonly observed practices.


\begin{DoxyItemize}
\item {\ttfamily $^\wedge$1.2.\+3} \+:= {\ttfamily $>$=1.\+2.\+3 $<$2.\+0.\+0}
\item {\ttfamily $^\wedge$0.2.\+3} \+:= {\ttfamily $>$=0.\+2.\+3 $<$0.\+3.\+0}
\item {\ttfamily $^\wedge$0.0.\+3} \+:= {\ttfamily $>$=0.\+0.\+3 $<$0.\+0.\+4}
\item {\ttfamily $^\wedge$1.2.\+3-\/beta.\+2} \+:= {\ttfamily $>$=1.\+2.\+3-\/beta.\+2 $<$2.\+0.\+0} Note that prereleases in the {\ttfamily 1.\+2.\+3} version will be allowed, if they are greater than or equal to {\ttfamily beta.\+2}. So, {\ttfamily 1.\+2.\+3-\/beta.\+4} would be allowed, but {\ttfamily 1.\+2.\+4-\/beta.\+2} would not, because it is a prerelease of a different {\ttfamily \mbox{[}major, minor, patch\mbox{]}} tuple.
\item {\ttfamily $^\wedge$0.0.\+3-\/beta} \+:= {\ttfamily $>$=0.\+0.\+3-\/beta $<$0.\+0.\+4} Note that prereleases in the {\ttfamily 0.\+0.\+3} version {\itshape only} will be allowed, if they are greater than or equal to {\ttfamily beta}. So, {\ttfamily 0.\+0.\+3-\/pr.\+2} would be allowed.
\end{DoxyItemize}

When parsing caret ranges, a missing {\ttfamily patch} value desugars to the number {\ttfamily 0}, but will allow flexibility within that value, even if the major and minor versions are both {\ttfamily 0}.


\begin{DoxyItemize}
\item {\ttfamily $^\wedge$1.2.\+x} \+:= {\ttfamily $>$=1.\+2.\+0 $<$2.\+0.\+0}
\item {\ttfamily $^\wedge$0.0.\+x} \+:= {\ttfamily $>$=0.\+0.\+0 $<$0.\+1.\+0}
\item {\ttfamily $^\wedge$0.0} \+:= {\ttfamily $>$=0.\+0.\+0 $<$0.\+1.\+0}
\end{DoxyItemize}

A missing {\ttfamily minor} and {\ttfamily patch} values will desugar to zero, but also allow flexibility within those values, even if the major version is zero.


\begin{DoxyItemize}
\item {\ttfamily $^\wedge$1.x} \+:= {\ttfamily $>$=1.\+0.\+0 $<$2.\+0.\+0}
\item {\ttfamily $^\wedge$0.x} \+:= {\ttfamily $>$=0.\+0.\+0 $<$1.\+0.\+0}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26547}{}\doxysubsection{Range Grammar}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26547}
Putting all this together, here is a Backus-\/\+Naur grammar for ranges, for the benefit of parser authors\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{range-\/set  ::= range ( logical-\/or range ) *}
\DoxyCodeLine{logical-\/or ::= ( ' ' ) * '||' ( ' ' ) *}
\DoxyCodeLine{range      ::= hyphen | simple ( ' ' simple ) * | ''}
\DoxyCodeLine{hyphen     ::= partial ' -\/ ' partial}
\DoxyCodeLine{simple     ::= primitive | partial | tilde | caret}
\DoxyCodeLine{primitive  ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial}
\DoxyCodeLine{partial    ::= xr ( '.' xr ( '.' xr qualifier ? )? )?}
\DoxyCodeLine{xr         ::= 'x' | 'X' | '*' | nr}
\DoxyCodeLine{nr         ::= '0' | ['1'-\/'9'] ( ['0'-\/'9'] ) *}
\DoxyCodeLine{tilde      ::= '\string~' partial}
\DoxyCodeLine{caret      ::= '\string^' partial}
\DoxyCodeLine{qualifier  ::= ( '-\/' pre )? ( '+' build )?}
\DoxyCodeLine{pre        ::= parts}
\DoxyCodeLine{build      ::= parts}
\DoxyCodeLine{parts      ::= part ( '.' part ) *}
\DoxyCodeLine{part       ::= nr | [-\/0-\/9A-\/Za-\/z]+ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26548}{}\doxysection{Functions}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26548}
All methods and classes take a final {\ttfamily options} object argument. All options in this object are {\ttfamily false} by default. The options supported are\+:


\begin{DoxyItemize}
\item {\ttfamily loose} Be more forgiving about not-\/quite-\/valid semver strings. (Any resulting output will always be 100\% strict compliant, of course.) For backwards compatibility reasons, if the {\ttfamily options} argument is a boolean value instead of an object, it is interpreted to be the {\ttfamily loose} param.
\item {\ttfamily include\+Prerelease} Set to suppress the \href{https://github.com/npm/node-semver\#prerelease-tags}{\texttt{ default behavior}} of excluding prerelease tagged versions from ranges unless they are explicitly opted into.
\end{DoxyItemize}

Strict-\/mode Comparators and Ranges will be strict about the Sem\+Ver strings that they parse.


\begin{DoxyItemize}
\item {\ttfamily valid(v)}\+: Return the parsed version, or null if it\textquotesingle{}s not valid.
\item {\ttfamily inc(v, release)}\+: Return the version incremented by the release type ({\ttfamily major}, {\ttfamily premajor}, {\ttfamily minor}, {\ttfamily preminor}, {\ttfamily patch}, {\ttfamily prepatch}, or {\ttfamily prerelease}), or null if it\textquotesingle{}s not valid
\begin{DoxyItemize}
\item {\ttfamily premajor} in one call will bump the version up to the next major version and down to a prerelease of that major version. {\ttfamily preminor}, and {\ttfamily prepatch} work the same way.
\item If called from a non-\/prerelease version, the {\ttfamily prerelease} will work the same as {\ttfamily prepatch}. It increments the patch version, then makes a prerelease. If the input version is already a prerelease it simply increments it.
\end{DoxyItemize}
\item {\ttfamily prerelease(v)}\+: Returns an array of prerelease components, or null if none exist. Example\+: `prerelease(\textquotesingle{}1.\+2.\+3-\/alpha.\+1') -\/$>$ \mbox{[}\textquotesingle{}alpha\textquotesingle{}, 1\mbox{]}{\ttfamily  $\ast$}major(v){\ttfamily \+: Return the major version number. $\ast$}minor(v){\ttfamily \+: Return the minor version number. $\ast$}patch(v){\ttfamily \+: Return the patch version number. $\ast$}intersects(r1, r2, loose)\`{}\+: Return true if the two supplied ranges or comparators intersect.
\item {\ttfamily parse(v)}\+: Attempt to parse a string as a semantic version, returning either a {\ttfamily Sem\+Ver} object or {\ttfamily null}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26549}{}\doxysubsection{Comparison}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26549}

\begin{DoxyItemize}
\item {\ttfamily gt(v1, v2)}\+: {\ttfamily v1 $>$ v2}
\item {\ttfamily gte(v1, v2)}\+: {\ttfamily v1 $>$= v2}
\item {\ttfamily lt(v1, v2)}\+: {\ttfamily v1 $<$ v2}
\item {\ttfamily lte(v1, v2)}\+: {\ttfamily v1 $<$= v2}
\item {\ttfamily eq(v1, v2)}\+: {\ttfamily v1 == v2} This is true if they\textquotesingle{}re logically equivalent, even if they\textquotesingle{}re not the exact same string. You already know how to compare strings.
\item {\ttfamily neq(v1, v2)}\+: {\ttfamily v1 != v2} The opposite of {\ttfamily eq}.
\item {\ttfamily cmp(v1, comparator, v2)}\+: Pass in a comparison string, and it\textquotesingle{}ll call the corresponding function above. {\ttfamily \char`\"{}===\char`\"{}} and {\ttfamily \char`\"{}!==\char`\"{}} do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
\item {\ttfamily compare(v1, v2)}\+: Return {\ttfamily 0} if {\ttfamily v1 == v2}, or {\ttfamily 1} if {\ttfamily v1} is greater, or {\ttfamily -\/1} if {\ttfamily v2} is greater. Sorts in ascending order if passed to {\ttfamily Array.\+sort()}.
\item {\ttfamily rcompare(v1, v2)}\+: The reverse of compare. Sorts an array of versions in descending order when passed to {\ttfamily Array.\+sort()}.
\item {\ttfamily diff(v1, v2)}\+: Returns difference between two versions by the release type ({\ttfamily major}, {\ttfamily premajor}, {\ttfamily minor}, {\ttfamily preminor}, {\ttfamily patch}, {\ttfamily prepatch}, or {\ttfamily prerelease}), or null if the versions are the same.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26550}{}\doxysubsection{Comparators}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26550}

\begin{DoxyItemize}
\item {\ttfamily intersects(comparator)}\+: Return true if the comparators intersect
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26551}{}\doxysubsection{Ranges}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26551}

\begin{DoxyItemize}
\item {\ttfamily valid\+Range(range)}\+: Return the valid range or null if it\textquotesingle{}s not valid
\item {\ttfamily satisfies(version, range)}\+: Return true if the version satisfies the range.
\item {\ttfamily max\+Satisfying(versions, range)}\+: Return the highest version in the list that satisfies the range, or {\ttfamily null} if none of them do.
\item {\ttfamily min\+Satisfying(versions, range)}\+: Return the lowest version in the list that satisfies the range, or {\ttfamily null} if none of them do.
\item {\ttfamily min\+Version(range)}\+: Return the lowest version that can possibly match the given range.
\item {\ttfamily gtr(version, range)}\+: Return {\ttfamily true} if version is greater than all the versions possible in the range.
\item {\ttfamily ltr(version, range)}\+: Return {\ttfamily true} if version is less than all the versions possible in the range.
\item {\ttfamily outside(version, range, hilo)}\+: Return true if the version is outside the bounds of the range in either the high or low direction. The {\ttfamily hilo} argument must be either the string `'$>$\textquotesingle{}{\ttfamily or}\textquotesingle{}$<$\textquotesingle{}{\ttfamily . (This is the function called by}gtr{\ttfamily and}ltr{\ttfamily .) $\ast$}intersects(range)\`{}\+: Return true if any of the ranges comparators intersect
\end{DoxyItemize}

Note that, since ranges may be non-\/contiguous, a version might not be greater than a range, less than a range, {\itshape or} satisfy a range! For example, the range {\ttfamily 1.\+2 $<$1.\+2.\+9 $\vert$$\vert$ $>$2.\+0.\+0} would have a hole from {\ttfamily 1.\+2.\+9} until {\ttfamily 2.\+0.\+0}, so the version {\ttfamily 1.\+2.\+10} would not be greater than the range (because {\ttfamily 2.\+0.\+1} satisfies, which is higher), nor less than the range (since {\ttfamily 1.\+2.\+8} satisfies, which is lower), and it also does not satisfy the range.

If you want to know if a version satisfies or does not satisfy a range, use the {\ttfamily satisfies(version, range)} function.\hypertarget{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26552}{}\doxysubsection{Coercion}\label{md_sfcode_node_modules_semver_intersect_node_modules_semver_README_autotoc_md26552}

\begin{DoxyItemize}
\item {\ttfamily coerce(version)}\+: Coerces a string to semver if possible
\end{DoxyItemize}

This aims to provide a very forgiving translation of a non-\/semver string to semver. It looks for the first digit in a string, and consumes all remaining characters which satisfy at least a partial semver (e.\+g., {\ttfamily 1}, {\ttfamily 1.\+2}, {\ttfamily 1.\+2.\+3}) up to the max permitted length (256 characters). Longer versions are simply truncated ({\ttfamily 4.\+6.\+3.\+9.\+2-\/alpha2} becomes {\ttfamily 4.\+6.\+3}). All surrounding text is simply ignored ({\ttfamily v3.\+4 replaces v3.\+3.\+1} becomes {\ttfamily 3.\+4.\+0}). Only text which lacks digits will fail coercion ({\ttfamily version one} is not valid). The maximum length for any semver component considered for coercion is 16 characters; longer components will be ignored ({\ttfamily 10000000000000000.\+4.\+7.\+4} becomes {\ttfamily 4.\+7.\+4}). The maximum value for any semver component is {\ttfamily Number.\+MAX\+\_\+\+SAFE\+\_\+\+INTEGER $\vert$$\vert$ (2$\ast$$\ast$53 -\/ 1)}; higher value components are invalid ({\ttfamily 9999999999999999.\+4.\+7.\+4} is likely invalid). 