Skip to content

Schema Transformations

Transformations play a key role in working with schemas, especially when you need to convert data from one type to another, such as parsing a string into a number or converting a date string into a Date object.

The Schema.transform function is designed to facilitate these conversions by linking two schemas together: one for the input type and one for the output type.

Here’s an overview of the Schema.transform function, which accepts five parameters:

ParameterDescriptionType
fromThe source schema, representing the starting point of the transformation.Schema<B, A, R1> where A is the input type and B is the intermediate type after initial validation.
toThe target schema, representing the endpoint of the transformation.Schema<D, C, R2> where C is the transformed type from B, and D is the final output type.
decodeA function that converts an intermediate value of type B to a value of type C.(b: B, a: A) => C
encodeA function that reverses the transformation, converting type C back to type B.(c: C, d: D) => B
strictoptional (but recommended)boolean

This function results in a schema Schema<D, A, R1 | R2>, integrating both the dependencies and transformations of the from and to schemas.

Example (Doubling a Number)

Here’s an example that demonstrates a schema transformation to double an input number:

1
import {
import Schema
Schema
} from "effect"
2
3
// Define a transformation that doubles the input number
4
const
const transformedSchema: Schema.transform<typeof Schema.Number, typeof Schema.Number>
transformedSchema
=
import Schema
Schema
.
const transform: <typeof Schema.Number, typeof Schema.Number>(from: typeof Schema.Number, to: typeof Schema.Number, options: { readonly decode: (fromA: number, fromI: number) => number; readonly encode: (toI: number, toA: number) => number; readonly strict?: true; } | { ...; }) => Schema.transform<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

transform
(
5
// Source schema
6
import Schema
Schema
.
(alias) class Number export Number
Number
,
7
// Target schema
8
import Schema
Schema
.
(alias) class Number export Number
Number
,
9
{
10
// optional but you get better error messages from TypeScript
11
(property) strict?: true
strict
: true,
12
// Transformation function to double the number
13
(property) decode: (fromA: number, fromI: number) => number
decode
: (
(parameter) n: number
n
) =>
(parameter) n: number
n
* 2,
14
// Reverse transformation to revert to the original number
15
(property) encode: (toI: number, toA: number) => number
encode
: (
(parameter) n: number
n
) =>
(parameter) n: number
n
/ 2
16
}
17
)

In this example, if you input 2, the schema will decode it to 4 and encode it back to 2.

Example (Converting an array to a ReadonlySet)

Here’s how you can convert an array to a ReadonlySet:

1
import {
import Schema
Schema
} from "effect"
2
3
const
const ReadonlySetFromArray: <A, I, R>(itemSchema: Schema.Schema<A, I, R>) => Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
ReadonlySetFromArray
= <
(type parameter) A in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
A
,
(type parameter) I in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
I
,
(type parameter) R in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
R
>(
4
(parameter) itemSchema: Schema.Schema<A, I, R>
itemSchema
:
import Schema
Schema
.
interface Schema<in out A, in out I = A, out R = never> namespace Schema
Schema
<
(type parameter) A in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
A
,
(type parameter) I in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
I
,
(type parameter) R in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
R
>
5
):
import Schema
Schema
.
interface Schema<in out A, in out I = A, out R = never> namespace Schema
Schema
<
interface ReadonlySet<T>
ReadonlySet
<
(type parameter) A in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
A
>,
interface ReadonlyArray<T>
ReadonlyArray
<
(type parameter) I in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
I
>,
(type parameter) R in <A, I, R>(itemSchema: Schema.Schema<A, I, R>): Schema.Schema<ReadonlySet<A>, ReadonlyArray<I>, R>
R
> =>
6
import Schema
Schema
.
const transform: <Schema.ReadonlySetFromSelf<Schema.SchemaClass<A, A, never>>, Schema.Array$<Schema.Schema<A, I, R>>>(from: Schema.Array$<Schema.Schema<A, I, R>>, to: Schema.ReadonlySetFromSelf<...>, options: { ...; } | { ...; }) => Schema.transform<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

transform
(
7
import Schema
Schema
.
(alias) Array<Schema.Schema<A, I, R>>(value: Schema.Schema<A, I, R>): Schema.Array$<Schema.Schema<A, I, R>> export Array
Array
(
(parameter) itemSchema: Schema.Schema<A, I, R>
itemSchema
),
8
import Schema
Schema
.
const ReadonlySetFromSelf: <Schema.SchemaClass<A, A, never>>(value: Schema.SchemaClass<A, A, never>) => Schema.ReadonlySetFromSelf<Schema.SchemaClass<A, A, never>>
ReadonlySetFromSelf
(
import Schema
Schema
.
const typeSchema: <A, I, R>(schema: Schema.Schema<A, I, R>) => Schema.SchemaClass<A, A, never>

The `typeSchema` function allows you to extract the `Type` portion of a schema, creating a new schema that conforms to the properties defined in the original schema without considering the initial encoding or transformation processes.

typeSchema
(
(parameter) itemSchema: Schema.Schema<A, I, R>
itemSchema
)),
9
{
10
(property) strict?: true
strict
: true,
11
(property) decode: (fromA: readonly A[], fromI: readonly I[]) => ReadonlySet<A>
decode
: (
(parameter) items: readonly A[]
items
) => new
var Set: SetConstructor new <A>(iterable?: Iterable<A> | null | undefined) => Set<A> (+1 overload)
Set
(
(parameter) items: readonly A[]
items
),
12
(property) encode: (toI: ReadonlySet<A>, toA: ReadonlySet<A>) => readonly A[]
encode
: (
(parameter) set: ReadonlySet<A>
set
) =>
var Array: ArrayConstructor
Array
.
(method) ArrayConstructor.from<A>(iterable: Iterable<A> | ArrayLike<A>): A[] (+3 overloads)

Creates an array from an iterable object.

from
(
(parameter) set: ReadonlySet<A>
set
.
(method) ReadonlySet<A>.values(): SetIterator<A>

Returns an iterable of values in the set.

values
())
13
}
14
)

Example (Trim Whitespace)

Here’s how to use the transform function to trim whitespace from strings:

1
import {
import Schema
Schema
} from "effect"
2
3
const
const transformedSchema: Schema.transform<typeof Schema.String, typeof Schema.String>
transformedSchema
=
import Schema
Schema
.
const transform: <typeof Schema.String, typeof Schema.String>(from: typeof Schema.String, to: typeof Schema.String, options: { readonly decode: (fromA: string, fromI: string) => string; readonly encode: (toI: string, toA: string) => string; readonly strict?: true; } | { ...; }) => Schema.transform<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

transform
(
4
// Source schema: accepts any string
5
import Schema
Schema
.
(alias) class String export String
String
,
6
// Target schema: also accepts any string
7
import Schema
Schema
.
(alias) class String export String
String
,
8
{
9
(property) strict?: true
strict
: true,
10
// Trim the string during decoding
11
(property) decode: (fromA: string, fromI: string) => string
decode
: (
(parameter) s: string
s
) =>
(parameter) s: string
s
.
(method) String.trim(): string

Removes the leading and trailing white space and line terminator characters from a string.

trim
(),
12
// No change during encoding
13
(property) encode: (toI: string, toA: string) => string
encode
: (
(parameter) s: string
s
) =>
(parameter) s: string
s
14
}
15
)

This schema automatically trims leading and trailing whitespace from a string during decoding. During encoding, it returns the string unchanged.

Improving the Transformation with a Filter

To ensure that strings are not only trimmed but also validated to exclude untrimmed inputs, you can restrict the target schema to only accept strings that are already trimmed:

1
import {
import Schema
Schema
} from "effect"
2
3
const
const transformedSchema: Schema.transform<typeof Schema.String, Schema.filter<typeof Schema.String>>
transformedSchema
=
import Schema
Schema
.
const transform: <Schema.filter<typeof Schema.String>, typeof Schema.String>(from: typeof Schema.String, to: Schema.filter<typeof Schema.String>, options: { readonly decode: (fromA: string, fromI: string) => string; readonly encode: (toI: string, toA: string) => string; readonly strict?: true; } | { ...; }) => Schema.transform<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

transform
(
4
// Source schema: accepts any string
5
import Schema
Schema
.
(alias) class String export String
String
,
6
// Target schema now only accepts strings that are trimmed
7
import Schema
Schema
.
(alias) class String export String
String
.
(method) Pipeable.pipe<typeof Schema.String, Schema.filter<typeof Schema.String>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<typeof Schema.String>): Schema.filter<...> (+21 overloads)
pipe
(
import Schema
Schema
.
function filter<typeof Schema.String>(predicate: (a: string, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.String) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) s: string
s
) =>
(parameter) s: string
s
===
(parameter) s: string
s
.
(method) String.trim(): string

Removes the leading and trailing white space and line terminator characters from a string.

