new Utilities()
A group of utility functions for restarting periodic's express application and helper functions to manipulate strings and other data structures.
- Copyright:
- Copyright (c) 2014 Typesettin. All rights reserved.
- License:
- MIT
- Source:
Requires
- module:fs
- module:util-merge
- module:path
Methods
-
async_run_cmd(cmd, args, asynccallback, callBack) → {function}
-
shorthand method for running shell commands
Parameters:
Name Type Description cmd
string shell command
args
array command line arguments
asynccallback
function async callback
callBack
function callback
- Source:
Returns:
callback(response)
- Type
- function
-
getAdminMenu(options) → {object}
-
add additional admin interface items from periodic extensions
Parameters:
Name Type Description options
object config options
- Source:
Returns:
admin menu json object
- Type
- object
-
isValidObjectID(str) → {Boolean}
-
simple helper function for validating mongo object IDs
Parameters:
Name Type Description str
string mongo object id
- Source:
Returns:
[description]
- Type
- Boolean
-
makeNiceAttribute(username) → {string}
-
replace all non alpha numeric tags with dashes and lowercase
Parameters:
Name Type Description username
string string to manipulate
- Source:
Returns:
manipulated string
- Type
- string
-
makeNiceName(username) → {string}
-
replace all non alpha numeric tags with dashes and lowercase
Parameters:
Name Type Description username
string string to manipulate
- Source:
Returns:
manipulated string
- Type
- string
-
removeEmptyObjectValues(obj) → {object}
-
remove empty object properties that have empty values
Parameters:
Name Type Description obj
object object to remove empty fields from
- Source:
Returns:
object with empty values removed
- Type
- object
-
removePrivateInfo(obj) → {object}
-
remove private data from user objects
Parameters:
Name Type Description obj
object user object
- Source:
Returns:
object with removed private data
- Type
- object
-
replaceBooleanStringObjectValues(obj) → {object}
-
replace boolean strings with actual boolean values
Parameters:
Name Type Description obj
object object to substitute values
- Source:
Returns:
object with boolean values
- Type
- object
Example
updatedThemeSettings = CoreUtilities.replaceBooleanStringObjectValues(updatedThemeSettings);
-
restart_app(options)
-
shorthand method for restarting periodic by updating the node script's watch file content/extensions/restart.json
Parameters:
Name Type Description options
object restartfile - define a custom restart file
- Source:
-
run_cmd(cmd, args, callBack) → {function}
-
shorthand method for running shell commands
Parameters:
Name Type Description cmd
string shell command
args
array command line arguments
callBack
function async callback
- Source:
Returns:
callback(response)
- Type
- function
-
sortObject(dir, field) → {function}
-
custom object sort by field
Parameters:
Name Type Description dir
string either asc or desc
field
string object property to seach
- Source:
Returns:
object sort compare function
- Type
- function
Example
req.controllerData.searchdocuments = searchdocuments.sort(CoreUtilities.sortObject('desc', 'createdat'));
-
stripTags(textinput) → {string}
-
replace all non alpha numeric tags with dashes and lowercase
Parameters:
Name Type Description textinput
string string to manipulate
- Source:
Returns:
manipulated string
- Type
- string