Skip to content

Effect Data Types

The Data module in the Effect ecosystem simplifies value comparison by automatically implementing the Equal and Hash traits. This eliminates the need for manual implementations, making equality checks straightforward.

Example (Comparing Structs with Data)

import {
import Data
Data
,
import Equal
Equal
} from "effect"
const
const person1: {
readonly name: string;
readonly age: number;
}
person1
=
import Data
Data
.
const struct: <{
name: string;
age: number;
}>(a: {
name: string;
age: number;
}) => {
readonly name: string;
readonly age: number;
}

@example

import { Data, Equal } from "effect"
const alice = Data.struct({ name: "Alice", age: 30 })
const bob = Data.struct({ name: "Bob", age: 40 })
assert.deepStrictEqual(Equal.equals(alice, alice), true)
assert.deepStrictEqual(Equal.equals(alice, Data.struct({ name: "Alice", age: 30 })), true)
assert.deepStrictEqual(Equal.equals(alice, { name: "Alice", age: 30 }), false)
assert.deepStrictEqual(Equal.equals(alice, bob), false)

@since2.0.0

struct
({
name: string
name
: "Alice",
age: number
age
: 30 })
const
const person2: {
readonly name: string;
readonly age: number;
}
person2
=
import Data
Data
.
const struct: <{
name: string;
age: number;
}>(a: {
name: string;
age: number;
}) => {
readonly name: string;
readonly age: number;
}

@example

import { Data, Equal } from "effect"
const alice = Data.struct({ name: "Alice", age: 30 })
const bob = Data.struct({ name: "Bob", age: 40 })
assert.deepStrictEqual(Equal.equals(alice, alice), true)
assert.deepStrictEqual(Equal.equals(alice, Data.struct({ name: "Alice", age: 30 })), true)
assert.deepStrictEqual(Equal.equals(alice, { name: "Alice", age: 30 }), false)
assert.deepStrictEqual(Equal.equals(alice, bob), false)

@since2.0.0

struct
({
name: string
name
: "Alice",
age: number
age
: 30 })
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Equal
Equal
.
function equals<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}>(self: {
readonly name: string;
readonly age: number;
}, that: {
readonly name: string;
readonly age: number;
}): boolean (+1 overload)

@since2.0.0

equals
(
const person1: {
readonly name: string;
readonly age: number;
}
person1
,
const person2: {
readonly name: string;
readonly age: number;
}
person2
))
// Output: true

By default, schemas like Schema.Struct do not implement the Equal and Hash traits. This means that two decoded objects with identical values will not be considered equal.

Example (Default Behavior Without Equal and Hash)

import {
import Schema
Schema
} from "effect"
import {
import Equal
Equal
} from "effect"
const
const schema: Schema.Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}>
schema
=
import Schema
Schema
.
function Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}>(fields: {
name: typeof Schema.String;
age: typeof Schema.Number;
}): Schema.Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}> (+1 overload)

@since3.10.0

Struct
({
name: typeof Schema.String
name
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
age: typeof Schema.Number
age
:
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
})
const
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
=
import Schema
Schema
.
const decode: <{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>(schema: Schema.Schema<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>, options?: ParseOptions) => (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<...>

@since3.10.0

decode
(
const schema: Schema.Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}>
schema
)
const
const person1: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person1
=
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
({
name: string
name
: "Alice",
age: number
age
: 30 })
const
const person2: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person2
=
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
({
name: string
name
: "Alice",
age: number
age
: 30 })
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Equal
Equal
.
function equals<Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>, Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>>(self: Effect<...>, that: Effect<...>): boolean (+1 overload)

@since2.0.0

equals
(
const person1: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person1
,
const person2: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person2
))
// Output: false

The Schema.Data function can be used to enhance a schema by including the Equal and Hash traits. This allows the resulting objects to support value-based equality.

Example (Using Schema.Data to Add Equality)

import {
import Schema
Schema
} from "effect"
import {
import Equal
Equal
} from "effect"
const
const schema: Schema.SchemaClass<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>
schema
=
import Schema
Schema
.
const Data: <never, {
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}>(item: Schema.Schema<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>) => Schema.SchemaClass<...>

@since3.10.0

Data
(
import Schema
Schema
.
function Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}>(fields: {
name: typeof Schema.String;
age: typeof Schema.Number;
}): Schema.Struct<{
name: typeof Schema.String;
age: typeof Schema.Number;
}> (+1 overload)

@since3.10.0

Struct
({
name: typeof Schema.String
name
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
age: typeof Schema.Number
age
:
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
})
)
const
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
=
import Schema
Schema
.
const decode: <{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>(schema: Schema.Schema<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>, options?: ParseOptions) => (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<...>

@since3.10.0

decode
(
const schema: Schema.SchemaClass<{
readonly name: string;
readonly age: number;
}, {
readonly name: string;
readonly age: number;
}, never>
schema
)
const
const person1: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person1
=
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
({
name: string
name
: "Alice",
age: number
age
: 30 })
const
const person2: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person2
=
const decode: (i: {
readonly name: string;
readonly age: number;
}, overrideOptions?: ParseOptions) => Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
decode
({
name: string
name
: "Alice",
age: number
age
: 30 })
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Equal
Equal
.
function equals<Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>, Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>>(self: Effect<...>, that: Effect<...>): boolean (+1 overload)

@since2.0.0

equals
(
const person1: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person1
,
const person2: Effect<{
readonly name: string;
readonly age: number;
}, ParseError, never>
person2
))
// Output: true

The Schema.Config function allows you to validate and manage application configuration settings using structured schemas. It ensures consistency in configuration data and provides detailed feedback for validation errors.

Syntax

Config: <A>(name: string, schema: Schema<A, string>) => Config<A>

This function requires two parameters:

  • name: Identifier for the configuration setting.
  • schema: Schema describing the expected data type and structure.

The function returns a Config object that is directly integrated with your application’s configuration management system.

The Schema.Config function operates through the following steps:

  1. Fetching Configuration: The configuration value is retrieved based on its name.
  2. Validation: The value is then validated against the schema. If the value does not conform to the schema, the function formats and returns detailed validation errors.
  3. Error Formatting: Errors are formatted using TreeFormatter.formatErrorSync to provide clear, actionable error messages.

Example (Validating Configuration Settings)

import {
import Schema
Schema
} from "effect"
import {
import Effect

@since2.0.0

@since2.0.0

@since2.0.0

Effect
} from "effect"
const
const myconfig: Config<string>
myconfig
=
import Schema
Schema
.
const Config: <string>(name: string, schema: Schema.Schema<string, string, never>) => Config<string>

@since3.10.0

Config
(
"Foo",
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const minLength: <string>(minLength: number, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>

@since3.10.0

minLength
(4))
)
const
const program: Effect.Effect<void, ConfigError, never>
program
=
import Effect

@since2.0.0

@since2.0.0

@since2.0.0

Effect
.
const gen: <YieldWrap<Effect.Effect<string, ConfigError, never>>, void>(f: (resume: Effect.Adapter) => Generator<YieldWrap<Effect.Effect<string, ConfigError, never>>, void, never>) => Effect.Effect<...> (+1 overload)

Provides a way to write effectful code using generator functions, simplifying control flow and error handling.

When to Use

gen allows you to write code that looks and behaves like synchronous code, but it can handle asynchronous tasks, errors, and complex control flow (like loops and conditions). It helps make asynchronous code more readable and easier to manage.

The generator functions work similarly to async/await but with more explicit control over the execution of effects. You can yield* values from effects and return the final result at the end.

@example

import { Effect } from "effect"
const addServiceCharge = (amount: number) => amount + 1
const applyDiscount = (
total: number,
discountRate: number
): Effect.Effect<number, Error> =>
discountRate === 0
? Effect.fail(new Error("Discount rate cannot be zero"))
: Effect.succeed(total - (total * discountRate) / 100)
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
const fetchDiscountRate = Effect.promise(() => Promise.resolve(5))
export const program = Effect.gen(function* () {
const transactionAmount = yield* fetchTransactionAmount
const discountRate = yield* fetchDiscountRate
const discountedAmount = yield* applyDiscount(
transactionAmount,
discountRate
)
const finalAmount = addServiceCharge(discountedAmount)
return `Final amount to charge: ${finalAmount}`
})

@since2.0.0

gen
(function* () {
const
const foo: string
foo
= yield*
const myconfig: Config<string>
myconfig
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(`ok: ${
const foo: string
foo
}`)
})
import Effect

@since2.0.0

@since2.0.0

@since2.0.0

Effect
.
const runSync: <void, ConfigError>(effect: Effect.Effect<void, ConfigError, never>) => void

Executes an effect synchronously, running it immediately and returning the result.

When to Use

Use runSync to run an effect that does not fail and does not include any asynchronous operations.

If the effect fails or involves asynchronous work, it will throw an error, and execution will stop where the failure or async operation occurs.

@seerunSyncExit for a version that returns an Exit type instead of throwing an error.

@example

// Title: Synchronous Logging
import { Effect } from "effect"
const program = Effect.sync(() => {
console.log("Hello, World!")
return 1
})
const result = Effect.runSync(program)
// Output: Hello, World!
console.log(result)
// Output: 1

@example

// Title: Incorrect Usage with Failing or Async Effects import { Effect } from "effect"

try { // Attempt to run an effect that fails Effect.runSync(Effect.fail("my error")) } catch (e) { console.error(e) } // Output: // (FiberFailure) Error: my error

try { // Attempt to run an effect that involves async work Effect.runSync(Effect.promise(() => Promise.resolve(1))) } catch (e) { console.error(e) } // Output: // (FiberFailure) AsyncFiberException: Fiber #0 cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work

@since2.0.0

runSync
(
const program: Effect.Effect<void, ConfigError, never>
program
)

To test the configuration, execute the following commands:

  • Test (with Missing Configuration Data)
    Terminal window
    npx tsx config.ts
    # Output:
    # [(Missing data at Foo: "Expected Foo to exist in the process context")]
  • Test (with Invalid Data)
    Terminal window
    Foo=bar npx tsx config.ts
    # Output:
    # [(Invalid data at Foo: "a string at least 4 character(s) long
    # └─ Predicate refinement failure
    # └─ Expected a string at least 4 character(s) long, actual "bar"")]
  • Test (with Valid Data)
    Terminal window
    Foo=foobar npx tsx config.ts
    # Output:
    # ok: foobar

The Schema.Option function is useful for converting an Option into a JSON-serializable format.

Syntax

Schema.Option(schema: Schema<A, I, R>)
InputOutput
{ _tag: "None" }Converted to Option.none()
{ _tag: "Some", value: I }Converted to Option.some(a), where I is decoded into A using the inner schema
InputOutput
Option.none()Converted to { _tag: "None" }
Option.some(A)Converted to { _tag: "Some", value: I }, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
const
const schema: Schema.Option<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const Option: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.Option<typeof Schema.NumberFromString>

@since3.10.0

Option
(
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".

@since3.10.0

NumberFromString
)
// ┌─── OptionEncoded<string>
// ▼
type
type Encoded = {
readonly _tag: "None";
} | {
readonly _tag: "Some";
readonly value: string;
}
Encoded
= typeof
const schema: Schema.Option<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, OptionEncoded<string>, never>.Encoded: Schema.OptionEncoded<string>
Encoded
// ┌─── Option<number>
// ▼
type
type Type = Option.None<number> | Option.Some<number>
Type
= typeof
const schema: Schema.Option<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, OptionEncoded<string>, never>.Type: Option.Option<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<number>, Schema.OptionEncoded<string>>(schema: Schema.Schema<Option.Option<number>, Schema.OptionEncoded<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.Option<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Schema.OptionEncoded<string>
encode
=
import Schema
Schema
.
encodeSync<Option.Option<number>, Schema.OptionEncoded<string>>(schema: Schema.Schema<Option.Option<number>, Schema.OptionEncoded<string>, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => Schema.OptionEncoded<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.Option<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
({
_tag: string
_tag
: "None" }))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
({
_tag: string
_tag
: "Some",
value: string
value
: "1" }))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Schema.OptionEncoded<string>
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <number>() => Option.Option<number>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: { _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Schema.OptionEncoded<string>
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <number>(value: number) => Option.Option<number>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
(1)))
// Output: { _tag: 'Some', value: '1' }

The Schema.OptionFromSelf function is designed for scenarios where Option values are already in the Option format and need to be decoded or encoded while transforming the inner value according to the provided schema.

Syntax

Schema.OptionFromSelf(schema: Schema<A, I, R>)
InputOutput
Option.none()Remains as Option.none()
Option.some(I)Converted to Option.some(A), where I is decoded into A using the inner schema
InputOutput
Option.none()Remains as Option.none()
Option.some(A)Converted to Option.some(I), where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
const
const schema: Schema.OptionFromSelf<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const OptionFromSelf: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.OptionFromSelf<typeof Schema.NumberFromString>

@since3.10.0

OptionFromSelf
(
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".

@since3.10.0

NumberFromString
)
// ┌─── Option<string>
// ▼
type
type Encoded = Option.None<string> | Option.Some<string>
Encoded
= typeof
const schema: Schema.OptionFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, Option<string>, never>.Encoded: Option.Option<string>
Encoded
// ┌─── Option<number>
// ▼
type
type Type = Option.None<number> | Option.Some<number>
Type
= typeof
const schema: Schema.OptionFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, Option<string>, never>.Type: Option.Option<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<number>, Option.Option<string>>(schema: Schema.Schema<Option.Option<number>, Option.Option<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.OptionFromSelf<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Option.Option<string>
encode
=
import Schema
Schema
.
encodeSync<Option.Option<number>, Option.Option<string>>(schema: Schema.Schema<Option.Option<number>, Option.Option<string>, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => Option.Option<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.OptionFromSelf<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <never>() => Option.Option<never>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <string>(value: string) => Option.Option<string>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
("1")))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Option.Option<string>
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <number>() => Option.Option<number>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => Option.Option<string>
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <number>(value: number) => Option.Option<number>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
(1)))
// Output: { _id: 'Option', _tag: 'Some', value: '1' }

