loader(dir, master, reload)
arg type default optional description dir string / false the folder to load master string / true the direcory the folder is located in reload boolean false true whether to clear cache before requiring
snowflake
: Object
setCFG({epoche:int, datacenter:int, worker:int, hostname:string})
: setups global snowflaker, needs to be done before calling next or undonext(cb(snowflake))
: get the next snowflake (cb optional as long as sequence doesn't overflow)undo(snowflake, base)
: resolve a snowflake given in a given base encodinggetHostname()
: returns the hostname set withsetCFG()
snowflake.Base64Converter
: object
fromInt(number)
: convert number to base64toInt(string)
: convert base64 string to numberclass HTTPS_CERTS extends EventEmitter
- event
CHANGE
: fired when a cert file changessupported params:
ca
,cert
,passphrase
,key
,pfx
values have to be file locations as strings
arg type default optional resp http.ServerResponse / false msg string / true headerOverwrite object / true statusCode number 400 true
arg type default optional resp http.ServerResponse / false data everything thats json.stringifiable / true headerOverwrite object / true statusCode number 200 true
arg type default optional stream http.IncomingMessage / false callback function(err, data:Buffer) / false returns a Promise that resolves with data as a buffer
arg type default optional description ref string or object null false ether a url or an url object paramOverwrites object {} true request params to overwrite maxRedirects number 3 true the max redirects to follow returns a header object
arg type default optional description setCookie string null true string for 'Set-Cookie' header headers Object null true additional headers
arg type default optional description api string / false the api to request in master module string / false one of validationRequest
,dataChangeRequest
ormasterRequest
cb function(data) / false callback to call when master responds ...args / / true args to parse to the api
returns a promise that resolves with the matching rows
arg type default optional description connectionOrPool / / false the connection/pool to the mysql server query string / false the sql query params / / true params to replace ?
with in queryretrys number 3 true how often to retry when a request fails
returns as a padded string
arg type default optional description txt number/string / false the value to pad width number 1 true the target string's length z string/number 0 true what to pad with, length: 1 Removes all dublicate values from an array
arg type default optional description array array / false the array to filter
arg type default optional description req http.IncomingMessage / false the http request to parse the body of cb function(err, {has:[...]}) / false the callback getting fired when done
returns a random hex string
arg type default optional description length number / false the length of the random salt returns hash as a string
arg type default optional description algorithm string 'sha512' false the hashing algorithm to use password string / false the data to hash salt string / false salt to improve hash security returns signature as a string
arg type default optional description data string / false the data to sign privKey string / false the privKey to sign with returns a boolean whether its a valid sign
arg type default optional description data string / false the data to validate signature string / false the signature to validate pubKey string / false the pubKey to validate with
checks whether a map contains a key ignoring case sensitivity returns a boolean
arg type default optional description targetKey / / false the key to search for gets a key of a map ignoring case sensitivity returns the keys matching value
arg type default optional description targetKey / / false the key to search for find an item in a map based on a boolean function search function should return true if its the item you search for returns the value of the searched item
arg type default optional description fn function(val, key, map) / false the search function returns a new map with the filtered items search function should return true to copy the item to the new map
arg type default optional description fn function(val, key, map) / false the search function returns all values of the map as an array
returns the string without html elements
returns a boolean
arg type default optional description lowerBound number / false the lower bound upperBound number / false the upper bound tolerance number 0 true numbers by which the lower/upper bound are allowed to be incorrect inclusive boolean false true whether to include the bound's value
- returns the normalised data
- XXX can be one of
Version
,Boolean
,UUID
,Time
,Timetable
,Lesson
,String
,LessonDiscrim
,ClassDiscrim
,Integer
,JSON
- data is the data to validate
- varname is the name of the var for thrown errors
- can be used with validateNullable
validateInStringArray(string_or_index:data, string:varname, [string]:arrayData, boolean:ignoreCase = false)
- returns the int of the index
- data is the data to validate or an index in the array
- varname is the name of the var for thrown errors
- arrayData is an array of strings to check for
- ignoreCase can enable ignoring case when comparing strings
- can not be used with validateNullable
- returns an array with all normalised values
- dataArray is the input data
- varname is the name of the var for thrown errors
- itemValidationFunc is a func to validate the array items, matches the
validateXXX(data, string:varname)
spec- canBeEmpty can enable allowing empty arrays
- can not be used with validateNullable
- returns null or the normalised data array
- dataArray is the input data
- varname is the name of the var for thrown errors
- itemValidationFunc is a func to validate the array items, matches the
validateXXX(data, string:varname)
spec- can not be used with validateNullable
- returns null or the response of the dataTester
- data is the input data
- varname is the name of the var for thrown errors
- dataTester is a func to validate the item, matches the
validateXXX(data, string:varname)
spec
- returns an object
{ int:start, int:end }
, both propertys are nullable- dataTime is the input data