normalize-version
Version:
Formats a version number to be a required number of points
26 lines (24 loc) • 552 B
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = function(version, numberOfPoints) {
var n;
if (numberOfPoints == null) {
numberOfPoints = 3;
}
if (version == null) {
return null;
}
version = String(version);
if (!version.match(/\d/)) {
return null;
}
n = version.split(/\./);
if (n.length === 1 && n[0] === '') {
return null;
}
while (n.length < numberOfPoints) {
n.push('0');
}
return n.slice(0, numberOfPoints).join('.');
};
}).call(this);