The Schema.OptionFromUndefinedOr function handles cases where undefined is treated as Option.none(), and all other values are interpreted as Option.some() based on the provided schema.

Syntax

Schema.OptionFromUndefinedOr(schema: Schema<A, I, R>)
InputOutput
undefinedConverted to Option.none()
IConverted to Option.some(A), where I is decoded into A using the inner schema
InputOutput
Option.none()Converted to undefined
Option.some(A)Converted to I, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
const
const schema: Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const OptionFromUndefinedOr: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>

@since3.10.0

OptionFromUndefinedOr
(
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".

@since3.10.0

NumberFromString
)
// ┌─── string | undefined
// ▼
type
type Encoded = string | undefined
Encoded
= typeof
const schema: Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | undefined, never>.Encoded: string | undefined
Encoded
// ┌─── Option<number>
// ▼
type
type Type = Option.None<number> | Option.Some<number>
Type
= typeof
const schema: Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | undefined, never>.Type: Option.Option<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<number>, string | undefined>(schema: Schema.Schema<Option.Option<number>, string | undefined, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | undefined
encode
=
import Schema
Schema
.
encodeSync<Option.Option<number>, string | undefined>(schema: Schema.Schema<Option.Option<number>, string | undefined, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => string | undefined
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.OptionFromUndefinedOr<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(
var undefined
undefined
))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
("1"))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | undefined
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <number>() => Option.Option<number>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: undefined
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | undefined
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <number>(value: number) => Option.Option<number>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
(1)))
// Output: "1"

The Schema.OptionFromUndefinedOr function handles cases where null is treated as Option.none(), and all other values are interpreted as Option.some() based on the provided schema.

Syntax

Schema.OptionFromNullOr(schema: Schema<A, I, R>)
InputOutput
nullConverted to Option.none()
IConverted to Option.some(A), where I is decoded into A using the inner schema
InputOutput
Option.none()Converted to null
Option.some(A)Converted to I, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
const
const schema: Schema.OptionFromNullOr<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const OptionFromNullOr: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.OptionFromNullOr<typeof Schema.NumberFromString>

@since3.10.0

OptionFromNullOr
(
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".

@since3.10.0

NumberFromString
)
// ┌─── string | null
// ▼
type
type Encoded = string | null
Encoded
= typeof
const schema: Schema.OptionFromNullOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | null, never>.Encoded: string | null
Encoded
// ┌─── Option<number>
// ▼
type
type Type = Option.None<number> | Option.Some<number>
Type
= typeof
const schema: Schema.OptionFromNullOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | null, never>.Type: Option.Option<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<number>, string | null>(schema: Schema.Schema<Option.Option<number>, string | null, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.OptionFromNullOr<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null
encode
=
import Schema
Schema
.
encodeSync<Option.Option<number>, string | null>(schema: Schema.Schema<Option.Option<number>, string | null, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => string | null
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.OptionFromNullOr<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(null))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
("1"))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <number>() => Option.Option<number>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: null
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <number>(value: number) => Option.Option<number>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
(1)))
// Output: "1"

The Schema.OptionFromNullishOr function handles cases where null or undefined are treated as Option.none(), and all other values are interpreted as Option.some() based on the provided schema. Additionally, it allows customization of how Option.none() is encoded (null or undefined).

Syntax

Schema.OptionFromNullishOr(
schema: Schema<A, I, R>,
onNoneEncoding: null | undefined
)
InputOutput
undefinedConverted to Option.none()
nullConverted to Option.none()
IConverted to Option.some(A), where I is decoded into A using the inner schema
InputOutput
Option.none()Converted to undefined or null based on user choice (onNoneEncoding)
Option.some(A)Converted to I, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
const
const schema: Schema.OptionFromNullishOr<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const OptionFromNullishOr: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString, onNoneEncoding: null | undefined) => Schema.OptionFromNullishOr<typeof Schema.NumberFromString>

@since3.10.0

OptionFromNullishOr
(
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".

@since3.10.0

NumberFromString
,
var undefined
undefined
// Encode Option.none() as undefined
)
// ┌─── string | null | undefined
// ▼
type
type Encoded = string | null | undefined
Encoded
= typeof
const schema: Schema.OptionFromNullishOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | null | undefined, never>.Encoded: string | null | undefined
Encoded
// ┌─── Option<number>
// ▼
type
type Type = Option.None<number> | Option.Some<number>
Type
= typeof
const schema: Schema.OptionFromNullishOr<typeof Schema.NumberFromString>
schema
.
Schema<Option<number>, string | null | undefined, never>.Type: Option.Option<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<number>, string | null | undefined>(schema: Schema.Schema<Option.Option<number>, string | null | undefined, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.OptionFromNullishOr<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null | undefined
encode
=
import Schema
Schema
.
encodeSync<Option.Option<number>, string | null | undefined>(schema: Schema.Schema<Option.Option<number>, string | null | undefined, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => string | ... 1 more ... | undefined
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.OptionFromNullishOr<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(null))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
(
var undefined
undefined
))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<number>
decode
("1"))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null | undefined
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <number>() => Option.Option<number>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: undefined
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<number>, overrideOptions?: ParseOptions) => string | null | undefined
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <number>(value: number) => Option.Option<number>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
(1)))
// Output: "1"

The Schema.OptionFromNonEmptyTrimmedString schema is designed for handling strings where trimmed empty strings are treated as Option.none(), and all other strings are converted to Option.some().

InputOutput
s: stringConverted to Option.some(s), if s.trim().length > 0
Converted to Option.none() otherwise
InputOutput
Option.none()Converted to ""
Option.some(s: string)Converted to s

Example

import {
import Schema
Schema
,
import Option

@since2.0.0

@since2.0.0

Option
} from "effect"
// ┌─── string
// ▼
type
type Encoded = Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>
Encoded
= typeof
import Schema
Schema
.
const OptionFromNonEmptyTrimmedString: Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>

Transforms strings into an Option type, effectively filtering out empty or whitespace-only strings by trimming them and checking their length. Returns none for invalid inputs and some for valid non-empty strings.

@example

import { Schema } from "effect"
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")

@since3.10.0

OptionFromNonEmptyTrimmedString
// ┌─── Option<string>
// ▼
type
type Type = Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>
Type
= typeof
import Schema
Schema
.
const OptionFromNonEmptyTrimmedString: Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>

Transforms strings into an Option type, effectively filtering out empty or whitespace-only strings by trimming them and checking their length. Returns none for invalid inputs and some for valid non-empty strings.

@example

import { Schema } from "effect"
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")

@since3.10.0

OptionFromNonEmptyTrimmedString
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Option.Option<string>, string>(schema: Schema.Schema<Option.Option<string>, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Option.Option<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
import Schema
Schema
.
const OptionFromNonEmptyTrimmedString: Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>

Transforms strings into an Option type, effectively filtering out empty or whitespace-only strings by trimming them and checking their length. Returns none for invalid inputs and some for valid non-empty strings.

@example

import { Schema } from "effect"
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")

@since3.10.0

OptionFromNonEmptyTrimmedString
)
const
const encode: (a: Option.Option<string>, overrideOptions?: ParseOptions) => string
encode
=
import Schema
Schema
.
encodeSync<Option.Option<string>, string>(schema: Schema.Schema<Option.Option<string>, string, never>, options?: ParseOptions): (a: Option.Option<...>, overrideOptions?: ParseOptions) => string
export encodeSync

@since3.10.0

encodeSync
(
import Schema
Schema
.
const OptionFromNonEmptyTrimmedString: Schema.transform<typeof Schema.String, Schema.OptionFromSelf<typeof Schema.NonEmptyTrimmedString>>

Transforms strings into an Option type, effectively filtering out empty or whitespace-only strings by trimming them and checking their length. Returns none for invalid inputs and some for valid non-empty strings.

@example

import { Schema } from "effect"
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none()
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a")
console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a")

@since3.10.0

OptionFromNonEmptyTrimmedString
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<string>
decode
(""))
// Output: { _id: 'Option', _tag: 'None' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<string>
decode
(" a "))
// Output: { _id: 'Option', _tag: 'Some', value: 'a' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Option.Option<string>
decode
("a"))
// Output: { _id: 'Option', _tag: 'Some', value: 'a' }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<string>, overrideOptions?: ParseOptions) => string
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const none: <string>() => Option.Option<string>

Creates a new Option that represents the absence of a value.

@since2.0.0

