Utilities Module

The utilities module provides utility helper methods.

The utilities module is made available via the following require statement:

const utils = require('utils');

Random Integer Generator

To generate a number between a supplied min and max values, use the randomInt() method.

usage: randomInt(min, max), where:

  • min: lower integer limit (inclusive).
  • max: upper integer limit (exclusive).
const randomNumber = utils.randomInt(5, 15);


To checks if a variable is a number, use the isNumeric() method.

Usage: isNumeric(variable) where:

  • variable: variable to test.
console.log(utils.isNumeric(5)); // true
console.log(utils.isNumeric('five')); // false
Functions support

PubNub Functions provides a rich set of tools, and this documentation does not cover all of the potential situations you may encounter. If you need help with a situation not covered by the documentation, please contact PubNub Support

Last updated on