trim
())),
8
{
9
(property) strict?: true
strict
: true,
10
// Trim the string during decoding
11
(property) decode: (fromA: string, fromI: string) => string
decode
: (
(parameter) s: string
s
) =>
(parameter) s: string
s
.
(method) String.trim(): string

Removes the leading and trailing white space and line terminator characters from a string.

trim
(),
12
// No change during encoding
13
(property) encode: (toI: string, toA: string) => string
encode
: (
(parameter) s: string
s
) =>
(parameter) s: string
s
14
}
15
)

In this improved example, the target schema is piped through a filter function. This function checks that the string is equal to its trimmed version, effectively ensuring that only strings without leading or trailing whitespace are considered valid. This is particularly useful for maintaining data integrity and can help prevent errors or inconsistencies in data processing.

Sometimes the strict type checking can impede certain operations where types might slightly deviate during the transformation process. For such cases, transform provides an option, strict: false, to relax type constraints and allow for more flexible data manipulation.

Example (Clamping Constructor)

Let’s consider the scenario where you need to define a constructor clamp that ensures a number falls within a specific range. This function returns a schema that “clamps” a number to a specified minimum and maximum range:

1
import {
import Schema
Schema
} from "effect"
2
import {
import Number
Number
} from "effect"
3
4
const
const clamp: (minimum: number, maximum: number) => <A extends number, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
clamp
=
5
(
(parameter) minimum: number
minimum
: number,
(parameter) maximum: number
maximum
: number) =>
6
<
(type parameter) A in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
A
extends number,
(type parameter) I in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
I
,
(type parameter) R in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
R
>(
(parameter) self: Schema.Schema<A, I, R>
self
:
import Schema
Schema
.
interface Schema<in out A, in out I = A, out R = never> namespace Schema
Schema
<
(type parameter) A in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
A
,
(type parameter) I in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
I
,
(type parameter) R in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
R
>) =>
7
import Schema
Schema
.
const transform: <Schema.filter<Schema.SchemaClass<A, A, never>>, Schema.Schema<A, I, R>>(from: Schema.Schema<A, I, R>, to: Schema.filter<Schema.SchemaClass<A, A, never>>, options: { ...; } | { ...; }) => Schema.transform<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

transform
(
8
(parameter) self: Schema.Schema<A, I, R>
self
,
9
(parameter) self: Schema.Schema<A, I, R>
self
.
(method) Pipeable.pipe<Schema.Schema<A, I, R>, Schema.SchemaClass<A, A, never>, Schema.filter<Schema.SchemaClass<A, A, never>>>(this: Schema.Schema<...>, ab: (_: Schema.Schema<A, I, R>) => Schema.SchemaClass<...>, bc: (_: Schema.SchemaClass<...>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe
(
10
import Schema
Schema
.
const typeSchema: <A, I, R>(schema: Schema.Schema<A, I, R>) => Schema.SchemaClass<A>

The `typeSchema` function allows you to extract the `Type` portion of a schema, creating a new schema that conforms to the properties defined in the original schema without considering the initial encoding or transformation processes.

typeSchema
,
11
import Schema
Schema
.
function filter<Schema.SchemaClass<A, A, never>>(predicate: (a: NoInfer<A>, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.SchemaClass<...>) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) a: A extends number
a
) =>
(parameter) a: A extends number
a
<=
(parameter) minimum: number
minimum
||
(parameter) a: A extends number
a
>=
(parameter) maximum: number
maximum
)
12
),
13
// @ts-expect-error
14
{
15
(property) strict?: true
strict
: true,
16
(property) decode: (fromA: A, fromI: I) => A
decode
: (
(parameter) a: A extends number
a
) =>
import Number
Number
.
const clamp: (self: number, options: { minimum: number; maximum: number; }) => number (+1 overload)

Restricts the given `number` to be within the range specified by the `minimum` and `maximum` values. - If the `number` is less than the `minimum` value, the function returns the `minimum` value. - If the `number` is greater than the `maximum` value, the function returns the `maximum` value. - Otherwise, it returns the original `number`.

clamp
(
(parameter) a: A extends number
a
, {
(property) minimum: number
minimum
,
(property) maximum: number
maximum
}),
17
(property) encode: (toI: A, toA: A) => A
encode
: (
(parameter) a: A extends number
a
) =>
(parameter) a: A extends number
a
18
}
19
)
20
/*
21
Argument of type '{ strict: true; decode: (a: A) => number; encode: (a: A) => A; }' is not assignable to parameter of type '{ readonly decode: (fromA: A, fromI: I) => A; readonly encode: (toI: A, toA: A) => A; readonly strict?: true; } | { readonly decode: (fromA: A, fromI: I) => unknown; readonly encode: (toI: A, toA: A) => unknown; readonly strict: false; }'.
22
The types returned by 'decode(...)' are incompatible between these types.
23
Type 'number' is not assignable to type 'A'.
24
'number' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'number'.ts(2345)
25
*/

In this code, Number.clamp is a function that adjusts the given number to stay within the specified range. However, the return type of Number.clamp may not strictly be of type A but just a number, which can lead to type mismatches according to TypeScript’s strict type-checking.

