CoLists

CoLists are ordered collections that work like JavaScript arrays. They provide indexed access, iteration methods, and length properties, making them perfect for managing sequences of items.

Creating CoLists

CoLists are defined by specifying the type of items they contain:

import { import coco, import zz } from "jazz-tools";

const const ListOfResources: co.List<z.z.ZodString>ListOfResources = import coco.
list<z.z.ZodString>(element: z.z.ZodString): co.List<z.z.ZodString>
export list
list
(import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString (+1 overload)
export string
string
());
export type type ListOfResources = CoList<string>ListOfResources = import coco.
type loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean ...
export loaded
loaded
<typeof const ListOfResources: co.List<z.z.ZodString>ListOfResources>;
const
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
ListOfTasks
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>(element: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<...>;
}, unknown, Account | Group>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>
Task
);
export type
type ListOfTasks = CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
ListOfTasks
= import coco.
type loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean ...
export loaded
loaded
<typeof
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
ListOfTasks
>;

To create a CoList:

// Create an empty list
const const resources: CoListInstance<z.z.ZodString>resources = import coco.
list<z.z.ZodString>(element: z.z.ZodString): co.List<z.z.ZodString>
export list
list
(import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString (+1 overload)
export string
string
()).
CoListSchema<ZodString>.create(items: readonly string[], options?: {
    owner: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): CoListInstance<...> (+1 overload)
create
([]);
// Create a list with initial items const
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Group | Account>>
tasks
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Group | Account>>(element: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<...>;
}, unknown, Group | Account>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Group | Account>
Task
).
CoListSchema<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; }, unknown, Group | Account>>.create(items: readonly (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | {
    title: string;
    status: "todo" | "in-progress" | "complete";
})[], options?: {
    owner: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): CoListInstance<...> (+1 overload)
create
([
{ title: stringtitle: "Prepare soil beds", status: "in-progress"status: "in-progress" }, { title: stringtitle: "Order compost", status: "todo"status: "todo" } ]);

Ownership

Like other CoValues, you can specify ownership when creating CoLists.

// Create with shared ownership
const const teamGroup: GroupteamGroup = class Group
@categoryIdentity & Permissions
Group
.
Group.create<Group>(this: CoValueClass<Group>, options?: {
    owner: Account;
} | Account): Group
create
();
const teamGroup: GroupteamGroup.Group.addMember(member: Account, role: AccountRole): void (+3 overloads)addMember(
const colleagueAccount: Account | ({
    readonly [x: string]: any;
} & Account)
colleagueAccount
, "writer");
const
const teamList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}, unknown, Group | Account>>
teamList
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}, unknown, Group | Account>>(element: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}, unknown, Group | Account>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}, unknown, Group | Account>
Task
).
CoListSchema<CoMapSchema<{ title: ZodString; status: ZodString; }, unknown, Group | Account>>.create(items: readonly (({
    readonly title: string;
    readonly status: string;
} & CoMap) | {
    title: string;
    status: string;
})[], options?: {
    owner: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): CoListInstance<...> (+1 overload)
create
([], { owner: Groupowner: const teamGroup: GroupteamGroup });

See Groups as permission scopes for more information on how to use groups to control access to CoLists.

Reading from CoLists

CoLists support standard array access patterns:

// Access by index
const 
const firstTask: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
firstTask
=
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
[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`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
const firstTask: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
firstTask
.title: stringtitle); // "Prepare soil beds"
// Get list length var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
.Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length
); // 2
// Iteration
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
.
Array<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.forEach(callbackfn: (value: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.
@paramcallbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
forEach
(
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
=> {
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.title: stringtitle);
// "Prepare soil beds" // "Order compost" }); // Array methods const
const todoTasks: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[]
todoTasks
=
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
.
Array<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.filter(predicate: (value: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[]) => unknown, thisArg?: any): ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
@parampredicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
filter
(
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
=>
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.status: "todo" | "in-progress" | "complete"status === "todo");
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
const todoTasks: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[]
todoTasks
.Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length
); // 1

Updating CoLists

Methods to update a CoList's items are grouped inside the $jazz namespace:

// Add items
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
("Tomatoes"); // Add to end
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.unshift(...items: string[]): number
Inserts new elements at the start of an array, and returns the new length of the array.
@paramitems Elements to insert at the start of the array.@categoryContent
unshift
("Lettuce"); // Add to beginning
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
.
CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.$jazz: CoListJazzApi<CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>>
$jazz
.
CoListJazzApi<CoListInstance<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; }, unknown, Account | Group>>>.push(...items: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | CoMapInit<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap>)[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
({ // Add complex items
title: stringtitle: "Install irrigation", // (Jazz will create status: "todo"status: "todo" // the CoValue for you!) }); // Replace items const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.set(index: number, value: string): voidset(0, "Cucumber"); // Replace by index // Modify nested items
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
[0].
CoMap.$jazz: CoMapJazzApi<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap>
Jazz methods for CoMaps are inside this property. This allows CoMaps to be used as plain objects while still having access to Jazz methods, and also doesn't limit which key names can be used inside CoMaps.
$jazz
.CoMapJazzApi<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.set<"status">(key: "status", value: "todo" | "in-progress" | "complete"): void
Set a value on the CoMap
@paramkey The key to set@paramvalue The value to set@categoryContent
set
("status", "complete"); // Update properties of references

Soft Deletion

You can do a soft deletion by using a deleted flag, then creating a helper method that explicitly filters out items where the deleted property is true.

const 
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>
Task
= import coco.
map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}>(shape: {
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | ... 1 more ... | "complete">;
    deleted: z.ZodOptional<...>;
}): co.Map<...>
export map
map
({
title: z.z.ZodStringtitle: import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString (+1 overload)
export string
string
(),
status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">status: import zz.
literal<readonly ["todo", "in-progress", "complete"]>(value: readonly ["todo", "in-progress", "complete"], params?: string | z.z.core.$ZodLiteralParams): z.z.ZodLiteral<"todo" | "in-progress" | "complete"> (+1 overload)
export literal
literal
(["todo", "in-progress", "complete"]),
deleted: z.ZodOptional<z.z.ZodBoolean>deleted: import zz.
optional<z.z.ZodBoolean>(innerType: z.z.ZodBoolean): z.ZodOptional<z.z.ZodBoolean>
export optional
optional
(import zz.
function boolean(params?: string | z.z.core.$ZodBooleanParams): z.z.ZodBoolean
export boolean
boolean
())
}); type
type Task = co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>
Task
= typeof
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>
Task
;
const
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
ListOfTasks
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>(element: co.Map<...>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>
Task
);
type
type ListOfTasks = co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
ListOfTasks
= typeof
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
ListOfTasks
;
export function
function getCurrentTasks(list: co.loaded<ListOfTasks>): ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[]
getCurrentTasks
(
list: CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null>
list
: import coco.
type loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean ...
export loaded
loaded
<
type ListOfTasks = co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
ListOfTasks
>) {
return
list: CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null>
list
.
Array<({ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly deleted: boolean | undefined; } & CoMap) | null>.filter<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap>(predicate: (value: ({
    readonly title: string;
    readonly status: "todo" | ... 1 more ... | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null, index: number, array: (({
    readonly title: string;
    readonly status: "todo" | ... 1 more ... | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null)[]) => value is {
    readonly title: string;
    readonly status: "todo" | ... 1 more ... | "complete";
    readonly deleted: boolean | undefined;
} & CoMap, thisArg?: any): ({
    readonly title: string;
    readonly status: "todo" | ... 1 more ... | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
@parampredicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
filter
(
(
task: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null
task
):
task: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null
task
is import coco.
type loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean ...
export loaded
loaded
<
type Task = co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>
Task
> => !
task: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | null
task
?.deleted: boolean | undefineddeleted
); } async function function main(): Promise<void>main() { const
const myTaskList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
myTaskList
=
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
ListOfTasks
.
CoListSchema<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; deleted: ZodOptional<ZodBoolean>; }, unknown, Account | Group>>.create(items: readonly (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | {
    title: string;
    status: "todo" | "in-progress" | "complete";
    deleted?: boolean | undefined;
})[], options?: {
    owner: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): CoListInstance<...> (+1 overload)
create
([]);
const myTaskList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
myTaskList
.
CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly deleted: boolean | undefined; } & CoMap>.$jazz: CoListJazzApi<CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>>
$jazz
.
CoListJazzApi<CoListInstance<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; deleted: ZodOptional<ZodBoolean>; }, unknown, Account | Group>>>.push(...items: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | CoMapInit<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap>)[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
({
title: stringtitle: "Tomatoes", status: "todo"status: "todo", deleted: falsedeleted: false });
const myTaskList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
myTaskList
.
CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly deleted: boolean | undefined; } & CoMap>.$jazz: CoListJazzApi<CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>>
$jazz
.
CoListJazzApi<CoListInstance<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; deleted: ZodOptional<ZodBoolean>; }, unknown, Account | Group>>>.push(...items: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | CoMapInit<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap>)[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
({
title: stringtitle: "Cucumbers", status: "todo"status: "todo", deleted: truedeleted: true });
const myTaskList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
myTaskList
.
CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly deleted: boolean | undefined; } & CoMap>.$jazz: CoListJazzApi<CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>>
$jazz
.
CoListJazzApi<CoListInstance<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; deleted: ZodOptional<ZodBoolean>; }, unknown, Account | Group>>>.push(...items: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap) | CoMapInit<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap>)[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
({
title: stringtitle: "Carrots", status: "todo"status: "todo" }); const
const activeTasks: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[]
activeTasks
=
function getCurrentTasks(list: co.loaded<ListOfTasks>): ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[]
getCurrentTasks
(
const myTaskList: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    deleted: z.ZodOptional<z.z.ZodBoolean>;
}, unknown, Account | Group>>
myTaskList
);
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
const activeTasks: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[]
activeTasks
.
Array<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly deleted: boolean | undefined; } & CoMap>.map<string>(callbackfn: (value: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap, index: number, array: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap)[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@paramcallbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
map
((
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap
task
) =>
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly deleted: boolean | undefined;
} & CoMap
task
.title: stringtitle));
// Output: ["Tomatoes", "Carrots"] }

There are several benefits to soft deletions:

  • recoverablity - Nothing is truly deleted, so recovery is possible in the future
  • data integrity - Relationships can be maintained between current and deleted values
  • auditable - The data can still be accessed, good for audit trails and checking compliance

Deleting Items

Jazz provides two methods to retain or remove items from a CoList:

// Remove items
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.remove(...indices: number[]): string[] (+1 overload)
Removes the elements at the specified indices from the array.
@paramindices The indices of the elements to remove.@returnsThe removed elements.@categoryContent
remove
(2); // By index
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const resources: CoListInstance<z.z.ZodString>resources); // ["Cucumber", "Peppers"]
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.remove(predicate: (item: string, index: number, coList: CoListInstance<z.z.ZodString>) => boolean): string[] (+1 overload)
Removes the elements matching the predicate from the array.
@parampredicate The predicate to match the elements to remove.@returnsThe removed elements.@categoryContent
remove
(item: stringitem => item: stringitem === "Cucumber"); // Or by predicate
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const resources: CoListInstance<z.z.ZodString>resources); // ["Tomatoes", "Peppers"]
// Keep only items matching the predicate const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.retain(predicate: (item: string, index: number, coList: CoListInstance<z.z.ZodString>) => boolean): string[]
Retains only the elements matching the predicate from the array.
@parampredicate The predicate to match the elements to retain.@returnsThe removed elements.@categoryContent
retain
(item: stringitem => item: stringitem !== "Cucumber");
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const resources: CoListInstance<z.z.ZodString>resources); // ["Tomatoes", "Peppers"]

You can also remove specific items by index with splice, or remove the first or last item with pop or shift:

// Remove 2 items starting at index 1
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.splice(start: number, deleteCount: number, ...items: string[]): string[]
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@paramstart The zero-based location in the array from which to start removing elements.@paramdeleteCount The number of elements to remove.@paramitems Elements to insert into the array in place of the deleted elements.@returnsAn array containing the elements that were deleted.@categoryContent
splice
(1, 2);
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const resources: CoListInstance<z.z.ZodString>resources); // ["Tomatoes"]
// Remove a single item at index 0 const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.splice(start: number, deleteCount: number, ...items: string[]): string[]
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@paramstart The zero-based location in the array from which to start removing elements.@paramdeleteCount The number of elements to remove.@paramitems Elements to insert into the array in place of the deleted elements.@returnsAn array containing the elements that were deleted.@categoryContent
splice
(0, 1);
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const resources: CoListInstance<z.z.ZodString>resources); // ["Cucumber", "Peppers"]
// Remove items const const lastItem: string | undefinedlastItem = const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.pop(): string | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.
@categoryContent
pop
(); // Remove and return last item
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.shift(): string | undefined
Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.
@categoryContent
shift
(); // Remove first item

Array Methods

CoLists support the standard JavaScript array methods you already know. Methods that mutate the array are grouped inside the $jazz namespace.

// Add multiple items at once
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
("Tomatoes", "Basil", "Peppers");
// Find items const const basil: "Basil" | undefinedbasil = const resources: CoListInstance<z.z.ZodString>resources.Array<string>.find<"Basil">(predicate: (value: string, index: number, obj: string[]) => value is "Basil", thisArg?: any): "Basil" | undefined (+1 overload)
Returns the value of the first element in the array where predicate is true, and undefined otherwise.
@parampredicate find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.@paramthisArg If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.
find
(r: stringr => r: stringr === "Basil");
// Filter (returns regular array, not a CoList) const const tItems: string[]tItems = const resources: CoListInstance<z.z.ZodString>resources.Array<string>.filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
@parampredicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
filter
(r: stringr => r: stringr.String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.
startsWith
("T"));
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(const tItems: string[]tItems); // ["Tomatoes"]

Type Safety

CoLists maintain type safety for their items:

// TypeScript catches type errors
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
("Carrots"); // ✓ Valid string
const resources: CoListInstance<z.z.ZodString>resources.CoList<string>.$jazz: CoListJazzApi<CoListInstance<z.z.ZodString>>$jazz.CoListJazzApi<CoListInstance<ZodString>>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
(42); // ✗ Type error: expected string
Argument of type 'number' is not assignable to parameter of type 'string'.
// For lists of references
const tasks: CoListInstance<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
tasks
.
Array<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.forEach(callbackfn: (value: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap)[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.
@paramcallbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
forEach
(
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
=> {
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.title: stringtitle); // TypeScript knows task has title
});

Best Practices

Common Patterns

List Rendering

CoLists work well with UI rendering libraries:

import { import coco, import zz } from "jazz-tools";
const 
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
ListOfTasks
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>(element: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<...>;
}, unknown, Account | Group>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>
Task
);
// React example function
function TaskList({ tasks }: {
    tasks: co.loaded<typeof ListOfTasks>;
}): React.JSX.Element
TaskList
({
tasks: CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
}: {
tasks: CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
: import coco.
type loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? readonly ((CoValue & ... 1 more ... & (ItemDepth extends boolean ...
export loaded
loaded
<typeof
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}, unknown, Account | Group>>
ListOfTasks
> }) {
return ( <React.JSX.IntrinsicElements.ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>ul> {
tasks: CoList<({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
.
Array<({ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap) | null>.map<React.JSX.Element | null>(callbackfn: (value: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null, index: number, array: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null)[]) => React.JSX.Element | null, thisArg?: any): (React.JSX.Element | null)[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@paramcallbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@paramthisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
map
(
task: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null
task
=> (
task: ({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap) | null
task
? (
<React.JSX.IntrinsicElements.li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>li React.Attributes.key?: React.Key | null | undefinedkey={
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.
CoMap.$jazz: CoMapJazzApi<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap>
Jazz methods for CoMaps are inside this property. This allows CoMaps to be used as plain objects while still having access to Jazz methods, and also doesn't limit which key names can be used inside CoMaps.
$jazz
.CoMapJazzApi<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; } & CoMap>.id: string
The ID of this `CoMap`
@categoryContent
id
}>
{
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.title: stringtitle} - {
task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
} & CoMap
task
.status: "todo" | "in-progress" | "complete"status}
</React.JSX.IntrinsicElements.li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>li> ): null ))} </React.JSX.IntrinsicElements.ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>ul> ); }

Managing Relations

CoLists can be used to create one-to-many relationships:

import { import coco, import zz } from "jazz-tools";

const 
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Task
= import coco.
map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}>(shape: {
    ...;
}): co.Map<...>
export map
map
({
title: z.z.ZodStringtitle: import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString (+1 overload)
export string
string
(),
status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">status: import zz.
literal<readonly ["todo", "in-progress", "complete"]>(value: readonly ["todo", "in-progress", "complete"], params?: string | z.z.core.$ZodLiteralParams): z.z.ZodLiteral<"todo" | "in-progress" | "complete"> (+1 overload)
export literal
literal
(["todo", "in-progress", "complete"]),
get
project: co.Optional<co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>
project
(): import coco.
class Optional<Shape extends CoreCoValueSchema = CoreCoValueSchema>
export Optional
Optional
<typeof
const Project: co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Project
> {
return import coco.
optional<co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>(schema: co.Map<...>): co.Optional<...>
export optional
optional
(
const Project: co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Project
);
} }); const
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>
ListOfTasks
= import coco.
list<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>(element: co.Map<...>): co.List<...>
export list
list
(
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Task
);
const
const Project: co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Project
= import coco.
map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}>(shape: {
    ...;
}): co.Map<...>
export map
map
({
name: z.z.ZodStringname: import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString (+1 overload)
export string
string
(),
get
tasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>
tasks
(): import coco.
class List<T extends AnyZodOrCoValueSchema>
export List
List
<typeof
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Task
> {
return
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>
ListOfTasks
;
} }); const
const project: {
    readonly name: string;
    readonly tasks: CoList<{
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<... & CoMap>;
        } & CoMap) | undefined;
    } & CoMap>;
} & CoMap
project
=
const Project: co.Map<{
    name: z.z.ZodString;
    readonly tasks: co.List<co.Map<{
        title: z.z.ZodString;
        status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
        readonly project: co.Optional<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Project
.
CoMapSchema<{ name: ZodString; readonly tasks: CoListSchema<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; readonly project: CoOptionalSchema<CoMapSchema<..., unknown, Account | Group>>; }, unknown, Account | Group>>; }, unknown, Account | Group>.create(init: {
    name: string;
    readonly tasks: readonly (({
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<(... & CoMap) | null> | null;
        } & CoMap) | null | undefined;
    } & CoMap) | {
        ...;
    })[] | CoList<(... & CoMap) | null>;
}, options?: {
    owner?: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): {
    ...;
} & CoMap (+1 overload)
create
(
{ name: stringname: "Garden Project",
tasks: readonly (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<(... & CoMap) | null> | null;
    } & CoMap) | null | undefined;
} & CoMap) | {
    ...;
})[] | CoList<...>
tasks
:
const ListOfTasks: co.List<co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>>
ListOfTasks
.
CoListSchema<CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; readonly project: CoOptionalSchema<CoMapSchema<{ name: ZodString; readonly tasks: CoListSchema<CoMapSchema<..., unknown, Account | Group>>; }, unknown, Account | Group>>; }, unknown, Account | Group>>.create(items: readonly (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<(... & CoMap) | null> | null;
    } & CoMap) | null | undefined;
} & CoMap) | {
    ...;
})[], options?: {
    owner: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): CoListInstance<...> (+1 overload)
create
([]),
}, ); const
const task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap
task
=
const Task: co.Map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: co.Optional<co.Map<{
        name: z.z.ZodString;
        readonly tasks: co.List<co.Map<..., unknown, Account | Group>>;
    }, unknown, Account | Group>>;
}, unknown, Account | Group>
Task
.
CoMapSchema<{ title: ZodString; status: ZodLiteral<"todo" | "in-progress" | "complete">; readonly project: CoOptionalSchema<CoMapSchema<{ name: ZodString; readonly tasks: CoListSchema<CoMapSchema<..., unknown, Account | Group>>; }, unknown, Account | Group>>; }, unknown, Account | Group>.create(init: {
    title: string;
    status: "todo" | "in-progress" | "complete";
    readonly project?: {
        name: string;
        readonly tasks: readonly (({
            readonly title: string;
            readonly status: "todo" | "in-progress" | "complete";
            readonly project: ({
                ...;
            } & CoMap) | ... 1 more ... | undefined;
        } & CoMap) | ...)[] | CoList<...>;
    } | ({
        ...;
    } & CoMap) | undefined;
}, options?: {
    owner?: Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Group): {
    ...;
} & CoMap (+1 overload)
create
({
title: stringtitle: "Plant seedlings", status: "todo" | "in-progress" | "complete"status: "todo",
project?: {
    name: string;
    readonly tasks: readonly (({
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<(... & CoMap) | null> | null;
        } & CoMap) | null | undefined;
    } & CoMap) | {
        ...;
    })[] | CoList<(... & CoMap) | null>;
} | ({
    ...;
} & CoMap) | undefined
project
:
const project: {
    readonly name: string;
    readonly tasks: CoList<{
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<... & CoMap>;
        } & CoMap) | undefined;
    } & CoMap>;
} & CoMap
project
, // Add a reference to the project
}); // Add a task to a garden project
const project: {
    readonly name: string;
    readonly tasks: CoList<{
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<... & CoMap>;
        } & CoMap) | undefined;
    } & CoMap>;
} & CoMap
project
.
tasks: CoList<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap>
tasks
.
CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly project: ({ readonly name: string; readonly tasks: CoList<... & CoMap>; } & CoMap) | undefined; } & CoMap>.$jazz: CoListJazzApi<CoList<{
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap>>
$jazz
.
CoListJazzApi<CoList<{ readonly title: string; readonly status: "todo" | "in-progress" | "complete"; readonly project: ({ readonly name: string; readonly tasks: CoList<... & CoMap>; } & CoMap) | undefined; } & CoMap>>.push(...items: (({
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap) | CoMapInit<...>)[]): number
Appends new elements to the end of an array, and returns the new length of the array.
@paramitems New elements to add to the array.@categoryContent
push
(
const task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap
task
);
// Access the project from the task var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
log
(
const task: {
    readonly title: string;
    readonly status: "todo" | "in-progress" | "complete";
    readonly project: ({
        readonly name: string;
        readonly tasks: CoList<... & CoMap>;
    } & CoMap) | undefined;
} & CoMap
task
.
project: ({
    readonly name: string;
    readonly tasks: CoList<{
        readonly title: string;
        readonly status: "todo" | "in-progress" | "complete";
        readonly project: ({
            readonly name: string;
            readonly tasks: CoList<... & CoMap>;
        } & CoMap) | undefined;
    } & CoMap>;
} & CoMap) | undefined
project
); // { name: "Garden Project", tasks: [task] }