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: CoListSchema<z.z.ZodString>ListOfResources = import coco.
list<z.z.ZodString>(element: z.z.ZodString): CoListSchema<z.z.ZodString>
export list
list
(import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString
export string
string
());
const
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>
ListOfTasks
= import coco.
list<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>(element: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>): CoListSchema<...>
export list
list
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
);

To create a CoList:

// Create an empty list
const const resources: CoList<string>resources = import coco.
list<z.z.ZodString>(element: z.z.ZodString): CoListSchema<z.z.ZodString>
export list
list
(import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString
export string
string
()).
create: (items: CoListInit<z.z.ZodString>, options?: {
    owner: Account | Group;
} | Account | Group) => CoList<...>
create
([]);
// Create a list with initial items const
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
= import coco.
list<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>(element: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>): CoListSchema<...>
export list
list
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
).
create: (items: CoListInit<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>, options?: {
    owner: Account | Group;
} | Account | Group) => CoList<...>
create
([
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
.
create: (init: {
    title: string;
    status: NonNullable<"todo" | "in-progress" | "complete">;
}, options?: {
    owner: Account | Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Account | Group) => {
    ...;
} & CoMap
create
({ title: stringtitle: "Prepare soil beds", status: NonNullable<"todo" | "in-progress" | "complete">status: "in-progress" }),
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
.
create: (init: {
    title: string;
    status: NonNullable<"todo" | "in-progress" | "complete">;
}, options?: {
    owner: Account | Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Account | Group) => {
    ...;
} & CoMap
create
({ title: stringtitle: "Order compost", status: NonNullable<"todo" | "in-progress" | "complete">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 (+1 overload)addMember(
const colleagueAccount: Account | ({
    [x: string]: any;
} & Account)
colleagueAccount
, "writer");
const
const teamList: CoList<{
    title: string;
    status: string;
} & CoMap>
teamList
= import coco.
list<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}>>(element: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}>): CoListSchema<CoMapSchema<...>>
export list
list
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}>
Task
).
create: (items: CoListInit<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodString;
}>>, options?: {
    owner: Account | Group;
} | Account | Group) => CoList<...>
create
([], { owner: Group | Accountowner: 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: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
firstTask
=
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
const firstTask: {
    title: string;
    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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
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: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
.
Array<{ title: string; status: "todo" | "in-progress" | "complete"; } & CoMap>.forEach(callbackfn: (value: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    title: string;
    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: {
    title: string;
    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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
task
.title: stringtitle);
// "Prepare soil beds" // "Order compost" }); // Array methods const
const todoTasks: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap)[]
todoTasks
=
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
.
Array<{ title: string; status: "todo" | "in-progress" | "complete"; } & CoMap>.filter(predicate: (value: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap)[]) => unknown, thisArg?: any): ({
    title: string;
    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: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
task
=>
task: {
    title: string;
    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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
const todoTasks: ({
    title: string;
    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

Update CoLists just like you would JavaScript arrays:

// Add items
const resources: CoList<string>resources.CoList<string>.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.
push
("Tomatoes"); // Add to end
const resources: CoList<string>resources.CoList<string>.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.
unshift
("Lettuce"); // Add to beginning
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
.
CoList<{ title: string; status: "todo" | "in-progress" | "complete"; } & CoMap>.push(...items: ({
    title: string;
    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.
push
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
.
create: (init: {
    title: string;
    status: NonNullable<"todo" | "in-progress" | "complete">;
}, options?: {
    owner: Account | Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Account | Group) => {
    ...;
} & CoMap
create
({ // Add complex items
title: stringtitle: "Install irrigation", status: NonNullable<"todo" | "in-progress" | "complete">status: "todo" })); // Replace items const resources: CoList<string>resources[0] = "Cucumber"; // Replace by index // Modify nested items
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
[0].status: "todo" | "in-progress" | "complete"status = "complete"; // Update properties of references

Deleting Items

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: CoList<string>resources.CoList<string>.splice(start: number, deleteCount: number, ...items: string[]): string[]
Splice the `CoList` at a given index.
@paramstart - The index to start the splice.@paramdeleteCount - The number of items to delete.@paramitems - The items to insert.
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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const resources: CoList<string>resources); // ["Cucumber", "Peppers"]
// Remove a single item at index 0 const resources: CoList<string>resources.CoList<string>.splice(start: number, deleteCount: number, ...items: string[]): string[]
Splice the `CoList` at a given index.
@paramstart - The index to start the splice.@paramdeleteCount - The number of items to delete.@paramitems - The items to insert.
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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const resources: CoList<string>resources); // ["Peppers"]
// Remove items const const lastItem: string | undefinedlastItem = const resources: CoList<string>resources.CoList<string>.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.
pop
(); // Remove and return last item
const resources: CoList<string>resources.CoList<string>.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.
shift
(); // Remove first item

Array Methods

CoLists support the standard JavaScript array methods you already know:

// Add multiple items at once
const resources: CoList<string>resources.CoList<string>.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.
push
("Tomatoes", "Basil", "Peppers");
// Find items const const basil: "Basil" | undefinedbasil = const resources: CoList<string>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: CoList<string>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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const tItems: string[]tItems); // ["Tomatoes"]
// Sort (modifies the CoList in-place) const resources: CoList<string>resources.Array<string>.sort(compareFn?: ((a: string, b: string) => number) | undefined): CoList<string>
Sorts an array in place. This method mutates the array and returns a reference to the same array.
@paramcompareFn Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. ```ts [11,2,22,1].sort((a, b) => a - b) ```
sort
();
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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const resources: CoList<string>resources); // ["Basil", "Peppers", "Tomatoes"]

Type Safety

CoLists maintain type safety for their items:

// TypeScript catches type errors
const resources: CoList<string>resources.CoList<string>.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.
push
("Carrots"); // ✓ Valid string
const resources: CoList<string>resources.CoList<string>.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.
push
(42); // ✗ Type error: expected string
Argument of type 'number' is not assignable to parameter of type 'string'.
// For lists of references
const tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap>
tasks
.
Array<{ title: string; status: "todo" | "in-progress" | "complete"; } & CoMap>.forEach(callbackfn: (value: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap, index: number, array: ({
    title: string;
    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: {
    title: string;
    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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
task: {
    title: string;
    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, 
type Loaded<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...
Loaded
} from "jazz-tools";
const
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>
ListOfTasks
= import coco.
list<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>(element: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>): CoListSchema<...>
export list
list
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>
Task
);
// React example function
function TaskList({ tasks }: {
    tasks: Loaded<typeof ListOfTasks>;
}): React.JSX.Element
TaskList
({
tasks: CoList<({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
}: {
tasks: CoList<({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
:
type Loaded<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends {
    ...;
} ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...
Loaded
<typeof
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
}>>
ListOfTasks
> }) {
return ( <JSX.IntrinsicElements.ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>ul> {
tasks: CoList<({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null>
tasks
.
Array<({ title: string; status: "todo" | "in-progress" | "complete"; } & CoMap) | null>.map<React.JSX.Element | null>(callbackfn: (value: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null, index: number, array: (({
    title: string;
    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: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null
task
=> (
task: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap) | null
task
? (
<JSX.IntrinsicElements.li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>li React.Attributes.key?: React.Key | null | undefinedkey={
task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
task
.CoMap.id: string
The ID of this `CoMap`
@categoryContent
id
}>
{
task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
task
.title: stringtitle} - {
task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
} & CoMap
task
.status: "todo" | "in-progress" | "complete"status}
</JSX.IntrinsicElements.li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>li> ): null ))} </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, 
type CoListSchema<T extends z.core.$ZodType> = z.z.core.$ZodArray<T> & {
    collaborative: true;
    create: (items: CoListInit<T>, options?: {
        owner: Account | Group;
    } | Account | Group) => CoList<InstanceOrPrimitiveOfSchema<T>>;
    load<const R extends RefsToResolve<CoListInstanceCoValuesNullable<T>> = true>(id: string, options?: {
        resolve?: RefsToResolveStrict<CoListInstanceCoValuesNullable<T>, R>;
        loadAs?: Account | AnonymousJazzAgent;
    }): Promise<Resolved<CoListInstanceCoValuesNullable<T>, R> | null>;
    subscribe<const R extends RefsToResolve<CoListInstanceCoValuesNullable<T>> = true>(id: string, options: SubscribeListenerOptions<CoListInstanceCoValuesNullable<T>, R>, listener: (value: Resolved<CoListInstanceCoValuesNullable<T>, R>, unsubscribe: () => void) => void): () => void;
    withHelpers<S extends z.z.core.$ZodType, T extends object>(this: S, helpers: (Self: S) => T): WithHelpers<S, T>;
}
CoListSchema
} from "jazz-tools";
const
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>
Task
= import coco.
map<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>(shape: {
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}): CoMapSchema<...>
export map
map
({
title: z.z.ZodStringtitle: import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString
export string
string
(),
status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">status: import zz.
literal<["todo", "in-progress", "complete"]>(value: ["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: z.ZodOptional<CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>>
project
(): import zz.
interface ZodOptional<T extends core.$ZodType = core.$ZodType<unknown, unknown>>
export ZodOptional
ZodOptional
<typeof
const Project: CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>
Project
> {
return import zz.
optional<CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>>(innerType: CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>): z.ZodOptional<...>
export optional
optional
(
const Project: CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>
Project
);
} }); const
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>
ListOfTasks
= import coco.
list<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>(element: CoMapSchema<...>): CoListSchema<...>
export list
list
(
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>
Task
);
const
const Project: CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>
Project
= import coco.
map<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>(shape: {
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}): CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>
export map
map
({
name: z.z.ZodStringname: import zz.
function string(params?: string | z.z.core.$ZodStringParams): z.z.ZodString
export string
string
(),
get
tasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>
tasks
():
type CoListSchema<T extends z.core.$ZodType> = z.z.core.$ZodArray<T> & {
    collaborative: true;
    create: (items: CoListInit<T>, options?: {
        owner: Account | Group;
    } | Account | Group) => CoList<InstanceOrPrimitiveOfSchema<T>>;
    load<const R extends RefsToResolve<CoListInstanceCoValuesNullable<T>> = true>(id: string, options?: {
        resolve?: RefsToResolveStrict<CoListInstanceCoValuesNullable<T>, R>;
        loadAs?: Account | AnonymousJazzAgent;
    }): Promise<Resolved<CoListInstanceCoValuesNullable<T>, R> | null>;
    subscribe<const R extends RefsToResolve<CoListInstanceCoValuesNullable<T>> = true>(id: string, options: SubscribeListenerOptions<CoListInstanceCoValuesNullable<T>, R>, listener: (value: Resolved<CoListInstanceCoValuesNullable<T>, R>, unsubscribe: () => void) => void): () => void;
    withHelpers<S extends z.z.core.$ZodType, T extends object>(this: S, helpers: (Self: S) => T): WithHelpers<S, T>;
}
CoListSchema
<typeof
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>
Task
> {
return
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>
ListOfTasks
;
} }); const
const project: {
    name: string;
    tasks: CoListSchema<typeof Task>;
} & CoMap
project
=
const Project: CoMapSchema<{
    name: z.z.ZodString;
    readonly tasks: CoListSchema<typeof Task>;
}>
Project
.
create: (init: {
    name: string;
    tasks: CoListSchema<typeof Task>;
}, options?: {
    owner: Account | Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Account | Group) => {
    ...;
} & CoMap
create
(
{ name: stringname: "Garden Project",
tasks: CoList<({
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & CoMap) | null>
tasks
:
const ListOfTasks: CoListSchema<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>
ListOfTasks
.
create: (items: CoListInit<CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>>, options?: {
    owner: Account | Group;
} | Account | Group) => CoList<...>
create
([]),
}, ); const
const task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & CoMap
task
=
const Task: CoMapSchema<{
    title: z.z.ZodString;
    status: z.z.ZodLiteral<"todo" | "in-progress" | "complete">;
    readonly project: z.ZodOptional<typeof Project>;
}>
Task
.
create: (init: {
    project?: z.ZodOptional<typeof Project>;
    title: string;
    status: NonNullable<"todo" | "in-progress" | "complete">;
}, options?: {
    owner: Account | Group;
    unique?: CoValueUniqueness["uniqueness"];
} | Account | Group) => {
    ...;
} & CoMap
create
({
title: stringtitle: "Plant seedlings", status: NonNullable<"todo" | "in-progress" | "complete">status: "todo",
project?: ({
    name: string;
    tasks: CoListSchema<typeof Task>;
} & CoMap) | undefined
project
:
const project: {
    name: string;
    tasks: CoListSchema<typeof Task>;
} & CoMap
project
, // Add a reference to the project
}); // Add a task to a garden project
const project: {
    name: string;
    tasks: CoListSchema<typeof Task>;
} & CoMap
project
.
tasks: CoList<{
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & CoMap>
tasks
.
CoList<{ title: string; status: "todo" | "in-progress" | "complete"; project: z.ZodOptional<typeof Project>; } & CoMap>.push(...items: ({
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & 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.
push
(
const task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & 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 (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(
const task: {
    title: string;
    status: "todo" | "in-progress" | "complete";
    project: z.ZodOptional<typeof Project>;
} & CoMap
task
.
project: ({
    name: string;
    tasks: CoListSchema<typeof Task>;
} & CoMap) | undefined
project
); // { name: "Garden Project", tasks: [task] }