There are two ways to resolve the type mismatch:

  1. Using Type Assertion: Adding a type cast can enforce the return type to be treated as type A:

    decode: (a) => Number.clamp(a, { minimum, maximum }) as A
  2. Using the Non-Strict Option: Setting strict: false in the transformation options allows the schema to bypass some of TypeScript’s type-checking rules, accommodating the type discrepancy:

    1
    import {
    import Schema
    Schema
    } from "effect"
    2
    import {
    import Number
    Number
    } from "effect"
    3
    4
    const
    const clamp: (minimum: number, maximum: number) => <A extends number, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    clamp
    =
    5
    (
    (parameter) minimum: number
    minimum
    : number,
    (parameter) maximum: number
    maximum
    : number) =>
    6
    <
    (type parameter) A in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    A
    extends number,
    (type parameter) I in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    I
    ,
    (type parameter) R in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    R
    >(
    (parameter) self: Schema.Schema<A, I, R>
    self
    :
    import Schema
    Schema
    .
    interface Schema<in out A, in out I = A, out R = never> namespace Schema
    Schema
    <
    (type parameter) A in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    A
    ,
    (type parameter) I in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    I
    ,
    (type parameter) R in <A extends number, I, R>(self: Schema.Schema<A, I, R>): Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.SchemaClass<A, A, never>>>
    R
    >) =>
    7
    import Schema
    Schema
    .
    const transform: <Schema.filter<Schema.SchemaClass<A, A, never>>, Schema.Schema<A, I, R>>(from: Schema.Schema<A, I, R>, to: Schema.filter<Schema.SchemaClass<A, A, never>>, options: { ...; } | { ...; }) => Schema.transform<...> (+1 overload)

    Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided mapping functions.

    transform
    (
    8
    (parameter) self: Schema.Schema<A, I, R>
    self
    ,
    9
    (parameter) self: Schema.Schema<A, I, R>
    self
    .
    (method) Pipeable.pipe<Schema.Schema<A, I, R>, Schema.SchemaClass<A, A, never>, Schema.filter<Schema.SchemaClass<A, A, never>>>(this: Schema.Schema<...>, ab: (_: Schema.Schema<A, I, R>) => Schema.SchemaClass<...>, bc: (_: Schema.SchemaClass<...>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
    pipe
    (
    10
    import Schema
    Schema
    .
    const typeSchema: <A, I, R>(schema: Schema.Schema<A, I, R>) => Schema.SchemaClass<A>

    The `typeSchema` function allows you to extract the `Type` portion of a schema, creating a new schema that conforms to the properties defined in the original schema without considering the initial encoding or transformation processes.

    typeSchema
    ,
    11
    import Schema
    Schema
    .
    function filter<Schema.SchemaClass<A, A, never>>(predicate: (a: NoInfer<A>, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.SchemaClass<...>) => Schema.filter<...> (+2 overloads)
    filter
    ((
    (parameter) a: A extends number
    a
    ) =>
    (parameter) a: A extends number
    a
    >=
    (parameter) minimum: number
    minimum
    &&
    (parameter) a: A extends number
    a
    <=
    (parameter) maximum: number
    maximum
    )
    12
    ),
    13
    {
    14
    (property) strict: false
    strict
    : false,
    15
    (property) decode: (fromA: A, fromI: I) => unknown
    decode
    : (
    (parameter) a: A extends number
    a
    ) =>
    import Number
    Number
    .
    const clamp: (self: number, options: { minimum: number; maximum: number; }) => number (+1 overload)

    Restricts the given `number` to be within the range specified by the `minimum` and `maximum` values. - If the `number` is less than the `minimum` value, the function returns the `minimum` value. - If the `number` is greater than the `maximum` value, the function returns the `maximum` value. - Otherwise, it returns the original `number`.

    clamp
    (
    (parameter) a: A extends number
    a
    , {
    (property) minimum: number
    minimum
    ,
    (property) maximum: number
    maximum
    }),
    16
    (property) encode: (toI: A, toA: A) => unknown
    encode
    : (
    (parameter) a: A extends number
    a
    ) =>
    (parameter) a: A extends number
    a
    17
    }
    18
    )

While the Schema.transform function is suitable for error-free transformations, the Schema.transformOrFail function is designed for more complex scenarios where transformations can fail during the decoding or encoding stages.

This function enables decoding/encoding functions to return either a successful result or an error, making it particularly useful for validating and processing data that might not always conform to expected formats.

The Schema.transformOrFail function utilizes the ParseResult module to manage potential errors:

ConstructorDescription
ParseResult.succeedIndicates a successful transformation, where no errors occurred.
ParseResult.failSignals a failed transformation, creating a new ParseError based on the provided ParseIssue.

Additionally, the ParseResult module provides constructors for dealing with various types of parse issues, such as:

  • Type
  • Missing
  • Unexpected
  • Forbidden
  • Pointer
  • Refinement
  • Transformation
  • Composite

These tools allow for detailed and specific error handling, enhancing the reliability of data processing operations.

Example (Converting a String to a Number)

A common use case for Schema.transformOrFail is converting string representations of numbers into actual numeric types. This scenario is typical when dealing with user inputs or data from external sources.

1
import {
import ParseResult
ParseResult
,
import Schema
Schema
} from "effect"
2
3
export const
const NumberFromString: Schema.transformOrFail<typeof Schema.String, typeof Schema.Number, never>
NumberFromString
=
import Schema
Schema
.
const transformOrFail: <typeof Schema.Number, typeof Schema.String, never, never>(from: typeof Schema.String, to: typeof Schema.Number, options: { readonly decode: (fromA: string, options: ParseOptions, ast: Transformation, fromI: string) => Effect<...>; readonly encode: (toI: number, options: ParseOptions, ast: Transformation, toA: number) => Effect<...>; readonly strict?: true; } | { ...; }) => Schema.transformOrFail<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided decoding functions.

transformOrFail
(
4
import Schema
Schema
.
(alias) class String export String
String
, // Source schema: accepts any string
5
import Schema
Schema
.
(alias) class Number export Number
Number
, // Target schema: expects a number
6
{
7
(property) strict?: true
strict
: true, // optional but you get better error messages from TypeScript
8
(property) decode: (fromA: string, options: ParseOptions, ast: Transformation, fromI: string) => Effect<number, ParseResult.ParseIssue, never>
decode
: (
(parameter) input: string
input
,
(parameter) options: ParseOptions
options
,
(parameter) ast: Transformation
ast
) => {
9
const
const parsed: number
parsed
=
function parseFloat(string: string): number

Converts a string to a floating-point number.

parseFloat
(
(parameter) input: string
input
)
10
if (
function isNaN(number: number): boolean

Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).

isNaN
(
const parsed: number
parsed
)) {
11
return
import ParseResult
ParseResult
.
const fail: (issue: ParseResult.ParseIssue) => Either<never, ParseResult.ParseIssue>
fail
(
12
new
import ParseResult
ParseResult
.
constructor Type(ast: AST, actual: unknown, message?: string | undefined): ParseResult.Type

The `Type` variant of the `ParseIssue` type represents an error that occurs when the `actual` value is not of the expected type. The `ast` field specifies the expected type, and the `actual` field contains the value that caused the error.

Type
(
13
(parameter) ast: Transformation
ast
,
14
(parameter) input: string
input
,
15
"Failed to convert string to number"
16
)
17
)
18
}
19
return
import ParseResult
ParseResult
.
const succeed: <number>(a: number) => Either<number, ParseResult.ParseIssue>
succeed
(
const parsed: number
parsed
)
20
},
21
(property) encode: (toI: number, options: ParseOptions, ast: Transformation, toA: number) => Effect<string, ParseResult.ParseIssue, never>
encode
: (
(parameter) input: number
input
,
(parameter) options: ParseOptions
options
,
(parameter) ast: Transformation
ast
) =>
import ParseResult
ParseResult
.
const succeed: <string>(a: string) => Either<string, ParseResult.ParseIssue>
succeed
(
(parameter) input: number
input
.
(method) Number.toString(radix?: number): string

Returns a string representation of an object.

toString
())
22
}
23
)

In this example:

  • Decoding: Attempts to parse the input string into a number. If the parsing results in NaN (indicating that the string is not a valid number), it fails with a descriptive error.
  • Encoding: Converts the number back to a string, assuming that the input number is valid.

Both decode and encode functions not only receive the value to transform (input), but also the parse options that the user sets when using the resulting schema, and the ast, which represents the low level definition of the schema you’re transforming.

In modern applications, especially those interacting with external APIs, you might need to transform data asynchronously. Schema.transformOrFail supports asynchronous transformations by allowing you to return an Effect.

Example (Asynchronously Converting a String to a Number Using an API)

Consider a situation where you need to validate a person’s ID by fetching data from an external API. Here’s how you can implement it:

1
import {
import Effect
Effect
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
// Define an API call function
4
const
const api: (url: string) => Effect.Effect<unknown, Error>
api
= (
(parameter) url: string
url
: string):
import Effect
Effect
.
interface Effect<out A, out E = never, out R = never> namespace Effect

The `Effect` interface defines a value that lazily describes a workflow or job. The workflow requires some context `R`, and may fail with an error of type `E`, or succeed with a value of type `A`. `Effect` values model resourceful interaction with the outside world, including synchronous, asynchronous, concurrent, and parallel interaction. They use a fiber-based concurrency model, with built-in support for scheduling, fine-grained interruption, structured concurrency, and high scalability. To run an `Effect` value, you need a `Runtime`, which is a type that is capable of executing `Effect` values.

Effect
<unknown,
interface Error
Error
> =>
5
import Effect
Effect
.
const tryPromise: <unknown, Error>(options: { readonly try: (signal: AbortSignal) => PromiseLike<unknown>; readonly catch: (error: unknown) => Error; }) => Effect.Effect<unknown, Error, never> (+1 overload)

Creates an `Effect` that represents an asynchronous computation that might fail. If the `Promise` returned by `evaluate` rejects, the error is caught and the effect fails with an `UnknownException`. An optional `AbortSignal` can be provided to allow for interruption of the wrapped `Promise` API. **Overload with custom error handling:** Creates an `Effect` that represents an asynchronous computation that might fail, with custom error mapping. If the `Promise` rejects, the `catch` function maps the error to an error of type `E`.

tryPromise
({
6
(property) try: (signal: AbortSignal) => PromiseLike<unknown>
try
: () =>
7
function fetch(input: string | URL | globalThis.Request, init?: RequestInit): Promise<Response>
fetch
(
(parameter) url: string
url
).
(method) Promise<Response>.then<unknown, unknown>(onfulfilled?: ((value: Response) => unknown) | null | undefined, onrejected?: ((reason: any) => unknown) | null | undefined): Promise<unknown>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
((
(parameter) res: Response
res
) => {
8
if (
(parameter) res: Response
res
.
(property) Response.ok: boolean
ok
) {
9
return
(parameter) res: Response
res
.
(property) BodyMixin.json: () => Promise<unknown>
json
() as
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<unknown>
10
}
11
throw new
var Error: ErrorConstructor new (message?: string) => Error
Error
(
var String: StringConstructor (value?: any) => string

Allows manipulation and formatting of text strings and determination and location of substrings within strings.

String
(
(parameter) res: Response
res
.
(property) Response.status: number
status
))
12
}),
13
(property) catch: (error: unknown) => Error
catch
: (
(parameter) e: unknown
e
) => new
var Error: ErrorConstructor new (message?: string) => Error
Error
(
var String: StringConstructor (value?: any) => string

Allows manipulation and formatting of text strings and determination and location of substrings within strings.

String
(
(parameter) e: unknown
e
))
14
})
15
16
const
const PeopleId: Schema.brand<typeof Schema.String, "PeopleId">
PeopleId
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Pipeable.pipe<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.brand<typeof Schema.String, "PeopleId">): Schema.brand<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const brand: <typeof Schema.String, "PeopleId">(brand: "PeopleId", annotations?: Schema.Annotations.Schema<string & Brand<"PeopleId">, readonly []> | undefined) => (self: typeof Schema.String) => Schema.brand<...>

Returns a nominal branded schema by applying a brand to a given schema. ``` Schema<A> + B -> Schema<A & Brand<B>> ```

brand
("PeopleId"))
17
18
// Define a schema with async transformation
19
const
const PeopleIdFromString: Schema.transformOrFail<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">, never>
PeopleIdFromString
=
import Schema
Schema
.
const transformOrFail: <Schema.brand<typeof Schema.String, "PeopleId">, typeof Schema.String, never, never>(from: typeof Schema.String, to: Schema.brand<typeof Schema.String, "PeopleId">, options: { ...; } | { ...; }) => Schema.transformOrFail<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided decoding functions.

transformOrFail
(
20
import Schema
Schema
.
(alias) class String export String
String
,
21
const PeopleId: Schema.brand<typeof Schema.String, "PeopleId">
PeopleId
,
22
{
23
(property) strict?: true
strict
: true,
24
(property) decode: (fromA: string, options: ParseOptions, ast: Transformation, fromI: string) => Effect.Effect<string, ParseResult.ParseIssue, never>
decode
: (
(parameter) s: string
s
,
(parameter) _: ParseOptions
_
,
(parameter) ast: Transformation
ast
) =>
25
import Effect
Effect
.
const mapBoth: <unknown, Error, never, ParseResult.Type, string>(self: Effect.Effect<unknown, Error, never>, options: { readonly onFailure: (e: Error) => ParseResult.Type; readonly onSuccess: (a: unknown) => string; }) => Effect.Effect<...> (+1 overload)

Returns an effect whose failure and success channels have been mapped by the specified `onFailure` and `onSuccess` functions.

mapBoth
(
const api: (url: string) => Effect.Effect<unknown, Error>
api
(`https://swapi.dev/api/people/${
(parameter) s: string
s
}`), {
26
(property) onFailure: (e: Error) => ParseResult.Type
onFailure
: (
(parameter) e: Error
e
) => new
import ParseResult
ParseResult
.
constructor Type(ast: AST, actual: unknown, message?: string | undefined): ParseResult.Type

The `Type` variant of the `ParseIssue` type represents an error that occurs when the `actual` value is not of the expected type. The `ast` field specifies the expected type, and the `actual` field contains the value that caused the error.

Type
(
(parameter) ast: Transformation
ast
,
(parameter) s: string
s
,
(parameter) e: Error
e
.
(property) Error.message: string
message
),
27
(property) onSuccess: (a: unknown) => string
onSuccess
: () =>
(parameter) s: string
s
28
}),
29
(property) encode: (toI: string, options: ParseOptions, ast: Transformation, toA: string & Brand<"PeopleId">) => Effect.Effect<string, ParseResult.ParseIssue, never>
encode
:
import ParseResult
ParseResult
.
const succeed: <A>(a: A) => Either<A, ParseResult.ParseIssue>
succeed
30
}
31
)
32
33
const
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, never>
decode
= (
(parameter) id: string
id
: string) =>
34
import Effect
Effect
.
const mapError: <string & Brand<"PeopleId">, ParseResult.ParseError, never, string>(self: Effect.Effect<string & Brand<"PeopleId">, ParseResult.ParseError, never>, f: (e: ParseResult.ParseError) => string) => Effect.Effect<...> (+1 overload)

Returns an effect with its error channel mapped using the specified function.

mapError
(
import Schema
Schema
.
const decodeUnknown: <string & Brand<"PeopleId">, string, never>(schema: Schema.Schema<string & Brand<"PeopleId">, string, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<...>
decodeUnknown
(
const PeopleIdFromString: Schema.transformOrFail<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">, never>
PeopleIdFromString
)(
(parameter) id: string
id
), (
(parameter) e: ParseResult.ParseError
e
) =>
35
import ParseResult
ParseResult
.
const TreeFormatter: ParseResult.ParseResultFormatter<string>
TreeFormatter
.
(property) ParseResultFormatter<string>.formatErrorSync: (error: ParseResult.ParseError) => string
formatErrorSync
(
(parameter) e: ParseResult.ParseError
e
)
36
)
37
38
import Effect
Effect
.
const runPromiseExit: <string & Brand<"PeopleId">, string>(effect: Effect.Effect<string & Brand<"PeopleId">, string, never>, options?: { readonly signal?: AbortSignal; } | undefined) => Promise<...>

Executes an effect and returns a `Promise` that resolves with an `Exit` describing the result. Use `runPromiseExit` when you need detailed information about the outcome of the effect, including success or failure, and you want to work with Promises.

runPromiseExit
(
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, never>
decode
("1")).
(method) Promise<Exit<string & Brand<"PeopleId">, string>>.then<void, never>(onfulfilled?: ((value: Exit<string & Brand<"PeopleId">, string>) => void | PromiseLike<void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<...>) | null | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
)
39
/*
40
Output:
41
{ _id: 'Exit', _tag: 'Success', value: '1' }
42
*/
43
44
import Effect
Effect
.
const runPromiseExit: <string & Brand<"PeopleId">, string>(effect: Effect.Effect<string & Brand<"PeopleId">, string, never>, options?: { readonly signal?: AbortSignal; } | undefined) => Promise<...>

Executes an effect and returns a `Promise` that resolves with an `Exit` describing the result. Use `runPromiseExit` when you need detailed information about the outcome of the effect, including success or failure, and you want to work with Promises.

runPromiseExit
(
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, never>
decode
("fail")).
(method) Promise<Exit<string & Brand<"PeopleId">, string>>.then<void, never>(onfulfilled?: ((value: Exit<string & Brand<"PeopleId">, string>) => void | PromiseLike<void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<...>) | null | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
)
45
/*
46
Output:
47
{
48
_id: 'Exit',
49
_tag: 'Failure',
50
cause: {
51
_id: 'Cause',
52
_tag: 'Fail',
53
failure: '(string <-> string & Brand<"PeopleId">)\n' +
54
'└─ Transformation process failure\n' +
55
' └─ Error: 404'
56
}
57
}
58
*/

For more complex scenarios where your transformation might depend on external services like a fetching function, you can declare these dependencies explicitly.

Example (Injecting Dependencies)

Here’s how to inject a fetch dependency into your transformation process:

1
import {
import Context
Context
,
import Effect
Effect
,
import Layer
Layer
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Fetch: Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>
Fetch
=
import Context
Context
.
const GenericTag: <"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>(key: string) => Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>

Creates a new `Tag` instance with an optional key parameter.

GenericTag
<"Fetch", typeof
function fetch(input: string | URL | globalThis.Request, init?: RequestInit): Promise<Response>
fetch
>("Fetch")
4
5
// API call function with dependency
6
const
const api: (url: string) => Effect.Effect<unknown, Error, "Fetch">
api
= (
(parameter) url: string
url
: string):
import Effect
Effect
.
interface Effect<out A, out E = never, out R = never> namespace Effect

The `Effect` interface defines a value that lazily describes a workflow or job. The workflow requires some context `R`, and may fail with an error of type `E`, or succeed with a value of type `A`. `Effect` values model resourceful interaction with the outside world, including synchronous, asynchronous, concurrent, and parallel interaction. They use a fiber-based concurrency model, with built-in support for scheduling, fine-grained interruption, structured concurrency, and high scalability. To run an `Effect` value, you need a `Runtime`, which is a type that is capable of executing `Effect` values.

Effect
<unknown,
interface Error
Error
, "Fetch"> =>
7
const Fetch: Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>
Fetch
.
(method) Pipeable.pipe<Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>, Effect.Effect<unknown, Error, "Fetch">>(this: Context.Tag<...>, ab: (_: Context.Tag<...>) => Effect.Effect<...>): Effect.Effect<...> (+21 overloads)
pipe
(
8
import Effect
Effect
.
const flatMap: <(input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>, unknown, Error, never>(f: (a: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>) => Effect.Effect<...>) => <E, R>(self: Effect.Effect<...>) => Effect.Effect<...> (+1 overload)

This function is a pipeable operator that maps over an `Effect` value, flattening the result of the mapping function into a new `Effect` value.

flatMap
((
(parameter) fetch: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>
fetch
) =>
9
import Effect
Effect
.
const tryPromise: <unknown, Error>(options: { readonly try: (signal: AbortSignal) => PromiseLike<unknown>; readonly catch: (error: unknown) => Error; }) => Effect.Effect<unknown, Error, never> (+1 overload)

Creates an `Effect` that represents an asynchronous computation that might fail. If the `Promise` returned by `evaluate` rejects, the error is caught and the effect fails with an `UnknownException`. An optional `AbortSignal` can be provided to allow for interruption of the wrapped `Promise` API. **Overload with custom error handling:** Creates an `Effect` that represents an asynchronous computation that might fail, with custom error mapping. If the `Promise` rejects, the `catch` function maps the error to an error of type `E`.

tryPromise
({
10
(property) try: (signal: AbortSignal) => PromiseLike<unknown>
try
: () =>
11
(parameter) fetch: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>
fetch
(
(parameter) url: string
url
).
(method) Promise<Response>.then<unknown, unknown>(onfulfilled?: ((value: Response) => unknown) | null | undefined, onrejected?: ((reason: any) => unknown) | null | undefined): Promise<unknown>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
((
(parameter) res: Response
res
) => {
12
if (
(parameter) res: Response
res
.
(property) Response.ok: boolean
ok
) {
13
return
(parameter) res: Response
res
.
(property) BodyMixin.json: () => Promise<unknown>
json
() as
interface Promise<T>

Represents the completion of an asynchronous operation

Promise
<unknown>
14
}
15
throw new
var Error: ErrorConstructor new (message?: string) => Error
Error
(
var String: StringConstructor (value?: any) => string

Allows manipulation and formatting of text strings and determination and location of substrings within strings.

String
(
(parameter) res: Response
res
.
(property) Response.status: number
status
))
16
}),
17
(property) catch: (error: unknown) => Error
catch
: (
(parameter) e: unknown
e
) => new
var Error: ErrorConstructor new (message?: string) => Error
Error
(
var String: StringConstructor (value?: any) => string

Allows manipulation and formatting of text strings and determination and location of substrings within strings.

String
(
(parameter) e: unknown
e
))
18
})
19
)
20
)
21
22
const
const PeopleId: Schema.brand<typeof Schema.String, "PeopleId">
PeopleId
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Pipeable.pipe<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.brand<typeof Schema.String, "PeopleId">): Schema.brand<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const brand: <typeof Schema.String, "PeopleId">(brand: "PeopleId", annotations?: Schema.Annotations.Schema<string & Brand<"PeopleId">, readonly []> | undefined) => (self: typeof Schema.String) => Schema.brand<...>

Returns a nominal branded schema by applying a brand to a given schema. ``` Schema<A> + B -> Schema<A & Brand<B>> ```

brand
("PeopleId"))
23
24
const
const PeopleIdFromString: Schema.transformOrFail<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">, "Fetch">
PeopleIdFromString
=
import Schema
Schema
.
const transformOrFail: <Schema.brand<typeof Schema.String, "PeopleId">, typeof Schema.String, "Fetch", never>(from: typeof Schema.String, to: Schema.brand<typeof Schema.String, "PeopleId">, options: { ...; } | { ...; }) => Schema.transformOrFail<...> (+1 overload)

Create a new `Schema` by transforming the input and output of an existing `Schema` using the provided decoding functions.

transformOrFail
(
25
import Schema
Schema
.
(alias) class String export String
String
,
26
const PeopleId: Schema.brand<typeof Schema.String, "PeopleId">
PeopleId
,
27
{
28
(property) strict?: true
strict
: true,
29
(property) decode: (fromA: string, options: ParseOptions, ast: Transformation, fromI: string) => Effect.Effect<string, ParseResult.ParseIssue, "Fetch">
decode
: (
(parameter) s: string
s
,
(parameter) _: ParseOptions
_
,
(parameter) ast: Transformation
ast
) =>
30
import Effect
Effect
.
const mapBoth: <unknown, Error, "Fetch", ParseResult.Type, string>(self: Effect.Effect<unknown, Error, "Fetch">, options: { readonly onFailure: (e: Error) => ParseResult.Type; readonly onSuccess: (a: unknown) => string; }) => Effect.Effect<...> (+1 overload)

Returns an effect whose failure and success channels have been mapped by the specified `onFailure` and `onSuccess` functions.

mapBoth
(
const api: (url: string) => Effect.Effect<unknown, Error, "Fetch">
api
(`https://swapi.dev/api/people/${
(parameter) s: string
s
}`), {
31
(property) onFailure: (e: Error) => ParseResult.Type
onFailure
: (
(parameter) e: Error
e
) => new
import ParseResult
ParseResult
.
constructor Type(ast: AST, actual: unknown, message?: string | undefined): ParseResult.Type

The `Type` variant of the `ParseIssue` type represents an error that occurs when the `actual` value is not of the expected type. The `ast` field specifies the expected type, and the `actual` field contains the value that caused the error.

Type
(
(parameter) ast: Transformation
ast
,
(parameter) s: string
s
,
(parameter) e: Error
e
.
(property) Error.message: string
message
),
32
(property) onSuccess: (a: unknown) => string
onSuccess
: () =>
(parameter) s: string
s
33
}),
34
(property) encode: (toI: string, options: ParseOptions, ast: Transformation, toA: string & Brand<"PeopleId">) => Effect.Effect<string, ParseResult.ParseIssue, never>
encode
:
import ParseResult
ParseResult
.
const succeed: <A>(a: A) => Either<A, ParseResult.ParseIssue>
succeed
35
}
36
)
37
38
const
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, "Fetch">
decode
= (
(parameter) id: string
id
: string) =>
39
import Effect
Effect
.
const mapError: <string & Brand<"PeopleId">, ParseResult.ParseError, "Fetch", string>(self: Effect.Effect<string & Brand<"PeopleId">, ParseResult.ParseError, "Fetch">, f: (e: ParseResult.ParseError) => string) => Effect.Effect<...> (+1 overload)

Returns an effect with its error channel mapped using the specified function.

mapError
(
import Schema
Schema
.
const decodeUnknown: <string & Brand<"PeopleId">, string, "Fetch">(schema: Schema.Schema<string & Brand<"PeopleId">, string, "Fetch">, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<...>
decodeUnknown
(
const PeopleIdFromString: Schema.transformOrFail<typeof Schema.String, Schema.brand<typeof Schema.String, "PeopleId">, "Fetch">
PeopleIdFromString
)(
(parameter) id: string
id
), (
(parameter) e: ParseResult.ParseError
e
) =>
40
import ParseResult
ParseResult
.
const TreeFormatter: ParseResult.ParseResultFormatter<string>
TreeFormatter
.
(property) ParseResultFormatter<string>.formatErrorSync: (error: ParseResult.ParseError) => string
formatErrorSync
(
(parameter) e: ParseResult.ParseError
e
)
41
)
42
43
const
const FetchLive: Layer.Layer<"Fetch", never, never>
FetchLive
=
import Layer
Layer
.
const succeed: <Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>>(tag: Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>, resource: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>) => Layer.Layer<...> (+1 overload)

Constructs a layer from the specified value.

succeed
(
const Fetch: Context.Tag<"Fetch", (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>>
Fetch
,
function fetch(input: string | URL | globalThis.Request, init?: RequestInit): Promise<Response>
fetch
)
44
45
import Effect
Effect
.
const runPromiseExit: <string & Brand<"PeopleId">, string>(effect: Effect.Effect<string & Brand<"PeopleId">, string, never>, options?: { readonly signal?: AbortSignal; } | undefined) => Promise<...>

Executes an effect and returns a `Promise` that resolves with an `Exit` describing the result. Use `runPromiseExit` when you need detailed information about the outcome of the effect, including success or failure, and you want to work with Promises.

runPromiseExit
(
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, "Fetch">
decode
("1").
(method) Pipeable.pipe<Effect.Effect<string & Brand<"PeopleId">, string, "Fetch">, Effect.Effect<string & Brand<"PeopleId">, string, never>>(this: Effect.Effect<...>, ab: (_: Effect.Effect<string & Brand<...>, string, "Fetch">) => Effect.Effect<...>): Effect.Effect<...> (+21 overloads)
pipe
(
import Effect
Effect
.
const provide: <"Fetch", never, never>(layer: Layer.Layer<"Fetch", never, never>) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, "Fetch">> (+9 overloads)

Splits the context into two parts, providing one part using the specified layer/context/runtime and leaving the remainder `R0`

provide
(
const FetchLive: Layer.Layer<"Fetch", never, never>
FetchLive
))).
(method) Promise<Exit<string & Brand<"PeopleId">, string>>.then<void, never>(onfulfilled?: ((value: Exit<string & Brand<"PeopleId">, string>) => void | PromiseLike<void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<...>) | null | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
46
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
47
)
48
/*
49
Output:
50
{ _id: 'Exit', _tag: 'Success', value: '1' }
51
*/
52
53
import Effect
Effect
.
const runPromiseExit: <string & Brand<"PeopleId">, string>(effect: Effect.Effect<string & Brand<"PeopleId">, string, never>, options?: { readonly signal?: AbortSignal; } | undefined) => Promise<...>

Executes an effect and returns a `Promise` that resolves with an `Exit` describing the result. Use `runPromiseExit` when you need detailed information about the outcome of the effect, including success or failure, and you want to work with Promises.

runPromiseExit
(
54
const decode: (id: string) => Effect.Effect<string & Brand<"PeopleId">, string, "Fetch">
decode
("fail").
(method) Pipeable.pipe<Effect.Effect<string & Brand<"PeopleId">, string, "Fetch">, Effect.Effect<string & Brand<"PeopleId">, string, never>>(this: Effect.Effect<...>, ab: (_: Effect.Effect<string & Brand<...>, string, "Fetch">) => Effect.Effect<...>): Effect.Effect<...> (+21 overloads)
pipe
(
import Effect
Effect
.
const provide: <"Fetch", never, never>(layer: Layer.Layer<"Fetch", never, never>) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, "Fetch">> (+9 overloads)

Splits the context into two parts, providing one part using the specified layer/context/runtime and leaving the remainder `R0`

provide
(
const FetchLive: Layer.Layer<"Fetch", never, never>
FetchLive
))
55
).
(method) Promise<Exit<string & Brand<"PeopleId">, string>>.then<void, never>(onfulfilled?: ((value: Exit<string & Brand<"PeopleId">, string>) => void | PromiseLike<void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<...>) | null | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
)
56
/*
57
Output:
58
{
59
_id: 'Exit',
60
_tag: 'Failure',
61
cause: {
62
_id: 'Cause',
63
_tag: 'Fail',
64
failure: '(string <-> string & Brand<"PeopleId">)\n' +
65
'└─ Transformation process failure\n' +
66
' └─ Error: 404'
67
}
68
}
69
*/

Combining and reusing schemas is a common requirement, the Schema.compose combinator allows you to do just that. It enables you to combine two schemas, Schema<B, A, R1> and Schema<C, B, R2>, into a single schema Schema<C, A, R1 | R2>:

1
import {
import Schema
Schema
} from "effect"
2
3
// Schema<readonly string[], string>
4
const
const schema1: Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>
schema1
=
import Schema
Schema
.
const split: (separator: string) => Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>

Returns a schema that allows splitting a string into an array of strings.

split
(",")
5
6
// Schema<readonly number[], readonly string[]>
7
const
const schema2: Schema.Array$<typeof Schema.NumberFromString>
schema2
=
import Schema
Schema
.
(alias) Array<typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString): Schema.Array$<typeof Schema.NumberFromString> export Array
Array
(
import Schema
Schema
.
class NumberFromString

This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

NumberFromString
)
8
9
// Schema<readonly number[], string>
10
const
const ComposedSchema: Schema.SchemaClass<readonly number[], string, never>
ComposedSchema
=
import Schema
Schema
.
const compose: <readonly string[], string, never, readonly number[], readonly string[], never>(from: Schema.Schema<readonly string[], string, never>, to: Schema.Schema<readonly number[], readonly string[], never>) => Schema.SchemaClass<readonly number[], string, never> (+7 overloads)
compose
(
const schema1: Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>
schema1
,
const schema2: Schema.Array$<typeof Schema.NumberFromString>
schema2
)

In this example, we have two schemas, schema1 and schema2. The first schema, schema1, takes a string and splits it into an array using a comma as the delimiter. The second schema, schema2, transforms an array of strings into an array of numbers.

Now, by using the compose combinator, we can create a new schema, ComposedSchema, that combines the functionality of both schema1 and schema2. This allows us to parse a string and directly obtain an array of numbers as a result.

If you need to be less restrictive when composing your schemas, i.e., when you have something like Schema<R1, A, B> and Schema<R2, C, D> where C is different from B, you can make use of the { strict: false } option:

1
import {
import Schema
Schema
} from "effect"
2
3
import Schema
Schema
.
const compose: <"0" | null, "0" | null, never>(to: Schema.Schema<"0" | null, "0" | null, never>, options?: { readonly strict: true; }) => <A, R1>(from: Schema.Schema<"0" | null, A, R1>) => Schema.SchemaClass<...> (+7 overloads)
compose
(
4
// @ts-expect-error
5
import Schema
Schema
.
function Union<[typeof Schema.Null, Schema.Literal<["0"]>]>(members_0: typeof Schema.Null, members_1: Schema.Literal<["0"]>): Schema.Union<[typeof Schema.Null, Schema.Literal<["0"]>]> (+3 overloads)
Union
(
import Schema
Schema
.
class Null
Null
,
import Schema
Schema
.
function Literal<["0"]>(literals_0: "0"): Schema.Literal<["0"]> (+2 overloads)
Literal
("0")),
6
import Schema
Schema
.
class NumberFromString

This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

NumberFromString
7
)
8
9
// ok
10
import Schema
Schema
.
const compose: <"0" | null, "0" | null, never, number, string, never>(from: Schema.Schema<"0" | null, "0" | null, never>, to: Schema.Schema<number, string, never>, options: { readonly strict: false; }) => Schema.SchemaClass<...> (+7 overloads)
compose
(
11
import Schema
Schema
.
function Union<[typeof Schema.Null, Schema.Literal<["0"]>]>(members_0: typeof Schema.Null, members_1: Schema.Literal<["0"]>): Schema.Union<[typeof Schema.Null, Schema.Literal<["0"]>]> (+3 overloads)
Union
(
import Schema
Schema
.
class Null
Null
,
import Schema
Schema
.
function Literal<["0"]>(literals_0: "0"): Schema.Literal<["0"]> (+2 overloads)
Literal
("0")),
12
import Schema
Schema
.
class NumberFromString

This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

NumberFromString
,
13
{
(property) strict: false
strict
: false }
14
)

The Schema.filterEffect function enhances the Schema.filter functionality by allowing the integration of effects, thus enabling asynchronous or dynamic validation scenarios. This is particularly useful when validations need to perform operations that require side effects, such as network requests or database queries.

Example (Validating Usernames Asynchronously)

1
import {
import Schema
Schema
} from "effect"
2
import {
import Effect
Effect
} from "effect"
3
4
async function
function validateUsername(username: string): Promise<boolean>
validateUsername
(
(parameter) username: string
username
: string) {
5
return
var Promise: PromiseConstructor

Represents the completion of an asynchronous operation

Promise
.
(method) PromiseConstructor.resolve<boolean>(value: boolean): Promise<boolean> (+2 overloads)

Creates a new resolved promise for the provided value.

resolve
(
(parameter) username: string
username
=== "gcanti")
6
}
7
8
const
const ValidUsername: Schema.transformOrFail<typeof Schema.String, Schema.SchemaClass<string, string, never>, never>
ValidUsername
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Pipeable.pipe<typeof Schema.String, Schema.filterEffect<typeof Schema.String, never>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filterEffect<typeof Schema.String, never>): Schema.filterEffect<...> (+21 overloads)
pipe
(
9
import Schema
Schema
.
const filterEffect: <typeof Schema.String, never>(f: (a: string, options: ParseOptions, self: Transformation) => Effect.Effect<FilterReturnType, never, never>) => (self: typeof Schema.String) => Schema.filterEffect<...> (+1 overload)
filterEffect
((
(parameter) username: string
username
) =>
10
import Effect
Effect
.
const promise: <string | boolean | Type | Missing | Unexpected | Forbidden | Pointer | Refinement | Transformation | Composite | Schema.FilterIssue | readonly Schema.FilterOutput[] | undefined>(evaluate: (signal: AbortSignal) => PromiseLike<...>) => Effect.Effect<...>

Creates an `Effect` that represents an asynchronous computation guaranteed to succeed. The provided function (`thunk`) returns a `Promise` that should never reject. If the `Promise` does reject, the rejection is treated as a defect. An optional `AbortSignal` can be provided to allow for interruption of the wrapped `Promise` API.

promise
(() =>
11
function validateUsername(username: string): Promise<boolean>
validateUsername
(
(parameter) username: string
username
).
(method) Promise<boolean>.then<true | "Invalid username", string | boolean | Type | Missing | Unexpected | Forbidden | Pointer | Refinement | ... 4 more ... | undefined>(onfulfilled?: ((value: boolean) => true | ... 1 more ... | PromiseLike<...>) | ... 1 more ... | undefined, onrejected?: ((reason: any) => string | ... 12 more ... | undefined) | ... 1 more ... | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
12
(
(parameter) valid: boolean
valid
) =>
(parameter) valid: boolean
valid
|| "Invalid username"
13
)
14
)
15
)
16
).
(method) Annotable<transformOrFail<typeof String$, SchemaClass<string, string, never>, never>, string, string, never>.annotations(annotations: Schema.Annotations.Schema<string, readonly []>): Schema.transformOrFail<typeof Schema.String, Schema.SchemaClass<string, string, never>, never>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
(property) Annotations.Schema<string, readonly []>.identifier?: string
identifier
: "ValidUsername" })
17
18
import Effect
Effect
.
const runPromise: <string, ParseError>(effect: Effect.Effect<string, ParseError, never>, options?: { readonly signal?: AbortSignal; } | undefined) => Promise<...>

