---
title: PenaltyBox
summary: A penalty box that can be used with EdgeRateLimiter or standalone for adding and checking if an entry is in the dataset.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/edge-rate-limiter/class.PenaltyBox/
---

**Kind:** Class  
**Module:** [edge-rate-limiter](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/edge-rate-limiter/)  
**Package:** @fastly/js-compute 4.0.1  
**Since:** 3.9.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/edge-rate-limiter.d.ts#L55

A penalty box that can be used with [EdgeRateLimiter](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/edge-rate-limiter/class.EdgeRateLimiter/) or standalone
for adding and checking if an entry is in the dataset.

**Note**: Can only be used when processing requests, not during build-time initialization.

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/edge-rate-limiter.d.ts#L61

```javascript
new PenaltyBox(name: string)
```

Open a penalty box identified by the given name.

**Parameters**

- `name`: `string` — The name of the penalty box to open.

## Methods

### add

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/edge-rate-limiter.d.ts#L70

```javascript
add(entry: string, timeToLive: number): void
```

Add an entry to the penalty box for the duration of the given `timeToLive`.

**Parameters**

- `entry`: `string` — The entry to add.
- `timeToLive`: `number`

  How long in minutes (1–60) the entry should be added
    into the penalty box. Value is truncated to the nearest minute.

**Returns**

`void`

**Throws**

- `TypeError` if `timeToLive` is not a number between 1 and 60.

### has

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/edge-rate-limiter.d.ts#L77

```javascript
has(entry: string): boolean
```

Check if an entry is in the penalty box.

**Parameters**

- `entry`: `string` — The entry to look up.

**Returns**

`boolean`

`true` if the entry is in the penalty box, otherwise `false`.
