Repository URL to install this package:
|
Version:
3.1.2 ▾
|
const isString = x => typeof x === 'string';
// eslint-disable-next-line
const toSemVer = (x, target = '9+') => {
// make array always
if (isString(x)) {
// replace?
x = x.replace('v', '').split('.').map(Number);
}
let MAJOR = x[0];
let PATCH = x[1];
let MINOR = x[2];
const VERSION = {
0: MAJOR,
1: PATCH,
2: MINOR,
};
// array-like
Object.defineProperty(VERSION, 'length', {
value: 3,
});
Object.defineProperty(VERSION, 'MAJOR', {
value: MAJOR,
enumerable: true,
});
Object.defineProperty(VERSION, 'PATCH', {
value: PATCH,
enumerable: true,
});
Object.defineProperty(VERSION, 'MINOR', {
value: MINOR,
enumerable: true,
});
Object.defineProperty(VERSION, 'toString', {
value: () => 'current is: ' + x.join('.') + '; target is: ' + target,
});
return VERSION;
};
module.exports = toSemVer;
//# sourceMappingURL=toSemVer.js.map