Executes an effect and returns a `Promise` that resolves with the result. Use `runPromise` when working with asynchronous effects and you need to integrate with code that uses Promises. If the effect fails, the returned Promise will be rejected with the error.

runPromise
(
import Schema
Schema
.
const decodeUnknown: <string, string, never>(schema: Schema.Schema<string, string, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<...>
decodeUnknown
(
const ValidUsername: Schema.transformOrFail<typeof Schema.String, Schema.SchemaClass<string, string, never>, never>
ValidUsername
)("xxx")).
(method) Promise<string>.then<void, never>(onfulfilled?: ((value: string) => void | PromiseLike<void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<...>

Attaches callbacks for the resolution and/or rejection of the Promise.

then
(
19
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
20
)
21
/*
22
ParseError: ValidUsername
23
└─ Transformation process failure
24
└─ Invalid username
25
*/

Splits a string into an array of strings.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>
schema
=
import Schema
Schema
.
const split: (separator: string) => Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>

Returns a schema that allows splitting a string into an array of strings.

split
(",")
4
5
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => readonly string[]
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<readonly string[], string>(schema: Schema.Schema<readonly string[], string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => readonly string[] export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.String>>
schema
)
6
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => readonly string[]
decode
("")) // [""]
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => readonly string[]
decode
(",")) // ["", ""]
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => readonly string[]
decode
("a,")) // ["a", ""]
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => readonly string[]
decode
("a,b")) // ["a", "b"]