none
()))
// Output: ""
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Option.Option<string>, overrideOptions?: ParseOptions) => string
encode
(
import Option

@since2.0.0

@since2.0.0

Option
.
const some: <string>(value: string) => Option.Option<string>

Creates a new Option that wraps the given value.

@paramvalue - The value to wrap.

@since2.0.0

some
("example")))
// Output: "example"

The Schema.Either function is useful for converting an Either into a JSON-serializable format.

Syntax

Schema.Either(options: {
left: Schema<LA, LI, LR>,
right: Schema<RA, RI, RR>
})
InputOutput
{ _tag: "Left", left: LI }Converted to Either.left(LA), where LI is decoded into LA using the inner left schema
{ _tag: "Right", right: RI }Converted to Either.right(RA), where RI is decoded into RA using the inner right schema
InputOutput
Either.left(LA)Converted to { _tag: "Left", left: LI }, where LA is encoded into LI using the inner left schema
Either.right(RA)Converted to { _tag: "Right", right: RI }, where RA is encoded into RI using the inner right schema

Example

import {
import Schema
Schema
,
import Either

@since2.0.0

@since2.0.0

Either
} from "effect"
const
const schema: Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
=
import Schema
Schema
.
const Either: <typeof Schema.NumberFromString, typeof Schema.Trim>({ left, right }: {
readonly left: typeof Schema.Trim;
readonly right: typeof Schema.NumberFromString;
}) => Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>

@since3.10.0

Either
({
left: typeof Schema.Trim
left
:
import Schema
Schema
.
class Trim

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

@since3.10.0

Trim
,
right: typeof Schema.NumberFromString
right
:
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".

@since3.10.0

NumberFromString
})
// ┌─── EitherEncoded<string, string>
// ▼
type
type Encoded = Schema.RightEncoded<string> | Schema.LeftEncoded<string>
Encoded
= typeof
const schema: Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
.
Schema<Either<number, string>, EitherEncoded<string, string>, never>.Encoded: Schema.EitherEncoded<string, string>
Encoded
// ┌─── Either<number, string>
// ▼
type
type Type = Either.Left<string, number> | Either.Right<string, number>
Type
= typeof
const schema: Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
.
Schema<Either<number, string>, EitherEncoded<string, string>, never>.Type: Either.Either<number, string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Either.Either<number, string>, Schema.EitherEncoded<string, string>>(schema: Schema.Schema<Either.Either<number, string>, Schema.EitherEncoded<string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
)
const
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Schema.EitherEncoded<string, string>
encode
=
import Schema
Schema
.
encodeSync<Either.Either<number, string>, Schema.EitherEncoded<string, string>>(schema: Schema.Schema<Either.Either<number, string>, Schema.EitherEncoded<string, string>, never>, options?: ParseOptions): (a: Either.Either<...>, overrideOptions?: ParseOptions) => Schema.EitherEncoded<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.Either<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
({
_tag: string
_tag
: "Left",
left: string
left
: " a " }))
// Output: { _id: 'Either', _tag: 'Left', left: 'a' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
({
_tag: string
_tag
: "Right",
right: string
right
: "1" }))
// Output: { _id: 'Either', _tag: 'Right', right: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Schema.EitherEncoded<string, string>
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const left: <string>(left: string) => Either.Either<never, string>

Constructs a new Either holding a Left value. This usually represents a failure, due to the right-bias of this structure.

@since2.0.0

left
("a")))
// Output: { _tag: 'Left', left: 'a' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Schema.EitherEncoded<string, string>
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const right: <number>(right: number) => Either.Either<number, never>

Constructs a new Either holding a Right value. This usually represents a successful value due to the right bias of this structure.

@since2.0.0

right
(1)))
// Output: { _tag: 'Right', right: '1' }

The Schema.EitherFromSelf function is designed for scenarios where Either values are already in the Either format and need to be decoded or encoded while transforming the inner valued according to the provided schemas.

Syntax

Schema.EitherFromSelf(options: {
left: Schema<LA, LI, LR>,
right: Schema<RA, RI, RR>
})
InputOutput
Either.left(LI)Converted to Either.left(LA), where LI is decoded into LA using the inner left schema
Either.right(RI)Converted to Either.right(RA), where RI is decoded into RA using the inner right schema
InputOutput
Either.left(LA)Converted to Either.left(LI), where LA is encoded into LI using the inner left schema
Either.right(RA)Converted to Either.right(RI), where RA is encoded into RI using the inner right schema

Example

import {
import Schema
Schema
,
import Either

@since2.0.0

@since2.0.0

Either
} from "effect"
const
const schema: Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
=
import Schema
Schema
.
const EitherFromSelf: <typeof Schema.NumberFromString, typeof Schema.Trim>({ left, right }: {
readonly left: typeof Schema.Trim;
readonly right: typeof Schema.NumberFromString;
}) => Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>

@since3.10.0

EitherFromSelf
({
left: typeof Schema.Trim
left
:
import Schema
Schema
.
class Trim

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

@since3.10.0

Trim
,
right: typeof Schema.NumberFromString
right
:
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".

@since3.10.0

NumberFromString
})
// ┌─── Either<string, string>
// ▼
type
type Encoded = Either.Left<string, string> | Either.Right<string, string>
Encoded
= typeof
const schema: Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
.
Schema<Either<number, string>, Either<string, string>, never>.Encoded: Either.Either<string, string>
Encoded
// ┌─── Either<number, string>
// ▼
type
type Type = Either.Left<string, number> | Either.Right<string, number>
Type
= typeof
const schema: Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
.
Schema<Either<number, string>, Either<string, string>, never>.Type: Either.Either<number, string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Either.Either<number, string>, Either.Either<string, string>>(schema: Schema.Schema<Either.Either<number, string>, Either.Either<string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
)
const
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Either.Either<string, string>
encode
=
import Schema
Schema
.
encodeSync<Either.Either<number, string>, Either.Either<string, string>>(schema: Schema.Schema<Either.Either<number, string>, Either.Either<string, string>, never>, options?: ParseOptions): (a: Either.Either<...>, overrideOptions?: ParseOptions) => Either.Either<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.EitherFromSelf<typeof Schema.NumberFromString, typeof Schema.Trim>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const left: <string>(left: string) => Either.Either<never, string>

Constructs a new Either holding a Left value. This usually represents a failure, due to the right-bias of this structure.

@since2.0.0

left
(" a ")))
// Output: { _id: 'Either', _tag: 'Left', left: 'a' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, string>
decode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const right: <string>(right: string) => Either.Either<string, never>

Constructs a new Either holding a Right value. This usually represents a successful value due to the right bias of this structure.

@since2.0.0

right
("1")))
// Output: { _id: 'Either', _tag: 'Right', right: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Either.Either<string, string>
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const left: <string>(left: string) => Either.Either<never, string>

Constructs a new Either holding a Left value. This usually represents a failure, due to the right-bias of this structure.

@since2.0.0

left
("a")))
// Output: { _id: 'Either', _tag: 'Left', left: 'a' }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, string>, overrideOptions?: ParseOptions) => Either.Either<string, string>
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const right: <number>(right: number) => Either.Either<number, never>

Constructs a new Either holding a Right value. This usually represents a successful value due to the right bias of this structure.

@since2.0.0

right
(1)))
// Output: { _id: 'Either', _tag: 'Right', right: '1' }

The Schema.EitherFromUnion function is designed to decode and encode Either values where the left and right sides are represented as distinct types. This schema enables conversions between raw union types and structured Either types.

Syntax

Schema.EitherFromUnion(options: {
left: Schema<LA, LI, LR>,
right: Schema<RA, RI, RR>
})
InputOutput
LIConverted to Either.left(LA), where LI is decoded into LA using the inner left schema
RIConverted to Either.right(RA), where RI is decoded into RA using the inner right schema
InputOutput
Either.left(LA)Converted to LI, where LA is encoded into LI using the inner left schema
Either.right(RA)Converted to RI, where RA is encoded into RI using the inner right schema

Example

import {
import Schema
Schema
,
import Either

@since2.0.0

@since2.0.0

Either
} from "effect"
const
const schema: Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>
schema
=
import Schema
Schema
.
const EitherFromUnion: <typeof Schema.NumberFromString, typeof Schema.Boolean>({ left, right }: {
readonly left: typeof Schema.Boolean;
readonly right: typeof Schema.NumberFromString;
}) => Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>

@example

import * as Schema from "effect/Schema"
// Schema<string | number, Either<string, number>>
Schema.EitherFromUnion({ left: Schema.String, right: Schema.Number })

@since3.10.0

EitherFromUnion
({
left: typeof Schema.Boolean
left
:
import Schema
Schema
.
class Boolean
export Boolean

@since3.10.0

Boolean
,
right: typeof Schema.NumberFromString
right
:
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".

@since3.10.0

NumberFromString
})
// ┌─── string | boolean
// ▼
type
type Encoded = string | boolean
Encoded
= typeof
const schema: Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>
schema
.
Schema<Either<number, boolean>, string | boolean, never>.Encoded: string | boolean
Encoded
// ┌─── Either<number, boolean>
// ▼
type
type Type = Either.Left<boolean, number> | Either.Right<boolean, number>
Type
= typeof
const schema: Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>
schema
.
Schema<Either<number, boolean>, string | boolean, never>.Type: Either.Either<number, boolean>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, boolean>
decode
=
import Schema
Schema
.
decodeUnknownSync<Either.Either<number, boolean>, string | boolean>(schema: Schema.Schema<Either.Either<number, boolean>, string | boolean, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>
schema
)
const
const encode: (a: Either.Either<number, boolean>, overrideOptions?: ParseOptions) => string | boolean
encode
=
import Schema
Schema
.
encodeSync<Either.Either<number, boolean>, string | boolean>(schema: Schema.Schema<Either.Either<number, boolean>, string | boolean, never>, options?: ParseOptions): (a: Either.Either<...>, overrideOptions?: ParseOptions) => string | boolean
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.EitherFromUnion<typeof Schema.NumberFromString, typeof Schema.Boolean>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, boolean>
decode
(true))
// Output: { _id: 'Either', _tag: 'Left', left: true }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<number, boolean>
decode
("1"))
// Output: { _id: 'Either', _tag: 'Right', right: 1 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, boolean>, overrideOptions?: ParseOptions) => string | boolean
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const left: <boolean>(left: boolean) => Either.Either<never, boolean>

Constructs a new Either holding a Left value. This usually represents a failure, due to the right-bias of this structure.

@since2.0.0

left
(true)))
// Output: true
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Either.Either<number, boolean>, overrideOptions?: ParseOptions) => string | boolean
encode
(
import Either

@since2.0.0

@since2.0.0

Either
.
const right: <number>(right: number) => Either.Either<number, never>

Constructs a new Either holding a Right value. This usually represents a successful value due to the right bias of this structure.

@since2.0.0

right
(1)))
// Output: "1"

The Schema.Exit function is useful for converting an Exit into a JSON-serializable format.

Syntax

