Module: Utils

Assorted useful utils that are used in many places
Author:
  • Kier Lindsay (syonfox) Not realy needed for this project but whatever if your reading this might be useful :)
Source:

Classes

RetObject

Members

(inner) RetObject this is my standard way of returning stuff success tells you wether the function successfuly executed or not, msg: is a frendly message of what happened data is any data you wish to return and debug is for debug error messaged or any other developer data

Source:

Methods

(static) fileHash()

https://gist.github.com/GuillermoPena/9233069?permalink_comment_id=2364896#gistcomment-2364896
Source:

(static) groupBy(xs, key) → {Object}

Groups array by key https://stackoverflow.com/questions/14446511/most-efficient-method-to-groupby-on-an-array-of-objects
Parameters:
Name Type Description
xs Array the array to group
key string the key to groupby
Source:
Returns:
Type
Object

(static) logfn(str)

Returns a function that logs the params its called with its parameters
Parameters:
Name Type Description
str a prefex string(s)
Source:
Returns:

(static) pgExecute(pg, stmt, successMsgopt) → {Promise.<RetObject>}

Execute a slq statement on a pg pool or client
Parameters:
Name Type Attributes Description
pg pg.Pool | pg.Client the pool or client to use to execute the statement.
stmt string the sql statement to execute
successMsg string <optional>
The message to send on success
Source:
Returns:
- fills in data if success and debug with error if failed;
Type
Promise.<RetObject>

(static) simpleExec(sh, cb)

Execute and logs stdout/err (spans a process internally and returns it)
Parameters:
Name Type Description
sh the shell command as you would type it
cb cb(data, done) whenever stdout is received
Source:

(static) unGroup(grp) → {Array}

Undoes what groupBy() does
Parameters:
Name Type Description
grp Object Object with arrays of values
Source:
Returns:
-the original arrays
Type
Array