---
source_url: https://www.pubnub.com/docs/serverless-sdk/modules-and-libraries/utils
title: utils
updated_at: 2026-09-30T07:20:08.000Z
---

# utils

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

The `utils` built-in module is available only inside a PubNub Function. It generates random integers and checks numeric values.

```javascript
const utils = require('utils');
```

## randomInt

`randomInt(min, max)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| min | Number | Yes |  | Lower bound, inclusive. |
| max | Number | Yes |  | Upper bound, exclusive. |

Returns: a random integer in `[min, max)`.

```javascript
const utils = require('utils');
const randomNumber = utils.randomInt(5, 15);
```

## isNumeric

`isNumeric(variable)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| variable | Any | Yes |  | Value to test. |

Returns: `true` if `variable` is a number, otherwise `false`.

```javascript
const utils = require('utils');
console.log(utils.isNumeric(5)); // true
console.log(utils.isNumeric('five')); // false
```

## Related reference

* [Modules and libraries](https://www.pubnub.com/docs/serverless-sdk/modules-and-libraries/overview.md). Every built-in module available inside a Function.

Last updated at: 2026-09-30T07:20:08.000Z