Schema.Exit(options: {
failure: Schema<FA, FI, FR>,
success: Schema<SA, SI, SR>,
defect: Schema<DA, DI, DR>
})
InputOutput
{ _tag: "Failure", cause: CauseEncoded<FI, DI> }Converted to Exit.failCause(Cause<FA>), where CauseEncoded<FI, DI> is decoded into Cause<FA> using the inner failure and defect schemas
{ _tag: "Success", value: SI }Converted to Exit.succeed(SA), where SI is decoded into SA using the inner success schema
InputOutput
Exit.failCause(Cause<FA>)Converted to { _tag: "Failure", cause: CauseEncoded<FI, DI> }, where Cause<FA> is encoded into CauseEncoded<FI, DI> using the inner failure and defect schemas
Exit.succeed(SA)Converted to { _tag: "Success", value: SI }, where SA is encoded into SI using the inner success schema

Example

import {
import Schema
Schema
,
import Exit
Exit
} from "effect"
const
const schema: Schema.Exit<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
=
import Schema
Schema
.
const Exit: <typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>({ defect, failure, success }: {
readonly failure: typeof Schema.String;
readonly success: typeof Schema.NumberFromString;
readonly defect: typeof Schema.String;
}) => Schema.Exit<...>

@since3.10.0

Exit
({
failure: typeof Schema.String
failure
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
success: typeof Schema.NumberFromString
success
:
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".

@since3.10.0

NumberFromString
,
defect: typeof Schema.String
defect
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
})
// ┌─── ExitEncoded<string, string, string>
// ▼
type
type Encoded = {
readonly _tag: "Failure";
readonly cause: Schema.CauseEncoded<string, string>;
} | {
readonly _tag: "Success";
readonly value: string;
}
Encoded
= typeof
const schema: Schema.Exit<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
.
Schema<Exit<number, string>, ExitEncoded<string, string, string>, never>.Encoded: Schema.ExitEncoded<string, string, string>
Encoded
// ┌─── Exit<number, string>
// ▼
type
type Type = Exit.Success<number, string> | Exit.Failure<number, string>
Type
= typeof
const schema: Schema.Exit<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
.
Schema<Exit<number, string>, ExitEncoded<string, string, string>, never>.Type: Exit.Exit<number, string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Exit.Exit<number, string>, Schema.ExitEncoded<string, string, string>>(schema: Schema.Schema<Exit.Exit<number, string>, Schema.ExitEncoded<string, string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.Exit<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
)
const
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Schema.ExitEncoded<string, string, string>
encode
=
import Schema
Schema
.
encodeSync<Exit.Exit<number, string>, Schema.ExitEncoded<string, string, string>>(schema: Schema.Schema<Exit.Exit<number, string>, Schema.ExitEncoded<string, string, string>, never>, options?: ParseOptions): (a: Exit.Exit<...>, overrideOptions?: ParseOptions) => Schema.ExitEncoded<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.Exit<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
({
_tag: string
_tag
: "Failure",
cause: {
_tag: string;
error: string;
}
cause
: {
_tag: string
_tag
: "Fail",
error: string
error
: "a" } })
)
/*
Output:
{
_id: 'Exit',
_tag: 'Failure',
cause: { _id: 'Cause', _tag: 'Fail', failure: 'a' }
}
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
({
_tag: string
_tag
: "Success",
value: string
value
: "1" }))
/*
Output:
{ _id: 'Exit', _tag: 'Success', value: 1 }
*/
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Schema.ExitEncoded<string, string, string>
encode
(
import Exit
Exit
.
const fail: <string>(error: string) => Exit.Exit<never, string>

Constructs a new Exit.Failure from the specified recoverable error of type E.

@since2.0.0

fail
("a")))
/*
Output:
{ _tag: 'Failure', cause: { _tag: 'Fail', error: 'a' } }
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Schema.ExitEncoded<string, string, string>
encode
(
import Exit
Exit
.
const succeed: <number>(value: number) => Exit.Exit<number, never>

Constructs a new Exit.Success containing the specified value of type A.

@since2.0.0

succeed
(1)))
/*
Output:
{ _tag: 'Success', value: '1' }
*/

The Schema.ExitFromSelf function is designed for scenarios where Exit values are already in the Exit format and need to be decoded or encoded while transforming the inner valued according to the provided schemas.

Syntax

Schema.ExitFromSelf(options: {
failure: Schema<FA, FI, FR>,
success: Schema<SA, SI, SR>,
defect: Schema<DA, DI, DR>
})
InputOutput
Exit.failCause(Cause<FI>)Converted to Exit.failCause(Cause<FA>), where Cause<FI> is decoded into Cause<FA> using the inner failure and defect schemas
Exit.succeed(SI)Converted to Exit.succeed(SA), where SI is decoded into SA using the inner success schema
InputOutput
Exit.failCause(Cause<FA>)Converted to Exit.failCause(Cause<FI>), where Cause<FA> is decoded into Cause<FI> using the inner failure and defect schemas
Exit.succeed(SA)Converted to Exit.succeed(SI), where SA is encoded into SI using the inner success schema

Example

import {
import Schema
Schema
,
import Exit
Exit
} from "effect"
const
const schema: Schema.ExitFromSelf<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
=
import Schema
Schema
.
const ExitFromSelf: <typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>({ defect, failure, success }: {
readonly failure: typeof Schema.String;
readonly success: typeof Schema.NumberFromString;
readonly defect: typeof Schema.String;
}) => Schema.ExitFromSelf<...>

@since3.10.0

ExitFromSelf
({
failure: typeof Schema.String
failure
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
success: typeof Schema.NumberFromString
success
:
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".

@since3.10.0

NumberFromString
,
defect: typeof Schema.String
defect
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
})
// ┌─── Exit<string, string>
// ▼
type
type Encoded = Exit.Success<string, string> | Exit.Failure<string, string>
Encoded
= typeof
const schema: Schema.ExitFromSelf<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
.
Schema<Exit<number, string>, Exit<string, string>, never>.Encoded: Exit.Exit<string, string>
Encoded
// ┌─── Exit<number, string>
// ▼
type
type Type = Exit.Success<number, string> | Exit.Failure<number, string>
Type
= typeof
const schema: Schema.ExitFromSelf<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
.
Schema<Exit<number, string>, Exit<string, string>, never>.Type: Exit.Exit<number, string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Exit.Exit<number, string>, Exit.Exit<string, string>>(schema: Schema.Schema<Exit.Exit<number, string>, Exit.Exit<string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.ExitFromSelf<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
)
const
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Exit.Exit<string, string>
encode
=
import Schema
Schema
.
encodeSync<Exit.Exit<number, string>, Exit.Exit<string, string>>(schema: Schema.Schema<Exit.Exit<number, string>, Exit.Exit<string, string>, never>, options?: ParseOptions): (a: Exit.Exit<...>, overrideOptions?: ParseOptions) => Exit.Exit<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.ExitFromSelf<typeof Schema.NumberFromString, typeof Schema.String, typeof Schema.String>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
(
import Exit
Exit
.
const fail: <string>(error: string) => Exit.Exit<never, string>

Constructs a new Exit.Failure from the specified recoverable error of type E.

@since2.0.0

fail
("a")))
/*
Output:
{
_id: 'Exit',
_tag: 'Failure',
cause: { _id: 'Cause', _tag: 'Fail', failure: 'a' }
}
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Exit.Exit<number, string>
decode
(
import Exit
Exit
.
const succeed: <string>(value: string) => Exit.Exit<string, never>

Constructs a new Exit.Success containing the specified value of type A.

@since2.0.0

succeed
("1")))
/*
Output:
{ _id: 'Exit', _tag: 'Success', value: 1 }
*/
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Exit.Exit<string, string>
encode
(
import Exit
Exit
.
const fail: <string>(error: string) => Exit.Exit<never, string>

Constructs a new Exit.Failure from the specified recoverable error of type E.

@since2.0.0

fail
("a")))
/*
Output:
{
_id: 'Exit',
_tag: 'Failure',
cause: { _id: 'Cause', _tag: 'Fail', failure: 'a' }
}
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: Exit.Exit<number, string>, overrideOptions?: ParseOptions) => Exit.Exit<string, string>
encode
(
import Exit
Exit
.
const succeed: <number>(value: number) => Exit.Exit<number, never>

Constructs a new Exit.Success containing the specified value of type A.

@since2.0.0

succeed
(1)))
/*
Output:
{ _id: 'Exit', _tag: 'Success', value: '1' }
*/

The Schema.ReadonlySet function is useful for converting a ReadonlySet into a JSON-serializable format.

Syntax

Schema.ReadonlySet(schema: Schema<A, I, R>)
InputOutput
ReadonlyArray<I>Converted to ReadonlySet<A>, where I is decoded into A using the inner schema
InputOutput
ReadonlySet<A>ReadonlyArray<I>, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.ReadonlySet$<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const ReadonlySet: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.ReadonlySet$<typeof Schema.NumberFromString>

@since3.10.0

ReadonlySet
(
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".

@since3.10.0

NumberFromString
)
// ┌─── readonly string[]
// ▼
type
type Encoded = readonly string[]
Encoded
= typeof
const schema: Schema.ReadonlySet$<typeof Schema.NumberFromString>
schema
.
Schema<ReadonlySet<number>, readonly string[], never>.Encoded: readonly string[]
Encoded
// ┌─── ReadonlySet<number>
// ▼
type
type Type = ReadonlySet<number>
Type
= typeof
const schema: Schema.ReadonlySet$<typeof Schema.NumberFromString>
schema
.
Schema<ReadonlySet<number>, readonly string[], never>.Type: ReadonlySet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<ReadonlySet<number>, readonly string[]>(schema: Schema.Schema<ReadonlySet<number>, readonly string[], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.ReadonlySet$<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: ReadonlySet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
=
import Schema
Schema
.
encodeSync<ReadonlySet<number>, readonly string[]>(schema: Schema.Schema<ReadonlySet<number>, readonly string[], never>, options?: ParseOptions): (a: ReadonlySet<...>, overrideOptions?: ParseOptions) => readonly string[]
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.ReadonlySet$<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<number>
decode
(["1", "2", "3"]))
// Output: Set(3) { 1, 2, 3 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: ReadonlySet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
(new
var Set: SetConstructor
new <number>(iterable?: Iterable<number> | null | undefined) => Set<number> (+1 overload)
Set
([1, 2, 3])))
// Output: [ '1', '2', '3' ]

The Schema.ReadonlySetFromSelf function is designed for scenarios where ReadonlySet values are already in the ReadonlySet format and need to be decoded or encoded while transforming the inner values according to the provided schema.

Syntax

Schema.ReadonlySetFromSelf(schema: Schema<A, I, R>)
InputOutput
ReadonlySet<I>Converted to ReadonlySet<A>, where I is decoded into A using the inner schema
InputOutput
ReadonlySet<A>ReadonlySet<I>, where A is encoded into I using the inner schema

Example

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const ReadonlySetFromSelf: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>

@since3.10.0

