jspm / sver

Simple Semver and SemverRange classes
MIT License
16 stars 4 forks source link

index.d.ts #3

Open GongT opened 4 years ago

GongT commented 4 years ago

export const semverRegEx: RegExp;
export const shortSemverRegEx: RegExp;

export class Semver {
    constructor(version: string);

    readonly major: number;
    readonly minor: number;
    readonly patch: number;
    readonly pre: string;
    readonly build: string;
    readonly tag: string;

    gt(version: Semver | string): boolean;

    lt(version: Semver | string): boolean;

    eq(version: Semver | string): boolean;

    matches(range: SemverRange | string, unstable ?: boolean): boolean

    static isValid(version: string): boolean;

    static compare(v1: string | Semver, v2: string | Semver): number;
}

export class SemverRange {
    constructor(versionRange: string);

    readonly isExact: boolean;

    readonly isExactSemver: boolean;

    readonly isExactTag: boolean;

    readonly isStable: boolean;

    readonly isMajor: boolean;

    readonly isWildcard: boolean;

    readonly type: 'wildcard' | 'major' | 'stable' | 'exact';
    readonly version: Semver;

    gt(range: SemverRange | string): boolean;

    lt(range: SemverRange | string): boolean;

    eq(range: SemverRange | string): boolean;

    has(versions: Semver | string, unstable: boolean): Semver;

    contains(range: SemverRange | string): boolean ;

    intersect(range: SemverRange | string): boolean ;

    bestMatch(versions: (Semver | string)[], unstable: boolean): Semver;

    static match(range: SemverRange | string, version: Semver, unstable ?: boolean): boolean

    static isValid(version: string): boolean;

    static compare(r1: string | SemverRange, r2: string | SemverRange): number;
}
guybedford commented 4 years ago

Thank you! Would you consider posting this to DefinitelyTyped?

GongT commented 4 years ago

Why not just put this file in your repo🌚

I write this file because I want to import {map} from 'jspm' from my tool.

But tsc can not find module "sver" during compile.

If use DefinitelyTyped, jspm should add @types/sver into its dependencies.