Utilities

Server.Modules. Utilities

# new Utilities(coreObj) → {Server.Modules.Utilities}

This is the Utilities Module of the Blackrock Application Server. It provides a large selection of utilities to help fast-track development of your next app or web service.

Parameters:
Name Type Description
coreObj Server.Modules.Core

The Core Module Singleton

Author:
  • Darren Smith
License:
  • Licensed under the LGPL license.
Returns:

module - The Utilities Module Singleton

Type
Server.Modules.Utilities
Example
Tbc...

Extends

Members

# (static) xml

Tbc...

Example
Tbc...

Methods

# (static) cloneObject(src) → {object}

Tbc...

Parameters:
Name Type Description
src object

Source Object

Returns:

target - Target Object

Type
object
Example
Tbc...

# (static) decrypt(text, key, encoding) → {string}

Tbc...

Parameters:
Name Type Description
text string

String of text to decrypt

key string

RSA key to use to decrypt the string

encoding string

Encoding for output. Supports - 'buffer', 'json' or 'utf8'

Returns:

decrypted - Decrypted string

Type
string
Example
Tbc...

# (static) encrypt(text, key, encoding) → {string}

Tbc...

Parameters:
Name Type Description
text string

String of text to encrypt

key string

RSA key to use to encrypt the string

encoding string

Encoding for output. Supports - 'buffer', 'binary', 'hex' or 'base64'.

Returns:

encrypted - Encrypted String

Type
string
Example
Tbc...

# (static) getCpuLoad(cb)

Tbc...

Parameters:
Name Type Description
cb function

Callback Function

Example
Tbc...

# (static) getCurrentDateInISO() → {string}

Tbc...

Returns:

currentDateISO - Current Date in ISO

Type
string
Example
Tbc...

# (static) getEndTime(start) → {*}

Tbc...

Parameters:
Name Type Description
start *

Start Time

Returns:

end - End Time

Type
*
Example
Tbc...

# (static) getMemoryUse(type) → {number}

Tbc...

Parameters:
Name Type Description
type string

Type

Returns:

module - Memory Use

Type
number
Example
Tbc...

# (static) getObjectMemoryUsage(object) → {number}

Derived From: sizeof.js A function to calculate the approximate memory usage of objects

Parameters:
Name Type Description
object object

Object to get Memory Usage Of

Author:
  • Kate Morley
Returns:

size - Object Size

Type
number
Example
Tbc...

# (static) getStartTime() → {*}

Tbc...

Returns:

time - Start Time

Type
*
Example
Tbc...

# (static) isJSON(input) → {string}

Tbc...

Parameters:
Name Type Description
input *

JSON Data (in String or Object Form)

Returns:

result - Result of Query (json_string | json_object | string)

Type
string
Example
Tbc...

# (static) isNil(value) → {boolean}

Tbc...

Parameters:
Name Type Description
value *

Value to Check

Returns:

result - Result of Check (True | False)

Type
boolean
Example
Tbc...

# (static) isNull(value) → {boolean}

Tbc...

Parameters:
Name Type Description
value *

Value to Check

Returns:

result - Result of Check (True | False)

Type
boolean
Example
Tbc...

# (static) isUndefined(value) → {boolean}

Tbc...

Parameters:
Name Type Description
value *

Value to Check

Returns:

result - Result of Check (True | False)

Type
boolean
Example
Tbc...

# (static) loadModule(name) → {Server.Modules.Core.Module}

Tbc...

Parameters:
Name Type Description
name string

Module Name

Returns:

module - Loaded Module

Type
Server.Modules.Core.Module
Example
Tbc...

# (static) objectLength(object) → {number}

Tbc...

Parameters:
Name Type Description
object object

The Javascript Object

Returns:

length - The size of the object (number of keys)

Type
number
Example
Tbc...

# (static) parseCsv(inputString, options, cb)

Tbc...

Parameters:
Name Type Description
inputString string

String of raw text data in CSV format

options object

Options object. Can set options.delimiter to something other than a comma

cb function

Callback function

Example
Tbc...

# (static) path(object, keys) → {*}

Tbc...

Parameters:
Name Type Description
object object

Object

keys array

Keys

Returns:

result - Result

Type
*
Example
Tbc...

# (static) prop(object, key) → {*}

Tbc...

Parameters:
Name Type Description
object object

Object

key string

Key

Returns:

result - Result

Type
*
Example
Tbc...

# (static) prop(obj, keyPath, value)

Tbc...

Parameters:
Name Type Description
obj object

Object

keyPath string

Key Path

value string

Value

Example
Tbc...

# (static) randomString(length) → {string}

Tbc...

Parameters:
Name Type Description
length number

Length of Random String to Generate

Returns:

text - The generated random string

Type
string
Example
Tbc...

# (static) uuid4() → {string}

Tbc...

Returns:

uuid - Generated UUID4 String

Type
string
Example
Tbc...

# (static) validateString(text, validator) → {boolean}

Tbc...

Parameters:
Name Type Description
text string

Input String to Validate

validator object

Validator for String

Properties
Name Type Description
whitelist string

Whitelist to validate against

regex string

Regex to Validate Against

email boolean

Whether to validate as email (True | False)

Returns:

result - Result of Validation

Type
boolean
Example
Tbc...