ReadonlySetFromSelf
(
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".

@since3.10.0

NumberFromString
)
// ┌─── ReadonlySet<string>
// ▼
type
type Encoded = ReadonlySet<string>
Encoded
= typeof
const schema: Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<ReadonlySet<number>, ReadonlySet<string>, never>.Encoded: ReadonlySet<string>
Encoded
// ┌─── ReadonlySet<number>
// ▼
type
type Type = ReadonlySet<number>
Type
= typeof
const schema: Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<ReadonlySet<number>, ReadonlySet<string>, never>.Type: ReadonlySet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<ReadonlySet<number>, ReadonlySet<string>>(schema: Schema.Schema<ReadonlySet<number>, ReadonlySet<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: ReadonlySet<number>, overrideOptions?: ParseOptions) => ReadonlySet<string>
encode
=
import Schema
Schema
.
encodeSync<ReadonlySet<number>, ReadonlySet<string>>(schema: Schema.Schema<ReadonlySet<number>, ReadonlySet<string>, never>, options?: ParseOptions): (a: ReadonlySet<...>, overrideOptions?: ParseOptions) => ReadonlySet<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.ReadonlySetFromSelf<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlySet<number>
decode
(new
var Set: SetConstructor
new <string>(iterable?: Iterable<string> | null | undefined) => Set<string> (+1 overload)
Set
(["1", "2", "3"])))
// Output: Set(3) { 1, 2, 3 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: ReadonlySet<number>, overrideOptions?: ParseOptions) => ReadonlySet<string>
encode
(new
var Set: SetConstructor
new <number>(iterable?: Iterable<number> | null | undefined) => Set<number> (+1 overload)
Set
([1, 2, 3])))
// Output: Set(3) { '1', '2', '3' }

The Schema.ReadonlyMap function is useful for converting a ReadonlyMap into a JSON-serializable format.

Syntax

Schema.ReadonlyMap(options: {
key: Schema<KA, KI, KR>,
value: Schema<VA, VI, VR>
})
InputOutput
ReadonlyArray<readonly [KI, VI]>Converted to ReadonlyMap<KA, VA>, where KI is decoded into KA using the inner key schema and VI is decoded into VA using the inner value schema
InputOutput
ReadonlyMap<KA, VA>Converted to ReadonlyArray<readonly [KI, VI]>, where KA is decoded into KI using the inner key schema and VA is decoded into VI using the inner value schema

Example

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const ReadonlyMap: <typeof Schema.String, typeof Schema.NumberFromString>({ key, value }: {
readonly key: typeof Schema.String;
readonly value: typeof Schema.NumberFromString;
}) => Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>

@since3.10.0

ReadonlyMap
({
key: typeof Schema.String
key
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
value: typeof Schema.NumberFromString
value
:
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".

@since3.10.0

NumberFromString
})
// ┌─── readonly (readonly [string, string])[]
// ▼
type
type Encoded = readonly (readonly [string, string])[]
Encoded
= typeof
const schema: Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<ReadonlyMap<string, number>, readonly (readonly [string, string])[], never>.Encoded: readonly (readonly [string, string])[]
Encoded
// ┌─── ReadonlyMap<string, number>
// ▼
type
type Type = ReadonlyMap<string, number>
Type
= typeof
const schema: Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<ReadonlyMap<string, number>, readonly (readonly [string, string])[], never>.Type: ReadonlyMap<string, number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<string, number>
decode
=
import Schema
Schema
.
decodeUnknownSync<ReadonlyMap<string, number>, readonly (readonly [string, string])[]>(schema: Schema.Schema<ReadonlyMap<string, number>, readonly (readonly [string, string])[], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
const
const encode: (a: ReadonlyMap<string, number>, overrideOptions?: ParseOptions) => readonly (readonly [string, string])[]
encode
=
import Schema
Schema
.
encodeSync<ReadonlyMap<string, number>, readonly (readonly [string, string])[]>(schema: Schema.Schema<ReadonlyMap<string, number>, readonly (readonly [string, string])[], never>, options?: ParseOptions): (a: ReadonlyMap<...>, overrideOptions?: ParseOptions) => readonly (readonly [...])[]
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.ReadonlyMap$<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<string, number>
decode
([
["a", "2"],
["b", "2"],
["c", "3"]
])
)
// Output: Map(3) { 'a' => 2, 'b' => 2, 'c' => 3 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: ReadonlyMap<string, number>, overrideOptions?: ParseOptions) => readonly (readonly [string, string])[]
encode
(
new
var Map: MapConstructor
new <string, number>(iterable?: Iterable<readonly [string, number]> | null | undefined) => Map<string, number> (+3 overloads)
Map
([
["a", 1],
["b", 2],
["c", 3]
])
)
)
// Output: [ [ 'a', '1' ], [ 'b', '2' ], [ 'c', '3' ] ]

The Schema.ReadonlyMapFromSelf function is designed for scenarios where ReadonlyMap values are already in the ReadonlyMap format and need to be decoded or encoded while transforming the inner values according to the provided schemas.

Syntax

Schema.ReadonlyMapFromSelf(options: {
key: Schema<KA, KI, KR>,
value: Schema<VA, VI, VR>
})
InputOutput
ReadonlyMap<KI, VI>Converted to ReadonlyMap<KA, VA>, where KI is decoded into KA using the inner key schema and VI is decoded into VA using the inner value schema
InputOutput
ReadonlyMap<KA, VA>Converted to ReadonlyMap<KI, VI>, where KA is decoded into KI using the inner key schema and VA is decoded into VI using the inner value schema

Example

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const ReadonlyMapFromSelf: <typeof Schema.String, typeof Schema.NumberFromString>({ key, value }: {
readonly key: typeof Schema.String;
readonly value: typeof Schema.NumberFromString;
}) => Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>

@since3.10.0

ReadonlyMapFromSelf
({
key: typeof Schema.String
key
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
value: typeof Schema.NumberFromString
value
:
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".

@since3.10.0

NumberFromString
})
// ┌─── ReadonlyMap<string, string>
// ▼
type
type Encoded = ReadonlyMap<string, string>
Encoded
= typeof
const schema: Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<ReadonlyMap<string, number>, ReadonlyMap<string, string>, never>.Encoded: ReadonlyMap<string, string>
Encoded
// ┌─── ReadonlyMap<string, number>
// ▼
type
type Type = ReadonlyMap<string, number>
Type
= typeof
const schema: Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<ReadonlyMap<string, number>, ReadonlyMap<string, string>, never>.Type: ReadonlyMap<string, number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<string, number>
decode
=
import Schema
Schema
.
decodeUnknownSync<ReadonlyMap<string, number>, ReadonlyMap<string, string>>(schema: Schema.Schema<ReadonlyMap<string, number>, ReadonlyMap<string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
const
const encode: (a: ReadonlyMap<string, number>, overrideOptions?: ParseOptions) => ReadonlyMap<string, string>
encode
=
import Schema
Schema
.
encodeSync<ReadonlyMap<string, number>, ReadonlyMap<string, string>>(schema: Schema.Schema<ReadonlyMap<string, number>, ReadonlyMap<string, string>, never>, options?: ParseOptions): (a: ReadonlyMap<...>, overrideOptions?: ParseOptions) => ReadonlyMap<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.ReadonlyMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<string, number>
decode
(
new
var Map: MapConstructor
new <string, string>(iterable?: Iterable<readonly [string, string]> | null | undefined) => Map<string, string> (+3 overloads)
Map
([
["a", "2"],
["b", "2"],
["c", "3"]
])
)
)
// Output: Map(3) { 'a' => 2, 'b' => 2, 'c' => 3 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: ReadonlyMap<string, number>, overrideOptions?: ParseOptions) => ReadonlyMap<string, string>
encode
(
new
var Map: MapConstructor
new <string, number>(iterable?: Iterable<readonly [string, number]> | null | undefined) => Map<string, number> (+3 overloads)
Map
([
["a", 1],
["b", 2],
["c", 3]
])
)
)
// Output: Map(3) { 'a' => '1', 'b' => '2', 'c' => '3' }

The Schema.ReadonlyMapFromRecord function is a utility to transform a ReadonlyMap into an object format, where keys are strings and values are serializable, and vice versa.

Syntax

Schema.ReadonlyMapFromRecord({
key: Schema<KA, KI, KR>,
value: Schema<VA, VI, VR>
})
InputOutput
{ readonly [x: string]: VI }Converts to ReadonlyMap<KA, VA>, where x is decoded into KA using the key schema and VI into VA using the value schema
InputOutput
ReadonlyMap<KA, VA>Converts to { readonly [x: string]: VI }, where KA is encoded into x using the key schema and VA into VI using the value schema

Example

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>
schema
=
import Schema
Schema
.
const ReadonlyMapFromRecord: <number, never, number, string, never>({ key, value }: {
key: Schema.Schema<number, string, never>;
value: Schema.Schema<number, string, never>;
}) => Schema.Schema<ReadonlyMap<number, number>, {
...;
}, never>

@since3.10.0

ReadonlyMapFromRecord
({
key: Schema.Schema<number, string, never>
key
:
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".

@since3.10.0

NumberFromString
,
value: Schema.Schema<number, string, never>
value
:
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".

@since3.10.0

NumberFromString
})
// ┌─── { readonly [x: string]: string; }
// ▼
type
type Encoded = {
readonly [x: string]: string;
}
Encoded
= typeof
const schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>
schema
.
Schema<ReadonlyMap<number, number>, { readonly [x: string]: string; }, never>.Encoded: {
readonly [x: string]: string;
}
Encoded
// ┌─── ReadonlyMap<number, number>
// ▼
type
type Type = ReadonlyMap<number, number>
Type
= typeof
const schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>
schema
.
Schema<ReadonlyMap<number, number>, { readonly [x: string]: string; }, never>.Type: ReadonlyMap<number, number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<number, number>
decode
=
import Schema
Schema
.
decodeUnknownSync<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}>(schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>
schema
)
const
const encode: (a: ReadonlyMap<number, number>, overrideOptions?: ParseOptions) => {
readonly [x: string]: string;
}
encode
=
import Schema
Schema
.
encodeSync<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}>(schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>, options?: ParseOptions): (a: ReadonlyMap<...>, overrideOptions?: ParseOptions) => {
readonly [x: string]: string;
}
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.Schema<ReadonlyMap<number, number>, {
readonly [x: string]: string;
}, never>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => ReadonlyMap<number, number>
decode
({
"1": "4",
"2": "5",
"3": "6"
})
)
// Output: Map(3) { 1 => 4, 2 => 5, 3 => 6 }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: ReadonlyMap<number, number>, overrideOptions?: ParseOptions) => {
readonly [x: string]: string;
}
encode
(
new
var Map: MapConstructor
new <number, number>(iterable?: Iterable<readonly [number, number]> | null | undefined) => Map<number, number> (+3 overloads)
Map
([
[1, 4],
[2, 5],
[3, 6]
])
)
)
// Output: { '1': '4', '2': '5', '3': '6' }

The Schema.HashSet function provides a way to map between HashSet and an array representation, allowing for JSON serialization and deserialization.

Syntax

Schema.HashSet(schema: Schema<A, I, R>)
InputOutput
ReadonlyArray<I>Converts to HashSet<A>, where each element in the array is decoded into type A using the schema
InputOutput
HashSet<A>Converts to ReadonlyArray<I>, where each element in the HashSet is encoded into type I using the schema

Example

import {
import Schema
Schema
} from "effect"
import {
import HashSet
HashSet
} from "effect"
const
const schema: Schema.HashSet<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const HashSet: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.HashSet<typeof Schema.NumberFromString>

@since3.10.0

