Utilities Module
The utils
module provides utility helper methods.
This module is available via the following require()
statement:
const utils = require('utils');
Random integer generator
Use the randomInt()
method to generate a number between the given minimum and maximum values.
Usage: randomInt(min, max)
where:
min
: lower integer limit (inclusive)max
: upper integer limit (exclusive)
const randomNumber = utils.randomInt(5, 15);
isNumeric
Use the isNumeric()
method to check if a variable is a number.
Usage: isNumeric(variable)
where:
variable
: value to test
console.log(utils.isNumeric(5)); // true
console.log(utils.isNumeric('five')); // false
Functions support
Functions provides a rich set of tools, and this documentation may not cover every situation. If you need help with a case not covered here, please contact PubNub Support.