new Utility()
Methods
- 
    
        
static checkInstance(fnName, valueName, value, cls)
 - 
    
    
Checks the type of a variable and throws if it is the wrong type
Parameters:
Name Type Description fnNamestring Name of the calling function (for cosmetic purposes)
valueNamestring Name of the function being checked (for cosmetic purposes)
value* The object to check
clsstring The expected type of the variable as reported by
typeofThrows:
- 
        
If
valueis not an object or not aninstanceof cls - Type
 - TypeError
 
 - 
        
 - 
    
        
static checkType(fnName, valueName, value, type)
 - 
    
    
Checks the type of a variable and throws if it is the wrong type
Parameters:
Name Type Description fnNamestring Name of the calling function (for cosmetic purposes)
valueNamestring Name of the function being checked (for cosmetic purposes)
value* The variable to check
typestring The expected type of the variable as reported by
typeofThrows:
- 
        
If
valueis nottypeof type - Type
 - TypeError
 
 - 
        
 - 
    
        
static createHiddenProp(obj, prop, val, roopt)
 - 
    
    
Creates a new property on an object that is hidden (non-enumerable) and optionally read-only. Syntactic sugar around
Object.definePropertyto help with readability.Parameters:
Name Type Attributes Default Description objobject The object to create the new property on
propstring The name of the new property
val* The value for the new property
roboolean <optional> 
false only (can't be written to).
falseif not specified. - 
    
        
async, static delay(ms) → {Promise}
 - 
    
    
Async version of setTimeout. To be replaced by timers/promises someday.
Parameters:
Name Type Description msnumber Number of milliseconds to delay. Passed to setTimeout.
Returns:
Promise -A Promise that resolves to
undefinedafter the specified number of milliseconds has passed. - 
    
        
static randomFloat(minopt, maxopt) → {number}
 - 
    
    
Returns a random integer <= min and >= max
Parameters:
Name Type Attributes Default Description minnumber <optional> 
0 Minimum number to return
maxnumber <optional> 
1 Maximum number to return
Returns:
number -A random float
 - 
    
        
static randomInt(minopt, maxopt) → {number}
 - 
    
    
Returns a random integer <= min and >= max
Parameters:
Name Type Attributes Default Description minnumber <optional> 
0 Minimum number to return
maxnumber <optional> 
(2**31)-1 Maximum number to return
Returns:
number -A random integer
 - 
    
        
static randomSeed(seed)
 - 
    
    
Seed the pseudo-random number generator (PRNG). Note that the sequence of random numbers will always be the same for the same seed.
Parameters:
Name Type Description seed* Takes any type and uses it as a seed for thte random number generator.
undefinedornullwill create a non-deterministic sequence of numbers. - 
    
        
static resolveFileOrString(str, opts) → {string}
 - 
    
    
Resolves a string to a filename and loads that file, or simply returns the string if it doesn't resolve to the file.
Parameters:
Name Type Description strstring A filename or string literal
optsObject Options for the resolution.
opts.basenamespecifies a folder of where to look for the files.opts.extspecifies a file extension (e.g..html) to append in looking for the file.Returns:
string -Returns the contents of the file if resolved to a file; otherwise, returns the original string