HashSet
(
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".

@since3.10.0

NumberFromString
)
// ┌─── readonly string[]
// ▼
type
type Encoded = readonly string[]
Encoded
= typeof
const schema: Schema.HashSet<typeof Schema.NumberFromString>
schema
.
Schema<HashSet<number>, readonly string[], never>.Encoded: readonly string[]
Encoded
// ┌─── HashSet<number>
// ▼
type
type Type = HashSet.HashSet<number>
Type
= typeof
const schema: Schema.HashSet<typeof Schema.NumberFromString>
schema
.
Schema<HashSet<number>, readonly string[], never>.Type: HashSet.HashSet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<HashSet.HashSet<number>, readonly string[]>(schema: Schema.Schema<HashSet.HashSet<number>, readonly string[], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.HashSet<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: HashSet.HashSet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
=
import Schema
Schema
.
encodeSync<HashSet.HashSet<number>, readonly string[]>(schema: Schema.Schema<HashSet.HashSet<number>, readonly string[], never>, options?: ParseOptions): (a: HashSet.HashSet<...>, overrideOptions?: ParseOptions) => readonly string[]
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.HashSet<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<number>
decode
(["1", "2", "3"]))
// Output: { _id: 'HashSet', values: [ 1, 2, 3 ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: HashSet.HashSet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
(
import HashSet
HashSet
.
const fromIterable: <number>(elements: Iterable<number>) => HashSet.HashSet<number>

Creates a new HashSet from an iterable collection of values.

@since2.0.0

fromIterable
([1, 2, 3])))
// Output: [ '1', '2', '3' ]

The Schema.HashSetFromSelf function is designed for scenarios where HashSet values are already in the HashSet format and need to be decoded or encoded while transforming the inner values according to the provided schema.

Syntax

Schema.HashSetFromSelf(schema: Schema<A, I, R>)
InputOutput
HashSet<I>Converts to HashSet<A>, decoding each element from type I to type A using the schema
InputOutput
HashSet<A>Converts to HashSet<I>, encoding each element from type A to type I using the schema

Example

import {
import Schema
Schema
} from "effect"
import {
import HashSet
HashSet
} from "effect"
const
const schema: Schema.HashSetFromSelf<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const HashSetFromSelf: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString) => Schema.HashSetFromSelf<typeof Schema.NumberFromString>

@since3.10.0

HashSetFromSelf
(
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".

@since3.10.0

NumberFromString
)
// ┌─── HashSet<string>
// ▼
type
type Encoded = HashSet.HashSet<string>
Encoded
= typeof
const schema: Schema.HashSetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<HashSet<number>, HashSet<string>, never>.Encoded: HashSet.HashSet<string>
Encoded
// ┌─── HashSet<number>
// ▼
type
type Type = HashSet.HashSet<number>
Type
= typeof
const schema: Schema.HashSetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<HashSet<number>, HashSet<string>, never>.Type: HashSet.HashSet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<HashSet.HashSet<number>, HashSet.HashSet<string>>(schema: Schema.Schema<HashSet.HashSet<number>, HashSet.HashSet<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.HashSetFromSelf<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: HashSet.HashSet<number>, overrideOptions?: ParseOptions) => HashSet.HashSet<string>
encode
=
import Schema
Schema
.
encodeSync<HashSet.HashSet<number>, HashSet.HashSet<string>>(schema: Schema.Schema<HashSet.HashSet<number>, HashSet.HashSet<string>, never>, options?: ParseOptions): (a: HashSet.HashSet<...>, overrideOptions?: ParseOptions) => HashSet.HashSet<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.HashSetFromSelf<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashSet.HashSet<number>
decode
(
import HashSet
HashSet
.
const fromIterable: <string>(elements: Iterable<string>) => HashSet.HashSet<string>

Creates a new HashSet from an iterable collection of values.

@since2.0.0

fromIterable
(["1", "2", "3"])))
// Output: { _id: 'HashSet', values: [ 1, 2, 3 ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: HashSet.HashSet<number>, overrideOptions?: ParseOptions) => HashSet.HashSet<string>
encode
(
import HashSet
HashSet
.
const fromIterable: <number>(elements: Iterable<number>) => HashSet.HashSet<number>

Creates a new HashSet from an iterable collection of values.

@since2.0.0

fromIterable
([1, 2, 3])))
// Output: { _id: 'HashSet', values: [ '1', '3', '2' ] }

The Schema.HashMap function is useful for converting a HashMap into a JSON-serializable format.

Syntax

Schema.HashMap(options: {
key: Schema<KA, KI, KR>,
value: Schema<VA, VI, VR>
})
InputOutput
ReadonlyArray<readonly [KI, VI]>Converts to HashMap<KA, VA>, where KI is decoded into KA and VI is decoded into VA using the specified schemas
InputOutput
HashMap<KA, VA>Converts to ReadonlyArray<readonly [KI, VI]>, where KA is encoded into KI and VA is encoded into VI using the specified schemas

Example

import {
import Schema
Schema
} from "effect"
import {
import HashMap
HashMap
} from "effect"
const
const schema: Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const HashMap: <typeof Schema.String, typeof Schema.NumberFromString>({ key, value }: {
readonly key: typeof Schema.String;
readonly value: typeof Schema.NumberFromString;
}) => Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>

@since3.10.0

HashMap
({
key: typeof Schema.String
key
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
value: typeof Schema.NumberFromString
value
:
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".

@since3.10.0

NumberFromString
})
// ┌─── readonly (readonly [string, string])[]
// ▼
type
type Encoded = readonly (readonly [string, string])[]
Encoded
= typeof
const schema: Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<HashMap<string, number>, readonly (readonly [string, string])[], never>.Encoded: readonly (readonly [string, string])[]
Encoded
// ┌─── HashMap<string, number>
// ▼
type
type Type = HashMap.HashMap<string, number>
Type
= typeof
const schema: Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<HashMap<string, number>, readonly (readonly [string, string])[], never>.Type: HashMap.HashMap<string, number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<string, number>
decode
=
import Schema
Schema
.
decodeUnknownSync<HashMap.HashMap<string, number>, readonly (readonly [string, string])[]>(schema: Schema.Schema<HashMap.HashMap<string, number>, readonly (readonly [string, string])[], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
const
const encode: (a: HashMap.HashMap<string, number>, overrideOptions?: ParseOptions) => readonly (readonly [string, string])[]
encode
=
import Schema
Schema
.
encodeSync<HashMap.HashMap<string, number>, readonly (readonly [string, string])[]>(schema: Schema.Schema<HashMap.HashMap<string, number>, readonly (readonly [string, string])[], never>, options?: ParseOptions): (a: HashMap.HashMap<...>, overrideOptions?: ParseOptions) => readonly (readonly [...])[]
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.HashMap<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<string, number>
decode
([
["a", "2"],
["b", "2"],
["c", "3"]
])
)
// Output: { _id: 'HashMap', values: [ [ 'a', 2 ], [ 'c', 3 ], [ 'b', 2 ] ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: HashMap.HashMap<string, number>, overrideOptions?: ParseOptions) => readonly (readonly [string, string])[]
encode
(
import HashMap
HashMap
.
const fromIterable: <string, number>(entries: Iterable<readonly [string, number]>) => HashMap.HashMap<string, number>

Creates a new HashMap from an iterable collection of key/value pairs.

@since2.0.0

fromIterable
([
["a", 1],
["b", 2],
["c", 3]
])
)
)
// Output: [ [ 'a', '1' ], [ 'c', '3' ], [ 'b', '2' ] ]

The Schema.HashMapFromSelf function is designed for scenarios where HashMap values are already in the HashMap format and need to be decoded or encoded while transforming the inner values according to the provided schemas.

Syntax

Schema.HashMapFromSelf(options: {
key: Schema<KA, KI, KR>,
value: Schema<VA, VI, VR>
})
InputOutput
HashMap<KI, VI>Converts to HashMap<KA, VA>, where KI is decoded into KA and VI is decoded into VA using the specified schemas
InputOutput
HashMap<KA, VA>Converts to HashMap<KI, VI>, where KA is encoded into KI and VA is encoded into VI using the specified schemas

Example

import {
import Schema
Schema
} from "effect"
import {
import HashMap
HashMap
} from "effect"
const
const schema: Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const HashMapFromSelf: <typeof Schema.String, typeof Schema.NumberFromString>({ key, value }: {
readonly key: typeof Schema.String;
readonly value: typeof Schema.NumberFromString;
}) => Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>

@since3.10.0

HashMapFromSelf
({
key: typeof Schema.String
key
:
import Schema
Schema
.
class String
export String

@since3.10.0

String
,
value: typeof Schema.NumberFromString
value
:
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".

@since3.10.0

NumberFromString
})
// ┌─── HashMap<string, string>
// ▼
type
type Encoded = HashMap.HashMap<string, string>
Encoded
= typeof
const schema: Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<HashMap<string, number>, HashMap<string, string>, never>.Encoded: HashMap.HashMap<string, string>
Encoded
// ┌─── HashMap<string, number>
// ▼
type
type Type = HashMap.HashMap<string, number>
Type
= typeof
const schema: Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
.
Schema<HashMap<string, number>, HashMap<string, string>, never>.Type: HashMap.HashMap<string, number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<string, number>
decode
=
import Schema
Schema
.
decodeUnknownSync<HashMap.HashMap<string, number>, HashMap.HashMap<string, string>>(schema: Schema.Schema<HashMap.HashMap<string, number>, HashMap.HashMap<string, string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
const
const encode: (a: HashMap.HashMap<string, number>, overrideOptions?: ParseOptions) => HashMap.HashMap<string, string>
encode
=
import Schema
Schema
.
encodeSync<HashMap.HashMap<string, number>, HashMap.HashMap<string, string>>(schema: Schema.Schema<HashMap.HashMap<string, number>, HashMap.HashMap<string, string>, never>, options?: ParseOptions): (a: HashMap.HashMap<...>, overrideOptions?: ParseOptions) => HashMap.HashMap<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.HashMapFromSelf<typeof Schema.String, typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => HashMap.HashMap<string, number>
decode
(
import HashMap
HashMap
.
const fromIterable: <string, string>(entries: Iterable<readonly [string, string]>) => HashMap.HashMap<string, string>

Creates a new HashMap from an iterable collection of key/value pairs.

@since2.0.0

fromIterable
([
["a", "2"],
["b", "2"],
["c", "3"]
])
)
)
// Output: { _id: 'HashMap', values: [ [ 'a', 2 ], [ 'c', 3 ], [ 'b', 2 ] ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: HashMap.HashMap<string, number>, overrideOptions?: ParseOptions) => HashMap.HashMap<string, string>
encode
(
import HashMap
HashMap
.
const fromIterable: <string, number>(entries: Iterable<readonly [string, number]>) => HashMap.HashMap<string, number>

Creates a new HashMap from an iterable collection of key/value pairs.

@since2.0.0

fromIterable
([
["a", 1],
["b", 2],
["c", 3]
])
)
)
// Output: { _id: 'HashMap', values: [ [ 'a', '1' ], [ 'c', '3' ], [ 'b', '2' ] ] }

The Schema.SortedSet function provides a way to map between SortedSet and an array representation, allowing for JSON serialization and deserialization.

Syntax