Removes whitespaces from the beginning and end of a string.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Trim

This schema allows removing whitespaces from the beginning and end of a string.

Trim
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("a")) // "a"
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" a")) // "a"
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("a ")) // "a"
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" a ")) // "a"

Note. If you were looking for a combinator to check if a string is trimmed, check out the trimmed filter.

Converts a string to lowercase.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Lowercase

This schema converts a string to lowercase.

Lowercase
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("A")) // "a"
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" AB")) // " ab"
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("Ab ")) // "ab "
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" ABc ")) // " abc "

Converts a string to uppercase.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Uppercase

This schema converts a string to uppercase.

Uppercase
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("a")) // "A"
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" ab")) // " AB"
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("aB ")) // "AB "
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" abC ")) // " ABC "

Converts a string to capitalized one.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Capitalize

This schema converts a string to capitalized one.

Capitalize
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("aa")) // "Aa"
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" ab")) // " ab"
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("aB ")) // "AB "
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" abC ")) // " abC "

Converts a string to uncapitalized one.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Uncapitalize

This schema converts a string to uncapitalized one.

Uncapitalize
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("AA")) // "aA"
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" AB")) // " AB"
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("Ab ")) // "ab "
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
(" AbC ")) // " AbC "

The Schema.parseJson constructor offers a method to convert JSON strings into the unknown type using the underlying functionality of JSON.parse. It also employs JSON.stringify for encoding.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.SchemaClass<unknown, string, never>
schema
=
import Schema
Schema
.
const parseJson: (options?: Schema.ParseJsonOptions) => Schema.SchemaClass<unknown, string> (+1 overload)

