> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# inRange es-toolkit

Checks if a value is within a specified range.

```typescript
const result = inRange(value, maximum);
const result = inRange(value, minimum, maximum);
```

## Usage

### `inRange(value, maximum)`

Use `inRange` when you want to check if a value is within the range from 0 to less than the maximum value. The minimum value is automatically set to 0.

```typescript
import { inRange } from 'es-toolkit/math';

// Check within the range from 0 to less than 5
const result1 = inRange(3, 5); // result1 is true (0 <= 3 < 5)
const result2 = inRange(5, 5); // result2 is false (5 is not less than 5)
const result3 = inRange(-1, 5); // result3 is false (-1 < 0)
```

#### Parameters


valuenumberrequired

The value to check.


maximumnumberrequired

The maximum value of the range (exclusive).

#### Returns

Returns `true` if the value is within the range from 0 (inclusive) to the maximum value (exclusive), otherwise `false`.

```typescript
boolean
```

### `inRange(value, minimum, maximum)`

Use `inRange` when you want to check if a value is within a specified minimum and maximum range.

```typescript
import { inRange } from 'es-toolkit/math';

// Check within the minimum and maximum range
const result1 = inRange(3, 2, 5); // result1 is true (2 <= 3 < 5)
const result2 = inRange(1, 2, 5); // result2 is false (1 < 2)
const result3 = inRange(5, 2, 5); // result3 is false (5 is not less than 5)

// Can be used with negative ranges
const result4 = inRange(-3, -5, -1); // result4 is true (-5 <= -3 < -1)
```

#### Parameters


valuenumberrequired

The value to check.


minimumnumberrequired

The minimum value of the range (inclusive).


maximumnumberrequired

The maximum value of the range (exclusive).

#### Returns

Returns `true` if the value is within the specified range, otherwise `false`.

```typescript
boolean
```

#### Throws

Throws an error if the minimum is greater than or equal to the maximum.


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/reference/math/inRange.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