Schema.SortedSet(schema: Schema<A, I, R>, order: Order<A>)
InputOutput
ReadonlyArray<I>Converts to SortedSet<A>, where each element in the array is decoded into type A using the schema
InputOutput
SortedSet<A>Converts to ReadonlyArray<I>, where each element in the SortedSet is encoded into type I using the schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Number
Number
,
import SortedSet
SortedSet
} from "effect"
const
const schema: Schema.SortedSet<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const SortedSet: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString, ordA: Order<number>) => Schema.SortedSet<typeof Schema.NumberFromString>

@since3.10.0

SortedSet
(
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".

@since3.10.0

NumberFromString
,
import Number
Number
.
const Order: Order<number>

@since2.0.0

Order
)
// ┌─── readonly string[]
// ▼
type
type Encoded = readonly string[]
Encoded
= typeof
const schema: Schema.SortedSet<typeof Schema.NumberFromString>
schema
.
Schema<SortedSet<number>, readonly string[], never>.Encoded: readonly string[]
Encoded
// ┌─── SortedSet<number>
// ▼
type
type Type = SortedSet.SortedSet<number>
Type
= typeof
const schema: Schema.SortedSet<typeof Schema.NumberFromString>
schema
.
Schema<SortedSet<number>, readonly string[], never>.Type: SortedSet.SortedSet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<SortedSet.SortedSet<number>, readonly string[]>(schema: Schema.Schema<SortedSet.SortedSet<number>, readonly string[], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.SortedSet<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: SortedSet.SortedSet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
=
import Schema
Schema
.
encodeSync<SortedSet.SortedSet<number>, readonly string[]>(schema: Schema.Schema<SortedSet.SortedSet<number>, readonly string[], never>, options?: ParseOptions): (a: SortedSet.SortedSet<...>, overrideOptions?: ParseOptions) => readonly string[]
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.SortedSet<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<number>
decode
(["1", "2", "3"]))
// Output: { _id: 'SortedSet', values: [ 1, 2, 3 ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: SortedSet.SortedSet<number>, overrideOptions?: ParseOptions) => readonly string[]
encode
(
import SortedSet
SortedSet
.
const fromIterable: <number>(ord: Order<number>) => <A>(iterable: Iterable<A>) => SortedSet.SortedSet<A> (+1 overload)

Creates a new SortedSet from an iterable collection of values.

@since2.0.0

fromIterable
(
import Number
Number
.
const Order: Order<number>

@since2.0.0

Order
)([1, 2, 3])))
// Output: [ '1', '2', '3' ]

The Schema.SortedSetFromSelf function is designed for scenarios where SortedSet values are already in the SortedSet format and need to be decoded or encoded while transforming the inner values according to the provided schema.

Syntax

Schema.SortedSetFromSelf(
schema: Schema<A, I, R>,
decodeOrder: Order<A>,
encodeOrder: Order<I>
)
InputOutput
SortedSet<I>Converts to SortedSet<A>, decoding each element from type I to type A using the schema
InputOutput
SortedSet<A>Converts to SortedSet<I>, encoding each element from type A to type I using the schema

Example

import {
import Schema
Schema
} from "effect"
import {
import Number
Number
,
import SortedSet
SortedSet
,
import String
String
} from "effect"
const
const schema: Schema.SortedSetFromSelf<typeof Schema.NumberFromString>
schema
=
import Schema
Schema
.
const SortedSetFromSelf: <typeof Schema.NumberFromString>(value: typeof Schema.NumberFromString, ordA: Order<number>, ordI: Order<string>) => Schema.SortedSetFromSelf<typeof Schema.NumberFromString>

@since3.10.0

SortedSetFromSelf
(
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".

@since3.10.0

NumberFromString
,
import Number
Number
.
const Order: Order<number>

@since2.0.0

Order
,
import String
String
.
const Order: Order<string>

@since2.0.0

Order
)
// ┌─── SortedSet<string>
// ▼
type
type Encoded = SortedSet.SortedSet<string>
Encoded
= typeof
const schema: Schema.SortedSetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<SortedSet<number>, SortedSet<string>, never>.Encoded: SortedSet.SortedSet<string>
Encoded
// ┌─── SortedSet<number>
// ▼
type
type Type = SortedSet.SortedSet<number>
Type
= typeof
const schema: Schema.SortedSetFromSelf<typeof Schema.NumberFromString>
schema
.
Schema<SortedSet<number>, SortedSet<string>, never>.Type: SortedSet.SortedSet<number>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<number>
decode
=
import Schema
Schema
.
decodeUnknownSync<SortedSet.SortedSet<number>, SortedSet.SortedSet<string>>(schema: Schema.Schema<SortedSet.SortedSet<number>, SortedSet.SortedSet<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.SortedSetFromSelf<typeof Schema.NumberFromString>
schema
)
const
const encode: (a: SortedSet.SortedSet<number>, overrideOptions?: ParseOptions) => SortedSet.SortedSet<string>
encode
=
import Schema
Schema
.
encodeSync<SortedSet.SortedSet<number>, SortedSet.SortedSet<string>>(schema: Schema.Schema<SortedSet.SortedSet<number>, SortedSet.SortedSet<string>, never>, options?: ParseOptions): (a: SortedSet.SortedSet<...>, overrideOptions?: ParseOptions) => SortedSet.SortedSet<...>
export encodeSync

@since3.10.0

encodeSync
(
const schema: Schema.SortedSetFromSelf<typeof Schema.NumberFromString>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => SortedSet.SortedSet<number>
decode
(
import SortedSet
SortedSet
.
const fromIterable: <string>(ord: Order<string>) => <A>(iterable: Iterable<A>) => SortedSet.SortedSet<A> (+1 overload)

Creates a new SortedSet from an iterable collection of values.

@since2.0.0

fromIterable
(
import String
String
.
const Order: Order<string>

@since2.0.0

Order
)(["1", "2", "3"])))
// Output: { _id: 'SortedSet', values: [ 1, 2, 3 ] }
// Encoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const encode: (a: SortedSet.SortedSet<number>, overrideOptions?: ParseOptions) => SortedSet.SortedSet<string>
encode
(
import SortedSet
SortedSet
.
const fromIterable: <number>(ord: Order<number>) => <A>(iterable: Iterable<A>) => SortedSet.SortedSet<A> (+1 overload)

Creates a new SortedSet from an iterable collection of values.

@since2.0.0

fromIterable
(
import Number
Number
.
const Order: Order<number>

@since2.0.0

Order
)([1, 2, 3])))
// Output: { _id: 'SortedSet', values: [ '1', '2', '3' ] }

The Duration schema family enables the transformation and validation of duration values across various formats, including hrtime, milliseconds, and nanoseconds.

Converts an hrtime(i.e. [seconds: number, nanos: number]) into a Duration.

Example

import {
import Schema
Schema
} from "effect"
const
const schema: typeof Schema.Duration
schema
=
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
// ┌─── readonly [seconds: number, nanos: number]
// ▼
type
type Encoded = readonly [seconds: number, nanos: number]
Encoded
= typeof
const schema: typeof Schema.Duration
schema
.
Schema<Duration, readonly [seconds: number, nanos: number], never>.Encoded: readonly [seconds: number, nanos: number]
Encoded
// ┌─── Duration
// ▼
type
type Type = Duration
Type
= typeof
const schema: typeof Schema.Duration
schema
.
Schema<Duration, readonly [seconds: number, nanos: number], never>.Type: Duration
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
=
import Schema
Schema
.
decodeUnknownSync<Duration, readonly [seconds: number, nanos: number]>(schema: Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Duration
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: typeof Schema.Duration
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
([0, 0]))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 0 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
([5000, 0]))
// Output: { _id: 'Duration', _tag: 'Nanos', hrtime: [ 5000, 0 ] }

The DurationFromSelf schema is designed to validate that a given value conforms to the Duration type.

Example

import {
import Schema
Schema
,
import Duration
Duration
} from "effect"
const
const schema: typeof Schema.DurationFromSelf
schema
=
import Schema
Schema
.
class DurationFromSelf

@since3.10.0

DurationFromSelf
// ┌─── Duration
// ▼
type
type Encoded = Duration.Duration
Encoded
= typeof
const schema: typeof Schema.DurationFromSelf
schema
.
Schema<Duration, Duration, never>.Encoded: Duration.Duration
Encoded
// ┌─── Duration
// ▼
type
type Type = Duration.Duration
Type
= typeof
const schema: typeof Schema.DurationFromSelf
schema
.
Schema<Duration, Duration, never>.Type: Duration.Duration
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
=
import Schema
Schema
.
decodeUnknownSync<Duration.Duration, Duration.Duration>(schema: Schema.Schema<Duration.Duration, Duration.Duration, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: typeof Schema.DurationFromSelf
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
(
import Duration
Duration
.
const seconds: (seconds: number) => Duration.Duration

@since2.0.0

seconds
(2)))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 2000 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
(null))
/*
throws:
ParseError: Expected DurationFromSelf, actual null
*/

Converts a number into a Duration where the number represents the number of milliseconds.

Example

import {
import Schema
Schema
} from "effect"
const
const schema: typeof Schema.DurationFromMillis
schema
=
import Schema
Schema
.
class DurationFromMillis

A schema that transforms a number tuple into a Duration. Treats the value as the number of milliseconds.

@since3.10.0

DurationFromMillis
// ┌─── number
// ▼
type
type Encoded = number
Encoded
= typeof
const schema: typeof Schema.DurationFromMillis
schema
.
Schema<Duration, number, never>.Encoded: number
Encoded
// ┌─── Duration
// ▼
type
type Type = Duration
Type
= typeof
const schema: typeof Schema.DurationFromMillis
schema
.
Schema<Duration, number, never>.Type: Duration
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
=
import Schema
Schema
.
decodeUnknownSync<Duration, number>(schema: Schema.Schema<Duration, number, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Duration
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: typeof Schema.DurationFromMillis
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
(0))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 0 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
(5000))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 5000 }

Converts a BigInt into a Duration where the number represents the number of nanoseconds.

Example

import {
import Schema
Schema
} from "effect"
const
const schema: typeof Schema.DurationFromNanos
schema
=
import Schema
Schema
.
class DurationFromNanos

A schema that transforms a bigint tuple into a Duration. Treats the value as the number of nanoseconds.

@since3.10.0

DurationFromNanos
// ┌─── bigint
// ▼
type
type Encoded = bigint
Encoded
= typeof
const schema: typeof Schema.DurationFromNanos
schema
.
Schema<Duration, bigint, never>.Encoded: bigint
Encoded
// ┌─── Duration
// ▼
type
type Type = Duration
Type
= typeof
const schema: typeof Schema.DurationFromNanos
schema
.
Schema<Duration, bigint, never>.Type: Duration
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
=
import Schema
Schema
.
decodeUnknownSync<Duration, bigint>(schema: Schema.Schema<Duration, bigint, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Duration
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: typeof Schema.DurationFromNanos
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
(0n))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 0 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration
decode
(5000000000n))
// Output: { _id: 'Duration', _tag: 'Nanos', hrtime: [ 5, 0 ] }

Clamps a Duration between a minimum and a maximum value.

Example

import {
import Schema
Schema
,
import Duration
Duration
} from "effect"
const
const schema: Schema.transform<Schema.Schema<Duration.Duration, Duration.Duration, never>, Schema.filter<Schema.Schema<Duration.Duration, Duration.Duration, never>>>
schema
=
import Schema
Schema
.
class DurationFromSelf

