mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
Merge pull request #3114 from jvilk/semver-fixes
[semver] Fixing type definition for satisfies to return a boolean.
This commit is contained in:
@@ -20,10 +20,9 @@ var loose:boolean;
|
||||
str = mod.valid(str);
|
||||
|
||||
str = mod.valid(str, loose);
|
||||
//TODO maybe add an enum for release?
|
||||
str = mod.inc(str, str, loose);
|
||||
|
||||
//Comparison
|
||||
// Comparison
|
||||
bool = mod.gt(v1, v2, loose);
|
||||
bool = mod.gte(v1, v2, loose);
|
||||
bool = mod.lt(v1, v2, loose);
|
||||
@@ -34,9 +33,9 @@ bool = mod.cmp(v1, x, v2, loose);
|
||||
num = mod.compare(v1, v2, loose);
|
||||
num = mod.rcompare(v1, v2, loose);
|
||||
|
||||
//Ranges
|
||||
// Ranges
|
||||
str = mod.validRange(str, loose);
|
||||
str = mod.satisfies(version, str, loose);
|
||||
bool = mod.satisfies(version, str, loose);
|
||||
str = mod.maxSatisfying(versions, str, loose);
|
||||
bool = mod.gtr(version, str, loose);
|
||||
bool = mod.ltr(version, str, loose);
|
||||
|
||||
Vendored
+99
-49
@@ -4,72 +4,122 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module SemVerModule {
|
||||
/**
|
||||
* Return the parsed version, or null if it's not valid.
|
||||
*/
|
||||
function valid(v: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||
*/
|
||||
function inc(v: string, release: string, loose?: boolean): string;
|
||||
|
||||
function valid(v:string, loose?:boolean):string; // Return the parsed version, or null if it's not valid.
|
||||
//TODO maybe add an enum for release?
|
||||
function inc(v:string, release:string, loose?:boolean):string; // Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||
// Comparison
|
||||
/**
|
||||
* v1 > v2
|
||||
*/
|
||||
function gt(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 >= v2
|
||||
*/
|
||||
function gte(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 < v2
|
||||
*/
|
||||
function lt(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 <= v2
|
||||
*/
|
||||
function lte(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||
*/
|
||||
function eq(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 != v2 The opposite of eq.
|
||||
*/
|
||||
function neq(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Pass in a comparison string, and it'll call the corresponding semver comparison function. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
|
||||
*/
|
||||
function cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||
*/
|
||||
function compare(v1: string, v2: string, loose?: boolean): number;
|
||||
/**
|
||||
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||
*/
|
||||
function rcompare(v1: string, v2: string, loose?: boolean): number;
|
||||
|
||||
//Comparison
|
||||
function gt(v1:string, v2:string, loose?:boolean):boolean; // v1 > v2
|
||||
function gte(v1:string, v2:string, loose?:boolean):boolean; // v1 >= v2
|
||||
function lt(v1:string, v2:string, loose?:boolean):boolean; // v1 < v2
|
||||
function lte(v1:string, v2:string, loose?:boolean):boolean; // v1 <= v2
|
||||
function eq(v1:string, v2:string, loose?:boolean):boolean; // v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||
function neq(v1:string, v2:string, loose?:boolean):boolean; // v1 != v2 The opposite of eq.
|
||||
function cmp(v1:string, comparator:any, v2:string, loose?:boolean):boolean; // Pass in a comparison string, and it'll call the corresponding function above. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
|
||||
function compare(v1:string, v2:string, loose?:boolean):number; // Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||
function rcompare(v1:string, v2:string, loose?:boolean):number; // The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||
|
||||
//Ranges
|
||||
function validRange(range:string, loose?:boolean):string; // Return the valid range or null if it's not valid
|
||||
function satisfies(version:string, range:string, loose?:boolean):string; // Return true if the version satisfies the range.
|
||||
function maxSatisfying(versions:string[], range:string, loose?:boolean):string; // Return the highest version in the list that satisfies the range, or null if none of them do.
|
||||
function gtr(version:string, range:string, loose?:boolean):boolean; // Return true if version is greater than all the versions possible in the range.
|
||||
function ltr(version:string, range:string, loose?:boolean):boolean; // Return true if version is less than all the versions possible in the range.
|
||||
function outside(version:string, range:string, hilo:string, loose?:boolean):boolean; // Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
// Ranges
|
||||
/**
|
||||
* Return the valid range or null if it's not valid
|
||||
*/
|
||||
function validRange(range: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return true if the version satisfies the range.
|
||||
*/
|
||||
function satisfies(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return the highest version in the list that satisfies the range, or null if none of them do.
|
||||
*/
|
||||
function maxSatisfying(versions: string[], range: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return true if version is greater than all the versions possible in the range.
|
||||
*/
|
||||
function gtr(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return true if version is less than all the versions possible in the range.
|
||||
*/
|
||||
function ltr(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
*/
|
||||
function outside(version: string, range: string, hilo: string, loose?: boolean): boolean;
|
||||
|
||||
class SemVerBase {
|
||||
raw:string;
|
||||
loose:boolean;
|
||||
format():string;
|
||||
inspect():string;
|
||||
toString():string;
|
||||
raw: string;
|
||||
loose: boolean;
|
||||
format(): string;
|
||||
inspect(): string;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class SemVer extends SemVerBase {
|
||||
constructor(version:string, loose?:boolean);
|
||||
class SemVer extends SemVerBase {
|
||||
constructor(version: string, loose?: boolean);
|
||||
|
||||
major:number;
|
||||
minor:number;
|
||||
patch:number;
|
||||
version:string;
|
||||
build:string[];
|
||||
prerelease:string[];
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
version: string;
|
||||
build: string[];
|
||||
prerelease: string[];
|
||||
|
||||
compare(other:SemVer):number;
|
||||
compareMain(other:SemVer):number;
|
||||
comparePre(other:SemVer):number;
|
||||
inc(release:string):SemVer;
|
||||
compare(other:SemVer): number;
|
||||
compareMain(other:SemVer): number;
|
||||
comparePre(other:SemVer): number;
|
||||
inc(release: string): SemVer;
|
||||
}
|
||||
|
||||
class Comparator extends SemVerBase {
|
||||
constructor(comp:string, loose?:boolean);
|
||||
constructor(comp: string, loose?: boolean);
|
||||
|
||||
semver:SemVer;
|
||||
operator:string;
|
||||
value:boolean;
|
||||
parse(comp:string) :void;
|
||||
test(version:SemVer):boolean;
|
||||
semver: SemVer;
|
||||
operator: string;
|
||||
value: boolean;
|
||||
parse(comp: string): void;
|
||||
test(version:SemVer): boolean;
|
||||
}
|
||||
|
||||
class Range extends SemVerBase {
|
||||
constructor(range:string, loose?:boolean);
|
||||
constructor(range: string, loose?: boolean);
|
||||
|
||||
set:Comparator[][];
|
||||
parseRange(range:string):Comparator[];
|
||||
test(version:SemVer):boolean;
|
||||
set: Comparator[][];
|
||||
parseRange(range: string): Comparator[];
|
||||
test(version: SemVer): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "semver" {
|
||||
export = SemVerModule;
|
||||
export = SemVerModule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user