The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding. You can optionally provide a `ParseJsonOptions` to configure both `JSON.parse` and `JSON.stringify` executions. Optionally, you can pass a schema `Schema<A, I, R>` to obtain an `A` type instead of `unknown`.

parseJson
()
4
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => unknown
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<unknown, string>(schema: Schema.Schema<unknown, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => unknown export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.SchemaClass<unknown, string, never>
schema
)
5
6
// Parse valid JSON strings
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => unknown
decode
("{}")) // Output: {}
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => unknown
decode
(`{"a":"b"}`)) // Output: { a: "b" }
9
10
// Attempting to decode an empty string results in an error
11
const decode: (u: unknown, overrideOptions?: ParseOptions) => unknown
decode
("")
12
/*
13
throws:
14
ParseError: (JsonString <-> unknown)
15
└─ Transformation process failure
16
└─ Unexpected end of JSON input
17
*/

Additionally, you can refine the parsing result by providing a schema to the parseJson constructor:

1
import {
import Schema
Schema
} from "effect"
2
3
// Schema<{ readonly a: number; }, string, never>
4
const
const schema: Schema.SchemaClass<{ readonly a: number; }, string, never>
schema
=
import Schema
Schema
.
const parseJson: <{ readonly a: number; }, { readonly a: number; }, never>(schema: Schema.Schema<{ readonly a: number; }, { readonly a: number; }, never>, options?: Schema.ParseJsonOptions) => Schema.SchemaClass<...> (+1 overload)