@since3.10.0

DurationFromSelf
.
Pipeable.pipe<typeof Schema.DurationFromSelf, Schema.transform<Schema.Schema<Duration.Duration, Duration.Duration, never>, Schema.filter<Schema.Schema<Duration.Duration, Duration.Duration, never>>>>(this: typeof Schema.DurationFromSelf, ab: (_: typeof Schema.DurationFromSelf) => Schema.transform<...>): Schema.transform<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const clampDuration: (minimum: Duration.DurationInput, maximum: Duration.DurationInput) => <A extends Duration.Duration, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.Schema<A>>>

Clamps a Duration between a minimum and a maximum value.

@since3.10.0

clampDuration
("5 seconds", "10 seconds")
)
// ┌─── Duration
// ▼
type
type Encoded = Duration.Duration
Encoded
= typeof
const schema: Schema.transform<Schema.Schema<Duration.Duration, Duration.Duration, never>, Schema.filter<Schema.Schema<Duration.Duration, Duration.Duration, never>>>
schema
.
Schema<Duration, Duration, never>.Encoded: Duration.Duration
Encoded
// ┌─── Duration
// ▼
type
type Type = Duration.Duration
Type
= typeof
const schema: Schema.transform<Schema.Schema<Duration.Duration, Duration.Duration, never>, Schema.filter<Schema.Schema<Duration.Duration, Duration.Duration, never>>>
schema
.
Schema<Duration, Duration, never>.Type: Duration.Duration
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
=
import Schema
Schema
.
decodeUnknownSync<Duration.Duration, Duration.Duration>(schema: Schema.Schema<Duration.Duration, Duration.Duration, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.transform<Schema.Schema<Duration.Duration, Duration.Duration, never>, Schema.filter<Schema.Schema<Duration.Duration, Duration.Duration, never>>>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
(
import Duration
Duration
.
const decode: (input: Duration.DurationInput) => Duration.Duration

@since2.0.0

decode
("2 seconds")))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 5000 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
(
import Duration
Duration
.
const decode: (input: Duration.DurationInput) => Duration.Duration

@since2.0.0

decode
("6 seconds")))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 6000 }
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Duration.Duration
decode
(
import Duration
Duration
.
const decode: (input: Duration.DurationInput) => Duration.Duration

@since2.0.0

decode
("11 seconds")))
// Output: { _id: 'Duration', _tag: 'Millis', millis: 10000 }

The Schema.Redacted function is specifically designed to handle sensitive information by converting a string into a Redacted object. This transformation ensures that the sensitive data is not exposed in the application’s output.

Example (Basic Redacted Schema)

import {
import Schema
Schema
} from "effect"
const
const schema: Schema.Redacted<typeof Schema.String>
schema
=
import Schema
Schema
.
const Redacted: <typeof Schema.String>(value: typeof Schema.String) => Schema.Redacted<typeof Schema.String>

A schema that transforms any type A into a Redacted<A>.

@since3.10.0

Redacted
(
import Schema
Schema
.
class String
export String

@since3.10.0

String
)
// ┌─── string
// ▼
type
type Encoded = string
Encoded
= typeof
const schema: Schema.Redacted<typeof Schema.String>
schema
.
Schema<Redacted<string>, string, never>.Encoded: string
Encoded
// ┌─── Redacted<string>
// ▼
type
type Type = Redacted<string>
Type
= typeof
const schema: Schema.Redacted<typeof Schema.String>
schema
.
Schema<Redacted<string>, string, never>.Type: Redacted<string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Redacted<string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Redacted<string>, string>(schema: Schema.Schema<Redacted<string>, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Redacted<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.Redacted<typeof Schema.String>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Redacted<string>
decode
("keep it secret, keep it safe"))
// Output: <redacted>

It’s important to note that when successfully decoding a Redacted, the output is intentionally obscured (<redacted>) to prevent the actual secret from being revealed in logs or console outputs.

Example (Exposure Risks During Errors)

In the example below, if the input string does not meet the criteria (e.g., contains spaces), the error message generated might inadvertently expose sensitive information included in the input.

import {
import Schema
Schema
} from "effect"
import {
import Redacted
Redacted
} from "effect"
const
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
=
import Schema
Schema
.
class Trimmed

@since3.10.0

Trimmed
.
Pipeable.pipe<typeof Schema.Trimmed, Schema.SchemaClass<Redacted.Redacted<string>, string, never>>(this: typeof Schema.Trimmed, ab: (_: typeof Schema.Trimmed) => Schema.SchemaClass<Redacted.Redacted<string>, string, never>): Schema.SchemaClass<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const compose: <Redacted.Redacted<string>, string, never, string>(to: Schema.Schema<Redacted.Redacted<string>, string, never>) => <A, R1>(from: Schema.Schema<string, A, R1>) => Schema.SchemaClass<...> (+7 overloads)

@since3.10.0

compose
(
import Schema
Schema
.
const Redacted: <typeof Schema.String>(value: typeof Schema.String) => Schema.Redacted<typeof Schema.String>

A schema that transforms any type A into a Redacted<A>.

@since3.10.0

Redacted
(
import Schema
Schema
.
class String
export String

@since3.10.0

String
))
)
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
const decodeUnknownEither: <Redacted.Redacted<string>, string>(schema: Schema.Schema<Redacted.Redacted<string>, string, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either<...>

@since3.10.0

decodeUnknownEither
(
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
)(" SECRET"))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> (string <-> Redacted(<redacted>)))\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " SECRET"'
}
}
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
const encodeEither: <Redacted.Redacted<string>, string>(schema: Schema.Schema<Redacted.Redacted<string>, string, never>, options?: ParseOptions) => (a: Redacted.Redacted<...>, overrideOptions?: ParseOptions) => Either<...>

@since3.10.0

encodeEither
(
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
)(
import Redacted
Redacted
.
const make: <string>(value: string) => Redacted.Redacted<string>

This function creates a Redacted<A> instance from a given value A, securely hiding its content.

@example

import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")

@since3.3.0

make
(" SECRET")))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> (string <-> Redacted(<redacted>)))\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " SECRET"'
}
}
*/

To reduce the risk of sensitive information leakage in error messages, you can customize the error messages to obscure sensitive details:

Example (Customizing Error Messages)

import {
import Schema
Schema
} from "effect"
import {
import Redacted
Redacted
} from "effect"
const
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
=
import Schema
Schema
.
class Trimmed

@since3.10.0

Trimmed
.
Annotable<refine<string, Schema<string, string, never>>, string, string, never>.annotations(annotations: Schema.Annotations.GenericSchema<string>): Schema.refine<string, Schema.Schema<string, string, never>>

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

annotations
({
Annotations.Schema<string, readonly []>.message?: MessageAnnotation
message
: () => "Expected Trimmed, actual <redacted>"
}).
Pipeable.pipe<Schema.refine<string, Schema.Schema<string, string, never>>, Schema.SchemaClass<Redacted.Redacted<string>, string, never>>(this: Schema.refine<...>, ab: (_: Schema.refine<string, Schema.Schema<...>>) => Schema.SchemaClass<...>): Schema.SchemaClass<...> (+21 overloads)
pipe
(
import Schema
Schema
.
const compose: <Redacted.Redacted<string>, string, never, string>(to: Schema.Schema<Redacted.Redacted<string>, string, never>) => <A, R1>(from: Schema.Schema<string, A, R1>) => Schema.SchemaClass<...> (+7 overloads)

@since3.10.0

compose
(
import Schema
Schema
.
const Redacted: <typeof Schema.String>(value: typeof Schema.String) => Schema.Redacted<typeof Schema.String>

A schema that transforms any type A into a Redacted<A>.

@since3.10.0

Redacted
(
import Schema
Schema
.
class String
export String

@since3.10.0

String
)))
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
const decodeUnknownEither: <Redacted.Redacted<string>, string>(schema: Schema.Schema<Redacted.Redacted<string>, string, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either<...>

@since3.10.0

decodeUnknownEither
(
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
)(" SECRET"))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> (string <-> Redacted(<redacted>)))\n' +
'└─ Encoded side transformation failure\n' +
' └─ Expected Trimmed, actual <redacted>'
}
}
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
const encodeEither: <Redacted.Redacted<string>, string>(schema: Schema.Schema<Redacted.Redacted<string>, string, never>, options?: ParseOptions) => (a: Redacted.Redacted<...>, overrideOptions?: ParseOptions) => Either<...>

@since3.10.0

encodeEither
(
const schema: Schema.SchemaClass<Redacted.Redacted<string>, string, never>
schema
)(
import Redacted
Redacted
.
const make: <string>(value: string) => Redacted.Redacted<string>

This function creates a Redacted<A> instance from a given value A, securely hiding its content.

@example

import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")

@since3.3.0

make
(" SECRET")))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> (string <-> Redacted(<redacted>)))\n' +
'└─ Encoded side transformation failure\n' +
' └─ Expected Trimmed, actual <redacted>'
}
}
*/

The Schema.RedactedFromSelf schema is designed to validate that a given value conforms to the Redacted type from the effect library.

Example

import {
import Schema
Schema
} from "effect"
import {
import Redacted
Redacted
} from "effect"
const
const schema: Schema.RedactedFromSelf<typeof Schema.String>
schema
=
import Schema
Schema
.
const RedactedFromSelf: <typeof Schema.String>(value: typeof Schema.String) => Schema.RedactedFromSelf<typeof Schema.String>

@since3.10.0

RedactedFromSelf
(
import Schema
Schema
.
class String
export String

@since3.10.0

String
)
// ┌─── Redacted<string>
// ▼
type
type Encoded = Redacted.Redacted<string>
Encoded
= typeof
const schema: Schema.RedactedFromSelf<typeof Schema.String>
schema
.
Schema<Redacted<string>, Redacted<string>, never>.Encoded: Redacted.Redacted<string>
Encoded
// ┌─── Redacted<string>
// ▼
type
type Type = Redacted.Redacted<string>
Type
= typeof
const schema: Schema.RedactedFromSelf<typeof Schema.String>
schema
.
Schema<Redacted<string>, Redacted<string>, never>.Type: Redacted.Redacted<string>
Type
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Redacted.Redacted<string>
decode
=
import Schema
Schema
.
decodeUnknownSync<Redacted.Redacted<string>, Redacted.Redacted<string>>(schema: Schema.Schema<Redacted.Redacted<string>, Redacted.Redacted<string>, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => Redacted.Redacted<...>
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const schema: Schema.RedactedFromSelf<typeof Schema.String>
schema
)
// Decoding examples
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Redacted.Redacted<string>
decode
(
import Redacted
Redacted
.
const make: <string>(value: string) => Redacted.Redacted<string>

This function creates a Redacted<A> instance from a given value A, securely hiding its content.

@example

import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")

@since3.3.0

make
("mysecret")))
// Output: <redacted>
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
const decode: (u: unknown, overrideOptions?: ParseOptions) => Redacted.Redacted<string>
decode
(null))
/*
throws:
ParseError: Expected Redacted(<redacted>), actual null
*/

It’s important to note that when successfully decoding a Redacted, the output is intentionally obscured (<redacted>) to prevent the actual secret from being revealed in logs or console outputs.