For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/functions/Option.inspectNone.md.

Function: inspectNone()

inspectNone<F>(fn): <O>(option) => OptionFor<O | ReturnType<F>, InferSome<O>>

Executes a side effect function when an Option or OptionAsync is a None, 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, 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.

Parameters

fn

F

Returns

<O>(option) => OptionFor<O | ReturnType<F>, InferSome<O>>

Examples

None Case

import { 
import Option
Option
} from 'byenull';
const
const option: Option.Option<never>
option
=
import Option
Option
.
function pipe<Option.Option<never>, Option.Option<never>>(a: Option.Option<never>, ab: (a: Option.Option<never>) => Option.Option<never>): Option.Option<never> (+25 overloads)

Applies a sequence of functions to a value, from left to right.

This utility enables function composition in a left-to-right manner. It supports up to 25 chained functions from A through Z.

@typeParamA - The initial input value type.@typeParamB-Z - Intermediate and final function return types.@paramvalue - The initial input value.@paramfunctions - Additional unary functions composing of the previous result.@returnsThe final result after applying all functions.@example
import { Option } from 'byenull';

const result = Option.pipe(
  2,
  x => x + 1,
  x => x * 3,
  x => `Result: ${x}`
);
// Result: 9
@categoryUtilities
pipe
(
import Option
Option
.
function none(): Option.Option<never>

Creates a None : an Option that holds no value.

@returnsA None.@example
import { Option } from 'byenull';

const option = Option.none();
// { type: 'None' }
@categoryCreators
none
(),
import Option
Option
.
function inspectNone<() => void>(fn: () => void): <O>(option: O) => Option.OptionFor<void | O, Option.InferSome<O>>

Executes a side effect function when an Option or OptionAsync is a None , 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 , the provided function is never called and the option is returned unchanged.

@typeParamF - The side effect function to execute on a None.@typeParamO - The input Option or OptionAsync.@example

None Case

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' }
@example

Some Case (fn is never called)

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 }
@example

Asynchronous Side Effect

import { Option } from 'byenull';

const option = await Option.pipe(
Option.none(),
Option.inspectNone(async () => {
await fetch('/api/logs?value=missing');
}),
);
// { type: 'None' }
@seeinspect - For inspecting a Some instead.@seepipe - It is recommended to use this function with the pipe function for better readability and composability.@categoryCombinators
inspectNone
(() =>
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
('Debug: No value present')),
); // Console output: "Debug: No value present" // Option: { type: 'None' }

Some Case (fn is never called)

import { 
import Option
Option
} from 'byenull';
const
const option: Option.Option<number>
option
=
import Option
Option
.
function pipe<Option.Option<number>, Option.Option<number>>(a: Option.Option<number>, ab: (a: Option.Option<number>) => Option.Option<number>): Option.Option<number> (+25 overloads)

Applies a sequence of functions to a value, from left to right.

This utility enables function composition in a left-to-right manner. It supports up to 25 chained functions from A through Z.

@typeParamA - The initial input value type.@typeParamB-Z - Intermediate and final function return types.@paramvalue - The initial input value.@paramfunctions - Additional unary functions composing of the previous result.@returnsThe final result after applying all functions.@example
import { Option } from 'byenull';

const result = Option.pipe(
  2,
  x => x + 1,
  x => x * 3,
  x => `Result: ${x}`
);
// Result: 9
@categoryUtilities
pipe
(
import Option
Option
.
function some<number>(value: number): Option.Option<number>

Creates a Some from a given value. Passing null or undefined returns None instead.

@typeParamT - The type of the value to wrap.@returnsA Some containing the value, or None if the value is nullish.@example
import { Option } from 'byenull';

const some = Option.some(42);
// { type: 'Some', value: 42 }

const none = Option.some(null);
// { type: 'None' }
@categoryCreators
some
(42),
import Option
Option
.
function inspectNone<() => void>(fn: () => void): <O>(option: O) => Option.OptionFor<void | O, Option.InferSome<O>>

Executes a side effect function when an Option or OptionAsync is a None , 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 , the provided function is never called and the option is returned unchanged.

@typeParamF - The side effect function to execute on a None.@typeParamO - The input Option or OptionAsync.@example

None Case

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' }
@example

Some Case (fn is never called)

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 }
@example

Asynchronous Side Effect

import { Option } from 'byenull';

const option = await Option.pipe(
Option.none(),
Option.inspectNone(async () => {
await fetch('/api/logs?value=missing');
}),
);
// { type: 'None' }
@seeinspect - For inspecting a Some instead.@seepipe - It is recommended to use this function with the pipe function for better readability and composability.@categoryCombinators
inspectNone
(() =>
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
('Debug: No value present')),
); // No console output // Option: { type: 'Some', value: 42 }

Asynchronous Side Effect

import { 
import Option
Option
} from 'byenull';
const
const option: Option.Option<never>
option
= await
import Option
Option
.
function pipe<Option.Option<never>, Option.OptionAsync<never>>(a: Option.Option<never>, ab: (a: Option.Option<never>) => Option.OptionAsync<never>): Option.OptionAsync<never> (+25 overloads)

Applies a sequence of functions to a value, from left to right.

This utility enables function composition in a left-to-right manner. It supports up to 25 chained functions from A through Z.

@typeParamA - The initial input value type.@typeParamB-Z - Intermediate and final function return types.@paramvalue - The initial input value.@paramfunctions - Additional unary functions composing of the previous result.@returnsThe final result after applying all functions.@example
import { Option } from 'byenull';

const result = Option.pipe(
  2,
  x => x + 1,
  x => x * 3,
  x => `Result: ${x}`
);
// Result: 9
@categoryUtilities
pipe
(
import Option
Option
.
function none(): Option.Option<never>

Creates a None : an Option that holds no value.

@returnsA None.@example
import { Option } from 'byenull';

const option = Option.none();
// { type: 'None' }
@categoryCreators
none
(),
import Option
Option
.
function inspectNone<() => Promise<void>>(fn: () => Promise<void>): <O>(option: O) => Option.OptionFor<Promise<void> | O, Option.InferSome<O>>

Executes a side effect function when an Option or OptionAsync is a None , 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 , the provided function is never called and the option is returned unchanged.

@typeParamF - The side effect function to execute on a None.@typeParamO - The input Option or OptionAsync.@example

None Case

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' }
@example

Some Case (fn is never called)

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 }
@example

Asynchronous Side Effect

import { Option } from 'byenull';

const option = await Option.pipe(
Option.none(),
Option.inspectNone(async () => {
await fetch('/api/logs?value=missing');
}),
);
// { type: 'None' }
@seeinspect - For inspecting a Some instead.@seepipe - It is recommended to use this function with the pipe function for better readability and composability.@categoryCombinators
inspectNone
(async () => {
await
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
fetch
('/api/logs?value=missing');
}), ); // { type: 'None' }

See

  • inspect - For inspecting a Some instead.
  • pipe - It is recommended to use this function with the pipe function for better readability and composability.