The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding. You can optionally provide a `ParseJsonOptions` to configure both `JSON.parse` and `JSON.stringify` executions. Optionally, you can pass a schema `Schema<A, I, R>` to obtain an `A` type instead of `unknown`.

parseJson
(
import Schema
Schema
.
function Struct<{ a: typeof Schema.Number; }>(fields: { a: typeof Schema.Number; }): Schema.Struct<{ a: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
(property) a: typeof Schema.Number
a
:
import Schema
Schema
.
(alias) class Number export Number
Number
}))

In this example, we’ve used parseJson with a struct schema to ensure that the parsed result has a specific structure, including an object with a numeric property “a”. This helps in handling JSON data with predefined shapes.

Decodes a base64 (RFC4648) encoded string into a UTF-8 string.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
const StringFromBase64: Schema.Schema<string, string, never>

Decodes a base64 (RFC4648) encoded string into a UTF-8 string.

StringFromBase64
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("Zm9vYmFy")) // "foobar"

Decodes a base64 (URL) encoded string into a UTF-8 string.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
const StringFromBase64Url: Schema.Schema<string, string, never>

Decodes a base64 (URL) encoded string into a UTF-8 string.

StringFromBase64Url
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("Zm9vYmFy")) // "foobar"

Decodes a hex encoded string into a UTF-8 string.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
const StringFromHex: Schema.Schema<string, string, never>

Decodes a hex encoded string into a UTF-8 string.

StringFromHex
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(new
var TextEncoder: new () => TextEncoder

`TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'` https://nodejs.org/api/globals.html#textencoder

TextEncoder
().
(method) TextEncoder.encode(input?: string): Uint8Array

UTF-8 encodes the `input` string and returns a `Uint8Array` containing the encoded bytes.

encode
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => string
decode
("0001020304050607")))
6
/*
7
Output:
8
Uint8Array(8) [
9
0, 1, 2, 3,
10
4, 5, 6, 7
11
]
12
*/

Transforms a string into a number by parsing the string using parseFloat.

The following special string values are supported: “NaN”, “Infinity”, “-Infinity”.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.NumberFromString
schema
=
import Schema
Schema
.
class NumberFromString

This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

NumberFromString
4
5
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<number, string>(schema: Schema.Schema<number, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => number export decodeUnknownSync
decodeUnknownSync
(
const schema: typeof Schema.NumberFromString
schema
)
6
7
// success cases
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("1")) // 1
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("-1")) // -1
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("1.5")) // 1.5
11
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("NaN")) // NaN
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("Infinity")) // Infinity
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("-Infinity")) // -Infinity
14
15
// failure cases
16
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("a")
17
/*
18
throws:
19
ParseError: NumberFromString
20
└─ Transformation process failure
21
└─ Expected NumberFromString, actual "a"
22
*/

Clamps a number between a minimum and a maximum value.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>
schema
=
import Schema
Schema
.
(alias) class Number export Number
Number
.
(method) Pipeable.pipe<typeof Schema.Number, Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.transform<...>): Schema.transform<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const clamp: (minimum: number, maximum: number) => <A extends number, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.Schema<A>>>

Clamps a number between a minimum and a maximum value.

clamp
(-1, 1)) // clamps the input to -1 <= x <= 1
4
5
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<number, number>(schema: Schema.Schema<number, number, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => number export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>
schema
)
6
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
(-3)) // -1
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
(0)) // 0
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
(3)) // 1

Transforms a string into a number by parsing the string using the parse function of the effect/Number module.

It returns an error if the value can’t be converted (for example when non-numeric characters are provided).

The following special string values are supported: “NaN”, “Infinity”, “-Infinity”.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.transformOrFail<Schema.Schema<string, string, never>, typeof Schema.Number, never>
schema
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Pipeable.pipe<typeof Schema.String, Schema.transformOrFail<Schema.Schema<string, string, never>, typeof Schema.Number, never>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.transformOrFail<Schema.Schema<string, string, never>, typeof Schema.Number, never>): Schema.transformOrFail<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const parseNumber: <A extends string, I, R>(self: Schema.Schema<A, I, R>) => Schema.transformOrFail<Schema.Schema<A, I, R>, typeof Schema.Number>

Transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

parseNumber
)
4
5
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<number, string>(schema: Schema.Schema<number, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => number export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.transformOrFail<Schema.Schema<string, string, never>, typeof Schema.Number, never>
schema
)
6
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("1")) // 1
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("Infinity")) // Infinity
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("NaN")) // NaN
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => number
decode
("-"))
11
/*
12
throws
13
ParseError: (string <-> number)
14
└─ Transformation process failure
15
└─ Expected (string <-> number), actual "-"
16
*/

Negates a boolean value.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => boolean
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<boolean, boolean>(schema: Schema.Schema<boolean, boolean, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => boolean export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class Not
Not
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => boolean
decode
(true)) // false
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => boolean
decode
(false)) // true

Transforms a string into a symbol by parsing the string using Symbol.for.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => symbol
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<symbol, string>(schema: Schema.Schema<symbol, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => symbol export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
(alias) class Symbol export Symbol

This schema transforms a `string` into a `symbol`.

Symbol
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => symbol
decode
("a")) // Symbol(a)

Transforms a string into a BigInt by parsing the string using the BigInt constructor.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<bigint, string>(schema: Schema.Schema<bigint, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => bigint export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
(alias) class BigInt export BigInt

This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function. It returns an error if the value can't be converted (for example when non-numeric characters are provided).

BigInt
)
4
5
// success cases
6
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("1")) // 1n
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("-1")) // -1n
8
9
// failure cases
10
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("a")
11
/*
12
throws:
13
ParseError: bigint
14
└─ Transformation process failure
15
└─ Expected bigint, actual "a"
16
*/
17
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("1.5") // throws
18
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("NaN") // throws
19
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("Infinity") // throws
20
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
("-Infinity") // throws

