You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
452 B
16 lines
452 B
'use strict';
|
|
|
|
exports.createGuid = function() {
|
|
function chunk() {
|
|
return Math.floor(Math.random() * 0x10000).toString(16);
|
|
}
|
|
return [chunk()+chunk(),chunk(),chunk(),chunk(),chunk()+chunk()+chunk()].join('-');
|
|
};
|
|
|
|
exports.ensure = function (value, description, predicate, map) {
|
|
if (predicate(value)) {
|
|
return map ? map(value) : value;
|
|
} else {
|
|
throw new Error(value + ' is not a ' + description);
|
|
}
|
|
};
|