Module: utils

Utility functions.
Source:

Methods

(static) bind(selfopt, fnopt) → {function}

Binds a function to an instance of an object.
Parameters:
Name Type Attributes Description
self object <optional>
An object to bind the fn function parameter to.
fn object <optional>
A function to bind to the self argument.
Source:
Returns:
Type
function

(static) chain(tasks, callbackopt)

Run async function in a chain, like Async.waterfall.
Parameters:
Name Type Attributes Description
tasks Array.<function()> | function Array of callback functions.
callback function <optional>
Final callback.
Source:

(static) copyArray(arropt) → {array}

Copies all elements into a new array, which is returned.
Parameters:
Name Type Attributes Description
arr array <optional>
Array to copy elements from.
Source:
Returns:
Type
array

(static) copyObject(objopt)

Copies all properties into a new object which is returned.
Parameters:
Name Type Attributes Description
obj object <optional>
Object to copy properties from.
Source:

(static) expBackoff(optsopt, callbackopt)

Waits using exponential backoff.
Parameters:
Name Type Attributes Description
opts object <optional>
Settings for this function. Expected keys: attempt, rand.
callback function <optional>
A callback function: function(err, timeout).
Source:

(static) formatTime(time) → {number|null}

Formats the time for Splunk Enterprise or Splunk Cloud as a the epoch time in seconds.
Parameters:
Name Type Description
time string | number | date A date string, timestamp, or Date object.
Source:
Returns:
Epoch time in seconds, or null if time is malformed.
Type
number | null

(static) orByFalseyProp(propopt) → {boolean}

Like utils.orByProp() but for a falsey property. The first argument after prop with that property defined will be returned. Useful for Booleans and numbers.
Parameters:
Name Type Attributes Description
prop string <optional>
property name for other arguments.
Source:
Returns:
Type
boolean

(static) orByProp(propopt) → {boolean}

Takes a property name, then any number of objects as arguments and performs logical OR operations on them one at a time Returns true as soon as a truthy value is found, else returning false.
Parameters:
Name Type Attributes Description
prop string <optional>
property name for other arguments.
Source:
Returns:
Type
boolean

(static) toArray(iterable) → {Array}

Converts an iterable into to an array.
Parameters:
Name Type Description
iterable Array | Object Thing to convert to an Array.
Source:
Returns:
Type
Array

(static) validateNonNegativeInt(valueopt, labelopt) → {number}

Tries to validate the value parameter as a non-negative integer.
Parameters:
Name Type Attributes Description
value number <optional>
Some value, expected to be a positive integer.
label number <optional>
Human readable name for value for error messages.
Source:
Throws:
Will throw an error if the value parameter cannot by parsed as an integer.
Returns:
Type
number

(static) whilst(conditionopt, bodyopt, callbackopt)

Asynchronous while loop.
Parameters:
Name Type Attributes Description
condition function <optional>
A function returning a boolean, the loop condition.
body function <optional>
A function, the loop body.
callback function <optional>
Final callback.
Source: