@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
72 lines (71 loc) • 4.24 kB
TypeScript
import { Range, SemVer } from 'semver';
/**
* A version written as its source string (e.g. `1.5-8`, `4.3.0`), as it appears in a `DESCRIPTION`, the signature
* database, or a bound. Distinct from a parsed {@link RVersion}: use {@link RVersion.parse}/{@link RVersion.compare}
* to order these. An alias for `string` that documents intent -- prefer it over a bare `string` for version values.
*/
export type VersionString = string;
/** A parsed R package version: a comparable {@link SemVer} that also keeps its original string as `.str`. */
export type RVersion = SemVer & {
str: string;
};
/** Helpers for R package versions (`1.2-3` style), which are freer than SemVer. */
export declare const RVersion: {
readonly name: "RVersion";
/**
* Parse an R version string into a {@link SemVer}, normalizing R's freer scheme (e.g. `0.4-9`). Unlike
* `new SemVer(version)` this coerces where needed; the original string is available via `.str`. Returns
* undefined (never throws) when the string cannot be coerced to a version at all.
* @see {@link RVersion.parseOrZero}
*/
readonly parse: (this: void, version: string) => RVersion | undefined;
/**
* Compare two R version strings following R's `numeric_version` scheme: split on `.` and `-`, compare
* numerically, shorter versions padded with zeros (`0.4-9 < 0.4.10 < 1.0`). Negative/zero/positive for
* `a` less than/equal to/greater than `b`.
*/
readonly compare: (this: void, a: string | undefined, b: string | undefined) => number;
/**
* Like {@link parse} but never undefined: a truly un-coercible version sorts as `0.0.0` while keeping its
* original string as `.str`, so it stays usable as a sort key.
* @see {@link RVersion.parse}
*/
readonly parseOrZero: (this: void, version: string) => RVersion;
/** The highest of some version strings by R's `numeric_version` order (`0.9.0 < 0.10.0`); undefined if none. */
readonly highest: (this: void, versions: Iterable<string>) => string | undefined;
};
/** the release date of an R version, matched by its `major.minor`, or `undefined` for versions older than the table */
export declare function rReleaseDate(version: string): Date | undefined;
/** Helpers for R package version ranges (DESCRIPTION constraints like `>= 0.4-9`). */
export declare const RRange: {
readonly name: "RRange";
/**
* Parse an R version range string into a {@link Range}, normalizing R's freer scheme. The original range
* string is available via `.str`.
*
* This never throws: an unparseable constraint (e.g. `>= abc`, or a git/URL "version" from a lockfile) yields
* `undefined` rather than aborting the caller, so a malformed constraint is *detectable* and simply contributes
* no version bound. Parsing is attempted first verbatim, then after normalizing R's scheme to SemVer.
*/
readonly parse: (this: void, range: string) => (Range & {
str: string;
}) | undefined;
/**
* Whether an R version string satisfies a range constraint, normalizing R's freer scheme on both sides.
* `range` may be a parsed {@link Range} or a raw constraint string. Returns `false` if either is unparseable
* (never throws), so a malformed version/constraint simply does not match.
*/
readonly satisfies: (this: void, version: string, range: Range | string) => boolean;
/**
* The range every one of `ranges` allows (semver reads a space-separated list as a conjunction). `undefined` if
* none were given or the combination is unparseable; it may still be a range no version satisfies, which
* {@link RVersion.parse|minVersion} reports.
*/
readonly intersect: (this: void, ranges: readonly Range[]) => (Range & {
str: string;
}) | undefined;
/** how a set of alternative requirements reads, in semver's `a || b` form (for reporting, not for parsing back) */
readonly formatAlternatives: (this: void, ranges: readonly Range[]) => string;
/** whether `version` satisfies at least one of `ranges` (an empty list constrains nothing, so it does) */
readonly satisfiesAny: (this: void, version: string, ranges: readonly Range[]) => boolean;
};