updated by GasGit automation

This commit is contained in:
Bruce McPherson 2016-10-14 12:11:07 +01:00
parent 08b8899934
commit 2681411eaf

View file

@ -175,6 +175,41 @@ var Utils = (function (ns) {
return result;
};
/**
* generateUniqueString
* get a unique string
* @param {number} optAbcLength the length of the alphabetic prefix
* @return {string} a unique string
**/
ns.generateUniqueString = function (optAbcLength) {
var abcLength = ns.isUndefined(optAbcLength) ? 3 : optAbcLength;
return (new Date().getTime()).toString(36) + arbitraryString(abcLength) ;
};
/**
* get an arbitrary alpha string
* @param {number} length of the string to generate
* @return {string} an alpha string
**/
ns.arbitraryString = function (length) {
var s = '';
for (var i = 0; i < length; i++) {
s += String.fromCharCode(ns.randBetween ( 97,122));
}
return s;
}
/**
* randBetween
* get an random number between x and y
* @param {number} min the lower bound
* @param {number} max the upper bound
* @return {number} the random number
**/
ns.randBetween = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
ns.yesish = function(s) {
var t = s.toString().toLowerCase();
return t === "yes" || "y" || "true" || "1";