Module: utils

This is a module of general purpose utilities that are helpful when building Voice apps
Source:

Methods

(static) getArrAsStr(arr)

Converts an array to a string
Parameters:
Name Type Description
arr Array.<Object> array of objects to be pulled togeter into a string
Source:
Example
utils.getArrAsStr([1, 2, 3])
  // returns '1, 2 and 3'

(static) getRand(min, max)

Returns a random number
Parameters:
Name Type Description
min Number generated number is to not be below this
max Number generated number is to not be greater than this
Source:

(static) loadArrayFromFile(dirName, fileName)

Loads a newline seperated array from a file - especially helpful when you have a long list of possible values
Parameters:
Name Type Description
dirName string path to target file
fileName string newline seperated array backed file
Source:
Example
violet.addInputTypes({
   category: {
     type: 'categoryType',
     values: utils.loadArrayFromFile(__dirname, 'potentialCategories.txt')
   }
 });

(inner) getNumAsStr(num)

Converts numbers 0-999 to a string
Parameters:
Name Type Description
num Number that is converted into a string, i.e. 11 -> eleven
Source:

(inner) promiseWhile(condition, action)

Supporting While Loop with promises
Parameters:
Name Type Description
condition function function returning a boolean as to whether the loop should run
action function function returning a promise and performing the loop action
Deprecated:
  • Use the module 'promise-while' instead
Source:
Documentation generated by JSDoc 3.5.5 on Mon Jul 23 2018 23:46:45 GMT-0400 (EDT)