Transforms a number into a BigInt by parsing the number using the BigInt constructor.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<bigint, number>(schema: Schema.Schema<bigint, number, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => bigint export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class BigIntFromNumber

This schema transforms a `number` into a `bigint` by parsing the number using the `BigInt` function. It returns an error if the value can't be safely encoded as a `number` due to being out of range.

BigIntFromNumber
)
4
const
const encode: (a: bigint, overrideOptions?: ParseOptions) => number
encode
=
import Schema
Schema
.
(alias) encodeSync<bigint, number>(schema: Schema.Schema<bigint, number, never>, options?: ParseOptions): (a: bigint, overrideOptions?: ParseOptions) => number export encodeSync
encodeSync
(
import Schema
Schema
.
class BigIntFromNumber

This schema transforms a `number` into a `bigint` by parsing the number using the `BigInt` function. It returns an error if the value can't be safely encoded as a `number` due to being out of range.

BigIntFromNumber
)
5
6
// success cases
7
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(1)) // 1n
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(-1)) // -1n
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const encode: (a: bigint, overrideOptions?: ParseOptions) => number
encode
(1n)) // 1
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const encode: (a: bigint, overrideOptions?: ParseOptions) => number
encode
(-1n)) // -1
11
12
// failure cases
13
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(1.5)
14
/*
15
throws:
16
ParseError: BigintFromNumber
17
└─ Transformation process failure
18
└─ Expected BigintFromNumber, actual 1.5
19
*/
20
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(
var NaN: number
NaN
) // throws
21
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(
var Infinity: number
Infinity
) // throws
22
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(-
var Infinity: number
Infinity
) // throws
23
const encode: (a: bigint, overrideOptions?: ParseOptions) => number
encode
(
var BigInt: BigIntConstructor (value: bigint | boolean | number | string) => bigint
BigInt
(
var Number: NumberConstructor

An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.

Number
.
(property) NumberConstructor.MAX_SAFE_INTEGER: number

The value of the largest integer n such that n and n + 1 are both exactly representable as a Number value. The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.

MAX_SAFE_INTEGER
) + 1n) // throws
24
const encode: (a: bigint, overrideOptions?: ParseOptions) => number
encode
(
var BigInt: BigIntConstructor (value: bigint | boolean | number | string) => bigint
BigInt
(
var Number: NumberConstructor

An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.

Number
.
(property) NumberConstructor.MIN_SAFE_INTEGER: number

The value of the smallest integer n such that n and n − 1 are both exactly representable as a Number value. The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).

MIN_SAFE_INTEGER
) - 1n) // throws

Clamps a BigInt between a minimum and a maximum value.

1
import {
import Schema
Schema
} from "effect"
2
3
// clamps the input to -1n <= x <= 1n
4
const
const schema: Schema.transform<Schema.Schema<bigint, bigint, never>, Schema.filter<Schema.Schema<bigint, bigint, never>>>
schema
=
import Schema
Schema
.
class BigIntFromSelf
BigIntFromSelf
.
(method) Pipeable.pipe<typeof Schema.BigIntFromSelf, Schema.transform<Schema.Schema<bigint, bigint, never>, Schema.filter<Schema.Schema<bigint, bigint, never>>>>(this: typeof Schema.BigIntFromSelf, ab: (_: typeof Schema.BigIntFromSelf) => Schema.transform<...>): Schema.transform<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const clampBigInt: (minimum: bigint, maximum: bigint) => <A extends bigint, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.Schema<A>>>

Clamps a bigint between a minimum and a maximum value.

clampBigInt
(-1n, 1n))
5
6
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<bigint, bigint>(schema: Schema.Schema<bigint, bigint, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => bigint export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.transform<Schema.Schema<bigint, bigint, never>, Schema.filter<Schema.Schema<bigint, bigint, never>>>
schema
)
7
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(-3n)) // -1n
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(0n)) // 0n
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => bigint
decode
(3n)) // 1n

Transforms a string into a valid Date, ensuring that invalid dates, such as new Date("Invalid Date"), are rejected.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Date
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<Date, string>(schema: Schema.Schema<Date, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Date export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
(alias) class Date export Date

This schema converts a `string` into a `Date` object using the `new Date` constructor. It ensures that only valid date strings are accepted, rejecting any strings that would result in an invalid date, such as `new Date("Invalid Date")`.

Date
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Date
decode
("1970-01-01T00:00:00.000Z")) // 1970-01-01T00:00:00.000Z
6
7
const decode: (u: unknown, overrideOptions?: ParseOptions) => Date
decode
("a")
8
/*
9
throws:
10
ParseError: Date
11
└─ Predicate refinement failure
12
└─ Expected Date, actual Invalid Date
13
*/
14
15
const
const validate: (u: unknown, overrideOptions?: ParseOptions) => Date
validate
=
import Schema
Schema
.
(alias) validateSync<Date, string, never>(schema: Schema.Schema<Date, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Date export validateSync
validateSync
(
import Schema
Schema
.
(alias) class Date export Date

This schema converts a `string` into a `Date` object using the `new Date` constructor. It ensures that only valid date strings are accepted, rejecting any strings that would result in an invalid date, such as `new Date("Invalid Date")`.

Date
)
16
17
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const validate: (u: unknown, overrideOptions?: ParseOptions) => Date
validate
(new
var Date: DateConstructor new (value: number | string | Date) => Date (+3 overloads)
Date
(0))) // 1970-01-01T00:00:00.000Z
18
const validate: (u: unknown, overrideOptions?: ParseOptions) => Date
validate
(new
var Date: DateConstructor new (value: number | string | Date) => Date (+3 overloads)
Date
("Invalid Date"))
19
/*
20
throws:
21
ParseError: Date
22
└─ Predicate refinement failure
23
└─ Expected Date, actual Invalid Date
24
*/

Transforms a string into a BigDecimal.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<BigDecimal, string>(schema: Schema.Schema<BigDecimal, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => BigDecimal export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class BigDecimal
BigDecimal
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal
decode
(".124")) // { _id: 'BigDecimal', value: '124', scale: 3 }

Transforms a number into a BigDecimal.

1
import {
import Schema
Schema
} from "effect"
2
3
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<BigDecimal, number>(schema: Schema.Schema<BigDecimal, number, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => BigDecimal export decodeUnknownSync
decodeUnknownSync
(
import Schema
Schema
.
class BigDecimalFromNumber

A schema that transforms a `number` into a `BigDecimal`. When encoding, this Schema will produce incorrect results if the BigDecimal exceeds the 64-bit range of a number.

BigDecimalFromNumber
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal
decode
(0.111)) // { _id: 'BigDecimal', value: '111', scale: 3 }

Clamps a BigDecimal between a minimum and a maximum value.

1
import {
import Schema
Schema
} from "effect"
2
import {
import BigDecimal
BigDecimal
} from "effect"
3
4
const
const schema: Schema.transform<Schema.Schema<BigDecimal.BigDecimal, string, never>, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, BigDecimal.BigDecimal, never>>>
schema
=
import Schema
Schema
.
class BigDecimal
BigDecimal
.
(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.transform<Schema.Schema<BigDecimal.BigDecimal, string, never>, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, BigDecimal.BigDecimal, never>>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.transform<...>): Schema.transform<...> (+21 overloads)
pipe
(
5
import Schema
Schema
.
const clampBigDecimal: (minimum: BigDecimal.BigDecimal, maximum: BigDecimal.BigDecimal) => <A extends BigDecimal.BigDecimal, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.Schema<A>>>

Clamps a `BigDecimal` between a minimum and a maximum value.

clampBigDecimal
(
6
import BigDecimal
BigDecimal
.
const fromNumber: (n: number) => BigDecimal.BigDecimal

Creates a `BigDecimal` from a `number` value. It is not recommended to convert a floating point number to a decimal directly, as the floating point representation may be unexpected.

fromNumber
(-1),
7
import BigDecimal
BigDecimal
.
const fromNumber: (n: number) => BigDecimal.BigDecimal

Creates a `BigDecimal` from a `number` value. It is not recommended to convert a floating point number to a decimal directly, as the floating point representation may be unexpected.

fromNumber
(1)
8
)
9
)
10
11
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal.BigDecimal
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<BigDecimal.BigDecimal, string>(schema: Schema.Schema<BigDecimal.BigDecimal, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => BigDecimal.BigDecimal export decodeUnknownSync
decodeUnknownSync
(
const schema: Schema.transform<Schema.Schema<BigDecimal.BigDecimal, string, never>, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, BigDecimal.BigDecimal, never>>>
schema
)
12
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal.BigDecimal
decode
("-2")) // { _id: 'BigDecimal', value: '-1', scale: 0 }
14
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal.BigDecimal
decode
("0")) // { _id: 'BigDecimal', value: '0', scale: 0 }
15
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => BigDecimal.BigDecimal
decode
("3")) // { _id: 'BigDecimal', value: '1', scale: 0 }