本文整理汇总了TypeScript中semver.compare函数的典型用法代码示例。如果您正苦于以下问题:TypeScript compare函数的具体用法?TypeScript compare怎么用?TypeScript compare使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compare函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: versionCompareFunction
export function versionCompareFunction(versionA: string, versionB: string): number {
if (!toolLib.isExplicitVersion(versionA) || !toolLib.isExplicitVersion(versionB)) {
throw tl.loc("VersionsCanNotBeCompared", versionA, versionB);
}
return semver.compare(versionA, versionB);
}
示例2:
schematicsToRun.sort((a, b) => {
const cmp = semver.compare(a.version, b.version);
// Revert to comparing the names of the collection if the versions are equal.
return cmp == 0 ? a.name.localeCompare(b.name) : cmp;
});
示例3: return
.filter(({ name, info, version, target }) => {
return (target && semver.compare(info.installed.version, version) < 0);
})
示例4: exec
import * as semver from "semver";
function exec(command: string) {
const result = shell.exec(command, { silent: true });
return (result.stdout as string).trim();
}
const PUBLISHED = (() => {
// Get the highest published version of any tag
const all = JSON.parse(exec(`npm show quicktype versions --json`));
return all[all.length - 1];
})();
const CURRENT = exec(`npm version`).match(/quicktype: '(.+)'/)[1];
switch (semver.compare(CURRENT, PUBLISHED)) {
case -1:
console.error(
`* package.json version is ${CURRENT} but ${PUBLISHED} is published. Patching...`
);
exec(`npm version ${PUBLISHED} --force --no-git-tag-version`);
shell.exec(`npm version patch --no-git-tag-version`);
break;
case 0:
console.error(
`* package.json version is ${CURRENT} but ${PUBLISHED} is published. Patching...`
);
shell.exec(`npm version patch --no-git-tag-version`);
break;
default:
// Greater than published, nothing to do
示例5:
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);
// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
comparatorResult = semver.rcompareIdentifiers(str, str);
versionsArr = semver.sort(['', new semver.SemVer('')]);
versionsArr = semver.rsort(['', new semver.SemVer('')]);
diff = semver.diff(v1, v2, loose);
// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, '<', loose);
示例6:
return result.sort((a, b) => semver.compare(b.version, a.version));
示例7: isOutdated
isOutdated(): boolean {
return semver.compare(this.installedVersion, this.latestVersion) < 0;
}
示例8:
str = semver.clean(str, loose);
str = semver.inc(str, str, loose);
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);
// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, x, v2, loose);
num = semver.compare(v1, v2, loose);
num = semver.rcompare(v1, v2, loose);
diff = semver.diff(v1, v2, loose);
// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, str, loose);
var ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;