> 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.

# isOk

Type guard that narrows a [`Result`](https://massaman.dev/concepts/result.md) to `Ok`.

```typescript
if (isOk(result)) {
  // result.value is T
}
```

## Usage

### `isOk(result)`

`isOk` is how you discriminate a `Result` in TypeScript — inside the truthy branch, `result.value` is `T`; in the falsy branch, `result` is `Err<E>` and preserves its specific error type.

```typescript
import { attempt, isOk } from 'massaman'

const parsed = attempt(() => JSON.parse(input))
if (isOk(parsed)) {
  console.log(parsed.value) // narrowed to T
} else {
  console.error(parsed.error) // narrowed to Error
}
```

For pattern matching across both branches, prefer [`match`](https://massaman.dev/reference/match/match.md) with [`P.ok`](https://massaman.dev/reference/match/P.md#pok) / [`P.err`](https://massaman.dev/reference/match/P.md#perr) — it's exhaustive and reads better with multi-arm logic.

#### Parameters


resultResult<T>required

the result to test.

#### Returns

`true` if the result is a success.

```typescript
result is Ok<T>
```

## See also

- [`isErr`](https://massaman.dev/reference/control/isErr.md) — the inverse guard
- [`unwrap`](https://massaman.dev/reference/control/unwrap.md) — extract the value or throw
- [`P.ok`](https://massaman.dev/reference/match/P.md#pok) — pattern value for `match`
- [Result & Errors concept guide](https://massaman.dev/concepts/result.md)
