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

# Function: inspectNone()

> **inspectNone**\<`F`>(`fn`): \<`O`>(`option`) => [`OptionFor`](/api/types/Option.OptionFor.md)\<`O` | `ReturnType`\<`F`>, [`InferSome`](/api/types/Option.InferSome.md)\<`O`>>

Executes a side effect function when an [Option](/api/types/Option.Option.md) or [OptionAsync](/api/types/Option.OptionAsync.md) is a [None](/api/types/Option.None.md),
without modifying the original option. This is useful for debugging, logging, or performing
other side effects while maintaining the original value.

If the input is a [Some](/api/types/Option.Some.md), the provided function is never called and the option is returned unchanged.

## Type Parameters

### F

`F` _extends_ () => `void` | `Promise`\<`void`>

The side effect function to execute on a [None](/api/types/Option.None.md).

## Parameters

### fn

`F`

## Returns

\<`O`>(`option`) => [`OptionFor`](/api/types/Option.OptionFor.md)\<`O` | `ReturnType`\<`F`>, [`InferSome`](/api/types/Option.InferSome.md)\<`O`>>

## Examples

**None Case**

```ts
import { Option } from 'byenull';

const option = Option.pipe(
  Option.none(),
  Option.inspectNone(() => console.log('Debug: No value present')),
);
// Console output: "Debug: No value present"
// Option: { type: 'None' }
```

**Some Case (fn is never called)**

```ts
import { Option } from 'byenull';

const option = Option.pipe(
  Option.some(42),
  Option.inspectNone(() => console.log('Debug: No value present')),
);
// No console output
// Option: { type: 'Some', value: 42 }
```

**Asynchronous Side Effect**

```ts
import { Option } from 'byenull';

const option = await Option.pipe(
  Option.none(),
  Option.inspectNone(async () => {
    await fetch('/api/logs?value=missing');
  }),
);
// { type: 'None' }
```

## See

- [inspect](/api/functions/Option.inspect.md) - For inspecting a [Some](/api/types/Option.Some.md) instead.
- [pipe](/api/functions/Option.pipe.md) - It is recommended to use this function with the [pipe](/api/functions/Option.pipe.md) function for better readability and composability.
