@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
12 lines • 649 B
JavaScript
function verCmp(a, b) {
const getComponents = v => v.split(/[-+]/)[0].split('.').map(i => +i);
const aComponents = getComponents(a);
const bComponents = getComponents(b);
const base = Math.max(...aComponents, ...bComponents) + 1;
const componentsToNumber = components => components.reverse().reduce((acc, n, idx) => acc + n * base ** idx, 0);
return componentsToNumber(aComponents) - componentsToNumber(bComponents);
}
export default function semverSatisfies(version, geVersion, ltVersion) {
return verCmp(version, geVersion) >= 0 && (ltVersion == null || verCmp(version, ltVersion) < 0);
}
//# sourceMappingURL=semver-satisfies.js.map