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

Function: some()

some<T>(value): Option<NonNullable<T>>

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

Type Parameters

T

T

The type of the value to wrap.

Parameters

value

T

Returns

Option<NonNullable<T>>

A Some containing the value, or None if the value is nullish.

Example

import { 
import Option
Option
} from 'byenull';
const
const some: Option.Option<number>
some
=
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);
// { type: 'Some', value: 42 } const
const none: Option.Option<never>
none
=
import Option
Option
.
function some<null>(value: null): Option.Option<never>

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
(null);
// { type: 'None' }